CompoundShapeToGraphics.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2015, 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_BLOCKS_COMPOUNDSHAPETOGRAPHICS_H
17 #define SURGSIM_BLOCKS_COMPOUNDSHAPETOGRAPHICS_H
18 
19 #include <memory>
20 #include <vector>
21 #include <string>
22 
24 
25 namespace SurgSim
26 {
27 namespace Graphics
28 {
29 class Representation;
30 }
31 
32 namespace Framework
33 {
34 class Component;
35 class Representation;
36 }
37 
38 namespace Math
39 {
40 class CompoundShape;
41 class Shape;
42 }
43 
44 namespace Blocks
45 {
46 
47 SURGSIM_STATIC_REGISTRATION(CompoundShapeToGraphics);
48 
53 {
54 public:
56  explicit CompoundShapeToGraphics(const std::string& name);
57 
59 
62 
63  void update(double dt) override;
64 
65  int getTargetManagerType() const override;
66 
67  bool doInitialize() override;
68 
69  bool doWakeUp() override;
70 
73  void setShape(const std::shared_ptr<Math::Shape>& shape);
74 
78  void setSource(const std::shared_ptr<Framework::Component>& component);
79 
84  void setTargets(const std::vector<std::shared_ptr<Framework::Component>> components);
85 
89  void addTarget(const std::shared_ptr<Framework::Component>& component);
90 
92  std::vector<std::shared_ptr<Framework::Component>> getTargets() const;
93 
95  std::shared_ptr<Math::CompoundShape> getShape() const;
96 
98  std::shared_ptr<Framework::Component> getSource() const;
99 
100 private:
101 
103  std::shared_ptr<Math::CompoundShape> m_shape;
104 
106  std::shared_ptr<Framework::Component> m_source;
107 
109  std::vector<std::shared_ptr<Graphics::Representation>> m_representations;
110 };
111 
112 }
113 }
114 
115 #endif
Definition: CompoundShapeToGraphics.cpp:29
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:42
Keep a set of Graphics representations in sync with a CompoundShape, the shape can either be set dire...
Definition: CompoundShapeToGraphics.h:52
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
Definition: CompoundShape.h:36
std::vector< std::shared_ptr< Graphics::Representation > > m_representations
List of graphics targets for updating.
Definition: CompoundShapeToGraphics.h:109
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:39
Behaviors perform actions.
Definition: Behavior.h:40
std::shared_ptr< Framework::Component > m_source
Source representation if known.
Definition: CompoundShapeToGraphics.h:106
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
std::shared_ptr< Math::CompoundShape > m_shape
Source shape used for updating.
Definition: CompoundShapeToGraphics.h:103
Generic rigid shape class defining a shape.
Definition: Shape.h:65