OsgManager.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_GRAPHICS_OSGMANAGER_H
17 #define SURGSIM_GRAPHICS_OSGMANAGER_H
18 
20 
21 #include <memory>
22 
23 #include <osgViewer/CompositeViewer>
24 
25 namespace SurgSim
26 {
27 
28 namespace Graphics
29 {
30 
31 class Representation;
32 class Group;
33 class View;
34 class OsgCamera;
35 class OsgGroup;
36 class OsgScreenSpacePass;
37 
42 class OsgManager : public Manager
43 {
44 public:
50  OsgManager();
52  virtual ~OsgManager();
53 
54  friend class OsgManagerTest;
55 
57  osg::ref_ptr<osgViewer::CompositeViewer> getOsgCompositeViewer() const;
58 
60  virtual void dumpDebugInfo() const override;
61 
62 protected:
63  virtual bool doUpdate(double dt) override;
64 
65  virtual bool doInitialize() override;
66 
67  virtual bool doStartUp() override;
68 
73  virtual bool addRepresentation(std::shared_ptr<Representation> representation) override;
74 
79  virtual bool addView(std::shared_ptr<View> view) override;
80 
85  virtual bool removeView(std::shared_ptr<View> view) override;
86 
87  virtual std::shared_ptr<Group> getOrCreateGroup(const std::string& name) override;
88 
89 private:
90 
93  void doBeforeStop();
94 
96  osg::ref_ptr<osgViewer::CompositeViewer> m_viewer;
97 
99  std::shared_ptr<OsgScreenSpacePass> m_hudElement;
100 };
101 
102 }; // namespace Graphics
103 
104 }; // namespace SurgSim
105 
106 #endif // SURGSIM_GRAPHICS_OSGMANAGER_H
virtual bool doUpdate(double dt) override
Performs an update for a single timestep.
Definition: OsgManager.cpp:135
Definition: DriveElementFromInputBehavior.cpp:27
std::shared_ptr< OsgScreenSpacePass > m_hudElement
Builtin RenderPass that can be used for HUD functionality, uses Group "ossHud".
Definition: OsgManager.h:99
void doBeforeStop()
Prepares the manager for its execution to be stopped.
Definition: OsgManager.cpp:167
virtual bool doStartUp() override
Starts up the manager after all threads have initialized.
Definition: OsgManager.cpp:130
osg::ref_ptr< osgViewer::CompositeViewer > getOsgCompositeViewer() const
Returns the OSG CompositeViewer used to manage and render the views.
Definition: OsgManager.cpp:174
osg::ref_ptr< osgViewer::CompositeViewer > m_viewer
OSG CompositeViewer to manage and render the individual views.
Definition: OsgManager.h:96
virtual bool addView(std::shared_ptr< View > view) override
Adds a view to the manager.
Definition: OsgManager.cpp:90
virtual void dumpDebugInfo() const override
OsgManager will write out the scenegraph in the working directory.
Definition: OsgManager.cpp:179
virtual ~OsgManager()
Destructor.
Definition: OsgManager.cpp:47
Basic graphics manager class which manages graphics components to provide a visualization of the scen...
Definition: Manager.h:37
virtual bool removeView(std::shared_ptr< View > view) override
Removes a view from the manager.
Definition: OsgManager.cpp:112
OSG-based implementation of graphics manager class.
Definition: OsgManager.h:42
virtual 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:51
virtual bool doInitialize() override
Initializes the manager.
Definition: OsgManager.cpp:124
OsgManager()
Constructor.
Definition: OsgManager.cpp:42
friend class OsgManagerTest
Definition: OsgManager.h:54
virtual bool addRepresentation(std::shared_ptr< Representation > representation) override
Adds an representation to the manager.
Definition: OsgManager.cpp:72