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,
00006                            Tilman Hoener zu Siederdissen, Knut Franke
00007     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net,
00008                            knut.franke*gmx.de
00009     Description          : Plot tool for selecting individual points of a curve.
00010 
00011  ***************************************************************************/
00012 
00013 /***************************************************************************
00014  *                                                                         *
00015  *  This program is free software; you can redistribute it and/or modify   *
00016  *  it under the terms of the GNU General Public License as published by   *
00017  *  the Free Software Foundation; either version 2 of the License, or      *
00018  *  (at your option) any later version.                                    *
00019  *                                                                         *
00020  *  This program is distributed in the hope that it will be useful,        *
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00023  *  GNU General Public License for more details.                           *
00024  *                                                                         *
00025  *   You should have received a copy of the GNU General Public License     *
00026  *   along with this program; if not, write to the Free Software           *
00027  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00028  *   Boston, MA  02110-1301  USA                                           *
00029  *                                                                         *
00030  ***************************************************************************/
00031 #ifndef DATA_PICKER_TOOL_H
00032 #define DATA_PICKER_TOOL_H
00033 
00034 #include "PlotToolInterface.h"
00035 #include <qwt_plot_marker.h>
00036 #include <qwt_plot_picker.h>
00037 
00038 class ApplicationWindow;
00039 class QwtPlotCurve;
00040 class QPoint;
00041 
00043 class DataPickerTool : public QwtPlotPicker, public PlotToolInterface
00044 {
00045     Q_OBJECT
00046     public:
00047         enum Mode { Display, Move, Remove };
00048         enum MoveMode {Free, Vertical, Horizontal};
00049         DataPickerTool(Graph *graph, ApplicationWindow *app, Mode mode, const QObject *status_target=NULL, const char *status_slot="");
00050         virtual ~DataPickerTool();
00051         virtual bool eventFilter(QObject *obj, QEvent *event);
00052         bool keyEventFilter(QKeyEvent *ke);
00053         QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
00054 
00055         void copySelection();
00056         void cutSelection();
00057         void pasteSelection();
00058         void removePoint();
00060         int findClosestPoint(QwtPlotCurve *c, double x, bool up);
00061 
00062         virtual int rtti() const {return PlotToolInterface::Rtti_DataPicker;};
00063 
00064         void selectTableRow();
00065 
00066     signals:
00071         void statusText(const QString&);
00073         void selected(QwtPlotCurve*, int);
00074     protected:
00075         void movePoint(const QPoint &cursor);
00076         virtual void append(const QPoint &point);
00077         virtual void move(const QPoint &point);
00078         virtual bool end(bool ok);
00079         void setSelection(QwtPlotCurve *curve, int point_index);
00080         void moveBy(int dx, int dy);
00081     private:
00082         ApplicationWindow *d_app;
00083         QwtPlotMarker d_selection_marker;
00084         Mode d_mode;
00085         QwtPlotCurve *d_selected_curve;
00086         int d_selected_point;
00087         MoveMode d_move_mode;
00088         QPoint d_restricted_move_pos;
00089 };
00090 
00091 #endif // ifndef DATA_PICKER_TOOL_H
00092 

Generated on Fri Nov 7 03:36:52 2008 for QtiPlot by  doxygen 1.5.6