mc_rtc::gui::StateBuilder Struct Reference

#include <mc_rtc/gui/StateBuilder.h>

Public Member Functions

 StateBuilder ()
 
template<typename T >
void addElement (const std::vector< std::string > &category, T element)
 
template<typename SourceT , typename T >
void addElement (SourceT *source, const std::vector< std::string > &category, T element)
 
template<typename T , typename... Args>
void addElement (const std::vector< std::string > &category, T element, Args... args)
 
template<typename SourceT , typename T , typename... Args>
void addElement (SourceT *source, const std::vector< std::string > &category, T element, Args... args)
 
template<typename T >
void addElement (const std::vector< std::string > &category, ElementsStacking stacking, T element)
 
template<typename SourceT , typename T >
void addElement (SourceT *source, const std::vector< std::string > &category, ElementsStacking stacking, T element)
 
template<typename T , typename... Args>
void addElement (const std::vector< std::string > &category, ElementsStacking stacking, T element, Args... args)
 
template<typename SourceT , typename T , typename... Args>
void addElement (SourceT *source, const std::vector< std::string > &category, ElementsStacking stacking, T element, Args... args)
 
bool hasElement (const std::vector< std::string > &category, const std::string &name)
 
void reset ()
 
void removeCategory (const std::vector< std::string > &category)
 
void removeElement (const std::vector< std::string > &category, const std::string &name)
 
void removeElements (void *source)
 
void removeElements (const std::vector< std::string > &category, void *source, bool recurse=false)
 
template<typename... Args>
void addXYPlot (const std::string &name, plot::AxisConfiguration xConfig, plot::AxisConfiguration yLeftConfig, plot::AxisConfiguration yRightConfig, Args... args)
 
template<typename... Args>
void addXYPlot (const std::string &name, plot::AxisConfiguration xConfig, plot::AxisConfiguration yLeftConfig, Args... args)
 
template<typename... Args>
void addXYPlot (const std::string &name, plot::AxisConfiguration xConfig, Args... args)
 
template<typename... Args>
void addXYPlot (const std::string &name, Args... args)
 
template<typename T , typename... Args>
void addPlot (const std::string &name, T abscissa, plot::AxisConfiguration yLeftConfig, plot::AxisConfiguration yRightConfig, Args... args)
 
template<typename T , typename... Args>
void addPlot (const std::string &name, T abscissa, plot::AxisConfiguration yLeftConfig, Args... args)
 
template<typename T , typename... Args>
void addPlot (const std::string &name, T abscissa, Args... args)
 
template<typename T >
bool addPlotData (const std::string &name, T data)
 
void removePlot (const std::string &name)
 
size_t update (std::vector< char > &data)
 
void update ()
 
bool handleRequest (const std::vector< std::string > &category, const std::string &name, const mc_rtc::Configuration &data)
 
mc_rtc::Configuration data ()
 
size_t size () const
 

Static Public Attributes

static constexpr int8_t PROTOCOL_VERSION = 4
 

Detailed Description

Used to build a GUI state from multiple objects

Constructor & Destructor Documentation

◆ StateBuilder()

mc_rtc::gui::StateBuilder::StateBuilder ( )

Constructor

Member Function Documentation

◆ addElement() [1/8]

template<typename T >
void mc_rtc::gui::StateBuilder::addElement ( const std::vector< std::string > &  category,
ElementsStacking  stacking,
element 
)

Add a given element and specify stacking

T must derive from Element

Parameters
categoryCategory of the element
stackingStacking direction
elementElement added to the GUI

◆ addElement() [2/8]

template<typename T , typename... Args>
void mc_rtc::gui::StateBuilder::addElement ( const std::vector< std::string > &  category,
ElementsStacking  stacking,
element,
Args...  args 
)

Add multiple elements to the same category at once with a specific stacking

Parameters
categoryCategory of the elements
elementElement added to the GUI
stackingStacking direction
argsOther elements added to the GUI

◆ addElement() [3/8]

template<typename T >
void mc_rtc::gui::StateBuilder::addElement ( const std::vector< std::string > &  category,
element 
)

Add a given element

Template Parameters
TMust derive from Element
Parameters
categoryCategory of the element
elementElement added to the GUI

◆ addElement() [4/8]

