SciDAVis  1.D4
RangeSelectorTool.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : RangeSelectorTool.h
3  Project : SciDAVis
4  --------------------------------------------------------------------
5  Copyright : (C) 2006,2007 by Ion Vasilief,
6  Tilman Benkert, Knut Franke
7  Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net,
8  knut.franke*gmx.de
9  Description : Plot tool for selecting ranges on curves.
10 
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  * This program is distributed in the hope that it will be useful, *
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
23  * GNU General Public License for more details. *
24  * *
25  * You should have received a copy of the GNU General Public License *
26  * along with this program; if not, write to the Free Software *
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
28  * Boston, MA 02110-1301 USA *
29  * *
30  ***************************************************************************/
31 #ifndef RANGE_SELECTOR_TOOL_H
32 #define RANGE_SELECTOR_TOOL_H
33 
34 #include "PlotToolInterface.h"
35 #include <qwt_double_rect.h>
36 #include <qwt_plot_marker.h>
37 #include <qwt_plot_picker.h>
38 
39 class QwtPlotCurve;
40 class QPoint;
41 class QEvent;
42 
54 class RangeSelectorTool : public QwtPlotPicker, public PlotToolInterface
55 {
56  Q_OBJECT
57  public:
58  RangeSelectorTool(Graph *graph, const QObject *status_target=NULL, const char *status_slot="");
59  virtual ~RangeSelectorTool();
60  virtual RTTI rtti() const { return RangeSelector; }
61  double minXValue() const { return qMin(d_active_marker.xValue(), d_inactive_marker.xValue()); }
62  double maxXValue() const { return qMax(d_active_marker.xValue(), d_inactive_marker.xValue()); }
63  int dataSize() const { return qAbs(d_active_point - d_inactive_point); }
64  virtual bool eventFilter(QObject *obj, QEvent *event);
65  bool keyEventFilter(QKeyEvent *ke);
66 
67  QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
69  void setSelectedCurve(QwtPlotCurve *curve);
70 
71  public slots:
72  virtual void pointSelected(const QPoint &point);
73 
74  signals:
79  void statusText(const QString&);
81  void changed();
82  protected:
83  virtual void append(const QPoint& point) { pointSelected(point); }
84  void emitStatusText();
85  void switchActiveMarker();
87  void setActivePoint(int index);
88  private:
91  QwtPlotCurve *d_selected_curve;
92 };
93 
94 #endif // ifndef RANGE_SELECTOR_TOOL_H
95