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 #include <qwt_double_rect.h>
00034 #include <qwt_plot_marker.h>
00035 #include <qwt_plot_picker.h>
00036 
00037 class QwtPlotCurve;
00038 class QPoint;
00039 class QEvent;
00040 
00052 class RangeSelectorTool : public QwtPlotPicker, public PlotToolInterface
00053 {
00054     Q_OBJECT
00055     public:
00056         RangeSelectorTool(Graph *graph, const QObject *status_target=NULL, const char *status_slot="");
00057         virtual ~RangeSelectorTool();
00058         double minXValue() const { return QMIN(d_active_marker.xValue(), d_inactive_marker.xValue()); }
00059         double maxXValue() const { return QMAX(d_active_marker.xValue(), d_inactive_marker.xValue()); }
00060         int dataSize() const { return qAbs(d_active_point - d_inactive_point); }
00061         virtual bool eventFilter(QObject *obj, QEvent *event);
00062         bool keyEventFilter(QKeyEvent *ke);
00063 
00064         QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
00066         void setSelectedCurve(QwtPlotCurve *curve);
00067 
00068         void copySelection();
00069         void cutSelection();
00070         void clearSelection();
00071         void pasteSelection();
00072         virtual int rtti() const {return PlotToolInterface::Rtti_RangeSelector;};
00073 
00074     public slots:
00075         virtual void pointSelected(const QPoint &point);
00076         void setCurveRange();
00077         void setEnabled(bool on = true);
00078 
00079     signals:
00084         void statusText(const QString&);
00086         void changed();
00087     protected:
00088         virtual void append(const QPoint& point) { pointSelected(point); }
00089         void emitStatusText();
00090         void switchActiveMarker();
00092         void setActivePoint(int index);
00093     private:
00094         QwtPlotMarker d_active_marker, d_inactive_marker;
00095         int d_active_point, d_inactive_point;
00096         QwtPlotCurve *d_selected_curve;
00097         bool d_enabled;
00098 };
00099 
00100 #endif // ifndef RANGE_SELECTOR_TOOL_H
00101 

Generated on Thu Feb 7 13:59:27 2008 for QtiPlot by  doxygen 1.5.4