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