PlotCurve.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_PLOTCURVE_HH_
18 #define GAZEBO_GUI_PLOT_PLOTCURVE_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"
27 #include "gazebo/util/system.hh"
28 
29 class QwtPlotCurve;
30 
31 namespace gazebo
32 {
33  namespace gui
34  {
35  // Forward declare private data class
36  class PlotCurvePrivate;
37 
38  class IncrementalPlot;
39 
41  class GZ_GUI_VISIBLE PlotCurve
42  {
45  public: explicit PlotCurve(const std::string &_label);
46 
48  public: ~PlotCurve();
49 
52  public: void AddPoint(const ignition::math::Vector2d &_pt);
53 
56  public: void AddPoints(const std::vector<ignition::math::Vector2d> &_pt);
57 
59  public: void Clear();
60 
63  public: void Attach(IncrementalPlot *_plot);
64 
66  public: void Detach();
67 
70  public: void SetLabel(const std::string &_label);
71 
74  public: std::string Label() const;
75 
78  public: void SetId(const unsigned int _id);
79 
82  public: unsigned int Id() const;
83 
87  public: void SetActive(const bool _active);
88 
91  public: bool Active() const;
92 
96  public: void SetAge(const unsigned int _age);
97 
100  public: unsigned int Age() const;
101 
104  public: unsigned int Size() const;
105 
108  public: ignition::math::Vector2d Min();
109 
112  public: ignition::math::Vector2d Max();
113 
118  public: ignition::math::Vector2d Point(const unsigned int _index) const;
119 
122  public: std::vector<ignition::math::Vector2d> Points() const;
123 
127  public: QwtPlotCurve *Curve();
128 
131  private: std::unique_ptr<PlotCurvePrivate> dataPtr;
132  };
133  }
134 }
135 #endif
PlotCurve(const std::string &_label)
Constructor.
ignition::math::Vector2d Max()
Get the max x and y values of this curve.
Forward declarations for the common classes.
Definition: Animation.hh:27
void SetActive(const bool _active)
Set whether the curve should be active.
void SetAge(const unsigned int _age)
Set the age of the curve.
~PlotCurve()
Destructor.
void SetLabel(const std::string &_label)
Set the curve label.
unsigned int Size() const
Get the number of data points in the curve.
bool Active() const
Get whether the curve is active.
void Clear()
Clear all data from the curve.
std::string Label() const
Get the curve label.
ignition::math::Vector2d Point(const unsigned int _index) const
Get a point in the curve.
Plot Curve data.
Definition: PlotCurve.hh:42
unsigned int Age() const
Get the age of the curve.
gui
Definition: KeyEventHandler.hh:29
A plotting widget that handles incremental addition of data.
Definition: IncrementalPlot.hh:47
QwtPlotCurve * Curve()
void AddPoints(const std::vector< ignition::math::Vector2d > &_pt)
Add points to the curve.
void Attach(IncrementalPlot *_plot)
Attach the curve to a plot.
std::vector< ignition::math::Vector2d > Points() const
Return all the sample points in the curve.
void Detach()
Detach the curve from the plot.
ignition::math::Vector2d Min()
Get the min x and y values of this curve.
void SetId(const unsigned int _id)
Set the curve id.
unsigned int Id() const
Get the curve id.
void AddPoint(const ignition::math::Vector2d &_pt)
Add a point to the curve.