OsgManager.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// 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 SURGSIM_GRAPHICS_OSGMANAGER_H
#define SURGSIM_GRAPHICS_OSGMANAGER_H
#include "SurgSim/Graphics/Manager.h"
#include <memory>
#include <osgViewer/CompositeViewer>
namespace SurgSim
{
namespace Graphics
{
class Representation;
class Group;
class View;
class OsgCamera;
class OsgGroup;
class OsgScreenSpacePass;
class OsgManager : public Manager
{
public:
OsgManager();
virtual ~OsgManager();
void setMultiThreading(bool val);
bool isMultiThreading() const;
friend class OsgManagerTest;
osg::ref_ptr<osgViewer::CompositeViewer> getOsgCompositeViewer() const;
void dumpDebugInfo() const override;
protected:
bool doUpdate(double dt) override;
bool doInitialize() override;
bool doStartUp() override;
bool addRepresentation(std::shared_ptr<Representation> representation) override;
bool addView(std::shared_ptr<View> view) override;
bool removeView(std::shared_ptr<View> view) override;
std::shared_ptr<Group> getOrCreateGroup(const std::string& name) override;
private:
void doBeforeStop();
osg::ref_ptr<osgViewer::CompositeViewer> m_viewer;
std::shared_ptr<OsgScreenSpacePass> m_hudElement;
};
}; // namespace Graphics
}; // namespace SurgSim
#endif // SURGSIM_GRAPHICS_OSGMANAGER_H
SurgSim::Graphics::OsgManager::doUpdate
bool doUpdate(double dt) override
Performs an update for a single timestep.
Definition: OsgManager.cpp:220
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgManager::m_hudElement
std::shared_ptr< OsgScreenSpacePass > m_hudElement
Builtin RenderPass that can be used for HUD functionality, uses Group "ossHud".
Definition: OsgManager.h:106
SurgSim::Graphics::OsgManager::setMultiThreading
void setMultiThreading(bool val)
Change the threading model of the graphics manager viewer.
Definition: OsgManager.cpp:114
SurgSim::Graphics::OsgManager::isMultiThreading
bool isMultiThreading() const
Definition: OsgManager.cpp:126
SurgSim::Graphics::OsgManager::doBeforeStop
void doBeforeStop()
Prepares the manager for its execution to be stopped.
Definition: OsgManager.cpp:252
SurgSim::Graphics::OsgManager::doStartUp
bool doStartUp() override
Starts up the manager after all threads have initialized.
Definition: OsgManager.cpp:215
Manager.h
SurgSim::Graphics::OsgManager::m_viewer
osg::ref_ptr< osgViewer::CompositeViewer > m_viewer
OSG CompositeViewer to manage and render the individual views.
Definition: OsgManager.h:103
SurgSim::Graphics::OsgManager::addView
bool addView(std::shared_ptr< View > view) override
Adds a view to the manager.
Definition: OsgManager.cpp:175
SurgSim::Graphics::OsgManager::dumpDebugInfo
void dumpDebugInfo() const override
OsgManager will write out the scenegraph in the working directory.
Definition: OsgManager.cpp:268
SurgSim::Graphics::OsgManager::~OsgManager
virtual ~OsgManager()
Destructor.
Definition: OsgManager.cpp:110
SurgSim::Graphics::Manager
Basic graphics manager class which manages graphics components to provide a visualization of the scen...
Definition: Manager.h:37
SurgSim::Graphics::OsgManager::removeView
bool removeView(std::shared_ptr< View > view) override
Removes a view from the manager.
Definition: OsgManager.cpp:197
SurgSim::Graphics::OsgManager::getOsgCompositeViewer
osg::ref_ptr< osgViewer::CompositeViewer > getOsgCompositeViewer() const
Returns the OSG CompositeViewer used to manage and render the views.
Definition: OsgManager.cpp:263
SurgSim::Graphics::OsgManager
OSG-based implementation of graphics manager class.
Definition: OsgManager.h:42
SurgSim::Graphics::OsgManager::getOrCreateGroup
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.
Definition: OsgManager.cpp:131
SurgSim::Graphics::OsgManager::doInitialize
bool doInitialize() override
Initializes the manager.
Definition: OsgManager.cpp:209
SurgSim::Graphics::OsgManager::OsgManager
OsgManager()
Constructor.
Definition: OsgManager.cpp:104
SurgSim::Graphics::OsgManager::OsgManagerTest
friend class OsgManagerTest
Definition: OsgManager.h:61
SurgSim::Graphics::OsgManager::addRepresentation
bool addRepresentation(std::shared_ptr< Representation > representation) override
Adds an representation to the manager.
Definition: OsgManager.cpp:152