Representation.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_REPRESENTATION_H
17 #define SURGSIM_GRAPHICS_REPRESENTATION_H
18 
20 
22 
23 #include <unordered_set>
24 
25 namespace SurgSim
26 {
27 
28 namespace Graphics
29 {
30 
31 class Manager;
32 class Material;
33 
40 {
41 public:
42 
43  static const std::string DefaultGroupName;
44  static const std::string DefaultHudGroupName;
45 
48  explicit Representation(const std::string& name);
49 
51  virtual ~Representation();
52 
56  virtual void setVisible(bool visible) = 0;
57 
60  virtual bool isVisible() const = 0;
61 
62  virtual void setLocalActive(bool val) override;
63 
67  virtual bool setMaterial(std::shared_ptr<Material> material) = 0;
68 
71  virtual std::shared_ptr<Material> getMaterial() const = 0;
72 
74  virtual void clearMaterial() = 0;
75 
78  virtual void setDrawAsWireFrame(bool val) = 0;
79 
82  virtual bool getDrawAsWireFrame() const = 0;
83 
86  virtual void update(double dt) = 0;
87 
92  virtual bool addGroupReference(const std::string& name);
93 
94 
97  void addGroupReferences(const std::vector<std::string>& groups);
98 
101  void setGroupReferences(const std::vector<std::string>& groups);
102 
106  void setGroupReference(const std::string& group);
107 
110  std::vector<std::string> getGroupReferences();
111 
115  bool removeGroupReference(const std::string& group);
116 
118  void clearGroupReferences();
119 
120 protected:
122 
123 private:
124 
126  std::unordered_set<std::string> m_groups;
127 
131  bool checkAwake(const std::string& functionName);
132 
133 };
134 
135 }; // namespace Graphics
136 
137 }; // namespace SurgSim
138 
139 #endif // SURGSIM_GRAPHICS_REPRESENTATION_H
virtual ~Representation()
Destructor.
Definition: Representation.cpp:120
Definition: DriveElementFromInputBehavior.cpp:27
Representation(const std::string &name)
Constructor.
Definition: Representation.cpp:30
std::unordered_set< std::string > m_groups
List of groups that this representation would like to be added.
Definition: Representation.h:126
virtual void setLocalActive(bool val) override
Set the component's active state.
Definition: Representation.cpp:125
void setGroupReference(const std::string &group)
Helper functions, this clears all the references and sets, only the reference given in the parameter...
Definition: Representation.cpp:100
void clearGroupReferences()
Clear all the Group references.
Definition: Representation.cpp:82
virtual void setVisible(bool visible)=0
Sets whether the representation is currently visible.
bool checkAwake(const std::string &functionName)
Check if the representation is awake and print a warning message if it is.
Definition: Representation.cpp:109
virtual std::shared_ptr< Material > getMaterial() const =0
Gets the material that defines the visual appearance of the representation.
bool m_isVisible
Definition: Representation.h:121
virtual bool setMaterial(std::shared_ptr< Material > material)=0
Sets the material that defines the visual appearance of the representation.
static const std::string DefaultHudGroupName
Definition: Representation.h:44
std::vector< std::string > getGroupReferences()
Gets group references.
Definition: Representation.cpp:77
virtual bool isVisible() const =0
Gets whether the representation is currently visible.
virtual void setDrawAsWireFrame(bool val)=0
Sets the representation to render as a wire frame.
virtual bool getDrawAsWireFrame() const =0
Return if the representation is rendered as a wire frame.
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:39
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
void addGroupReferences(const std::vector< std::string > &groups)
Adds a list of group references.
Definition: Representation.cpp:54
static const std::string DefaultGroupName
Definition: Representation.h:43
virtual void update(double dt)=0
Updates the representation.
virtual bool addGroupReference(const std::string &name)
Add a reference to a group, this will eventual add this representation to the group with the the same...
Definition: Representation.cpp:43
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
virtual void clearMaterial()=0
Removes the material from the representation.
void setGroupReferences(const std::vector< std::string > &groups)
Sets the list of group references.
Definition: Representation.cpp:65
bool removeGroupReference(const std::string &group)
Function to remove an unwanted reference.
Definition: Representation.cpp:90