##

PlotCanvas.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_PLOTCANVAS_HH_
#define GAZEBO_GUI_PLOT_PLOTCANVAS_HH_
#include <memory>
#include <string>
#include <vector>
#include <ignition/math/Vector2.hh>
#include "gazebo/gui/qt.h"
#include "gazebo/gui/plot/ExportDialog.hh"
#include "gazebo/gui/plot/PlottingTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace gui
{
// Forward declare private data class
class IncrementalPlot;
class PlotCanvasPrivate;
class GZ_GUI_VISIBLE PlotCanvas : public QWidget
{
Q_OBJECT
public: explicit PlotCanvas(QWidget *_parent);
public: virtual ~PlotCanvas();
public: void SetVariableLabel(const unsigned int _id,
const std::string &_label);
public: unsigned int AddVariable(const std::string &_variable,
const unsigned int _plotId = EmptyPlot);
public: void RemoveVariable(const unsigned int _id,
const unsigned int _plotId = EmptyPlot);
public: unsigned int AddPlot();
public: void RemovePlot(const unsigned int _plotId);
public: unsigned int PlotCount() const;
public: unsigned int VariableCount(const unsigned int _plotId) const;
public: void Restart();
public: void Update();
public: unsigned int PlotByVariable(const unsigned int _variableId) const;
public: std::vector<IncrementalPlot *> Plots() const;
public: PlotCurveWeakPtr PlotCurve(const unsigned int _variableId);
public: void Clear();
public: void SetDeleteCanvasEnabled(const bool _enable);
public: virtual bool eventFilter(QObject *_o, QEvent *_event);
public: std::string Title() const;
public: void Export(const std::string &_dirName,
const FileType _type) const;
private: void ExportPDF(const std::string &_dirName) const;
private: void ExportCSV(const std::string &_dirName) const;
private: void AddVariable(const unsigned int _id,
const std::string &_variable,
const unsigned int _plotId = EmptyPlot);
private: void UpdateAxisLabel();
Q_SIGNALS: void CanvasDeleted();
private slots: void OnAddVariable(const std::string &_variable);
private slots: void OnAddVariable(const unsigned int _id,
const std::string &_variable, const unsigned int _targetId);
private slots: void OnRemoveVariable(const unsigned int _id,
const unsigned int _targetId);
private slots: void OnMoveVariable(const unsigned int _id,
const unsigned int _targetId);
private slots: void OnSetVariableLabel(const unsigned int _id,
const std::string &_label);
private slots: void OnClearCanvas();
private slots: void OnDeleteCanvas();
private slots: void OnShowGrid();
private slots: void OnShowHoverLine();
public: static const unsigned int EmptyPlot;
private: std::unique_ptr<PlotCanvasPrivate> dataPtr;
};
}
}
#endif
gazebo::gui::PlotCanvas::~PlotCanvas
virtual ~PlotCanvas()
Destructor.
gazebo::gui::PlotCanvas::Title
std::string Title() const
Get the title of the plot.
PlottingTypes.hh
default namespace for gazebo
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::gui::PlotCanvas::AddVariable
unsigned int AddVariable(const std::string &_variable, const unsigned int _plotId=EmptyPlot)
Add a new variable to a plot.
qt.h
gazebo::gui::PlotCanvas::PlotByVariable
unsigned int PlotByVariable(const unsigned int _variableId) const
Get the plot id which the variable is plotted in.
gazebo::gui::PlotCanvas::Clear
void Clear()
Clear the canvas and remove all variables and plots.
gazebo::gui::PlotCanvas::PlotCount
unsigned int PlotCount() const
Get the number of plots in this canvas.
ExportDialog.hh
system.hh
gazebo::gui::PlotCanvas::Plots
std::vector< IncrementalPlot * > Plots() const
Get all the plots in this canvas.
gazebo::gui::PlotCanvas::EmptyPlot
static const unsigned int EmptyPlot
Empty plot used to indicate non-existent plot.
Definition: PlotCanvas.hh:207
gazebo::gui::FileType
FileType
Supported file types.
Definition: ExportDialog.hh:34
gazebo::gui::PlotCanvas::Restart
void Restart()
Restart plotting.
gazebo::gui::PlotCanvas
Plot canvas.
Definition: PlotCanvas.hh:40
gazebo::gui::PlotCanvas::PlotCanvas
PlotCanvas(QWidget *_parent)
Constructor.
gazebo::gui::PlotCanvas::SetVariableLabel
void SetVariableLabel(const unsigned int _id, const std::string &_label)
Set the label of a variable.
gazebo::gui::PlotCanvas::Update
void Update()
Update plots and curves with new data.
gazebo::gui::PlotCanvas::eventFilter
virtual bool eventFilter(QObject *_o, QEvent *_event)
Used to filter scroll wheel events.
gazebo::gui::PlotCanvas::RemoveVariable
void RemoveVariable(const unsigned int _id, const unsigned int _plotId=EmptyPlot)
Remove a variable from a plot.
gazebo::gui::PlotCanvas::VariableCount
unsigned int VariableCount(const unsigned int _plotId) const
Get the number of variables in a plot.
gazebo::gui::PlotCurve
Plot Curve data.
Definition: PlotCurve.hh:41
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::PlotCurveWeakPtr
std::weak_ptr< PlotCurve > PlotCurveWeakPtr
Definition: PlottingTypes.hh:41
gazebo::gui::PlotCanvas::SetDeleteCanvasEnabled
void SetDeleteCanvasEnabled(const bool _enable)
Set whether or not to enable the delete canvas option in settings.
gazebo::gui::PlotCanvas::AddPlot
unsigned int AddPlot()
Add a new plot to the canvas.
gazebo::gui::PlotCanvas::CanvasDeleted
void CanvasDeleted()
Qt signal to request self-deletion.
gazebo::gui::PlotCanvas::PlotCurve
PlotCurveWeakPtr PlotCurve(const unsigned int _variableId)
Get the curve associated with the variable.
gazebo::gui::PlotCanvas::RemovePlot
void RemovePlot(const unsigned int _plotId)
Remove a plot from the canvas.
gazebo::gui::PlotCanvas::Export
void Export(const std::string &_dirName, const FileType _type) const
Export to PDF files in the given directory.