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
31class QwtPlotCurve;
32
33namespace 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: explicit 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
common
Definition FuelModelDatabase.hh:37
gui
Definition KeyEventHandler.hh:29
default namespace for gazebo
A Time class, can be used to hold wall- or sim-time.
Definition Time.hh:48
A plotting widget that handles incremental addition of data.
Definition IncrementalPlot.hh:47
void SetPeriod(const common::Time &_time)
Set the period over which to plot.
PlotCurveWeakPtr Curve(const std::string &_label) const
Find a plot curve by name.
std::vector< PlotCurveWeakPtr > Curves() const
Get all curves in this plot.
void ShowAxisLabel(const PlotAxis _axis, const bool _show)
Set whether to show the axis label.
void dropEvent(QDropEvent *_evt)
Used to accept drop events.
virtual ~IncrementalPlot()
Destructor.
void AttachCurve(PlotCurveWeakPtr _curve)
Attach a curve to this plot.
void AddPoints(const unsigned int _id, const std::vector< ignition::math::Vector2d > &_pts)
Add new points to a curve.
void AddPoint(const unsigned int _id, const ignition::math::Vector2d &_pt)
Add a new point to a curve.
void VariableAdded(const std::string &_name)
Qt signal emitted when a variable pill is added.
PlotAxis
Axis enum.
Definition IncrementalPlot.hh:52
@ Y_RIGHT_AXIS
right y axis
Definition IncrementalPlot.hh:63
@ X_TOP_AXIS
top x axis
Definition IncrementalPlot.hh:57
@ X_BOTTOM_AXIS
bottom x axis
Definition IncrementalPlot.hh:54
@ Y_LEFT_AXIS
left y axis
Definition IncrementalPlot.hh:60
void ShowGrid(const bool _show)
Set whether to show the grid lines.
bool IsShowGrid() const
Get whether the grid lines are shown.
PlotCurvePtr DetachCurve(const unsigned int _id)
Detach a curve from this plot.
IncrementalPlot(QWidget *_parent=nullptr)
Constructor.
void ShowHoverLine(const bool _show)
Set whether to show the hover line.
void Clear()
Clear all points from the plot.
virtual QSize sizeHint() const
Give QT a size hint.
void RemoveCurve(const unsigned int _id)
Remove a curve by id.
void SetCurveLabel(const unsigned int _id, const std::string &_label)
Set a new label for the given curve.
void Update()
Update all the curves in the plot.
void dragEnterEvent(QDragEnterEvent *_evt)
Used to accept drag enter events.
PlotCurveWeakPtr Curve(const unsigned int _id) const
Find a plot curve by id.
PlotCurveWeakPtr AddCurve(const std::string &_label)
Add a named curve.
bool IsShowHoverLine() const
Get whether the hover line is shown.
std::weak_ptr< PlotCurve > PlotCurveWeakPtr
Definition PlottingTypes.hh:41
std::shared_ptr< PlotCurve > PlotCurvePtr
Definition PlottingTypes.hh:37
Forward declarations for the common classes.
Definition Animation.hh:27