All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OsgRepresentation.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_OSGREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGREPRESENTATION_H
18 
19 #include <memory>
20 
21 #include <osg/ref_ptr>
22 
24 
25 namespace osg
26 {
27 class Node;
28 class PositionAttitudeTransform;
29 class Switch;
30 }
31 
32 namespace SurgSim
33 {
34 namespace Graphics
35 {
36 
37 class OsgMaterial;
38 
42 class OsgRepresentation : public virtual Representation
43 {
44 public:
46  explicit OsgRepresentation(const std::string& name);
48  virtual ~OsgRepresentation();
49 
51  osg::ref_ptr<osg::Node> getOsgNode() const;
52 
56  virtual void setVisible(bool visible) override;
57 
60  virtual bool isVisible() const override;
61 
66  virtual bool setMaterial(std::shared_ptr<Material> material) override;
67 
70  virtual std::shared_ptr<Material> getMaterial() const override;
71 
73  virtual void clearMaterial() override;
74 
75  virtual void setDrawAsWireFrame(bool val) override;
76  virtual bool getDrawAsWireFrame() const override;
77 
80  virtual void update(double dt) override;
81 
82 protected:
83  virtual void doUpdate(double dt);
84 
86  osg::ref_ptr<osg::Switch> m_switch;
88  osg::ref_ptr<osg::PositionAttitudeTransform> m_transform;
89 
91  std::shared_ptr<OsgMaterial> m_material;
92 
95 };
96 
97 }; // Graphics
98 }; // SurgSim
99 
100 #endif // SURGSIM_GRAPHICS_OSGREPRESENTATION_H
bool m_drawAsWireFrame
Indicates if the representation is rendered as a wireframe.
Definition: OsgRepresentation.h:94
virtual void clearMaterial() override
Removes the material from the representation.
Definition: OsgRepresentation.cpp:96
virtual ~OsgRepresentation()
Destructor.
Definition: OsgRepresentation.cpp:53
osg::ref_ptr< osg::Switch > m_switch
Switch used to toggle the visibility of the representation.
Definition: OsgRepresentation.h:86
osg::ref_ptr< osg::PositionAttitudeTransform > m_transform
Transform used to pose the representation.
Definition: OsgRepresentation.h:88
virtual void setVisible(bool visible) override
Sets whether the representation is currently visible.
Definition: OsgRepresentation.cpp:58
virtual void setDrawAsWireFrame(bool val) override
Sets the representation to render as a wire frame.
Definition: OsgRepresentation.cpp:112
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:39
osg::ref_ptr< osg::Node > getOsgNode() const
Returns the root OSG Node for this representations portion of the scene graph.
Definition: OsgRepresentation.cpp:102
virtual bool getDrawAsWireFrame() const override
Return if the representation is rendered as a wire frame.
Definition: OsgRepresentation.cpp:130
virtual bool setMaterial(std::shared_ptr< Material > material) override
Sets the material that defines the visual appearance of the representation.
Definition: OsgRepresentation.cpp:77
std::shared_ptr< OsgMaterial > m_material
Material defining the visual appearance of the representation.
Definition: OsgRepresentation.h:91
virtual void update(double dt) override
Updates the representation.
Definition: OsgRepresentation.cpp:69
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:42
virtual void doUpdate(double dt)
Definition: OsgRepresentation.cpp:107
OsgRepresentation(const std::string &name)
Constructor.
Definition: OsgRepresentation.cpp:37
virtual std::shared_ptr< Material > getMaterial() const override
Gets the material that defines the visual appearance of the representation.
Definition: OsgRepresentation.cpp:91
virtual bool isVisible() const override
Gets whether the representation is currently visible.
Definition: OsgRepresentation.cpp:64