PlotCanvas.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GAZEBO_GUI_PLOT_PLOTCANVAS_HH_
18 #define GAZEBO_GUI_PLOT_PLOTCANVAS_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <ignition/math/Vector2.hh>
25 
26 #include "gazebo/gui/qt.h"
29 #include "gazebo/util/system.hh"
30 
31 namespace gazebo
32 {
33  namespace gui
34  {
35  // Forward declare private data class
36  class IncrementalPlot;
37  class PlotCanvasPrivate;
38 
40  class GZ_GUI_VISIBLE PlotCanvas : public QWidget
41  {
42  Q_OBJECT
43 
46  public: explicit PlotCanvas(QWidget *_parent);
47 
49  public: virtual ~PlotCanvas();
50 
54  public: void SetVariableLabel(const unsigned int _id,
55  const std::string &_label);
56 
61  public: unsigned int AddVariable(const std::string &_variable,
62  const unsigned int _plotId = EmptyPlot);
63 
69  public: void RemoveVariable(const unsigned int _id,
70  const unsigned int _plotId = EmptyPlot);
71 
74  public: unsigned int AddPlot();
75 
78  public: void RemovePlot(const unsigned int _plotId);
79 
82  public: unsigned int PlotCount() const;
83 
87  public: unsigned int VariableCount(const unsigned int _plotId) const;
88 
91  public: void Restart();
92 
94  public: void Update();
95 
99  public: unsigned int PlotByVariable(const unsigned int _variableId) const;
100 
103  public: std::vector<IncrementalPlot *> Plots() const;
104 
108  public: PlotCurveWeakPtr PlotCurve(const unsigned int _variableId);
109 
111  public: void Clear();
112 
116  public: void SetDeleteCanvasEnabled(const bool _enable);
117 
122  public: virtual bool eventFilter(QObject *_o, QEvent *_event);
123 
126  public: std::string Title() const;
127 
131  public: void Export(const std::string &_dirName,
132  const FileType _type) const;
133 
137  private: void ExportPDF(const std::string &_dirName) const;
138 
142  private: void ExportCSV(const std::string &_dirName) const;
143 
150  private: void AddVariable(const unsigned int _id,
151  const std::string &_variable,
152  const unsigned int _plotId = EmptyPlot);
153 
157  private: void UpdateAxisLabel();
158 
160  Q_SIGNALS: void CanvasDeleted();
161 
164  private slots: void OnAddVariable(const std::string &_variable);
165 
171  private slots: void OnAddVariable(const unsigned int _id,
172  const std::string &_variable, const unsigned int _targetId);
173 
178  private slots: void OnRemoveVariable(const unsigned int _id,
179  const unsigned int _targetId);
180 
185  private slots: void OnMoveVariable(const unsigned int _id,
186  const unsigned int _targetId);
187 
191  private slots: void OnSetVariableLabel(const unsigned int _id,
192  const std::string &_label);
193 
195  private slots: void OnClearCanvas();
196 
198  private slots: void OnDeleteCanvas();
199 
201  private slots: void OnShowGrid();
202 
204  private slots: void OnShowHoverLine();
205 
207  public: static const unsigned int EmptyPlot;
208 
211  private: std::unique_ptr<PlotCanvasPrivate> dataPtr;
212  };
213  }
214 }
215 #endif
Forward declarations for the common classes.
Definition: Animation.hh:26
FileType
Supported file types.
Definition: ExportDialog.hh:34
Plot canvas.
Definition: PlotCanvas.hh:40
std::weak_ptr< PlotCurve > PlotCurveWeakPtr
Definition: PlottingTypes.hh:41
gui
Definition: KeyEventHandler.hh:29
default namespace for gazebo
static const unsigned int EmptyPlot
Empty plot used to indicate non-existent plot.
Definition: PlotCanvas.hh:207
Plot Curve data.
Definition: PlotCurve.hh:41