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_CURVE_H 00020 #define RQT_MULTIPLOT_PLOT_CURVE_H 00021 00022 #include <QObject> 00023 #include <QPair> 00024 #include <QPointF> 00025 00026 #include <qwt/qwt_plot_curve.h> 00027 00028 #include <rqt_multiplot/BoundingRectangle.h> 00029 #include <rqt_multiplot/CurveConfig.h> 00030 #include <rqt_multiplot/MessageBroker.h> 00031 00032 namespace rqt_multiplot { 00033 class CurveData; 00034 class CurveDataSequencer; 00035 00036 class PlotCurve : 00037 public QObject, 00038 public QwtPlotCurve { 00039 Q_OBJECT 00040 public: 00041 PlotCurve(QObject* parent = 0); 00042 virtual ~PlotCurve(); 00043 00044 void setConfig(CurveConfig* config); 00045 CurveConfig* getConfig() const; 00046 void setBroker(MessageBroker* broker); 00047 MessageBroker* getBroker() const; 00048 CurveData* getData() const; 00049 CurveDataSequencer* getDataSequencer() const; 00050 QPair<double, double> getPreferredAxisScale(CurveConfig::Axis 00051 axis) const; 00052 BoundingRectangle getPreferredScale() const; 00053 00054 void attach(QwtPlot* plot); 00055 void detach(); 00056 00057 void run(); 00058 void pause(); 00059 void clear(); 00060 00061 signals: 00062 void preferredScaleChanged(const BoundingRectangle& bounds); 00063 void replotRequested(); 00064 00065 private: 00066 CurveConfig* config_; 00067 00068 MessageBroker* broker_; 00069 00070 CurveData* data_; 00071 CurveDataSequencer* dataSequencer_; 00072 00073 bool paused_; 00074 00075 private slots: 00076 void configTitleChanged(const QString& title); 00077 void configAxisConfigChanged(); 00078 void configColorConfigCurrentColorChanged(const QColor& color); 00079 void configStyleConfigChanged(); 00080 void configDataConfigChanged(); 00081 00082 void dataSequencerPointReceived(const QPointF& point); 00083 }; 00084 }; 00085 00086 #endif