SurgSim::Graphics::OsgManager Class Reference

OSG-based implementation of graphics manager class. More...

`#include <SurgSim/Graphics/OsgManager.h>`

Inheritance diagram for SurgSim::Graphics::OsgManager:

## Public Member Functions

| OsgManager ()
| Constructor. More...
virtual | ~OsgManager ()
| Destructor. More...
void | setMultiThreading (bool val)
| Change the threading model of the graphics manager viewer. More...
bool | isMultiThreading () const
osg::ref_ptr< osgViewer::CompositeViewer > | getOsgCompositeViewer () const
| Returns the OSG CompositeViewer used to manage and render the views. More...
void | dumpDebugInfo () const override
| OsgManager will write out the scenegraph in the working directory. More...
Public Member Functions inherited from SurgSim::Graphics::Manager
| Manager ()
| Constructor. More...
virtual | ~Manager ()
| Destructor. More...
const std::vector< std::shared_ptr< Representation > > & | getRepresentations () const
| Returns the representations assigned to the manager. More...
const std::unordered_map< std::string, std::shared_ptr< Group > > & | getGroups () const
| Returns the groups assigned to the manager. More...
const std::vector< std::shared_ptr< View > > & | getViews () const
| Returns the views assigned to the manager. More...
Public Member Functions inherited from SurgSim::Framework::ComponentManager
| ComponentManager (const std::string &name="Unknown Component Manager")
virtual | ~ComponentManager ()
bool | enqueueAddComponent (const std::shared_ptr< Component > &component)
| Queues a component to be added later. More...
bool | enqueueRemoveComponent (const std::shared_ptr< Component > &component)
| Queues a component to be removed. More...
std::shared_ptr< Runtime > | getRuntime () const
void | setRuntime (std::shared_ptr< Runtime > val)
Public Member Functions inherited from SurgSim::Framework::BasicThread
| BasicThread (const std::string &name="Unknown Thread")
virtual | ~BasicThread () noexcept(false)
| C++11 introduced noexcept. More...
void | start (std::shared_ptr< Barrier > startupBarrier=nullptr, bool isSynchronous=false)
| C++11 introduced noexcept. More...
void | stop ()
| Stopping the execution, blocks until the running thread has actually stopped,. More...
void | setIdle (bool isIdle)
| Set/Unset the thread in an idle state (doUpdate() called or not in the update() method) More...
bool | isIdle ()
| Query if this thread is in idle state or not. More...
bool | isInitialized ()
| Query if this object is initialized. More...
bool | isRunning () const
| Query if this object is running. More...
void | operator() ()
| This is what boost::thread executes on thread creation. More...
boost::thread & | getThread ()
std::string | getName () const
void | setRate (double val)
| Set the update rate of the thread. More...
bool | setSynchronous (bool val)
| Sets the thread to synchronized execution in concert with the startup barrier, the startup barrier has to exist for this call to succeed. More...
bool | isSynchronous ()
| Query if this object is synchronized. More...
double | getCpuTime () const
size_t | getUpdateCount () const
void | resetCpuTimeAndUpdateCount ()
| Reset the cpu time and the update count to 0. More...

## Protected Member Functions

