00001
00002
00014 #ifndef FIGUREEDITOR_H
00015 #define FIGUREEDITOR_H
00016
00017 #include "qt/libqthippo.h"
00018
00019 #ifdef _MSC_VER
00020 #include <msdevstudio/MSconfig.h>
00021 #endif
00022
00023 #include <qglobal.h>
00024 #if QT_VERSION < 0x040000
00025 #include <qcanvas.h>
00026 #else
00027
00028 #include <q3canvas.h>
00029 #endif
00030
00031 #include <string>
00032 #include <vector>
00033
00034 class PickTable;
00035 class QMouseEvent;
00036 class QResizeEvent;
00063 #if QT_VERSION < 0x040000
00064 class MDL_QTHIPPOPLOT_API FigureEditor : public QCanvasView
00065 #else
00066 class MDL_QTHIPPOPLOT_API FigureEditor : public Q3CanvasView
00067 #endif
00068 {
00069
00070 protected:
00071
00073 int m_apage_w;
00074
00076 int m_apage_h;
00077
00082 double m_scale_factor;
00083
00086 bool m_zoom_mode;
00087
00089 static QPrinter * s_printer;
00090
00094 bool m_printer_bounds;
00095
00099 #if QT_VERSION < 0x040000
00100 void resizeCanvasToFit ( QCanvasItem * item );
00101 #else
00102 void resizeCanvasToFit ( Q3CanvasItem * item );
00103 #endif
00104
00106 void savePrinterSettings ();
00107
00111 void initPrinter ();
00112
00116 void addPageMargin ( int x, int y );
00117
00123 void calcPrinterMetrics ();
00124
00127 double maximumZ () const;
00128
00131 void setUnselectedVisible ( bool yes );
00132
00133 protected:
00134
00136 int m_upage_w;
00137
00139 int m_upage_h;
00140
00151 #if QT_VERSION < 0x040000
00152 std::vector < QCanvasItem * > m_items;
00153 #else
00154 std::vector < Q3CanvasItem * > m_items;
00155 #endif
00156
00160 static QString s_app_key;
00161
00165 static QString s_registry;
00166
00170 #if QT_VERSION < 0x040000
00171 QCanvas * m_canvas;
00172 #else
00173 Q3Canvas * m_canvas;
00174 #endif
00175
00177 #if QT_VERSION < 0x040000
00178 std::vector < QCanvasItem * > m_selected_list;
00179 #else
00180 std::vector < Q3CanvasItem * > m_selected_list;
00181 #endif
00182
00184 QPoint moving_start;
00185
00187 QPoint zoom_start;
00188
00191 enum Location { none, invalid,
00192 upper_left, upper_middle, upper_right,
00193 middle_left, middle_right,
00194 lower_left, lower_middle, lower_right };
00195
00197 Location m_whereClicked;
00198
00200 virtual void notifyObservers () = 0;
00201
00202 virtual void contentsMousePressEvent(QMouseEvent*);
00203
00205 virtual void controlMousePressEvent () = 0;
00206
00211 void contentsMouseMoveEvent ( QMouseEvent *, double aspect );
00212
00214 void whereClicked ( );
00215
00217 #if QT_VERSION < 0x040000
00218 void placeGraphOnSelected ( QCanvasRectangle * item );
00219 #else
00220 void placeGraphOnSelected ( Q3CanvasRectangle * item );
00221 #endif
00222
00226 void setSelectedItems ( bool state );
00227
00229 QRect getSelectedBounds () const;
00230
00232 void clearSelectedList ();
00233
00237 #if QT_VERSION < 0x040000
00238 void setCollidingSelected ( const QCanvasItem * target );
00239 #else
00240 void setCollidingSelected ( const Q3CanvasItem * target );
00241 #endif
00242
00245 void saveSelectedAsPixmap ( const std::string & filename );
00246
00249 void saveAreaAsPixmap ( const QRect & area, const std::string & filename );
00250
00253 void print ( QPrinter * printer );
00254
00257 #if QT_VERSION < 0x040000
00258 void removeFromItemList ( QCanvasItem * item );
00259 #else
00260 void removeFromItemList ( Q3CanvasItem * item );
00261 #endif
00262
00263 public:
00264
00266 #if QT_VERSION < 0x040000
00267 FigureEditor ( QCanvas *, QWidget * parent = 0,
00268 const char * name = 0, Qt::WFlags f = 0 );
00269 #else
00270 FigureEditor ( Q3Canvas *, QWidget * parent = 0,
00271 const char * name = 0, Qt::WFlags f = 0 );
00272 #endif
00273
00275 void static setAppKey ( const std::string & );
00276
00279 void showPrinterMargins ( bool on );
00280
00282 void setPrinterSettings ();
00283
00286 virtual void print ();
00287
00290 virtual void print ( const std::string & filename );
00291
00295 void resizeEvent ( QResizeEvent * e );
00296
00298 void addPage ();
00299
00301 #if QT_VERSION < 0x040000
00302 QCanvasItem * selectedItem () const;
00303 #else
00304 Q3CanvasItem * selectedItem () const;
00305 #endif
00306
00309 #if QT_VERSION < 0x040000
00310 void setSelectedItem ( QCanvasItem * );
00311 #else
00312 void setSelectedItem ( Q3CanvasItem * );
00313 #endif
00314
00316 void setAllSelected ( bool flag = true );
00317
00319 void setLocked ( bool flag );
00320
00321
00323 void setZoomMode ( bool flag );
00324
00326 bool getZoomMode ( ) const;
00327
00330 void clear();
00331
00336 #if QT_VERSION < 0x040000
00337 void placeGraph ( QCanvasRectangle * );
00338 #else
00339 void placeGraph ( Q3CanvasRectangle * );
00340 #endif
00341
00343 #if QT_VERSION < 0x040000
00344 void add ( QCanvasItem * item );
00345 #else
00346 void add ( Q3CanvasItem * item );
00347 #endif
00348
00351 #if QT_VERSION < 0x040000
00352 void paste ( QCanvasItem * item );
00353 #else
00354 void paste ( Q3CanvasItem * item );
00355 #endif
00356
00361 #if QT_VERSION < 0x040000
00362 void remove ( QCanvasItem * item );
00363 #else
00364 void remove ( Q3CanvasItem * item );
00365 #endif
00366
00368 #if QT_VERSION < 0x040000
00369 std::vector < QCanvasItem * > & getSelectedItems ();
00370 #else
00371 std::vector < Q3CanvasItem * > & getSelectedItems ();
00372 #endif
00373
00375 bool isSingleItemSelected () const;
00376
00378 #if QT_VERSION < 0x040000
00379 void addSelectedItem ( QCanvasItem * item );
00380 #else
00381 void addSelectedItem ( Q3CanvasItem * item );
00382 #endif
00383
00386 #if QT_VERSION < 0x040000
00387 void removeSelectedItem ( QCanvasItem * item );
00388 #else
00389 void removeSelectedItem ( Q3CanvasItem * item );
00390 #endif
00391
00393 void setSelectedFlags ();
00394
00399 void scaleBy ( double factor );
00400
00402 void viewZoomIn();
00403
00405 void viewZoomOut();
00406
00409 void viewZoomReset ();
00410
00412 virtual void viewShowPickTable() = 0;
00413
00416 #if QT_VERSION < 0x040000
00417 void ensureVisible ( const QCanvasItem * item );
00418 #else
00419 void ensureVisible ( const Q3CanvasItem * item );
00420 #endif
00421
00422 };
00423
00424 #endif // FIGUREEDITOR_H