IncrementalPlot.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_INCREMENTALPLOT_HH_
18 #define GAZEBO_GUI_PLOT_INCREMENTALPLOT_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 class QwtPlotCurve;
32 
33 namespace gazebo
34 {
35  namespace common
36  {
37  class Time;
38  }
39 
40  namespace gui
41  {
42  // Forward declare private data class
43  class IncrementalPlotPrivate;
44 
46  class GZ_GUI_VISIBLE IncrementalPlot : public QwtPlot
47  {
48  Q_OBJECT
49 
51  public: enum PlotAxis
52  {
54  X_BOTTOM_AXIS = 0,
55 
57  X_TOP_AXIS = 1,
58 
60  Y_LEFT_AXIS = 2,
61 
63  Y_RIGHT_AXIS = 3
64  };
65 
68  public: IncrementalPlot(QWidget *_parent = nullptr);
69 
71  public: virtual ~IncrementalPlot();
72 
76  public: PlotCurveWeakPtr AddCurve(const std::string &_label);
77 
81  public: void AddPoint(const unsigned int _id,
82  const ignition::math::Vector2d &_pt);
83 
87  public: void AddPoints(const unsigned int _id,
88  const std::vector<ignition::math::Vector2d> &_pts);
89 
91  public: void Clear();
92 
96  public: PlotCurveWeakPtr Curve(const std::string &_label) const;
97 
101  public: PlotCurveWeakPtr Curve(const unsigned int _id) const;
102 
104  public: void Update();
105 
108  public: void RemoveCurve(const unsigned int _id);
109 
112  public: void SetPeriod(const common::Time &_time);
113 
116  public: void AttachCurve(PlotCurveWeakPtr _curve);
117 
121  public: PlotCurvePtr DetachCurve(const unsigned int _id);
122 
126  public: void SetCurveLabel(const unsigned int _id,
127  const std::string &_label);
128 
132  public: void ShowAxisLabel(const PlotAxis _axis, const bool _show);
133 
136  public: void ShowGrid(const bool _show);
137 
140  public: bool IsShowGrid() const;
141 
144  public: void ShowHoverLine(const bool _show);
145 
148  public: bool IsShowHoverLine() const;
149 
152  public: std::vector<PlotCurveWeakPtr> Curves() const;
153 
156  public: virtual QSize sizeHint() const;
157 
160  protected: void dragEnterEvent(QDragEnterEvent *_evt);
161 
164  protected: void dropEvent(QDropEvent *_evt);
165 
168  Q_SIGNALS: void VariableAdded(const std::string &_name);
169 
172  private: std::unique_ptr<IncrementalPlotPrivate> dataPtr;
173  };
174  }
175 }
176 #endif
std::shared_ptr< PlotCurve > PlotCurvePtr
Definition: PlottingTypes.hh:37
std::weak_ptr< PlotCurve > PlotCurveWeakPtr
Definition: PlottingTypes.hh:41
PlotAxis
Axis enum.
Definition: IncrementalPlot.hh:51
default namespace for gazebo
A plotting widget that handles incremental addition of data.
Definition: IncrementalPlot.hh:46
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44