CanvasView.h

Go to the documentation of this file.
00001 /* -*- mode: c++ -*- */
00002 
00016 #ifndef CanvasView_H
00017 #define CanvasView_H
00018 
00019 #include "FigureEditor.h"
00020 
00021 #if QT_VERSION < 0x040000
00022 #else
00023 //Added by the Qt porting tool:
00024 #include <QtGui/QMouseEvent>
00025 #endif
00026 
00027 
00028 #ifdef _MSC_VER
00029 #include <msdevstudio/MSconfig.h>
00030 #endif
00031 
00032 #include <list>
00033 #include <map>
00034 
00035 #if QT_VERSION < 0x040000
00036 class QFileDialog;
00037 #else
00038 class Q3FileDialog;
00039 class Q3MainWindow;
00040 #endif
00041 
00042 class QActionGroup;
00043 class QFont;
00044 class QMainWindow;
00045 class QAction;
00046 
00047 namespace hippodraw {
00048 
00049 class Inspector;
00050 class PlotterBase;
00051 class QtView;
00052 class ViewBase;
00053 class XmlController;
00054 class NTuple;
00055 class PickTable;
00056 class CreateNTuple;
00057 class QtGroupView;
00058 
00096 class MDL_QTHIPPOPLOT_API CanvasView : public FigureEditor
00097 {
00098 
00099 Q_OBJECT
00100 
00101 private:
00102 
00104   std::list <QAction *> m_recent_list;
00105 
00107   mutable std::vector < const ViewBase * > m_views; 
00108 
00110   mutable std::vector < const ViewBase * > m_sel_views; 
00111 
00113   std::map < const QtView *, PickTable * > m_table_map; 
00114 
00116   static XmlController * s_xml_controller;
00117 
00119   Inspector * m_inspector;
00120 
00123   static const std::string s_app_name;
00124 
00126   static std::string s_image_filters;
00127 
00130 #if QT_VERSION < 0x040000
00131    QCanvasRectangle * m_drag_rect;
00132 #else
00133    Q3CanvasRectangle * m_drag_rect;
00134 #endif
00135 
00141 #if QT_VERSION < 0x040000
00142   QFileDialog * m_image_dialog;
00143 #else
00144   Q3FileDialog * m_image_dialog;
00145 #endif
00146 
00148    std::vector<double> m_mouseData;
00149 
00151    bool fillPickedPoint(QMouseEvent * e, std::vector<double> & picked);
00152 
00155    void fillMouseData(const std::vector<double> & picked);
00156 
00157    void updatePickTable(QtView * qtview, std::vector<double> & picked);
00158 
00159    void setPlotZoom(const std::vector<double> & start_picked, 
00160                     const std::vector<double> & picked);
00161 
00164   int m_num_width;
00165 
00168   int m_num_height;
00169 
00172   bool m_add_selected;
00173   
00176   int m_cut_mode;
00177 
00183   int m_edge;
00184 
00187   bool m_clicked;
00188   
00191   double old_pos, old_pos_x, old_pos_y;
00192 
00193 
00196   std::vector<double> m_current_range;
00197   
00200   void initSettings ();
00201 
00204   void saveSettings () const;
00205 
00208   void initFitterDefault ();
00209 
00212   void setFitterDefault ( const std::string & name );
00213 
00216   void initFitterMenu ( QActionGroup * group );
00217 
00220   static void createImageFilters ();
00221 
00225   static bool isValidImageFormat ( const std::string & suffix );
00226 
00230 #if QT_VERSION < 0x040000
00231   QFileDialog * createImageDialog ();
00232 #else
00233   Q3FileDialog * createImageDialog ();
00234 #endif
00235  
00237   void setChanged ( bool yes = true );
00238 
00241   void addView ( QtView * view, bool select );
00242 
00245 #if QT_VERSION < 0x040000
00246   void placeItems ( const std::vector < QCanvasItem * > & items );
00247 #else
00248   void placeItems ( const std::vector < Q3CanvasItem * > & items );
00249 #endif
00250 
00253   virtual void calcDefaultSize ( QtView * view, double aspect_ratio = 0.0);
00254 
00258   void moveToPlotter ( const PlotterBase * plotter, QtView * view );
00259 
00262   void sizeAndPlace ( QtView * view );
00263 
00267   std::pair<double, double> moveToPlotterAt ( const PlotterBase * plotter,
00268                                                QtView * view,
00269                                                double x, double y );
00270 
00274   void fillSelectedWithObservers ( std::vector < const ViewBase * > & );
00275 
00276   PlotterBase * getRightClickedPlotter();
00277 
00278 
00279 
00280 protected:
00281 
00283   virtual void contentsMouseMoveEvent ( QMouseEvent * );
00284   virtual void contentsMousePressEvent ( QMouseEvent * );
00285 
00289   virtual void controlMousePressEvent ();
00290 
00294   virtual void contentsMouseReleaseEvent(QMouseEvent*);
00295 
00296 public:
00297  
00298 #if QT_VERSION < 0x040000
00299    CanvasView ( QCanvas *, QWidget * parent = 0, 
00300                 const char * name = 0, Qt::WFlags f = 0 );
00301 #else
00302    CanvasView ( Q3Canvas *, QWidget * parent = 0, 
00303                 const char * name = 0, Qt::WFlags f = 0 );
00304 #endif
00305 
00306   void initFrom ( const std::list < ViewBase * > & views );
00307 
00309   void initFromFile ( const std::string & filename );
00310 
00316   void initFitterSettings ( QActionGroup * group);
00317 
00320   void initRecentFiles ( QActionGroup * ag );
00321 
00324 #if QT_VERSION < 0x040000
00325   void initDockWindows ( QMainWindow * mw );
00326 #else
00327   void initDockWindows ( Q3MainWindow * mw );
00328 #endif
00329 
00331   void addRecentFile (const QString & filename, QActionGroup * ag );
00332 
00335   void setFitterDefault ( const QString & name );
00336 
00338   void copySelectedToPasteboard ();
00339 
00342   void copyFromPasteboard ();
00343 
00347   void addFromPasteboard ();
00348 
00352   void deleteSelected ( bool paste );
00353 
00356   void pasteViews ( const std::list < ViewBase * > & views );
00357 
00359   void restoreFromSelectCopy ();
00360 
00362   void setCurrentRange();
00363 
00365   std::vector<double>& getCurrentRange() ;
00366 
00369   void setInspector ( Inspector * inspector );
00370 
00372   Inspector * getInspector ();
00373 
00381   void notifyObservers ();
00382 
00384   PlotterBase * selectedPlotter () const;
00385 
00388   std::vector < PlotterBase * > getSelectedPlotters () const;
00389 
00393   void addPlotDisplay ( PlotterBase * plotter, bool select);
00394 
00396 #if QT_VERSION < 0x040000
00397   void autosaveSettings ( QMainWindow * mw);
00398 #else
00399   void autosaveSettings ( Q3MainWindow * mw);
00400 #endif
00401 public:
00402 
00406   void addTextDisplay ( PlotterBase * plotter, 
00407                         const std::string & s, 
00408                         const std::string & text = std::string () );
00409 
00414    std::pair<double, double> addTextDisplayAt ( PlotterBase * plotter,
00415                                                 const std::string & type,
00416                                                 const std::string & text,
00417                                                 double xrel, double yrel);
00418 
00419 
00421   void addFuncDisplay ( PlotterBase * plotter, const std::string & s );
00422 
00425   void removeDisplay ( PlotterBase * plotter );
00426 
00430   const std::vector < const ViewBase * > & selectedViews () const;
00431 
00436   const std::vector < const ViewBase * > & views () const;
00437 
00441   void fillPlotterList ( std::vector < PlotterBase * > & plotter_list );
00442 
00445   QtView * getViewFor ( const PlotterBase * plotter ) const;
00446 
00450   void previousView ();
00451 
00454   virtual void print ();
00455 
00458   virtual void print ( const std::string & filename );
00459 
00462   void reTile ();
00463 
00466   void reTilePage ();
00467 
00470   void setIntervalEnabled ( bool yes = true );
00471 
00473   void removeSelected ();
00474 
00476   void hideSelected ();
00477 
00482   void saveSelectedImages ();
00483 
00485    void saveSelectedImages ( const std::string & filename );
00486 
00489   void savePlotAsEps ( const PlotterBase * plotter,
00490                        const std::string & filename ) const;
00491 
00497   void savePlotAsFits ( const PlotterBase * plotter,
00498                         const std::string & filename ) const;
00499 
00502   void saveAs ( const std::string & filename ) const;
00503 
00506   static void saveAs ( const std::vector < const ViewBase * > & views,
00507                        const std::string & filename );
00508 
00511   static void saveAs ( const std::vector < PlotterBase * > & plotters,
00512                        const std::string & filename );
00513 
00518   void exportTextTuple ( const std::string & suffix );
00519 
00522   void showInspector ();
00523 
00525   void viewShowPickTable();
00526 
00529    const std::vector<double> & mouseEventData();
00530 
00534   void setPlotMatrix ( unsigned int columns, unsigned int rows );
00535 
00537   void createNTuple();
00538 
00540   void setup ();
00541   
00542  
00544   void setFonts( const QFont & font );
00545     
00547   void helpAbout ();
00548 
00551   const std::string & applicationName () const;
00552 
00555   void setAddedSelected ( bool yes );
00556 
00557   void setCutMode ( int mode );
00558 
00561   NTuple * getPickTable ();
00562 
00565   NTuple * getPickTable ( const PlotterBase * plotter );
00566 
00568   void groupView ();
00569 
00571   void ungroupView ();
00572 
00573 private:
00574 
00577   bool existingFileWarning ( const std::string & filename );
00578 
00581   void invalidImageFormatError ( const std::string & filename );
00582 
00584   void saveSelectedAsEps ( const std::string & filename );
00585 
00586 
00592   void saveSelectedAsFits ( const std::string & filename );
00593 public:
00597   void showFitsError () const;
00598 private:
00599 
00603   void setVisibleNonViews ( bool visible );
00604 
00612   void saveSelectedImages ( const std::string & filename, 
00613                             bool check_existing );
00614   
00617   static void toLower ( std::string & upper );
00618 
00619 public slots: 
00620 
00625   void addPlotDisplay ( PlotterBase * plotter );
00626 
00628   void clear ();
00629 
00635   void savePlotAsImage ( const PlotterBase * plotter,
00636                          const std::string & filename );
00637 
00640   void swapOrientation ();
00641 
00644   static QtView * wrapPlotter ( PlotterBase * plotter );
00645 
00646 };
00647 
00648 } // namespace hippodraw
00649 
00650 #endif // CanvasView_H

Generated for HippoDraw Class Library by doxygen