opensurgsim
Public Member Functions | List of all members
SurgSim::Framework::SceneElement Class Referenceabstract

SceneElement is the basic part of a scene, it is a container of components. More...

#include <SceneElement.h>

Inheritance diagram for SurgSim::Framework::SceneElement:
MockSceneElement SurgSim::Blocks::PostprocessingView SurgSim::Blocks::SphereElement SurgSim::Framework::BasicSceneElement SurgSim::Graphics::RenderPass ConstructorSceneElement StapleElement SurgSim::Blocks::VisualizeConstraints SurgSim::Graphics::ViewElement SurgSim::Graphics::OsgScreenSpacePass SurgSim::Graphics::MockViewElement SurgSim::Graphics::OsgViewElement

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< ComponentgetComponent (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 >
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::RigidTransform3dgetPose () const
 Get the pose of this SceneElement. More...
 
std::shared_ptr< PoseComponentgetPoseComponent ()
 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< ScenegetScene ()
 Gets the Scene. More...
 
void setRuntime (std::weak_ptr< Runtime > runtime)
 Sets the Runtime. More...
 
std::shared_ptr< RuntimegetRuntime ()
 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< SceneElementgetSharedPtr ()
 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...
 

Detailed Description

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.

Note
A SceneElement needs to be created as a shared_ptr.

Constructor & Destructor Documentation

§ SceneElement()

SurgSim::Framework::SceneElement::SceneElement ( const std::string &  name)
explicit

Constructor.

Parameters
nameName of this SceneElement

Member Function Documentation

§ addComponent()

bool SurgSim::Framework::SceneElement::addComponent ( std::shared_ptr< Component component)

Adds a component, calls initialize() on the component, if SceneElement::isInitialized() is true.

Parameters
componentThe component.
Returns
true if it succeeds, false if it fails.

§ addToGroup()

void SurgSim::Framework::SceneElement::addToGroup ( const std::string &  group)

Add this scene element to the given group.

Parameters
groupname of the group

§ decode()

bool SurgSim::Framework::SceneElement::decode ( const YAML::Node &  node)
virtual

Pull data from a YAML::Node.

Exceptions
SurgSim::Framework::AssertionFailureif the SceneElement is already initialized
Parameters
nodethe node to decode.
Returns
true if the decoding succeeded and the node was formatted correctly, false otherwise

§ encode()

YAML::Node SurgSim::Framework::SceneElement::encode ( bool  standalone) const
virtual

Convert to a YAML::Node.

Parameters
standalonewhen true, all the components will be represented as full component, when false they will be represented as references
Returns
A node with all the public data of this instance

§ getClassName()

std::string SurgSim::Framework::SceneElement::getClassName ( ) const
virtual
Returns
the class name for this class

§ getComponent()

std::shared_ptr< Component > SurgSim::Framework::SceneElement::getComponent ( const std::string &  name) const

Gets the component identified by name.

Parameters
nameThe name.
Returns
The component or nullptr if the component cannot be found.

§ getComponents() [1/2]

std::vector< std::shared_ptr< Component > > SurgSim::Framework::SceneElement::getComponents ( ) const

Gets all the components of this SceneElement.

Returns
The components.

§ getComponents() [2/2]

template<class T >
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.

Returns
The type T components

§ getGroups()

std::vector< std::string > SurgSim::Framework::SceneElement::getGroups ( ) const
Returns
all the groups of this scene element

§ getName()

std::string SurgSim::Framework::SceneElement::getName ( ) const

Return the name of this SceneElement.

Returns
The name.

§ getPose()

const SurgSim::Math::RigidTransform3d & SurgSim::Framework::SceneElement::getPose ( ) const

Get the pose of this SceneElement.

Returns
the pose

§ getPoseComponent()

std::shared_ptr< PoseComponent > SurgSim::Framework::SceneElement::getPoseComponent ( )

Get the PoseComponent that controls the pose all Representations in this SceneElement.

Returns
the PoseComponent

§ getRuntime()

std::shared_ptr< Runtime > SurgSim::Framework::SceneElement::getRuntime ( )

Gets the runtime.

Returns
The runtime.

§ getScene()

std::shared_ptr< Scene > SurgSim::Framework::SceneElement::getScene ( )

Gets the Scene.

Returns
The scene.

§ getSharedPtr()

std::shared_ptr< SceneElement > SurgSim::Framework::SceneElement::getSharedPtr ( )

Gets a shared pointer to this SceneElement.

Returns
The shared pointer.

§ getValue() [1/3]

template<class T >
T SurgSim::Framework::SceneElement::getValue ( const std::string &  component,
const std::string &  property 
) const

Retrieves the property value from a component.

Exceptions
SurgSim::Framework::AssertionFailureIf the conversion fails or the property cannot be found.
Template Parameters
TThe requested type for the property.
Parameters
componentThe name of the component.
propertyThe name of the property.
Returns
The value of the property if found.

§ getValue() [2/3]

boost::any SurgSim::Framework::SceneElement::getValue ( const std::string &  component,
const std::string &  property 
) const

Retrieves the property value from a component.

Exceptions
SurgSim::Framework::AssertionFailureif the property cannot be found
Parameters
componentThe name of the component.
propertyThe name of the property.
Returns
The value of the property if found.

§ getValue() [3/3]

template<class T >
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.

Template Parameters
Tthe type of the property
Parameters
componentThe name of the component.
propertyThe name of the property.
[out]valueIf non-null, will receive the value of the given property.
Returns
true if value != nullptr and the property is found.

§ inGroup()

bool SurgSim::Framework::SceneElement::inGroup ( const std::string &  name)

Test whether this SceneElement is in a specific group.

Parameters
namegroup to test
Returns
true if the SceneElement is in group name

§ initialize()

bool SurgSim::Framework::SceneElement::initialize ( )

Executes the initialize operation.

Returns
true if it succeeds, false if it fails.

§ isActive()

bool SurgSim::Framework::SceneElement::isActive ( ) const
Returns
True if this SceneElement is active; Otherwise, false.

§ isInitialized()

bool SurgSim::Framework::SceneElement::isInitialized ( ) const

Return if this SceneElement is initialized.

Returns
True if this SceneElement is initialized; Otherwise, false.

§ removeComponent() [1/2]

bool SurgSim::Framework::SceneElement::removeComponent ( std::shared_ptr< Component component)

Removes a given component.

Parameters
componentThe component.
Returns
true if it succeeds, false if it fails or the component cannot be found.

§ removeComponent() [2/2]

bool SurgSim::Framework::SceneElement::removeComponent ( const std::string &  name)

Removes the component described by name.

Parameters
nameThe name.
Returns
true if it succeeds, false if it fails or the component cannot be found.

§ removeFromGroup()

void SurgSim::Framework::SceneElement::removeFromGroup ( const std::string &  group)

Remove this scene element from the given group.

Parameters
groupname of the group

§ setActive()

void SurgSim::Framework::SceneElement::setActive ( bool  val)

Set this SceneElement's status (active/inactive)

Note
Set 'inactive' on an active SceneElement will cause all the components it contains to not be processed.
Set 'active' on an inactive SceneElement will cause all the components it contains which are active
to be processed again.
Inactive components will not be processed no matter the SceneElement is active or inactive.
Parameters
valTrue to set the SceneElement active, false to set inactive.

§ setGroups()

void SurgSim::Framework::SceneElement::setGroups ( const std::vector< std::string > &  groups)

Set the groups of this scene element.

Parameters
groupsall the groups that this scene element should be in

§ setPose()

void SurgSim::Framework::SceneElement::setPose ( const SurgSim::Math::RigidTransform3d pose)

Set the pose of this SceneElement.

Parameters
poseThe pose

§ setRuntime()

void SurgSim::Framework::SceneElement::setRuntime ( std::weak_ptr< Runtime runtime)

Sets the Runtime.

Parameters
runtimePointer to the runtime.

§ setScene()

void SurgSim::Framework::SceneElement::setScene ( std::weak_ptr< Scene scene)

Sets the Scene.

Parameters
scenePointer to the scene.

§ setValue()

void SurgSim::Framework::SceneElement::setValue ( const std::string &  component,
const std::string &  property,
const boost::any &  value 
)

Sets the property value of a component.

Exceptions
SurgSim::Framework::AssertionFailureIf the property cannot be found.
Parameters
componentThe name of the component.
propertyThe name of the property.
valueThe value that it should be set to.

The documentation for this class was generated from the following files: