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_TABLE_WIDGET_H 00020 #define RQT_MULTIPLOT_PLOT_TABLE_WIDGET_H 00021 00022 #include <QGridLayout> 00023 #include <QVector> 00024 #include <QWidget> 00025 00026 #include <rqt_multiplot/BagReader.h> 00027 #include <rqt_multiplot/BoundingRectangle.h> 00028 #include <rqt_multiplot/MessageSubscriberRegistry.h> 00029 #include <rqt_multiplot/PlotTableConfig.h> 00030 00031 namespace rqt_multiplot { 00032 class PlotWidget; 00033 00034 class PlotTableWidget : 00035 public QWidget { 00036 Q_OBJECT 00037 public: 00038 PlotTableWidget(QWidget* parent = 0); 00039 virtual ~PlotTableWidget(); 00040 00041 void setConfig(PlotTableConfig* config); 00042 PlotTableConfig* getConfig() const; 00043 size_t getNumRows() const; 00044 size_t getNumColumns() const; 00045 PlotWidget* getPlotWidget(size_t row, size_t column) const; 00046 MessageSubscriberRegistry* getRegistry() const; 00047 BagReader* getBagReader() const; 00048 00049 void runPlots(); 00050 void pausePlots(); 00051 void clearPlots(); 00052 00053 void requestReplot(); 00054 void forceReplot(); 00055 00056 void renderToPixmap(QPixmap& pixmap); 00057 void writeFormattedCurveAxisTitles(QStringList& formattedAxisTitles); 00058 void writeFormattedCurveData(QList<QStringList>& formattedData); 00059 00060 void loadFromBagFile(const QString& fileName); 00061 void saveToImageFile(const QString& fileName); 00062 void saveToTextFile(const QString& fileName); 00063 00064 signals: 00065 void plotPausedChanged(); 00066 void jobStarted(const QString& toolTip); 00067 void jobProgressChanged(double progress); 00068 void jobFinished(const QString& toolTip); 00069 void jobFailed(const QString& toolTip); 00070 00071 private: 00072 QGridLayout* layout_; 00073 QVector<QVector<PlotWidget*> > plotWidgets_; 00074 00075 PlotTableConfig* config_; 00076 00077 MessageSubscriberRegistry* registry_; 00078 BagReader* bagReader_; 00079 00080 void updatePlotScale(const BoundingRectangle& bounds, PlotWidget* 00081 excluded = 0); 00082 00083 private slots: 00084 void configBackgroundColorChanged(const QColor& color); 00085 void configForegroundColorChanged(const QColor& color); 00086 void configNumPlotsChanged(size_t numRows, size_t numColumns); 00087 void configLinkScaleChanged(bool link); 00088 void configTrackPointsChanged(bool track); 00089 00090 void plotPreferredScaleChanged(const BoundingRectangle& bounds); 00091 void plotCurrentScaleChanged(const BoundingRectangle& bounds); 00092 void plotCursorActiveChanged(bool active); 00093 void plotCursorCurrentPositionChanged(const QPointF& position); 00094 void plotPausedChanged(bool paused); 00095 void plotStateChanged(int state); 00096 00097 void bagReaderReadingStarted(); 00098 void bagReaderReadingProgressChanged(double progress); 00099 void bagReaderReadingFinished(); 00100 void bagReaderReadingFailed(const QString& error); 00101 }; 00102 }; 00103 00104 #endif