bool | doUpdate (double dt) override
| Performs an update for a single timestep. More...
bool | doInitialize () override
| Initializes the manager. More...
bool | doStartUp () override
| Starts up the manager after all threads have initialized. More...
bool | addRepresentation (std::shared_ptr< Representation > representation) override
| Adds an representation to the manager. More...
bool | addView (std::shared_ptr< View > view) override
| Adds a view to the manager. More...
bool | removeView (std::shared_ptr< View > view) override
| Removes a view from the manager. More...
std::shared_ptr< Group > | getOrCreateGroup (const std::string &name) override
| Fetch a group with a given name, if the group does not exist, create it. More...
Protected Member Functions inherited from SurgSim::Graphics::Manager
virtual bool | executeAdditions (const std::shared_ptr< SurgSim::Framework::Component > &component)
| Adds a component. More...
virtual bool | executeRemovals (const std::shared_ptr< SurgSim::Framework::Component > &component)
| Removes a component. More...
virtual bool | removeRepresentation (std::shared_ptr< Representation > representation)
| Removes an representation from the manager. More...
int | getType () const override
| Overrides ComponentManager::getType() More...
virtual void | addGroup (std::shared_ptr< Group > group)
| Adds a group to the manager, override for manager specific behavior when adding. More...
Protected Member Functions inherited from SurgSim::Framework::ComponentManager
template<class T >
std::shared_ptr< T > | tryAddComponent (std::shared_ptr< SurgSim::Framework::Component > component, std::vector< std::shared_ptr< T >> *container)
| Template version of the addComponent method. More...
template<class T >
bool | tryRemoveComponent (std::shared_ptr< SurgSim::Framework::Component > component, std::vector< std::shared_ptr< T >> *container)
| Template version of the removeComponent method. More...
void | processComponents ()
| Processes all the components that are scheduled for addition or removal, this needs to be called inside the doUpdate() function. More...
void | processBehaviors (const double dt)
| Processes behaviors This needs to be called inside doUpdate() function in each 'sub' manager. More...
void | copyScheduledComponents (std::vector< std::shared_ptr< Component >> *inflightAdditions, std::vector< std::shared_ptr< Component >> *inflightRemovals, std::vector< std::shared_ptr< SceneElement >> *inflightElements)
| Helper, blocks access to the additions and removal queue and copies the components from there to the intermediate inflight queues, after this call, the incoming queues will be empty. More...
std::shared_ptr< SurgSim::Framework::Logger > | getLogger () const
| Returns this manager's logger. More...
template<class T >
void | retireComponents (const std::vector< std::shared_ptr< T >> &container)
Protected Member Functions inherited from SurgSim::Framework::BasicThread
bool | initialize ()
| Trigger the initialization of this object, this will be called before all other threads doStartup() are called. More...
bool | startUp ()
| Trigger the startup of this object, this will be called after all other threads doInit() was called the thread will only enter the run loop triggering upated() if all threads doInit() and doStartup() returned true. More...
bool | waitForBarrier (bool success)

## Private Member Functions

void | doBeforeStop ()
| Prepares the manager for its execution to be stopped. More...

## Private Attributes

osg::ref_ptr< osgViewer::CompositeViewer > | m_viewer
| OSG CompositeViewer to manage and render the individual views. More...
std::shared_ptr< OsgScreenSpacePass > | m_hudElement
| Builtin RenderPass that can be used for HUD functionality, uses Group "ossHud". More...

## Friends

class | OsgManagerTest

## Additional Inherited Members

Protected Attributes inherited from SurgSim::Framework::ComponentManager
boost::mutex | m_componentMutex
| Blocks protects addition and removal queues. More...
std::vector< std::shared_ptr< SurgSim::Framework::Behavior > > | m_behaviors
| Collection of behaviors. More...
std::vector< std::shared_ptr< Component > > | m_componentAdditions
std::vector< std::shared_ptr< Component > > | m_componentRemovals
std::vector< std::shared_ptr< SceneElement > > | m_elementCache
Protected Attributes inherited from SurgSim::Framework::BasicThread
Timer | m_timer
| Timer to measure the actual time taken to doUpdate. More...
std::shared_ptr< SurgSim::Framework::Logger > | m_logger
| Logger for this thread. More...

## Detailed Description

OSG-based implementation of graphics manager class.

A Graphics::OsgManager sets up an osgViewer::CompositeViewer to manage and render each Graphics::OsgView added to the Manager.

## Constructor & Destructor Documentation

## OsgManager()

SurgSim::Graphics::OsgManager::OsgManager | ( |  | ) |

Constructor.

Sets up a default Camera which will be used if for any View that does not have a Camera assigned Sets up a default Group which is assigned to the default Camera. All added representations and groups will be added to this group.

## ~OsgManager()

SurgSim::Graphics::OsgManager::~OsgManager | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## addRepresentation()

bool SurgSim::Graphics::OsgManager::addRepresentation | ( | std::shared_ptr< Representation > | representation | ) |

