00001 #ifndef PLOT_H 00002 #define PLOT_H 00003 00004 #include <qwt_plot.h> 00005 #include <qwt_plot_grid.h> 00006 00007 #include "Plot/PlotCurve.h" 00008 00009 #include <QTimer> 00010 00011 class QwtLegend; 00012 class QwtPlotGrid; 00013 00014 class PlotSelector; 00015 class PlotTracker; 00016 class PlotZoomer; 00017 00018 class Plot : public QwtPlot 00019 { 00020 Q_OBJECT 00021 00022 //===================================================================================== 00023 // Constructors and destructor 00024 //===================================================================================== 00025 public: 00026 Plot( QWidget* parent = 0 ); 00027 virtual ~Plot(); 00028 00029 //===================================================================================== 00030 // Signals 00031 //===================================================================================== 00032 signals: 00033 void curveContextMenuRequested( const QPoint& point, PlotCurve* curve ); 00034 void canvasContextMenuRequested( const QPoint& point, PlotCurve* curve ); 00035 void canvasMousePressed( const QPoint& point ); 00036 void mouseMoved(); 00037 void deleteKeyPressed(); 00038 void signal_curveAttached(PlotCurve *curve); 00039 00040 //===================================================================================== 00041 // Slots 00042 //===================================================================================== 00043 public slots: 00044 void showCurve( QwtPlotItem* item, bool flag ); 00045 void curveContextMenuRequested( const QPoint& point ); 00046 void replot(); 00047 00048 //void filterData(); 00049 00050 //===================================================================================== 00051 // Methods 00052 //===================================================================================== 00053 public: 00054 PlotTracker* tracker() { return m_tracker; } 00055 PlotZoomer* zoomerLeft() { return m_zoomerLeft; } 00056 PlotZoomer* zoomerRight() { return m_zoomerRight; } 00057 PlotSelector* selector() { return m_selector; } 00058 QwtPlotGrid* grid() { return m_grid; } 00059 void enableGrid(bool flag){ 00060 if (flag && !gridIsEnabled()) m_grid->attach(this); 00061 if (!flag && gridIsEnabled()) m_grid->detach(); 00062 } 00063 bool gridIsEnabled(){ 00064 return static_cast<bool>(m_grid->plot()); 00065 } 00066 00067 00068 protected: 00069 // Inherited from QwtPlot 00070 virtual void resizeEvent ( QResizeEvent* e ); 00071 00072 // Inherited from QWidget 00073 void mousePressEvent( QMouseEvent* event ); 00074 void mouseMoveEvent( QMouseEvent* event ); 00075 void keyPressEvent( QKeyEvent* event ); 00076 00077 private: 00078 // void adjustCanvasGradient(); 00079 00080 //===================================================================================== 00081 // Members 00082 //===================================================================================== 00083 private: 00084 QwtLegend* m_legend; 00085 PlotTracker* m_tracker; 00086 PlotZoomer* m_zoomerLeft; 00087 PlotZoomer* m_zoomerRight; 00088 PlotSelector* m_selector; 00089 QwtPlotGrid* m_grid; 00090 QTimer replotTimer; 00091 }; 00092 00093 #endif