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 
97 {
98 
99 Q_OBJECT
100 
101 private:
102 
104  std::list <QAction *> m_recent_list;
105 
107  mutable std::vector < const ViewBase * > m_views;
108 
110  mutable std::vector < const ViewBase * > m_sel_views;
111 
113  std::map < const QtView *, PickTable * > m_table_map;
114 
117 
120 
123  static const std::string s_app_name;
124 
126  static std::string s_image_filters;
127 
130 #if QT_VERSION < 0x040000
132 #else
133  Q3CanvasRectangle * m_drag_rect;
134 #endif
135 
141 #if QT_VERSION < 0x040000
143 #else
144  Q3FileDialog * m_image_dialog;
145 #endif
146 
148  std::vector<double> m_mouseData;
149 
151  bool fillPickedPoint(QMouseEvent * e, std::vector<double> & picked);
152 
155  void fillMouseData(const std::vector<double> & picked);
156 
157  void updatePickTable(QtView * qtview, std::vector<double> & picked);
158 
159  void setPlotZoom(const std::vector<double> & start_picked,
160  const std::vector<double> & picked);
161 
165 
169 
173 
177 
183  int m_edge;
184 
187  bool m_clicked;
188 
191  double old_pos, old_pos_x, old_pos_y;
192 
193 
196  std::vector<double> m_current_range;
197 
200  void initSettings ();
201 
204  void saveSettings () const;
205 
208  void initFitterDefault ();
209 
212  void setFitterDefault ( const std::string & name );
213 
216  void initFitterMenu ( QActionGroup * group );
217 
220  static void createImageFilters ();
221 
225  static bool isValidImageFormat ( const std::string & suffix );
226 
230 #if QT_VERSION < 0x040000
231  QFileDialog * createImageDialog ();
232 #else
233  Q3FileDialog * createImageDialog ();
234 #endif
235 
237  void setChanged ( bool yes = true );
238 
241  void addView ( QtView * view, bool select );
242 
245 #if QT_VERSION < 0x040000
246  void placeItems ( const std::vector < QCanvasItem * > & items );
247 #else
248  void placeItems ( const std::vector < Q3CanvasItem * > & items );
249 #endif
250 
253  virtual void calcDefaultSize ( QtView * view, double aspect_ratio = 0.0);
254 
258  void moveToPlotter ( const PlotterBase * plotter, QtView * view );
259 
262  void sizeAndPlace ( QtView * view );
263 
267  std::pair<double, double> moveToPlotterAt ( const PlotterBase * plotter,
268  QtView * view,
269  double x, double y );
270 
274  void fillSelectedWithObservers ( std::vector < const ViewBase * > & );
275 
276  PlotterBase * getRightClickedPlotter();
277 
278 
279 
280 protected:
281 
283  virtual void contentsMouseMoveEvent ( QMouseEvent * );
284  virtual void contentsMousePressEvent ( QMouseEvent * );
285 
289  virtual void controlMousePressEvent ();
290 
294  virtual void contentsMouseReleaseEvent(QMouseEvent*);
295 
296 public:
297 
298 #if QT_VERSION < 0x040000
299  CanvasView ( QCanvas *, QWidget * parent = 0,
300  const char * name = 0, Qt::WFlags f = 0 );
301 #else
302  CanvasView ( Q3Canvas *, QWidget * parent = 0,
303  const char * name = 0, Qt::WFlags f = 0 );
304 #endif
305 
306  void initFrom ( const std::list < ViewBase * > & views );
307 
309  void initFromFile ( const std::string & filename );
310 
316  void initFitterSettings ( QActionGroup * group);
317 
320  void initRecentFiles ( QActionGroup * ag );
321 
324 #if QT_VERSION < 0x040000
325  void initDockWindows ( QMainWindow * mw );
326 #else
327  void initDockWindows ( Q3MainWindow * mw );
328 #endif
329 
331  void addRecentFile (const QString & filename, QActionGroup * ag );
332 
335  void setFitterDefault ( const QString & name );
336 
338  void copySelectedToPasteboard ();
339 
342  void copyFromPasteboard ();
343 
347  void addFromPasteboard ();
348 
352  void deleteSelected ( bool paste );
353 
356  void pasteViews ( const std::list < ViewBase * > & views );
357 
359  void restoreFromSelectCopy ();
360 
362  void setCurrentRange();
363 
365  std::vector<double>& getCurrentRange() ;
366 
369  void setInspector ( Inspector * inspector );
370 
372  Inspector * getInspector ();
373 
381  void notifyObservers ();
382 
384  PlotterBase * selectedPlotter () const;
385 
388  std::vector < PlotterBase * > getSelectedPlotters () const;
389 
393  void addPlotDisplay ( PlotterBase * plotter, bool select);
394 
396 #if QT_VERSION < 0x040000
397  void autosaveSettings ( QMainWindow * mw);
398 #else
399  void autosaveSettings ( Q3MainWindow * mw);
400 #endif
401 public:
402 
406  void addTextDisplay ( PlotterBase * plotter,
407  const std::string & s,
408  const std::string & text = std::string () );
409 
414  std::pair<double, double> addTextDisplayAt ( PlotterBase * plotter,
415  const std::string & type,
416  const std::string & text,
417  double xrel, double yrel);
418 
419 
421  void addFuncDisplay ( PlotterBase * plotter, const std::string & s );
422 
425  void removeDisplay ( PlotterBase * plotter );
426 
430  const std::vector < const ViewBase * > & selectedViews () const;
431 
436  const std::vector < const ViewBase * > & views () const;
437 
441  void fillPlotterList ( std::vector < PlotterBase * > & plotter_list );
442 
445  QtView * getViewFor ( const PlotterBase * plotter ) const;
446 
450  void previousView ();
451 
454  virtual void print ();
455 
458  virtual void print ( const std::string & filename );
459 
462  void reTile ();
463 
466  void reTilePage ();
467 
470  void setIntervalEnabled ( bool yes = true );
471 
473  void removeSelected ();
474 
476  void hideSelected ();
477 
482  void saveSelectedImages ();
483 
485  void saveSelectedImages ( const std::string & filename );
486 
489  void savePlotAsEps ( const PlotterBase * plotter,
490  const std::string & filename ) const;
491 
497  void savePlotAsFits ( const PlotterBase * plotter,
498  const std::string & filename ) const;
499 
502  void saveAs ( const std::string & filename ) const;
503 
506  static void saveAs ( const std::vector < const ViewBase * > & views,
507  const std::string & filename );
508 
511  static void saveAs ( const std::vector < PlotterBase * > & plotters,
512  const std::string & filename );
513 
518  void exportTextTuple ( const std::string & suffix );
519 
522  void showInspector ();
523 
525  void viewShowPickTable();
526 
529  const std::vector<double> & mouseEventData();
530 
534  void setPlotMatrix ( unsigned int columns, unsigned int rows );
535 
537  void createNTuple();
538 
540  void setup ();
541 
542 
544  void setFonts( const QFont & font );
545 
547  void helpAbout ();
548 
551  const std::string & applicationName () const;
552 
555  void setAddedSelected ( bool yes );
556 
557  void setCutMode ( int mode );
558 
561  NTuple * getPickTable ();
562 
565  NTuple * getPickTable ( const PlotterBase * plotter );
566 
568  void groupView ();
569 
571  void ungroupView ();
572 
573 private:
574 
577  bool existingFileWarning ( const std::string & filename );
578 
581  void invalidImageFormatError ( const std::string & filename );
582 
584  void saveSelectedAsEps ( const std::string & filename );
585 
586 
592  void saveSelectedAsFits ( const std::string & filename );
593 public:
597  void showFitsError () const;
598 private:
599 
603  void setVisibleNonViews ( bool visible );
604 
612  void saveSelectedImages ( const std::string & filename,
613  bool check_existing );
614 
617  static void toLower ( std::string & upper );
618 
619 public slots:
620 
625  void addPlotDisplay ( PlotterBase * plotter );
626 
628  void clear ();
629 
635  void savePlotAsImage ( const PlotterBase * plotter,
636  const std::string & filename );
637 
640  void swapOrientation ();
641 
644  static QtView * wrapPlotter ( PlotterBase * plotter );
645 
646 };
647 
648 } // namespace hippodraw
649 
650 #endif // CanvasView_H
int m_edge
For cut mode 1, edge or corner selected.
Definition: CanvasView.h:183
static XmlController * s_xml_controller
The XML controller.
Definition: CanvasView.h:116
std::map< const QtView *, PickTable * > m_table_map
A map from a view to the PickTable.
Definition: CanvasView.h:113
std::vector< const ViewBase * > m_sel_views
Temporary list of selected QtView objects on the canvas.
Definition: CanvasView.h:110
std::list< QAction * > m_recent_list
List of menu items of recently opened files.
Definition: CanvasView.h:104
This class implements additional FigureEditor functionality particular to QtView objects.
Definition: CanvasView.h:96
#define MDL_QTHIPPOPLOT_API
Definition: libqthippo.h:36
int m_num_height
Number of default sized plots vertically.
Definition: CanvasView.h:168
std::vector< double > m_mouseData
3-vector of mouse event data
Definition: CanvasView.h:148
std::vector< const ViewBase * > m_views
Temporary list of QtView objects on the canvas.
Definition: CanvasView.h:107
static std::string s_image_filters
A QFileDialog filters string for supported image types.
Definition: CanvasView.h:126
bool m_add_selected
Set to true if displays should be selected when added.
Definition: CanvasView.h:172
return yes
Definition: CanvasView.cxx:883
static const std::string s_app_name
The application name.
Definition: CanvasView.h:123
The base class for the PlotterBase hierarchy.
Definition: PlotterBase.h:55
int m_cut_mode
Cut mode: 1: normal; 2: click; 3: drag.
Definition: CanvasView.h:176
PyArray_TYPES type(numeric::array arr)
Definition: num_util.cpp:249
stream * mw
Definition: CanvasView.cxx:169
bool m_clicked
For cut mode 2, clicked or not.
Definition: CanvasView.h:187
int m_num_width
Number of default sized plots horizontally.
Definition: CanvasView.h:164
The class of derived from ViewBase and QCanvasRectangle for drawing on a QCanvas. ...
Definition: QtView.h:41
A DataSource class implemented with std::vector&lt;double&gt; to store the column data. ...
Definition: NTuple.h:33
QCanvasRectangle * m_drag_rect
Rectangle showing the area which is to be magnified.
Definition: CanvasView.h:131
std::vector< double > m_current_range
Set to the current range of the selected plotter.
Definition: CanvasView.h:196
Inspector * m_inspector
The Inspector object.
Definition: CanvasView.h:119
QFileDialog * m_image_dialog
The QFileDialog for saving images.
Definition: CanvasView.h:142
A base class that is the interface between GUI and the XML serialization and deserialization.
Definition: XmlController.h:53
hippodraw::FigureEditor class interface and nested class implementation
This class implements additional QCanvasView functionality.
Definition: FigureEditor.h:73
A derived class of InspectorBase class which is generated by the Qt designer.
Definition: Inspector.h:234

Generated for HippoDraw Class Library by doxygen