PlotWidget.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_WIDGET_H
00020 #define RQT_MULTIPLOT_PLOT_WIDGET_H
00021 
00022 #include <QIcon>
00023 #include <QList>
00024 #include <QMenu>
00025 #include <QRect>
00026 #include <QStringList>
00027 #include <QTimer>
00028 #include <QVector>
00029 #include <QWidget>
00030 
00031 #include <rqt_multiplot/BoundingRectangle.h>
00032 #include <rqt_multiplot/MessageBroker.h>
00033 #include <rqt_multiplot/PlotConfig.h>
00034 
00035 namespace Ui {
00036   class PlotWidget;
00037 };
00038 
00039 namespace rqt_multiplot {
00040   class PlotCursor;
00041   class PlotCurve;
00042   class PlotLegend;
00043   class PlotMagnifier;
00044   class PlotPanner;
00045   class PlotZoomer;
00046 
00047   class PlotWidget :
00048     public QWidget {
00049   Q_OBJECT
00050   public:
00051     enum State {
00052       Normal,
00053       Maximized
00054     };
00055 
00056     PlotWidget(QWidget* parent = 0);
00057     virtual ~PlotWidget();
00058 
00059     void setConfig(PlotConfig* config);
00060     PlotConfig* getConfig() const;
00061     void setBroker(MessageBroker* broker);
00062     MessageBroker* getBroker() const;
00063     PlotCursor* getCursor() const;
00064     BoundingRectangle getPreferredScale() const;
00065     void setCurrentScale(const BoundingRectangle& bounds);
00066     const BoundingRectangle& getCurrentScale() const;
00067     bool isPaused() const;
00068     bool isReplotRequested() const;
00069     void setState(State state);
00070     State getState() const;
00071     void setCanChangeState(bool can);
00072     bool canChangeState() const;
00073 
00074     void run();
00075     void pause();
00076     void clear();
00077 
00078     void requestReplot();
00079     void forceReplot();
00080 
00081     void renderToPixmap(QPixmap& pixmap, const QRectF& bounds = QRectF());
00082     void writeFormattedCurveAxisTitles(QStringList& formattedAxisTitles);
00083     void writeFormattedCurveData(QList<QStringList>& formattedData);
00084 
00085     void saveToImageFile(const QString& fileName);
00086     void saveToTextFile(const QString& fileName);
00087 
00088   signals:
00089     void preferredScaleChanged(const BoundingRectangle& bounds);
00090     void currentScaleChanged(const BoundingRectangle& bounds);
00091     void pausedChanged(bool paused);
00092     void stateChanged(int state);
00093     void cleared();
00094 
00095   protected:
00096     void dragEnterEvent(QDragEnterEvent* event);
00097     void dropEvent(QDropEvent* event);
00098 
00099     bool eventFilter(QObject* object, QEvent* event);
00100 
00101   private:
00102     Ui::PlotWidget* ui_;
00103 
00104     QIcon runIcon_;
00105     QIcon pauseIcon_;
00106     QIcon normalIcon_;
00107     QIcon maximizedIcon_;
00108     QTimer* timer_;
00109     QMenu* menuImportExport_;
00110 
00111     PlotConfig* config_;
00112 
00113     MessageBroker* broker_;
00114 
00115     QVector<PlotCurve*> curves_;
00116 
00117     PlotLegend* legend_;
00118     PlotCursor* cursor_;
00119     PlotPanner* panner_;
00120     PlotMagnifier* magnifier_;
00121     PlotZoomer* zoomer_;
00122 
00123     bool paused_;
00124     bool rescale_;
00125     bool replot_;
00126     State state_;
00127 
00128     BoundingRectangle currentBounds_;
00129 
00130     void updateAxisTitle(PlotAxesConfig::Axis axis);
00131 
00132   private slots:
00133     void timerTimeout();
00134 
00135     void configTitleChanged(const QString& title);
00136     void configCurveAdded(size_t index);
00137     void configCurveRemoved(size_t index);
00138     void configCurvesCleared();
00139     void configCurveConfigChanged(size_t index);
00140     void configXAxisConfigChanged();
00141     void configYAxisConfigChanged();
00142     void configLegendConfigChanged();
00143     void configPlotRateChanged(double rate);
00144 
00145     void curveReplotRequested();
00146 
00147     void lineEditTitleTextChanged(const QString& text);
00148     void lineEditTitleEditingFinished();
00149 
00150     void pushButtonRunPauseClicked();
00151     void pushButtonClearClicked();
00152     void pushButtonSetupClicked();
00153     void pushButtonImportExportClicked();
00154     void pushButtonStateClicked();
00155     void menuExportImageFileTriggered();
00156     void menuExportTextFileTriggered();
00157 
00158     void plotXBottomScaleDivChanged();
00159     void plotYLeftScaleDivChanged();
00160   };
00161 };
00162 
00163 #endif


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Tue May 9 2017 02:16:02