override protected virtual

Adds an representation to the manager.

Parameters

  representation | The representation to be added. Only allows OsgRepresentation components, any other will not be set and it will return false.

Returns
  True if the representation was not in this manager and has been successfully added, false if it fails.

Reimplemented from SurgSim::Graphics::Manager.

## addView()

bool SurgSim::Graphics::OsgManager::addView | ( | std::shared_ptr< View > | view | ) |

override protected virtual

Adds a view to the manager.

Parameters

  view | The view to be added. Only allows OsgView components, any other will not be set and it will return false.

Returns
  True if the view was not in this manager and has been successfully added, false if it fails.

Reimplemented from SurgSim::Graphics::Manager.

## doBeforeStop()

void SurgSim::Graphics::OsgManager::doBeforeStop | ( |  | ) |

private virtual

Prepares the manager for its execution to be stopped.

Note
  Called from this thread before joined

Reimplemented from SurgSim::Graphics::Manager.

## doInitialize()

bool SurgSim::Graphics::OsgManager::doInitialize | ( |  | ) |

override protected virtual

Initializes the manager.

Returns
  True if it succeeds, false if it fails

Reimplemented from SurgSim::Graphics::Manager.

## doStartUp()

bool SurgSim::Graphics::OsgManager::doStartUp | ( |  | ) |

override protected virtual

Starts up the manager after all threads have initialized.

Returns
  True if it succeeds, false if it fails

Reimplemented from SurgSim::Graphics::Manager.

## doUpdate()

bool SurgSim::Graphics::OsgManager::doUpdate | ( | double | dt | ) |

override protected virtual

Performs an update for a single timestep.

Parameters

  dt | The time in seconds of the preceding timestep.

Reimplemented from SurgSim::Graphics::Manager.

## dumpDebugInfo()

void SurgSim::Graphics::OsgManager::dumpDebugInfo | ( |  | ) | const

override virtual

OsgManager will write out the scenegraph in the working directory.

Implements SurgSim::Graphics::Manager.

## getOrCreateGroup()

std::shared_ptr< Group > SurgSim::Graphics::OsgManager::getOrCreateGroup | ( | const std::string & | name | ) |

override protected virtual

Fetch a group with a given name, if the group does not exist, create it.

Parameters

  name | Name of the group to be fetched.

Returns
  group with the given name.

Implements SurgSim::Graphics::Manager.

## getOsgCompositeViewer()

osg::ref_ptr< osgViewer::CompositeViewer > SurgSim::Graphics::OsgManager::getOsgCompositeViewer | ( |  | ) | const

Returns the OSG CompositeViewer used to manage and render the views.

## isMultiThreading()

bool SurgSim::Graphics::OsgManager::isMultiThreading | ( |  | ) | const

Returns
  true when the viewer is multithreading

## removeView()

bool SurgSim::Graphics::OsgManager::removeView | ( | std::shared_ptr< View > | view | ) |

override protected virtual

Removes a view from the manager.

Parameters

  view | The view to be removed.

Returns
  True if the view was in this manager and has been successfully removed, false if it fails.

Postcondition
  The view is removed from the manager and the osgViewer::CompositeViewer.

Reimplemented from SurgSim::Graphics::Manager.

## setMultiThreading()

void SurgSim::Graphics::OsgManager::setMultiThreading | ( | bool | val | ) |

Change the threading model of the graphics manager viewer.

Parameters

  val | enables or disables multithreading in the viewer

## Friends And Related Function Documentation

## OsgManagerTest

friend class OsgManagerTest

friend

## Member Data Documentation

## m_hudElement

std::shared_ptr<OsgScreenSpacePass> SurgSim::Graphics::OsgManager::m_hudElement

private

Builtin RenderPass that can be used for HUD functionality, uses Group "ossHud".

## m_viewer

osg::ref_ptr<osgViewer::CompositeViewer> SurgSim::Graphics::OsgManager::m_viewer

private

OSG CompositeViewer to manage and render the individual views.

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

- SurgSim/Graphics/OsgManager.h
- SurgSim/Graphics/OsgManager.cpp