RangeSelectorTool.h
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 int dataSize() const { return qAbs(d_active_point - d_inactive_point); }
00066 virtual bool eventFilter(QObject *obj, QEvent *event);
00067 bool keyEventFilter(QKeyEvent *ke);
00068
00069 QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
00071 void setSelectedCurve(QwtPlotCurve *curve);
00072
00073 void copySelection();
00074 void cutSelection();
00075 void clearSelection();
00076 void pasteSelection();
00077 virtual int rtti() const {return PlotToolInterface::Rtti_RangeSelector;};
00078
00079 void setVisible(bool on);
00080 bool isVisible(){return d_visible;};
00081
00082 public slots:
00083 virtual void pointSelected(const QPoint &point);
00084 void setCurveRange();
00085 void setEnabled(bool on = true);
00086
00087 private slots:
00088 void copyMultipleSelection();
00089 void clearMultipleSelection();
00090 void cutMultipleSelection();
00091
00092 signals:
00097 void statusText(const QString&);
00099 void changed();
00100
00101 protected:
00102 virtual void append(const QPoint& point) { pointSelected(point); }
00103 void emitStatusText();
00104 void switchActiveMarker();
00106 void setActivePoint(int index);
00107
00108 private:
00109 enum RangeEditOperation{Copy, Cut, Delete};
00110
00111 void showSelectionDialog(RangeEditOperation op = Copy);
00112 bool mightNeedMultipleSelection();
00114 void copySelectedCurve();
00116 void clearSelectedCurve();
00117
00118 QwtPlotMarker d_active_marker, d_inactive_marker;
00119 int d_active_point, d_inactive_point;
00120 QwtPlotCurve *d_selected_curve;
00121 bool d_enabled;
00122 bool d_visible;
00123
00124 QPointer <QDialog> d_selection_dialog;
00126 QList<QCheckBox *> d_selection_lst;
00127 };
00128
00129 #endif // ifndef RANGE_SELECTOR_TOOL_H