PlotCursor.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2015 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
19 #ifndef RQT_MULTIPLOT_PLOT_CURSOR_H
20 #define RQT_MULTIPLOT_PLOT_CURSOR_H
21 
22 #include <QColor>
23 #include <QPoint>
24 #include <QVector>
25 
26 #include <qwt/qwt_plot_picker.h>
27 
28 class QwtPlotCanvas;
29 
30 namespace rqt_multiplot {
31  class PlotCursor :
32  public QwtPlotPicker {
33  Q_OBJECT
34  public:
35  PlotCursor(QwtPlotCanvas* canvas);
36  ~PlotCursor();
37 
38  void setActive(bool active, const QPointF& position = QPointF(0.0, 0.0));
39  using QwtPlotPicker::isActive;
40  void setCurrentPosition(const QPointF& position);
41  const QPointF& getCurrentPosition() const;
42  void setTrackPoints(bool track);
43  bool arePointsTracked() const;
44  bool hasMouseControl() const;
45 
46  void update();
47 
48  void drawRubberBand(QPainter* painter) const;
49 
50  signals:
51  void activeChanged(bool active);
52  void currentPositionChanged(const QPointF& position);
53 
54  protected:
55  QRect getTextRect(const QPointF& point, const QFont& font) const;
56 
57  QwtText trackerTextF(const QPointF& point) const;
58 
59  void begin();
60  void move(const QPoint& point);
61  bool end(bool ok = true);
62 
63  bool eventFilter(QObject* object, QEvent* event);
64 
65  void updateDisplay();
66  void updateTrackedPoints();
67 
68  void drawTrackedPoints(QPainter* painter) const;
69 
70  private:
71  struct TrackedPoint {
72  QPointF position;
73  QColor color;
74  };
75 
77  QVector<TrackedPoint> trackedPoints_;
78 
81 
82  private slots:
85  };
86 };
87 
88 #endif
QRect getTextRect(const QPointF &point, const QFont &font) const
Definition: PlotCursor.cpp:123
void drawTrackedPoints(QPainter *painter) const
Definition: PlotCursor.cpp:315
bool arePointsTracked() const
Definition: PlotCursor.cpp:115
QwtText trackerTextF(const QPointF &point) const
Definition: PlotCursor.cpp:168
PlotCursor(QwtPlotCanvas *canvas)
Definition: PlotCursor.cpp:44
bool eventFilter(QObject *object, QEvent *event)
Definition: PlotCursor.cpp:246
void move(const QPoint &point)
Definition: PlotCursor.cpp:221
void setActive(bool active, const QPointF &position=QPointF(0.0, 0.0))
Definition: PlotCursor.cpp:67
bool hasMouseControl() const
Definition: PlotCursor.cpp:119
QVector< TrackedPoint > trackedPoints_
Definition: PlotCursor.h:77
void setCurrentPosition(const QPointF &position)
Definition: PlotCursor.cpp:89
void currentPositionChanged(const QPointF &position)
void activeChanged(bool active)
void setTrackPoints(bool track)
Definition: PlotCursor.cpp:106
void drawRubberBand(QPainter *painter) const
Definition: PlotCursor.cpp:196
const QPointF & getCurrentPosition() const
Definition: PlotCursor.cpp:102
bool end(bool ok=true)
Definition: PlotCursor.cpp:235


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Wed Jul 10 2019 03:49:44