00001 #ifndef PLOTMAGNIFIER_H 00002 #define PLOTMAGNIFIER_H 00003 00004 #include <QTimer> 00005 #include "qwt_plot_magnifier.h" 00006 #include "qwt_plot.h" 00007 #include <QEvent> 00008 00009 class PlotMagnifier : public QwtPlotMagnifier 00010 { 00011 Q_OBJECT 00012 00013 public: 00014 explicit PlotMagnifier( QWidget *canvas); 00015 virtual ~PlotMagnifier() override; 00016 00017 void setAxisLimits(int axis,double lower, double upper); 00018 virtual void widgetWheelEvent( QWheelEvent *event ) override; 00019 00020 enum AxisMode {X_AXIS, Y_AXIS, BOTH_AXES}; 00021 00022 virtual void rescale( double factor ) override 00023 { 00024 rescale( factor, _default_mode ); 00025 } 00026 00027 void setDefaultMode(AxisMode mode) { _default_mode = mode; } 00028 00029 void rescale( double factor, AxisMode axis ); 00030 protected: 00031 00032 virtual void widgetMousePressEvent( QMouseEvent* event ) override; 00033 00034 double _lower_bounds[QwtPlot::axisCnt]; 00035 double _upper_bounds[QwtPlot::axisCnt]; 00036 00037 QPointF _mouse_position; 00038 00039 signals: 00040 void rescaled(QRectF new_size); 00041 00042 private: 00043 QPointF invTransform(QPoint pos); 00044 QTimer _future_emit; 00045 AxisMode _default_mode; 00046 00047 }; 00048 00049 #endif // PLOTMAGNIFIER_H