PlotWidget.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_WIDGET_H
20 #define RQT_MULTIPLOT_PLOT_WIDGET_H
21 
22 #include <QIcon>
23 #include <QList>
24 #include <QMenu>
25 #include <QRect>
26 #include <QStringList>
27 #include <QTimer>
28 #include <QVector>
29 #include <QWidget>
30 
34 
35 namespace Ui {
36  class PlotWidget;
37 };
38 
39 namespace rqt_multiplot {
40  class PlotCursor;
41  class PlotCurve;
42  class PlotLegend;
43  class PlotMagnifier;
44  class PlotPanner;
45  class PlotZoomer;
46 
47  class PlotWidget :
48  public QWidget {
49  Q_OBJECT
50  public:
51  enum State {
53  Maximized
54  };
55 
56  PlotWidget(QWidget* parent = 0);
57  virtual ~PlotWidget();
58 
59  void setConfig(PlotConfig* config);
60  PlotConfig* getConfig() const;
61  void setBroker(MessageBroker* broker);
62  MessageBroker* getBroker() const;
63  PlotCursor* getCursor() const;
64  BoundingRectangle getPreferredScale() const;
65  void setCurrentScale(const BoundingRectangle& bounds);
66  const BoundingRectangle& getCurrentScale() const;
67  bool isPaused() const;
68  bool isReplotRequested() const;
69  void setState(State state);
70  State getState() const;
71  void setCanChangeState(bool can);
72  bool canChangeState() const;
73 
74  void run();
75  void pause();
76  void clear();
77 
78  void requestReplot();
79  void forceReplot();
80 
81  void renderToPixmap(QPixmap& pixmap, const QRectF& bounds = QRectF());
82  void writeFormattedCurveAxisTitles(QStringList& formattedAxisTitles);
83  void writeFormattedCurveData(QList<QStringList>& formattedData);
84 
85  void saveToImageFile(const QString& fileName);
86  void saveToTextFile(const QString& fileName);
87 
88  signals:
89  void preferredScaleChanged(const BoundingRectangle& bounds);
90  void currentScaleChanged(const BoundingRectangle& bounds);
91  void pausedChanged(bool paused);
92  void stateChanged(int state);
93  void cleared();
94 
95  protected:
96  void dragEnterEvent(QDragEnterEvent* event);
97  void dropEvent(QDropEvent* event);
98 
99  bool eventFilter(QObject* object, QEvent* event);
100 
101  private:
102  Ui::PlotWidget* ui_;
103 
104  QIcon runIcon_;
105  QIcon pauseIcon_;
106  QIcon normalIcon_;
108  QTimer* timer_;
110 
112 
114 
115  QVector<PlotCurve*> curves_;
116 
122 
123  bool paused_;
124  bool rescale_;
125  bool replot_;
127 
129 
130  void updateAxisTitle(PlotAxesConfig::Axis axis);
131 
132  private slots:
133  void timerTimeout();
134 
135  void configTitleChanged(const QString& title);
136  void configCurveAdded(size_t index);
137  void configCurveRemoved(size_t index);
138  void configCurvesCleared();
139  void configCurveConfigChanged(size_t index);
140  void configXAxisConfigChanged();
141  void configYAxisConfigChanged();
142  void configLegendConfigChanged();
143  void configPlotRateChanged(double rate);
144 
145  void curveReplotRequested();
146 
147  void lineEditTitleTextChanged(const QString& text);
148  void lineEditTitleEditingFinished();
149 
150  void pushButtonRunPauseClicked();
151  void pushButtonClearClicked();
152  void pushButtonSetupClicked();
153  void pushButtonImportExportClicked();
154  void pushButtonStateClicked();
155  void menuExportImageFileTriggered();
156  void menuExportTextFileTriggered();
157 
158  void plotXBottomScaleDivChanged();
159  void plotYLeftScaleDivChanged();
160  };
161 };
162 
163 #endif
QVector< PlotCurve * > curves_
Definition: PlotWidget.h:115
PlotMagnifier * magnifier_
Definition: PlotWidget.h:120
BoundingRectangle currentBounds_
Definition: PlotWidget.h:128
void run(ClassLoader *loader)
MessageBroker * broker_
Definition: PlotWidget.h:113
Ui::PlotWidget * ui_
Definition: PlotWidget.h:102


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