Representation.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2016, 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 bool setMaterial(std::shared_ptr<SurgSim::Framework::Component> material) = 0;
57 
60  virtual std::shared_ptr<Material> getMaterial() const = 0;
61 
63  virtual void clearMaterial() = 0;
64 
67  virtual void setDrawAsWireFrame(bool val) = 0;
68 
71  virtual bool getDrawAsWireFrame() const = 0;
72 
75  virtual void setGenerateTangents(bool value) = 0;
76 
78  virtual bool isGeneratingTangents() const = 0;
79 
82  virtual void update(double dt) = 0;
83 
88  virtual bool addGroupReference(const std::string& name);
89 
90 
93  void addGroupReferences(const std::vector<std::string>& groups);
94 
97  void setGroupReferences(const std::vector<std::string>& groups);
98 
102  void setGroupReference(const std::string& group);
103 
106  std::vector<std::string> getGroupReferences() const;
107 
111  bool removeGroupReference(const std::string& group);
112 
114  void clearGroupReferences();
115 
116 private:
118  std::unordered_set<std::string> m_groups;
119 
123  bool checkAwake(const std::string& functionName);
124 };
125 
126 }; // namespace Graphics
127 }; // namespace SurgSim
128 
129 #endif // SURGSIM_GRAPHICS_REPRESENTATION_H
virtual ~Representation()
Destructor.
Definition: Representation.cpp:120
Definition: CompoundShapeToGraphics.cpp:29
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:118
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
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.
static const std::string DefaultHudGroupName
Definition: Representation.h:44
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
std::vector< std::string > getGroupReferences() const
Gets group references.
Definition: Representation.cpp:77
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
virtual void setGenerateTangents(bool value)=0
Enable or disable the generation of tangents.
void addGroupReferences(const std::vector< std::string > &groups)
Adds a list of group references.
Definition: Representation.cpp:54
virtual bool setMaterial(std::shared_ptr< SurgSim::Framework::Component > material)=0
Sets the material that defines the visual appearance of the representation.
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.
virtual bool isGeneratingTangents() const =0
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