RangeSelectorTool.h
Go to the documentation of this file.
/***************************************************************************
File : RangeSelectorTool.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006,2007 by Ion Vasilief, Knut Franke
Email (use @ for *) : ion_vasilief*yahoo.fr, knut.franke*gmx.de
Description : Plot tool for selecting ranges on curves.
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef RANGE_SELECTOR_TOOL_H
#define RANGE_SELECTOR_TOOL_H
#include "PlotToolInterface.h"
#include <QPointer>
#include <qwt_double_rect.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_picker.h>
class QwtPlotCurve;
class QPoint;
class QEvent;
class QDialog;
class QCheckBox;
class RangeSelectorTool : public QwtPlotPicker, public PlotToolInterface
{
Q_OBJECT
public:
RangeSelectorTool(Graph *graph, const QObject *status_target=NULL, const char *status_slot="");
virtual ~RangeSelectorTool();
double minXValue() const { return QMIN(d_active_marker.xValue(), d_inactive_marker.xValue()); }
double maxXValue() const { return QMAX(d_active_marker.xValue(), d_inactive_marker.xValue()); }
double minYValue() const { return QMIN(d_active_marker.yValue(), d_inactive_marker.yValue()); }
double maxYValue() const { return QMAX(d_active_marker.yValue(), d_inactive_marker.yValue()); }
int dataSize() const { return qAbs(d_active_point - d_inactive_point); }
virtual bool eventFilter(QObject *obj, QEvent *event);
bool keyEventFilter(QKeyEvent *ke);
QwtPlotCurve *selectedCurve() const { return d_selected_curve; }
void setSelectedCurve(QwtPlotCurve *curve);
void copySelection();
void cutSelection();
void clearSelection();
void pasteSelection();
virtual int rtti() const {return PlotToolInterface::Rtti_RangeSelector;};
void setVisible(bool on);
bool isVisible(){return d_visible;};
public slots:
virtual void pointSelected(const QPoint &point);
void setCurveRange();
void setEnabled(bool on = true);
private slots:
void copyMultipleSelection();
void clearMultipleSelection();
void cutMultipleSelection();
signals:
void statusText(const QString&);
void changed();
protected:
virtual void append(const QPoint& point) { pointSelected(point); }
void emitStatusText();
void switchActiveMarker();
void setActivePoint(int index);
private:
enum RangeEditOperation{Copy, Cut, Delete};
void showSelectionDialog(RangeEditOperation op = Copy);
bool mightNeedMultipleSelection();
void copySelectedCurve();
void clearSelectedCurve();
QwtPlotMarker d_active_marker, d_inactive_marker;
int d_active_point, d_inactive_point;
QwtPlotCurve *d_selected_curve;
bool d_enabled;
bool d_visible;
QPointer <QDialog> d_selection_dialog;
QList<QCheckBox *> d_selection_lst;
};
#endif // ifndef RANGE_SELECTOR_TOOL_H
RangeSelectorTool::maxXValue
double maxXValue() const
Definition: RangeSelectorTool.h:64
RangeSelectorTool::Cut
Definition: RangeSelectorTool.h:111
RangeSelectorTool::clearMultipleSelection
void clearMultipleSelection()
Definition: RangeSelectorTool.cpp:407
RangeSelectorTool::d_active_marker
QwtPlotMarker d_active_marker
Definition: RangeSelectorTool.h:120
RangeSelectorTool::setSelectedCurve
void setSelectedCurve(QwtPlotCurve *curve)
Caller is responsible for replot.
Definition: RangeSelectorTool.cpp:134
RangeSelectorTool::append
virtual void append(const QPoint &point)
Definition: RangeSelectorTool.h:104
RangeSelectorTool::maxYValue
double maxYValue() const
Definition: RangeSelectorTool.h:66
RangeSelectorTool::pasteSelection
void pasteSelection()
Definition: RangeSelectorTool.cpp:561
RangeSelectorTool::cutSelection
void cutSelection()
Definition: RangeSelectorTool.cpp:298
RangeSelectorTool::~RangeSelectorTool
virtual ~RangeSelectorTool()
Definition: RangeSelectorTool.cpp:99
RangeSelectorTool::RangeEditOperation
RangeEditOperation
Definition: RangeSelectorTool.h:111
Graph
A 2D-plotting widget.
Definition: Graph.h:123
PlotToolInterface::Rtti_RangeSelector
Definition: PlotToolInterface.h:68
RangeSelectorTool::switchActiveMarker
void switchActiveMarker()
Definition: RangeSelectorTool.cpp:217
RangeSelectorTool::copySelection
void copySelection()
Definition: RangeSelectorTool.cpp:311
RangeSelectorTool::cutMultipleSelection
void cutMultipleSelection()
Definition: RangeSelectorTool.cpp:369
RangeSelectorTool::clearSelectedCurve
void clearSelectedCurve()
Clears data range from the selected curve.
Definition: RangeSelectorTool.cpp:517
RangeSelectorTool::minXValue
double minXValue() const
Definition: RangeSelectorTool.h:63
RangeSelectorTool::clearSelection
void clearSelection()
Definition: RangeSelectorTool.cpp:322
RangeSelectorTool::d_inactive_marker
QwtPlotMarker d_inactive_marker
Definition: RangeSelectorTool.h:120
RangeSelectorTool::showSelectionDialog
void showSelectionDialog(RangeEditOperation op=Copy)
Definition: RangeSelectorTool.cpp:453
RangeSelectorTool::d_active_point
int d_active_point
Definition: RangeSelectorTool.h:121
RangeSelectorTool::statusText
void statusText(const QString &)
RangeSelectorTool::minYValue
double minYValue() const
Definition: RangeSelectorTool.h:65
RangeSelectorTool::Delete
Definition: RangeSelectorTool.h:111
RangeSelectorTool::copySelectedCurve
void copySelectedCurve()
Copies data range from the selected curve to clipboard.
Definition: RangeSelectorTool.cpp:333
RangeSelectorTool::isVisible
bool isVisible()
Definition: RangeSelectorTool.h:82
RangeSelectorTool::d_selection_dialog
QPointer< QDialog > d_selection_dialog
Definition: RangeSelectorTool.h:126
RangeSelectorTool::dataSize
int dataSize() const
Definition: RangeSelectorTool.h:67
RangeSelectorTool::changed
void changed()
Emitted whenever the selected curve and/or range have changed.
RangeSelectorTool::pointSelected
virtual void pointSelected(const QPoint &point)
Definition: RangeSelectorTool.cpp:110
RangeSelectorTool::d_enabled
bool d_enabled
Definition: RangeSelectorTool.h:123
RangeSelectorTool::Copy
Definition: RangeSelectorTool.h:111
RangeSelectorTool::emitStatusText
void emitStatusText()
Definition: RangeSelectorTool.cpp:157
RangeSelectorTool::setEnabled
void setEnabled(bool on=true)
Definition: RangeSelectorTool.cpp:640
RangeSelectorTool::RangeSelectorTool
RangeSelectorTool(Graph *graph, const QObject *status_target=NULL, const char *status_slot="")
Definition: RangeSelectorTool.cpp:48
RangeSelectorTool::setCurveRange
void setCurveRange()
Definition: RangeSelectorTool.cpp:627
RangeSelectorTool::setVisible
void setVisible(bool on)
Definition: RangeSelectorTool.cpp:647
RangeSelectorTool::setActivePoint
void setActivePoint(int index)
Caller is responsible for replot.
Definition: RangeSelectorTool.cpp:147
PlotToolInterface.h
PlotToolInterface
Definition: PlotToolInterface.h:60
RangeSelectorTool::eventFilter
virtual bool eventFilter(QObject *obj, QEvent *event)
Definition: RangeSelectorTool.cpp:230
RangeSelectorTool::d_selection_lst
QList< QCheckBox * > d_selection_lst
Keeps track of the multiple curves selection.
Definition: RangeSelectorTool.h:128
RangeSelectorTool::keyEventFilter
bool keyEventFilter(QKeyEvent *ke)
Definition: RangeSelectorTool.cpp:243
RangeSelectorTool::d_visible
bool d_visible
Definition: RangeSelectorTool.h:124
RangeSelectorTool::selectedCurve
QwtPlotCurve * selectedCurve() const
Definition: RangeSelectorTool.h:71
RangeSelectorTool
Definition: RangeSelectorTool.h:57
RangeSelectorTool::rtti
virtual int rtti() const
Definition: RangeSelectorTool.h:79
RangeSelectorTool::mightNeedMultipleSelection
bool mightNeedMultipleSelection()
Definition: RangeSelectorTool.cpp:354
RangeSelectorTool::d_inactive_point
int d_inactive_point
Definition: RangeSelectorTool.h:121
RangeSelectorTool::copyMultipleSelection
void copyMultipleSelection()
Definition: RangeSelectorTool.cpp:375
RangeSelectorTool::d_selected_curve
QwtPlotCurve * d_selected_curve
Definition: RangeSelectorTool.h:122