QtiPlot 0.9.8.2
DataPickerTool.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : DataPickerTool.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 individual points of a curve.
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 DATA_PICKER_TOOL_H
00030 #define DATA_PICKER_TOOL_H
00031 
00032 #include "PlotToolInterface.h"
00033 #include <qwt_plot_marker.h>
00034 #include <qwt_plot_picker.h>
00035 
00036 class ApplicationWindow;
00037 class QwtPlotCurve;
00038 class QPoint;
00039 
00041 class DataPickerTool : public QwtPlotPicker, public PlotToolInterface
00042 {
00043     Q_OBJECT
00044     public:
00045         enum Mode { Display, Move, Remove, MoveCurve};
00046         enum MoveMode {Free, Vertical, Horizontal};
00047         DataPickerTool(Graph *graph, ApplicationWindow *app, Mode mode, const QObject *status_target=NULL, const char *status_slot="");
00048         virtual ~DataPickerTool();
00049         virtual bool eventFilter(QObject *obj, QEvent *event);
00050         bool keyEventFilter(QKeyEvent *ke);
00051         QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
00052         void setSelectedCurve(QwtPlotCurve *c){if (c) setSelection(c, 0);};
00053         int selectedPointIndex(){return d_selected_point;};
00054 
00055         void copySelection();
00056         void cutSelection();
00057         void pasteSelection();
00058         void removePoint();
00059 
00061         Mode mode(){return d_mode;};
00062         void setMode(Mode m){d_mode = m;};
00063 
00065         int findClosestPoint(QwtPlotCurve *c, double x, bool up);
00066 
00067         virtual int rtti() const {return PlotToolInterface::Rtti_DataPicker;};
00068 
00069         void selectTableRow();
00070 
00071         ApplicationWindow *applicationWindow(){return d_app;};
00072 
00073     public slots:
00074         void pasteSelectionAsLayerText();
00075 
00076     signals:
00081         void statusText(const QString&);
00083         void selected(QwtPlotCurve*, int);
00084     protected:
00085         void movePoint(const QPoint &cursor);
00086         virtual void append(const QPoint &point);
00087         virtual void move(const QPoint &point);
00088         virtual bool end(bool ok);
00089         virtual void setSelection(QwtPlotCurve *curve, int point_index);
00090         void moveBy(int dx, int dy);
00091 
00092         ApplicationWindow *d_app;
00093         QwtPlotMarker d_selection_marker;
00094         Mode d_mode;
00095         QwtPlotCurve *d_selected_curve;
00096         int d_selected_point;
00097         MoveMode d_move_mode;
00098         QPoint d_restricted_move_pos;
00099 };
00100 
00102 class BaselineTool : public DataPickerTool
00103 {
00104     Q_OBJECT
00105 
00106     public:
00107         BaselineTool(QwtPlotCurve *curve, Graph *graph, ApplicationWindow *app);
00108 
00109     protected:
00110         void setSelection(QwtPlotCurve *curve, int point_index);
00111 };
00112 
00113 #endif // ifndef DATA_PICKER_TOOL_H
00114