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 RANGE_SELECTOR_TOOL_H
00030 #define RANGE_SELECTOR_TOOL_H
00031
00032 #include "PlotToolInterface.h"
00033
00034 #include <QPointer>
00035
00036 #include <qwt_double_rect.h>
00037 #include <qwt_plot_marker.h>
00038 #include <qwt_plot_picker.h>
00039
00040 class QwtPlotCurve;
00041 class QPoint;
00042 class QEvent;
00043 class QDialog;
00044 class QCheckBox;
00045
00057 class RangeSelectorTool : public QwtPlotPicker, public PlotToolInterface
00058 {
00059 Q_OBJECT
00060 public:
00061 RangeSelectorTool(Graph *graph, const QObject *status_target=NULL, const char *status_slot="");
00062 virtual ~RangeSelectorTool();
00063 double minXValue() const { return QMIN(d_active_marker.xValue(), d_inactive_marker.xValue()); }
00064 double maxXValue() const { return QMAX(d_active_marker.xValue(), d_inactive_marker.xValue()); }
00065 double minYValue() const { return QMIN(d_active_marker.yValue(), d_inactive_marker.yValue()); }
00066 double maxYValue() const { return QMAX(d_active_marker.yValue(), d_inactive_marker.yValue()); }
00067 int dataSize() const { return qAbs(d_active_point - d_inactive_point); }
00068 virtual bool eventFilter(QObject *obj, QEvent *event);
00069 bool keyEventFilter(QKeyEvent *ke);
00070
00071 QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
00073 void setSelectedCurve(QwtPlotCurve *curve);
00074
00075 void copySelection();
00076 void cutSelection();
00077 void clearSelection();
00078 void pasteSelection();
00079 virtual int rtti() const {return PlotToolInterface::Rtti_RangeSelector;};
00080
00081 void setVisible(bool on);
00082 bool isVisible(){return d_visible;};
00083
00084 public slots:
00085 virtual void pointSelected(const QPoint &point);
00086 void setCurveRange();
00087 void setEnabled(bool on = true);
00088
00089 private slots:
00090 void copyMultipleSelection();
00091 void clearMultipleSelection();
00092 void cutMultipleSelection();
00093
00094 signals:
00099 void statusText(const QString&);
00101 void changed();
00102
00103 protected:
00104 virtual void append(const QPoint& point) { pointSelected(point); }
00105 void emitStatusText();
00106 void switchActiveMarker();
00108 void setActivePoint(int index);
00109
00110 private:
00111 enum RangeEditOperation{Copy, Cut, Delete};
00112
00113 void showSelectionDialog(RangeEditOperation op = Copy);
00114 bool mightNeedMultipleSelection();
00116 void copySelectedCurve();
00118 void clearSelectedCurve();
00119
00120 QwtPlotMarker d_active_marker, d_inactive_marker;
00121 int d_active_point, d_inactive_point;
00122 QwtPlotCurve *d_selected_curve;
00123 bool d_enabled;
00124 bool d_visible;
00125
00126 QPointer <QDialog> d_selection_dialog;
00128 QList<QCheckBox *> d_selection_lst;
00129 };
00130
00131 #endif // ifndef RANGE_SELECTOR_TOOL_H