template<typename T , typename... Args>
void mc_rtc::gui::StateBuilder::addElement ( const std::vector< std::string > &  category,
element,
Args...  args 
)

Add multiple elements to the same category at once

Parameters
categoryCategory of the elements
elementElement added to the GUI
argsOther elements added to the GUI

◆ addElement() [5/8]

template<typename SourceT , typename T >
void mc_rtc::gui::StateBuilder::addElement ( SourceT *  source,
const std::vector< std::string > &  category,
ElementsStacking  stacking,
element 
)

Add a given element and specify stacking

T must derive from Element

Parameters
sourceSource attached to this object
categoryCategory of the element
stackingStacking direction
elementElement added to the GUI

◆ addElement() [6/8]

template<typename SourceT , typename T , typename... Args>
void mc_rtc::gui::StateBuilder::addElement ( SourceT *  source,
const std::vector< std::string > &  category,
ElementsStacking  stacking,
element,
Args...  args 
)

Add multiple elements to the same category at once with a specific stacking

Parameters
sourceSource attached to this object
categoryCategory of the elements
elementElement added to the GUI
stackingStacking direction
argsOther elements added to the GUI

◆ addElement() [7/8]

template<typename SourceT , typename T >
void mc_rtc::gui::StateBuilder::addElement ( SourceT *  source,
const std::vector< std::string > &  category,
element 
)

Add a given element

Template Parameters
SourceTType of the source pointer
TMust derive from Element
Parameters
sourceSource attached to this object
categoryCategory of the element
elementElement added to the GUI

◆ addElement() [8/8]

template<typename SourceT , typename T , typename... Args>
void mc_rtc::gui::StateBuilder::addElement ( SourceT *  source,
const std::vector< std::string > &  category,
element,
Args...  args 
)

Add multiple elements to the same category at once

Parameters
sourceSource attached to this object
categoryCategory of the elements
elementElement added to the GUI
argsOther elements added to the GUI

◆ addPlot() [1/3]

template<typename T , typename... Args>
void mc_rtc::gui::StateBuilder::addPlot ( const std::string &  name,
abscissa,
Args...  args 
)

Add a plot identified by the provided name

In this form, T is expected to provide an abscissa, the other parameters are expected to provide Y-axis or XY-axis data

Parameters
nameName of the plot, this is a unique identifier
abscissaDescribe the abscissa axis

◆ addPlot() [2/3]

template<typename T , typename... Args>
void mc_rtc::gui::StateBuilder::addPlot ( const std::string &  name,
abscissa,
plot::AxisConfiguration  yLeftConfig,
Args...  args 
)

Add a plot identified by the provided name

In this form, T is expected to provide an abscissa, the other parameters are expected to provide Y-axis or 2D data

Parameters
nameName of the plot, this is a unique identifier
abscissaDescribe the abscissa axis
yLeftConfigConfiguration for the left axis

◆ addPlot() [3/3]

template<typename T , typename... Args>
void mc_rtc::gui::StateBuilder::addPlot ( const std::string &  name,
abscissa,
plot::AxisConfiguration  yLeftConfig,
plot::AxisConfiguration  yRightConfig,
Args...  args 
)

Add a plot identified by the provided name

In this form, T is expected to provide an abscissa, the other parameters are expected to provide Y-axis or 2D data

Parameters
nameName of the plot, this is a unique identifier
abscissaDescribe the abscissa axis
yLeftConfigConfiguration for the left axis
yRightConfigConfiguration for the right axis

◆ addPlotData()

template<typename T >
bool mc_rtc::gui::StateBuilder::addPlotData ( const std::string &  name,
data 
)

Add more data to an existing plot

T must be a Y-axis or 2D data

No-op if the plot has not been added yet

No-op if T a Y-axis and the plot was added with addXYPlot

Parameters
nameName of the plot, it must have been added via addPlot or addXYPlot before
dataExtra data to be added
Returns
True if the data was added, false otherwise

◆ addXYPlot() [1/4]

template<typename... Args>
void mc_rtc::gui::StateBuilder::addXYPlot ( const std::string &  name,
Args...  args 
)

Add a plot identified by the provided name

In this form, Args are expected to provide 2D data

Parameters
nameName of the plot
xConfigConfiguration for the left axis
yLeftConfigConfiguration for the left axis

