QtiPlot  0.9.8.2
DataPickerTool.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : DataPickerTool.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006,2007 by Ion Vasilief, Knut Franke
6  Email (use @ for *) : ion_vasilief*yahoo.fr, knut.franke*gmx.de
7  Description : Plot tool for selecting individual points of a curve.
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef DATA_PICKER_TOOL_H
30 #define DATA_PICKER_TOOL_H
31 
32 #include "PlotToolInterface.h"
33 #include <qwt_plot_marker.h>
34 #include <qwt_plot_picker.h>
35 
36 class ApplicationWindow;
37 class QwtPlotCurve;
38 class QPoint;
39 
41 class DataPickerTool : public QwtPlotPicker, public PlotToolInterface
42 {
43  Q_OBJECT
44  public:
47  DataPickerTool(Graph *graph, ApplicationWindow *app, Mode mode, const QObject *status_target=NULL, const char *status_slot="");
48  virtual ~DataPickerTool();
49  virtual bool eventFilter(QObject *obj, QEvent *event);
50  bool keyEventFilter(QKeyEvent *ke);
51  QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
52  void setSelectedCurve(QwtPlotCurve *c){if (c) setSelection(c, 0);};
54 
55  void copySelection();
56  void cutSelection();
57  void pasteSelection();
58  void removePoint();
59 
61  Mode mode(){return d_mode;};
62  void setMode(Mode m){d_mode = m;};
63 
65  int findClosestPoint(QwtPlotCurve *c, double x, bool up);
66 
67  virtual int rtti() const {return PlotToolInterface::Rtti_DataPicker;};
68 
69  void selectTableRow();
70 
72 
73  public slots:
75 
76  signals:
81  void statusText(const QString&);
83  void selected(QwtPlotCurve*, int);
84  protected:
85  void movePoint(const QPoint &cursor);
86  virtual void append(const QPoint &point);
87  virtual void move(const QPoint &point);
88  virtual bool end(bool ok);
89  virtual void setSelection(QwtPlotCurve *curve, int point_index);
90  void moveBy(int dx, int dy);
91 
93  QwtPlotMarker d_selection_marker;
95  QwtPlotCurve *d_selected_curve;
99 };
100 
103 {
104  Q_OBJECT
105 
106  public:
107  BaselineTool(QwtPlotCurve *curve, Graph *graph, ApplicationWindow *app);
108 
109  protected:
110  void setSelection(QwtPlotCurve *curve, int point_index);
111 };
112 
113 #endif // ifndef DATA_PICKER_TOOL_H
114