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
double maxXValue() const
Definition: RangeSelectorTool.h:64
Definition: RangeSelectorTool.h:111
void clearMultipleSelection()
Definition: RangeSelectorTool.cpp:407
QwtPlotMarker d_active_marker
Definition: RangeSelectorTool.h:120
void setSelectedCurve(QwtPlotCurve *curve)
Caller is responsible for replot.
Definition: RangeSelectorTool.cpp:134
virtual void append(const QPoint &point)
Definition: RangeSelectorTool.h:104
double maxYValue() const
Definition: RangeSelectorTool.h:66
void pasteSelection()
Definition: RangeSelectorTool.cpp:561
void cutSelection()
Definition: RangeSelectorTool.cpp:298
virtual ~RangeSelectorTool()
Definition: RangeSelectorTool.cpp:99
RangeEditOperation
Definition: RangeSelectorTool.h:111
A 2D-plotting widget.
Definition: Graph.h:123
Definition: PlotToolInterface.h:68
void switchActiveMarker()
Definition: RangeSelectorTool.cpp:217
void copySelection()
Definition: RangeSelectorTool.cpp:311
void cutMultipleSelection()
Definition: RangeSelectorTool.cpp:369
void clearSelectedCurve()
Clears data range from the selected curve.
Definition: RangeSelectorTool.cpp:517
double minXValue() const
Definition: RangeSelectorTool.h:63
void clearSelection()
Definition: RangeSelectorTool.cpp:322
QwtPlotMarker d_inactive_marker
Definition: RangeSelectorTool.h:120
void showSelectionDialog(RangeEditOperation op=Copy)
Definition: RangeSelectorTool.cpp:453
int d_active_point
Definition: RangeSelectorTool.h:121
void statusText(const QString &)
double minYValue() const
Definition: RangeSelectorTool.h:65
Definition: RangeSelectorTool.h:111
void copySelectedCurve()
Copies data range from the selected curve to clipboard.
Definition: RangeSelectorTool.cpp:333
bool isVisible()
Definition: RangeSelectorTool.h:82
QPointer< QDialog > d_selection_dialog
Definition: RangeSelectorTool.h:126
int dataSize() const
Definition: RangeSelectorTool.h:67
void changed()
Emitted whenever the selected curve and/or range have changed.
virtual void pointSelected(const QPoint &point)
Definition: RangeSelectorTool.cpp:110
bool d_enabled
Definition: RangeSelectorTool.h:123
Definition: RangeSelectorTool.h:111
void emitStatusText()
Definition: RangeSelectorTool.cpp:157
void setEnabled(bool on=true)
Definition: RangeSelectorTool.cpp:640
RangeSelectorTool(Graph *graph, const QObject *status_target=NULL, const char *status_slot="")
Definition: RangeSelectorTool.cpp:48
void setCurveRange()
Definition: RangeSelectorTool.cpp:627
void setVisible(bool on)
Definition: RangeSelectorTool.cpp:647
void setActivePoint(int index)
Caller is responsible for replot.
Definition: RangeSelectorTool.cpp:147
Definition: PlotToolInterface.h:60
virtual bool eventFilter(QObject *obj, QEvent *event)
Definition: RangeSelectorTool.cpp:230
QList< QCheckBox * > d_selection_lst
Keeps track of the multiple curves selection.
Definition: RangeSelectorTool.h:128
bool keyEventFilter(QKeyEvent *ke)
Definition: RangeSelectorTool.cpp:243
bool d_visible
Definition: RangeSelectorTool.h:124
QwtPlotCurve * selectedCurve() const
Definition: RangeSelectorTool.h:71
Definition: RangeSelectorTool.h:57
virtual int rtti() const
Definition: RangeSelectorTool.h:79
bool mightNeedMultipleSelection()
Definition: RangeSelectorTool.cpp:354
int d_inactive_point
Definition: RangeSelectorTool.h:121
void copyMultipleSelection()
Definition: RangeSelectorTool.cpp:375
QwtPlotCurve * d_selected_curve
Definition: RangeSelectorTool.h:122