QtiPlot  0.9.8.2
RangeSelectorTool.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : RangeSelectorTool.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 ranges on curves.
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 RANGE_SELECTOR_TOOL_H
30 #define RANGE_SELECTOR_TOOL_H
31 
32 #include "PlotToolInterface.h"
33 
34 #include <QPointer>
35 
36 #include <qwt_double_rect.h>
37 #include <qwt_plot_marker.h>
38 #include <qwt_plot_picker.h>
39 
40 class QwtPlotCurve;
41 class QPoint;
42 class QEvent;
43 class QDialog;
44 class QCheckBox;
45 
57 class RangeSelectorTool : public QwtPlotPicker, public PlotToolInterface
58 {
59  Q_OBJECT
60  public:
61  RangeSelectorTool(Graph *graph, const QObject *status_target=NULL, const char *status_slot="");
62  virtual ~RangeSelectorTool();
63  double minXValue() const { return QMIN(d_active_marker.xValue(), d_inactive_marker.xValue()); }
64  double maxXValue() const { return QMAX(d_active_marker.xValue(), d_inactive_marker.xValue()); }
65  double minYValue() const { return QMIN(d_active_marker.yValue(), d_inactive_marker.yValue()); }
66  double maxYValue() const { return QMAX(d_active_marker.yValue(), d_inactive_marker.yValue()); }
67  int dataSize() const { return qAbs(d_active_point - d_inactive_point); }
68  virtual bool eventFilter(QObject *obj, QEvent *event);
69  bool keyEventFilter(QKeyEvent *ke);
70 
71  QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
73  void setSelectedCurve(QwtPlotCurve *curve);
74 
75  void copySelection();
76  void cutSelection();
77  void clearSelection();
78  void pasteSelection();
79  virtual int rtti() const {return PlotToolInterface::Rtti_RangeSelector;};
80 
81  void setVisible(bool on);
82  bool isVisible(){return d_visible;};
83 
84  public slots:
85  virtual void pointSelected(const QPoint &point);
86  void setCurveRange();
87  void setEnabled(bool on = true);
88 
89  private slots:
90  void copyMultipleSelection();
92  void cutMultipleSelection();
93 
94  signals:
99  void statusText(const QString&);
101  void changed();
102 
103  protected:
104  virtual void append(const QPoint& point) { pointSelected(point); }
105  void emitStatusText();
106  void switchActiveMarker();
108  void setActivePoint(int index);
109 
110  private:
112 
116  void copySelectedCurve();
118  void clearSelectedCurve();
119 
122  QwtPlotCurve *d_selected_curve;
123  bool d_enabled;
124  bool d_visible;
125 
126  QPointer <QDialog> d_selection_dialog;
128  QList<QCheckBox *> d_selection_lst;
129 };
130 
131 #endif // ifndef RANGE_SELECTOR_TOOL_H