PlotCursor.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2015 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00019 #ifndef RQT_MULTIPLOT_PLOT_CURSOR_H
00020 #define RQT_MULTIPLOT_PLOT_CURSOR_H
00021 
00022 #include <QColor>
00023 #include <QPoint>
00024 #include <QVector>
00025 
00026 #include <qwt/qwt_plot_picker.h>
00027 
00028 class QwtPlotCanvas;
00029 
00030 namespace rqt_multiplot {
00031   class PlotCursor :
00032     public QwtPlotPicker {
00033   Q_OBJECT
00034   public:
00035     PlotCursor(QwtPlotCanvas* canvas);
00036     ~PlotCursor();
00037 
00038     void setActive(bool active, const QPointF& position = QPointF(0.0, 0.0));
00039     using QwtPlotPicker::isActive;
00040     void setCurrentPosition(const QPointF& position);
00041     const QPointF& getCurrentPosition() const;
00042     void setTrackPoints(bool track);
00043     bool arePointsTracked() const;
00044     bool hasMouseControl() const;
00045 
00046     void update();
00047 
00048     void drawRubberBand(QPainter* painter) const;
00049 
00050   signals:
00051     void activeChanged(bool active);
00052     void currentPositionChanged(const QPointF& position);
00053 
00054   protected:
00055     QRect getTextRect(const QPointF& point, const QFont& font) const;
00056 
00057     QwtText trackerTextF(const QPointF& point) const;
00058 
00059     void begin();
00060     void move(const QPoint& point);
00061     bool end(bool ok = true);
00062 
00063     bool eventFilter(QObject* object, QEvent* event);
00064 
00065     void updateDisplay();
00066     void updateTrackedPoints();
00067 
00068     void drawTrackedPoints(QPainter* painter) const;
00069 
00070   private:
00071     struct TrackedPoint {
00072       QPointF position;
00073       QColor color;
00074     };
00075 
00076     QPointF currentPosition_;
00077     QVector<TrackedPoint> trackedPoints_;
00078 
00079     bool trackPoints_;
00080     bool mouseControl_;
00081 
00082   private slots:
00083     void plotXAxisScaleDivChanged();
00084     void plotYAxisScaleDivChanged();
00085   };
00086 };
00087 
00088 #endif


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Thu Jun 6 2019 21:49:11