RangeSelectorTool.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : RangeSelectorTool.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006,2007 by Ion Vasilief, Knut Franke
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr, knut.franke*gmx.de
00007     Description          : Plot tool for selecting ranges on curves.
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
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

Generated by  doxygen 1.6.2