opensurgsim
|
SceneElement is the basic part of a scene, it is a container of components. More...
#include <SceneElement.h>
Public Member Functions | |
SceneElement (const std::string &name) | |
Constructor. More... | |
virtual | ~SceneElement () |
Destructor. | |
virtual std::string | getClassName () const |
bool | addComponent (std::shared_ptr< Component > component) |
Adds a component, calls initialize() on the component, if SceneElement::isInitialized() is true. More... | |
bool | removeComponent (std::shared_ptr< Component > component) |
Removes a given component. More... | |
bool | removeComponent (const std::string &name) |
Removes the component described by name. More... | |
void | removeComponents () |
Removes all components. | |
std::shared_ptr< Component > | getComponent (const std::string &name) const |
Gets the component identified by name. More... | |
std::vector< std::shared_ptr< Component > > | getComponents () const |
Gets all the components of this SceneElement. More... | |
template<class T > | |
std::vector< std::shared_ptr< T > > | getComponents () const |
Template version of getComponents method to get all the components with type T. More... | |
template<class T > | |
T | getValue (const std::string &component, const std::string &property) const |
Retrieves the property value from a component. More... | |
boost::any | getValue (const std::string &component, const std::string &property) const |
Retrieves the property value from a component. More... | |
template<class T > | |
bool | getValue (const std::string &component, const std::string &property, T *value) const |
Retrieves the property value from a component, and convertis it to the type of the output parameter. More... | |
void | setValue (const std::string &component, const std::string &property, const boost::any &value) |
Sets the property value of a component. More... | |
void | addToGroup (const std::string &group) |
Add this scene element to the given group. More... | |
void | removeFromGroup (const std::string &group) |
Remove this scene element from the given group. More... | |
void | setGroups (const std::vector< std::string > &groups) |
Set the groups of this scene element. More... | |
std::vector< std::string > | getGroups () const |
bool | inGroup (const std::string &name) |
Test whether this SceneElement is in a specific group. More... | |
bool | initialize () |
Executes the initialize operation. More... | |
std::string | getName () const |
Return the name of this SceneElement. More... | |
void | setPose (const SurgSim::Math::RigidTransform3d &pose) |
Set the pose of this SceneElement. More... | |
const SurgSim::Math::RigidTransform3d & | getPose () const |
Get the pose of this SceneElement. More... | |
std::shared_ptr< PoseComponent > | getPoseComponent () |
Get the PoseComponent that controls the pose all Representations in this SceneElement. More... | |
void | setScene (std::weak_ptr< Scene > scene) |
Sets the Scene. More... | |
std::shared_ptr< Scene > | getScene () |
Gets the Scene. More... | |
void | setRuntime (std::weak_ptr< Runtime > runtime) |
Sets the Runtime. More... | |
std::shared_ptr< Runtime > | getRuntime () |
Gets the runtime. More... | |
bool | isInitialized () const |
Return if this SceneElement is initialized. More... | |
void | setActive (bool val) |
Set this SceneElement's status (active/inactive) More... | |
bool | isActive () const |
std::shared_ptr< SceneElement > | getSharedPtr () |
Gets a shared pointer to this SceneElement. More... | |
virtual YAML::Node | encode (bool standalone) const |
Convert to a YAML::Node. More... | |
virtual bool | decode (const YAML::Node &node) |
Pull data from a YAML::Node. More... | |
SceneElement is the basic part of a scene, it is a container of components.
When a SceneElement is added to a Scene, the Scene will call initialize() on the SceneElement, which in turn will call initialize() on all its components. If a component is added to a SceneElement after the SceneElement was initialized, the component will be initialized immediately.
|
explicit |
Constructor.
name | Name of this SceneElement |
bool SurgSim::Framework::SceneElement::addComponent | ( | std::shared_ptr< Component > | component | ) |
Adds a component, calls initialize() on the component, if SceneElement::isInitialized() is true.
component | The component. |
void SurgSim::Framework::SceneElement::addToGroup | ( | const std::string & | group | ) |
Add this scene element to the given group.
group | name of the group |
|
virtual |
Pull data from a YAML::Node.
SurgSim::Framework::AssertionFailure | if the SceneElement is already initialized |
node | the node to decode. |
|
virtual |
Convert to a YAML::Node.
standalone | when true, all the components will be represented as full component, when false they will be represented as references |
|
virtual |
std::shared_ptr< Component > SurgSim::Framework::SceneElement::getComponent | ( | const std::string & | name | ) | const |
Gets the component identified by name.
name | The name. |
std::vector< std::shared_ptr< Component > > SurgSim::Framework::SceneElement::getComponents | ( | ) | const |
Gets all the components of this SceneElement.
std::vector< std::shared_ptr< T > > SurgSim::Framework::SceneElement::getComponents | ( | ) | const |
Template version of getComponents method to get all the components with type T.
Implementation of getComponents method to get all the components with type T.
std::vector< std::string > SurgSim::Framework::SceneElement::getGroups | ( | ) | const |
std::string SurgSim::Framework::SceneElement::getName | ( | ) | const |
Return the name of this SceneElement.
const SurgSim::Math::RigidTransform3d & SurgSim::Framework::SceneElement::getPose | ( | ) | const |
Get the pose of this SceneElement.
std::shared_ptr< PoseComponent > SurgSim::Framework::SceneElement::getPoseComponent | ( | ) |
Get the PoseComponent that controls the pose all Representations in this SceneElement.
std::shared_ptr< Runtime > SurgSim::Framework::SceneElement::getRuntime | ( | ) |
Gets the runtime.
std::shared_ptr< Scene > SurgSim::Framework::SceneElement::getScene | ( | ) |
Gets the Scene.
std::shared_ptr< SceneElement > SurgSim::Framework::SceneElement::getSharedPtr | ( | ) |
Gets a shared pointer to this SceneElement.
T SurgSim::Framework::SceneElement::getValue | ( | const std::string & | component, |
const std::string & | property | ||
) | const |
Retrieves the property value from a component.
SurgSim::Framework::AssertionFailure | If the conversion fails or the property cannot be found. |
T | The requested type for the property. |
component | The name of the component. |
property | The name of the property. |
boost::any SurgSim::Framework::SceneElement::getValue | ( | const std::string & | component, |
const std::string & | property | ||
) | const |
Retrieves the property value from a component.
SurgSim::Framework::AssertionFailure | if the property cannot be found |
component | The name of the component. |
property | The name of the property. |
bool SurgSim::Framework::SceneElement::getValue | ( | const std::string & | component, |
const std::string & | property, | ||
T * | value | ||
) | const |
Retrieves the property value from a component, and convertis it to the type of the output parameter.
This does not throw.
T | the type of the property |
component | The name of the component. | |
property | The name of the property. | |
[out] | value | If non-null, will receive the value of the given property. |
bool SurgSim::Framework::SceneElement::inGroup | ( | const std::string & | name | ) |
Test whether this SceneElement is in a specific group.
name | group to test |
bool SurgSim::Framework::SceneElement::initialize | ( | ) |
Executes the initialize operation.
bool SurgSim::Framework::SceneElement::isActive | ( | ) | const |
bool SurgSim::Framework::SceneElement::isInitialized | ( | ) | const |
Return if this SceneElement is initialized.
bool SurgSim::Framework::SceneElement::removeComponent | ( | std::shared_ptr< Component > | component | ) |
Removes a given component.
component | The component. |
bool SurgSim::Framework::SceneElement::removeComponent | ( | const std::string & | name | ) |
Removes the component described by name.
name | The name. |
void SurgSim::Framework::SceneElement::removeFromGroup | ( | const std::string & | group | ) |
Remove this scene element from the given group.
group | name of the group |
void SurgSim::Framework::SceneElement::setActive | ( | bool | val | ) |
Set this SceneElement's status (active/inactive)
val | True to set the SceneElement active, false to set inactive. |
void SurgSim::Framework::SceneElement::setGroups | ( | const std::vector< std::string > & | groups | ) |
Set the groups of this scene element.
groups | all the groups that this scene element should be in |
void SurgSim::Framework::SceneElement::setPose | ( | const SurgSim::Math::RigidTransform3d & | pose | ) |
Set the pose of this SceneElement.
pose | The pose |
void SurgSim::Framework::SceneElement::setRuntime | ( | std::weak_ptr< Runtime > | runtime | ) |
Sets the Runtime.
runtime | Pointer to the runtime. |
void SurgSim::Framework::SceneElement::setScene | ( | std::weak_ptr< Scene > | scene | ) |
Sets the Scene.
scene | Pointer to the scene. |
void SurgSim::Framework::SceneElement::setValue | ( | const std::string & | component, |
const std::string & | property, | ||
const boost::any & | value | ||
) |
Sets the property value of a component.
SurgSim::Framework::AssertionFailure | If the property cannot be found. |
component | The name of the component. |
property | The name of the property. |
value | The value that it should be set to. |