◆ addXYPlot() [2/4]

template<typename... Args>
void mc_rtc::gui::StateBuilder::addXYPlot ( const std::string &  name,
plot::AxisConfiguration  xConfig,
Args...  args 
)

Add a plot identified by the provided name

In this form, Args are expected to provide 2D data

Parameters
nameName of the plot
xConfigConfiguration for the left axis
yLeftConfigConfiguration for the left axis

◆ addXYPlot() [3/4]

template<typename... Args>
void mc_rtc::gui::StateBuilder::addXYPlot ( const std::string &  name,
plot::AxisConfiguration  xConfig,
plot::AxisConfiguration  yLeftConfig,
Args...  args 
)

Add a plot identified by the provided name

In this form, Args are expected to provide 2D data

Parameters
nameName of the plot
xConfigConfiguration for the left axis
yLeftConfigConfiguration for the left axis

◆ addXYPlot() [4/4]

template<typename... Args>
void mc_rtc::gui::StateBuilder::addXYPlot ( const std::string &  name,
plot::AxisConfiguration  xConfig,
plot::AxisConfiguration  yLeftConfig,
plot::AxisConfiguration  yRightConfig,
Args...  args 
)

Add a plot identified by the provided name

In this form, Args are expected to provide 2D data

Parameters
nameName of the plot
xConfigConfiguration for the left axis
yLeftConfigConfiguration for the left axis
yRightConfigConfiguration for the right axis

◆ data()

mc_rtc::Configuration mc_rtc::gui::StateBuilder::data ( )

Access static data store

This assumes you are accessing the data to modify and will trigger a regeneration of the data portion of the message. For better performances use sparsely.

◆ handleRequest()

bool mc_rtc::gui::StateBuilder::handleRequest ( const std::vector< std::string > &  category,
const std::string &  name,
const mc_rtc::Configuration data 
)

Handle a request

◆ hasElement()

bool mc_rtc::gui::StateBuilder::hasElement ( const std::vector< std::string > &  category,
const std::string &  name 
)

Checks if an element is already in the GUI

Parameters
categoryCategory of the element
nameName of the element
Returns
True if the element is already in the gui

◆ removeCategory()

void mc_rtc::gui::StateBuilder::removeCategory ( const std::vector< std::string > &  category)

Remove a given category

◆ removeElement()

void mc_rtc::gui::StateBuilder::removeElement ( const std::vector< std::string > &  category,
const std::string &  name 
)

Remove a single element

◆ removeElements() [1/2]

void mc_rtc::gui::StateBuilder::removeElements ( const std::vector< std::string > &  category,
void *  source,
bool  recurse = false 
)

Remove all elements attached to the given source in the specified category

Parameters
categoryCategory where elements will be searched
sourceSource that will be searched
recurseAlso search for elements in sub-categories of the given category

◆ removeElements() [2/2]

void mc_rtc::gui::StateBuilder::removeElements ( void *  source)

Remove all elements attached to the given source

One should prefer to remove a category or target a specific category, otherwise the whole GUI has to be searched to find matching elements

For example, if your source has added a category and a few elements in the root: gui()->removeCategory({"MyCategory"}); gui()->removeElements({}, this); Should be used instead of: gui()->removeElements(this);

◆ removePlot()

void mc_rtc::gui::StateBuilder::removePlot ( const std::string &  name)

Remove a plot identified by the provided name

◆ reset()

void mc_rtc::gui::StateBuilder::reset ( )

Remove all elements

◆ size()

size_t mc_rtc::gui::StateBuilder::size ( ) const
inline

Return the number of elements in the GUI

◆ update() [1/2]

void mc_rtc::gui::StateBuilder::update ( )

Update the plots only

◆ update() [2/2]

size_t mc_rtc::gui::StateBuilder::update ( std::vector< char > &  data)

Update the GUI message

Parameters
dataWill hold binary data representing the GUI
Returns
Effective size of the GUI message

Member Data Documentation

◆ PROTOCOL_VERSION

constexpr int8_t mc_rtc::gui::StateBuilder::PROTOCOL_VERSION = 4
staticconstexpr

Increment this version when an update makes old client code incompatible

Things that will break the client:

  • Removing fields from an existing element
  • Changing data requirements

Things that should not affect the client:


The documentation for this struct was generated from the following file: