##

IncrementalPlot.hh
Go to the documentation of this file.
/*
* Copyright (C) 2016 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_GUI_PLOT_INCREMENTALPLOT_HH_
#define GAZEBO_GUI_PLOT_INCREMENTALPLOT_HH_
#include <memory>
#include <string>
#include <vector>
#include <ignition/math/Vector2.hh>
#include "gazebo/gui/qt.h"
#include "gazebo/gui/plot/qwt_gazebo.h"
#include "gazebo/gui/plot/PlottingTypes.hh"
#include "gazebo/util/system.hh"
class QwtPlotCurve;
namespace gazebo
{
namespace common
{
class Time;
}
namespace gui
{
// Forward declare private data class
class IncrementalPlotPrivate;
class GZ_GUI_VISIBLE IncrementalPlot : public QwtPlot
{
Q_OBJECT
public: enum PlotAxis
{
X_BOTTOM_AXIS = 0,
X_TOP_AXIS = 1,
Y_LEFT_AXIS = 2,
Y_RIGHT_AXIS = 3
};
public: explicit IncrementalPlot(QWidget *_parent = nullptr);
public: virtual ~IncrementalPlot();
public: PlotCurveWeakPtr AddCurve(const std::string &_label);
public: void AddPoint(const unsigned int _id,
const ignition::math::Vector2d &_pt);
public: void AddPoints(const unsigned int _id,
const std::vector<ignition::math::Vector2d> &_pts);
public: void Clear();
public: PlotCurveWeakPtr Curve(const std::string &_label) const;
public: PlotCurveWeakPtr Curve(const unsigned int _id) const;
public: void Update();
public: void RemoveCurve(const unsigned int _id);
public: void SetPeriod(const common::Time &_time);
public: void AttachCurve(PlotCurveWeakPtr _curve);
public: PlotCurvePtr DetachCurve(const unsigned int _id);
public: void SetCurveLabel(const unsigned int _id,
const std::string &_label);
public: void ShowAxisLabel(const PlotAxis _axis, const bool _show);
public: void ShowGrid(const bool _show);
public: bool IsShowGrid() const;
public: void ShowHoverLine(const bool _show);
public: bool IsShowHoverLine() const;
public: std::vector<PlotCurveWeakPtr> Curves() const;
public: virtual QSize sizeHint() const;
protected: void dragEnterEvent(QDragEnterEvent *_evt);
protected: void dropEvent(QDropEvent *_evt);
Q_SIGNALS: void VariableAdded(const std::string &_name);
private: std::unique_ptr<IncrementalPlotPrivate> dataPtr;
};
}
}
#endif
gazebo::gui::IncrementalPlot::Update
void Update()
Update all the curves in the plot.
gazebo::gui::IncrementalPlot::IncrementalPlot
IncrementalPlot(QWidget *_parent=nullptr)
Constructor.
qwt_gazebo.h
PlottingTypes.hh
default namespace for gazebo
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
qt.h
gazebo::gui::IncrementalPlot::Y_RIGHT_AXIS
right y axis
Definition: IncrementalPlot.hh:63
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
gazebo::gui::IncrementalPlot::PlotAxis
PlotAxis
Axis enum.
Definition: IncrementalPlot.hh:51
common
common
Definition: FuelModelDatabase.hh:37
gazebo::gui::IncrementalPlot::Y_LEFT_AXIS
left y axis
Definition: IncrementalPlot.hh:60
system.hh
gazebo::gui::IncrementalPlot::AttachCurve
void AttachCurve(PlotCurveWeakPtr _curve)
Attach a curve to this plot.
gazebo::gui::IncrementalPlot::Curve
PlotCurveWeakPtr Curve(const std::string &_label) const
Find a plot curve by name.
gazebo::gui::IncrementalPlot::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *_evt)
Used to accept drag enter events.
gazebo::gui::IncrementalPlot::ShowGrid
void ShowGrid(const bool _show)
Set whether to show the grid lines.
gazebo::gui::IncrementalPlot::DetachCurve
PlotCurvePtr DetachCurve(const unsigned int _id)
Detach a curve from this plot.
gazebo::gui::IncrementalPlot::Clear
void Clear()
Clear all points from the plot.
gazebo::gui::IncrementalPlot::AddCurve
PlotCurveWeakPtr AddCurve(const std::string &_label)
Add a named curve.
gazebo::gui::IncrementalPlot::IsShowGrid
bool IsShowGrid() const
Get whether the grid lines are shown.
gazebo::gui::IncrementalPlot::SetPeriod
void SetPeriod(const common::Time &_time)
Set the period over which to plot.
gazebo::gui::IncrementalPlot::AddPoint
void AddPoint(const unsigned int _id, const ignition::math::Vector2d &_pt)
Add a new point to a curve.
gazebo::gui::IncrementalPlot::RemoveCurve
void RemoveCurve(const unsigned int _id)
Remove a curve by id.
gazebo::gui::IncrementalPlot::X_TOP_AXIS
top x axis
Definition: IncrementalPlot.hh:57
gazebo::gui::IncrementalPlot::VariableAdded
void VariableAdded(const std::string &_name)
Qt signal emitted when a variable pill is added.
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::IncrementalPlot
A plotting widget that handles incremental addition of data.
Definition: IncrementalPlot.hh:46
gazebo::gui::IncrementalPlot::ShowAxisLabel
void ShowAxisLabel(const PlotAxis _axis, const bool _show)
Set whether to show the axis label.
gazebo::gui::IncrementalPlot::Curves
std::vector< PlotCurveWeakPtr > Curves() const
Get all curves in this plot.
gazebo::gui::PlotCurvePtr
std::shared_ptr< PlotCurve > PlotCurvePtr
Definition: PlottingTypes.hh:37
gazebo::gui::PlotCurveWeakPtr
std::weak_ptr< PlotCurve > PlotCurveWeakPtr
Definition: PlottingTypes.hh:41
gazebo::gui::IncrementalPlot::ShowHoverLine
void ShowHoverLine(const bool _show)
Set whether to show the hover line.
gazebo::gui::IncrementalPlot::SetCurveLabel
void SetCurveLabel(const unsigned int _id, const std::string &_label)
Set a new label for the given curve.
gazebo::gui::IncrementalPlot::sizeHint
virtual QSize sizeHint() const
Give QT a size hint.
gazebo::gui::IncrementalPlot::AddPoints
void AddPoints(const unsigned int _id, const std::vector< ignition::math::Vector2d > &_pts)
Add new points to a curve.
gazebo::gui::IncrementalPlot::X_BOTTOM_AXIS
bottom x axis
Definition: IncrementalPlot.hh:54
gazebo::gui::IncrementalPlot::dropEvent
void dropEvent(QDropEvent *_evt)
Used to accept drop events.
gazebo::gui::IncrementalPlot::~IncrementalPlot
virtual ~IncrementalPlot()
Destructor.
gazebo::gui::IncrementalPlot::IsShowHoverLine
bool IsShowHoverLine() const
Get whether the hover line is shown.