DataPickerTool.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef DATA_PICKER_TOOL_H
00030 #define DATA_PICKER_TOOL_H
00031
00032 #include "PlotToolInterface.h"
00033 #include <qwt_plot_marker.h>
00034 #include <qwt_plot_picker.h>
00035
00036 class ApplicationWindow;
00037 class QwtPlotCurve;
00038 class QPoint;
00039
00041 class DataPickerTool : public QwtPlotPicker, public PlotToolInterface
00042 {
00043 Q_OBJECT
00044 public:
00045 enum Mode { Display, Move, Remove, MoveCurve };
00046 enum MoveMode {Free, Vertical, Horizontal};
00047 DataPickerTool(Graph *graph, ApplicationWindow *app, Mode mode, const QObject *status_target=NULL, const char *status_slot="");
00048 virtual ~DataPickerTool();
00049 virtual bool eventFilter(QObject *obj, QEvent *event);
00050 bool keyEventFilter(QKeyEvent *ke);
00051 QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
00052
00053 void copySelection();
00054 void cutSelection();
00055 void pasteSelection();
00056 void removePoint();
00057
00059 Mode mode(){return d_mode;};
00060 void setMode(Mode m){d_mode = m;};
00061
00063 int findClosestPoint(QwtPlotCurve *c, double x, bool up);
00064
00065 virtual int rtti() const {return PlotToolInterface::Rtti_DataPicker;};
00066
00067 void selectTableRow();
00068
00069 signals:
00074 void statusText(const QString&);
00076 void selected(QwtPlotCurve*, int);
00077 protected:
00078 void movePoint(const QPoint &cursor);
00079 virtual void append(const QPoint &point);
00080 virtual void move(const QPoint &point);
00081 virtual bool end(bool ok);
00082 void setSelection(QwtPlotCurve *curve, int point_index);
00083 void moveBy(int dx, int dy);
00084 private:
00085 ApplicationWindow *d_app;
00086 QwtPlotMarker d_selection_marker;
00087 Mode d_mode;
00088 QwtPlotCurve *d_selected_curve;
00089 int d_selected_point;
00090 MoveMode d_move_mode;
00091 QPoint d_restricted_move_pos;
00092 };
00093
00094 #endif // ifndef DATA_PICKER_TOOL_H
00095