FigureEditor.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 
14 #ifndef FIGUREEDITOR_H
15 #define FIGUREEDITOR_H
16 
17 #include "libqthippo.h"
18 
19 #ifdef _MSC_VER
20 #include <msdevstudio/MSconfig.h>
21 #endif
22 
23 #include <qglobal.h> // for version
24 #if QT_VERSION < 0x040000
25 #include <qcanvas.h>
26 #else
27 //Added by the Qt porting tool:
28 #include <QtCore/QCustomEvent>
29 #include <q3canvas.h>
30 #endif
31 
32 #include <string>
33 #include <vector>
34 
35 class QMouseEvent;
36 class QResizeEvent;
37 
38 namespace hippodraw {
39 
40 class PickTable;
41 
72 #if QT_VERSION < 0x040000
74 #else
75 class MDL_QTHIPPOPLOT_API FigureEditor : public Q3CanvasView
76 #endif
77 {
78 
79 private:
80 
84 class CanvasEvent : public QCustomEvent
85 {
86 private:
89 #if QT_VERSION < 0x040000
91 #else
92  const Q3CanvasItem * m_item;
93 #endif
94 
95 public:
96 
99 #if QT_VERSION < 0x040000
100  CanvasEvent ( const QCanvasItem * item )
101 #else
102  CanvasEvent ( const Q3CanvasItem * item )
103 #endif
104  : QCustomEvent ( 1000 ),
105  m_item ( item )
106  {}
107 
110 #if QT_VERSION < 0x040000
111  const QCanvasItem * item () const
112 #else
113  const Q3CanvasItem * item () const
114 #endif
115  {
116  return m_item;
117  }
118 };
119 
122  virtual void customEvent ( QCustomEvent * event );
123 
124 protected:
125 
128 
131 
137 
141 
143  static QPrinter * s_printer;
144 
149 
154 
158 #if QT_VERSION < 0x040000
159  void resizeCanvasToFit ( QCanvasItem * item );
160 #else
161  void resizeCanvasToFit ( Q3CanvasItem * item );
162 #endif
163 
165  void savePrinterSettings ();
166 
170  void initPrinter ();
171 
175  void addPageMargin ( int x, int y );
176 
183  void calcPrinterMetrics ( QPaintDevice * );
184 
189  double maximumZ () const;
190 
193  void setUnselectedVisible ( bool yes );
194 
197  void mouseMoveMultiItem( QMouseEvent * e );
198 
199 
202  void
203 #if QT_VERSION < 0X040000
204  movePlotterWithText ( QCanvasItem * item, float dx, float dy );
205 #else
206  movePlotterWithText ( Q3CanvasItem * item, float dx, float dy );
207 #endif
208 
209 
212  QPixmap * createPixmap ( const QRect & rectangle ) const;
213 
217  QImage createImage ( const QRect & rectange ) const;
218 
219 protected:
220 
223 
226 
237 #if QT_VERSION < 0x040000
238  std::vector < QCanvasItem * > m_items;
239 #else
240  std::vector < Q3CanvasItem * > m_items;
241 #endif
242 
243 
244 
251 #if QT_VERSION < 0x040000
253 #else
254  Q3CanvasItem * m_rightItem;
255 #endif
256 
257 
262 #if QT_VERSION < 0x040000
264 #else
265  Q3CanvasItem * m_preSelected;
266 #endif
267 
268 
273 
278 
282 #if QT_VERSION < 0x040000
284 #else
285  Q3Canvas * m_canvas;
286 #endif
287 
289 #if QT_VERSION < 0x040000
290  std::vector < QCanvasItem * > m_selected_list;
291 #else
292  std::vector < Q3CanvasItem * > m_selected_list;
293 #endif
294 
297 
300 
303 
306 
309  enum Location { none, invalid,
310  upper_left, upper_middle, upper_right,
311  middle_left, middle_right,
312  lower_left, lower_middle, lower_right };
313 
316 
318  virtual void notifyObservers () = 0;
319 
322 #if QT_VERSION < 0x040000
323  void makeVisible ( const QCanvasItem * item );
324 #else
325  void makeVisible ( const Q3CanvasItem * item );
326 #endif
327 
328  virtual void contentsMousePressEvent(QMouseEvent*);
329 
331  virtual void controlMousePressEvent () = 0;
332 
338  void contentsMouseMoveEvent ( QMouseEvent *, double aspect );
339 
341  void contentsMouseReleaseEvent (QMouseEvent *);
342 
343 
345  void whereClicked ( );
346 
348 #if QT_VERSION < 0x040000
349  void placeGraphOnSelected ( QCanvasRectangle * item );
350 #else
351  void placeGraphOnSelected ( Q3CanvasRectangle * item );
352 #endif
353 
357  void setSelectedItems ( bool state );
358 
360  QRect getSelectedBounds () const;
361 
363  void clearSelectedList ();
364 
368 #if QT_VERSION < 0x040000
369  void setCollidingSelected ( const QCanvasItem * target );
370 #else
371  void setCollidingSelected ( const Q3CanvasItem * target );
372 #endif
373 
376  void saveSelectedAsPixmap ( const std::string & filename );
377 
380  void saveAreaAsPixmap ( const QRect & area, const std::string & filename );
381 
384  void copySelectedToClipboard ();
385 
388  void print ( QPrinter * printer );
389 
392 #if QT_VERSION < 0x040000
393  void removeFromItemList ( QCanvasItem * item );
394 #else
395  void removeFromItemList ( Q3CanvasItem * item );
396 #endif
397 
398 #if QT_VERSION < 0x040000
399  void addToItemList ( QCanvasItem * item );
400 #else
401  void addToItemList ( Q3CanvasItem * item );
402 #endif
403 
404 public:
405 
407 #if QT_VERSION < 0x040000
408  FigureEditor ( QCanvas *, QWidget * parent = 0,
409  const char * name = 0, Qt::WFlags f = 0 );
410 #else
411  FigureEditor ( Q3Canvas *, QWidget * parent = 0,
412  const char * name = 0, Qt::WFlags f = 0 );
413 #endif
414 
416  void static setAppKey ( const std::string & );
417 
420  void showPrinterMargins ( bool on );
421 
423  void setPrinterSettings ();
424 
427  virtual void print ();
428 
431  virtual void print ( const std::string & filename );
432 
436  void resizeEvent ( QResizeEvent * e );
437 
439  void addPage ();
440 
442 #if QT_VERSION < 0x040000
443  QCanvasItem * selectedItem () const;
444 #else
445  Q3CanvasItem * selectedItem () const;
446 #endif
447 
450 #if QT_VERSION < 0x040000
451  void setSelectedItem ( QCanvasItem * );
452 #else
453  void setSelectedItem ( Q3CanvasItem * );
454 #endif
455 
456 
458 #if QT_VERSION < 0x040000
459  QCanvasItem * getRightItem ();
460 #else
461  Q3CanvasItem * getRightItem ();
462 #endif
463 
465  void setAllSelected ( bool flag = true );
466 
468  void setLocked ( bool flag );
469 
470 
472  void setZoomMode ( bool flag );
473 
475  bool getZoomMode ( ) const;
476 
479  void clear();
480 
485 #if QT_VERSION < 0x040000
486  void placeGraph ( QCanvasRectangle * );
487 #else
488  void placeGraph ( Q3CanvasRectangle * );
489 #endif
490 
492 #if QT_VERSION < 0x040000
493  void add ( QCanvasItem * item );
494 #else
495  void add ( Q3CanvasItem * item );
496 #endif
497 
500 #if QT_VERSION < 0x040000
501  void paste ( QCanvasItem * item );
502 #else
503  void paste ( Q3CanvasItem * item );
504 #endif
505 
510 #if QT_VERSION < 0x040000
511  void remove ( QCanvasItem * item );
512 #else
513  void remove ( Q3CanvasItem * item );
514 #endif
515 
521 #if QT_VERSION < 0x040000
522  void hide ( QCanvasItem * item );
523 #else
524  void hide ( Q3CanvasItem * item );
525 #endif
526 
528 #if QT_VERSION < 0x040000
529  std::vector < QCanvasItem * > & getSelectedItems ();
530 #else
531  std::vector < Q3CanvasItem * > & getSelectedItems ();
532 #endif
533 
535  bool isSingleItemSelected () const;
536 
538 #if QT_VERSION < 0x040000
539  void addSelectedItem ( QCanvasItem * item );
540 #else
541  void addSelectedItem ( Q3CanvasItem * item );
542 #endif
543 
546 #if QT_VERSION < 0x040000
547  void removeSelectedItem ( QCanvasItem * item );
548 #else
549  void removeSelectedItem ( Q3CanvasItem * item );
550 #endif
551 
553  void setSelectedFlags ();
554 
559  void scaleBy ( double factor );
560 
562  void viewZoomIn();
563 
565  void viewZoomOut();
566 
569  void viewZoomReset ();
570 
572  virtual void viewShowPickTable() = 0;
573 
576 #if QT_VERSION < 0x040000
577  void ensureVisible ( const QCanvasItem * item );
578 #else
579  void ensureVisible ( const Q3CanvasItem * item );
580 #endif
581 
584  const QString & getAppKey () const;
585 
588  const QString & getRegistry () const;
589 
592  void enterEvent ( QEvent * );
593 
596  void leaveEvent ( QEvent * );
597 
598 
599 };
600 
601 } // namespace hippodraw
602 
603 #endif // FIGUREEDITOR_H

Generated for HippoDraw Class Library by doxygen