00001 #ifndef CUSTOMTRACKER_H 00002 #define CUSTOMTRACKER_H 00003 00004 #include <QEvent> 00005 #include "qwt_plot_picker.h" 00006 #include "qwt_picker_machine.h" 00007 #include "qwt_plot_marker.h" 00008 00009 class QwtPlotCurve; 00010 00011 00012 class CurveTracker: public QObject 00013 { 00014 Q_OBJECT 00015 public: 00016 explicit CurveTracker(QwtPlot * ); 00017 00018 QPointF actualPosition() const; 00019 00020 typedef enum { 00021 LINE_ONLY, 00022 VALUE, 00023 VALUE_NAME 00024 }Parameter; 00025 00026 public slots: 00027 00028 void setPosition(const QPointF & pos); 00029 00030 void setParameter(Parameter par); 00031 00032 void setEnabled(bool enable); 00033 00034 void redraw() 00035 { 00036 setPosition(_prev_trackerpoint); 00037 } 00038 00039 private: 00040 QLineF curveLineAt( const QwtPlotCurve *, double x ) const; 00041 00042 QPointF transform( QPoint); 00043 00044 QPoint invTransform( QPointF); 00045 00046 QPointF _prev_trackerpoint; 00047 std::vector<QwtPlotMarker*> _marker; 00048 QwtPlotMarker* _line_marker; 00049 QwtPlotMarker* _text_marker; 00050 QwtPlot* _plot; 00051 Parameter _param; 00052 bool _visible; 00053 00054 }; 00055 00056 #endif // CUSTOMTRACKER_H