CanvasView.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 
16 #ifndef CanvasView_H
17 #define CanvasView_H
18 
19 #include "FigureEditor.h"
20 
21 #if QT_VERSION < 0x040000
22 #else
23 //Added by the Qt porting tool:
24 #include <QtGui/QMouseEvent>
25 #endif
26 
27 
28 #ifdef _MSC_VER
29 #include <msdevstudio/MSconfig.h>
30 #endif
31 
32 #include <list>
33 #include <map>
34 
35 #if QT_VERSION < 0x040000
36 class QFileDialog;
37 #else
38 class Q3FileDialog;
39 class Q3MainWindow;
40 #endif
41 
42 class QActionGroup;
43 class QFont;
44 class QMainWindow;
45 class QAction;
46 
47 namespace hippodraw {
48 
49 class Inspector;
50 class PlotterBase;
51 class QtView;
52 class ViewBase;
53 class XmlController;
54 class NTuple;
55 class PickTable;
56 class CreateNTuple;
57 class QtGroupView;
58 
95 {
96 
97 Q_OBJECT
98 
99 private:
100 
102  std::list <QAction *> m_recent_list;
103 
105  mutable std::vector < const ViewBase * > m_views;
106 
108  mutable std::vector < const ViewBase * > m_sel_views;
109 
111  std::map < const QtView *, PickTable * > m_table_map;
112 
115 
118 
121  static const std::string s_app_name;
122 
124  static std::string s_image_filters;
125 
128 #if QT_VERSION < 0x040000
130 #else
131  Q3CanvasRectangle * m_drag_rect;
132 #endif
133 
139 #if QT_VERSION < 0x040000
141 #else
142  Q3FileDialog * m_image_dialog;
143 #endif
144 
146  std::vector<double> m_mouseData;
147 
149  bool fillPickedPoint(QMouseEvent * e, std::vector<double> & picked);
150 
153  void fillMouseData(const std::vector<double> & picked);
154 
155  void updatePickTable(QtView * qtview, std::vector<double> & picked);
156 
157  void setPlotZoom(const std::vector<double> & start_picked,
158  const std::vector<double> & picked);
159 
163 
167 
171 
175 
181  int m_edge;
182 
185  bool m_clicked;
186 
189  double old_pos, old_pos_x, old_pos_y;
190 
191 
194  std::vector<double> m_current_range;
195 
198  void initSettings ();
199 
202  void saveSettings () const;
203 
206  void initFitterDefault ();
207 
210  void setFitterDefault ( const std::string & name );
211 
214  void initFitterMenu ( QActionGroup * group );
215 
218  static void createImageFilters ();
219 
223  static bool isValidImageFormat ( const std::string & suffix );
224 
228 #if QT_VERSION < 0x040000
229  QFileDialog * createImageDialog ();
230 #else
231  Q3FileDialog * createImageDialog ();
232 #endif
233 
235  void setChanged ( bool yes = true );
236 
239  void addView ( QtView * view, bool select );
240 
243 #if QT_VERSION < 0x040000
244  void placeItems ( const std::vector < QCanvasItem * > & items );
245 #else
246  void placeItems ( const std::vector < Q3CanvasItem * > & items );
247 #endif
248 
251  virtual void calcDefaultSize ( QtView * view, double aspect_ratio = 0.0);
252 
256  void moveToPlotter ( const PlotterBase * plotter, QtView * view );
257 
260  void sizeAndPlace ( QtView * view );
261 
265  std::pair<double, double> moveToPlotterAt ( const PlotterBase * plotter,
266  QtView * view,
267  double x, double y );
268 
272  void fillSelectedWithObservers ( std::vector < const ViewBase * > & );
273 
274  PlotterBase * getRightClickedPlotter();
275 
276 
277 
278 protected:
279 
281  virtual void contentsMouseMoveEvent ( QMouseEvent * );
282  virtual void contentsMousePressEvent ( QMouseEvent * );
283 
287  virtual void controlMousePressEvent ();
288 
292  virtual void contentsMouseReleaseEvent(QMouseEvent*);
293 
294 public:
295 
296 #if QT_VERSION < 0x040000
297  CanvasView ( QCanvas *, QWidget * parent = 0,
298  const char * name = 0, Qt::WFlags f = 0 );
299 #else
300  CanvasView ( Q3Canvas *, QWidget * parent = 0,
301  const char * name = 0, Qt::WFlags f = 0 );
302 #endif
303 
304  void initFrom ( const std::list < ViewBase * > & views );
305 
307  void initFromFile ( const std::string & filename );
308 
314  void initFitterSettings ( QActionGroup * group);
315 
318  void initRecentFiles ( QActionGroup * ag );
319 
322 #if QT_VERSION < 0x040000
323  void initDockWindows ( QMainWindow * mw );
324 #else
325  void initDockWindows ( Q3MainWindow * mw );
326 #endif
327 
329  void addRecentFile (const QString & filename, QActionGroup * ag );
330 
333  void setFitterDefault ( const QString & name );
334 
336  void copySelectedToPasteboard ();
337 
340  void copyFromPasteboard ();
341 
345  void addFromPasteboard ();
346 
350  void deleteSelected ( bool paste );
351 
354  void pasteViews ( const std::list < ViewBase * > & views );
355 
357  void restoreFromSelectCopy ();
358 
360  void setCurrentRange();
361 
363  std::vector<double>& getCurrentRange() ;
364 
367  void setInspector ( Inspector * inspector );
368 
370  Inspector * getInspector ();
371 
379  void notifyObservers ();
380 
382  PlotterBase * selectedPlotter () const;
383 
386  std::vector < PlotterBase * > getSelectedPlotters () const;
387 
391  void addPlotDisplay ( PlotterBase * plotter, bool select);
392 
394 #if QT_VERSION < 0x040000
395  void autosaveSettings ( QMainWindow * mw);
396 #else
397  void autosaveSettings ( Q3MainWindow * mw);
398 #endif
399 public:
400 
404  void addTextDisplay ( PlotterBase * plotter,
405  const std::string & s,
406  const std::string & text = std::string () );
407 
412  std::pair<double, double> addTextDisplayAt ( PlotterBase * plotter,
413  const std::string & type,
414  const std::string & text,
415  double xrel, double yrel);
416 
417 
419  void addFuncDisplay ( PlotterBase * plotter, const std::string & s );
420 
423  void removeDisplay ( PlotterBase * plotter );
424 
428  const std::vector < const ViewBase * > & selectedViews () const;
429 
434  const std::vector < const ViewBase * > & views () const;
435 
439  void fillPlotterList ( std::vector < PlotterBase * > & plotter_list );
440 
443  QtView * getViewFor ( const PlotterBase * plotter ) const;
444 
448  void previousView ();
449 
452  virtual void print ();
453 
456  virtual void print ( const std::string & filename );
457 
460  void reTile ();
461 
464  void reTilePage ();
465 
468  void setIntervalEnabled ( bool yes = true );
469 
471  void removeSelected ();
472 
474  void hideSelected ();
475 
480  void saveSelectedImages ();
481 
483  void saveSelectedImages ( const std::string & filename );
484 
487  void savePlotAsEps ( const PlotterBase * plotter,
488  const std::string & filename ) const;
489 
495  void savePlotAsFits ( const PlotterBase * plotter,
496  const std::string & filename ) const;
497 
500  void saveAs ( const std::string & filename ) const;
501 
504  static void saveAs ( const std::vector < const ViewBase * > & views,
505  const std::string & filename );
506 
509  static void saveAs ( const std::vector < PlotterBase * > & plotters,
510  const std::string & filename );
511 
516  void exportTextTuple ( const std::string & suffix );
517 
520  void showInspector ();
521 
523  void viewShowPickTable();
524 
527  const std::vector<double> & mouseEventData();
528 
532  void setPlotMatrix ( unsigned int columns, unsigned int rows );
533 
535  void createNTuple();
536 
538  void setup ();
539 
540 
542  void setFonts( const QFont & font );
543 
545  void helpAbout ();
546 
549  const std::string & applicationName () const;
550 
553  void setAddedSelected ( bool yes );
554 
555  void setCutMode ( int mode );
556 
559  NTuple * getPickTable ();
560 
563  NTuple * getPickTable ( const PlotterBase * plotter );
564 
566  void groupView ();
567 
569  void ungroupView ();
570 
571 private:
572 
575  bool existingFileWarning ( const std::string & filename );
576 
579  void invalidImageFormatError ( const std::string & filename );
580 
582  void saveSelectedAsEps ( const std::string & filename );
583 
584 
590  void saveSelectedAsFits ( const std::string & filename );
591 public:
595  void showFitsError () const;
596 private:
597 
601  void setVisibleNonViews ( bool visible );
602 
610  void saveSelectedImages ( const std::string & filename,
611  bool check_existing );
612 
615  static void toLower ( std::string & upper );
616 
617 public slots:
618 
623  void addPlotDisplay ( PlotterBase * plotter );
624 
626  void clear ();
627 
633  void savePlotAsImage ( const PlotterBase * plotter,
634  const std::string & filename );
635 
638  void swapOrientation ();
639 
642  static QtView * wrapPlotter ( PlotterBase * plotter );
643 
644 };
645 
646 } // namespace hippodraw
647 
648 #endif // CanvasView_H

Generated for HippoDraw Class Library by doxygen