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 
00053         void copySelection();
00054         void cutSelection();
00055         void pasteSelection();
00056         void removePoint();
00057 
00059         Mode mode(){return d_mode;};
00060         void setMode(Mode m){d_mode = m;};
00061 
00063         int findClosestPoint(QwtPlotCurve *c, double x, bool up);
00064 
00065         virtual int rtti() const {return PlotToolInterface::Rtti_DataPicker;};
00066 
00067         void selectTableRow();
00068 
00069     signals:
00074         void statusText(const QString&);
00076         void selected(QwtPlotCurve*, int);
00077     protected:
00078         void movePoint(const QPoint &cursor);
00079         virtual void append(const QPoint &point);
00080         virtual void move(const QPoint &point);
00081         virtual bool end(bool ok);
00082         void setSelection(QwtPlotCurve *curve, int point_index);
00083         void moveBy(int dx, int dy);
00084     private:
00085         ApplicationWindow *d_app;
00086         QwtPlotMarker d_selection_marker;
00087         Mode d_mode;
00088         QwtPlotCurve *d_selected_curve;
00089         int d_selected_point;
00090         MoveMode d_move_mode;
00091         QPoint d_restricted_move_pos;
00092 };
00093 
00094 #endif // ifndef DATA_PICKER_TOOL_H
00095 

Generated by  doxygen 1.6.2