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
SurgSim::Framework::Component
Component is the main interface class to pass information to the system managers each will decide whe...
Definition: Component.h:46
SurgSim::Blocks::CompoundShapeToGraphics::setSource
void setSource(const std::shared_ptr< Framework::Component > &component)
Sets the source component, the components needs to provide a shape and that shape needs to be a compo...
Definition: CompoundShapeToGraphics.cpp:106
SurgSim::Blocks::CompoundShapeToGraphics::CompoundShapeToGraphics
CompoundShapeToGraphics(const std::string &name)
Constructor.
Definition: CompoundShapeToGraphics.cpp:37
SurgSim::Blocks::CompoundShapeToGraphics::getShape
std::shared_ptr< Math::CompoundShape > getShape() const
Definition: CompoundShapeToGraphics.cpp:140
SurgSim::Blocks::CompoundShapeToGraphics::getTargets
std::vector< std::shared_ptr< Framework::Component > > getTargets() const
Definition: CompoundShapeToGraphics.cpp:133
SurgSim::Blocks::CompoundShapeToGraphics::setTargets
void setTargets(const std::vector< std::shared_ptr< Framework::Component >> components)
Sets the graphics targets to be used, each target will be update with the pose of the corresponding s...
Definition: CompoundShapeToGraphics.cpp:115
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:41
SurgSim
Definition: CompoundShapeToGraphics.cpp:30
SurgSim::Blocks::CompoundShapeToGraphics::m_representations
std::vector< std::shared_ptr< Graphics::Representation > > m_representations
List of graphics targets for updating.
Definition: CompoundShapeToGraphics.h:109
SurgSim::Blocks::CompoundShapeToGraphics::setShape
void setShape(const std::shared_ptr< Math::Shape > &shape)
Sets the shape to be used for synchronization.
Definition: CompoundShapeToGraphics.cpp:95
SurgSim::Blocks::CompoundShapeToGraphics::addTarget
void addTarget(const std::shared_ptr< Framework::Component > &component)
Adds a single target to the list of targets, the target needs to be a graphics representation.
Definition: CompoundShapeToGraphics.cpp:124
SurgSim::Blocks::CompoundShapeToGraphics::update
void update(double dt) override
Update the behavior.
Definition: CompoundShapeToGraphics.cpp:54
SurgSim::Framework::Representation
Representations are manifestations of a SceneElement.
Definition: Representation.h:34
SurgSim::Math::CompoundShape
Definition: CompoundShape.h:37
SurgSim::Blocks::CompoundShapeToGraphics::~CompoundShapeToGraphics
~CompoundShapeToGraphics()
Destructor.
Definition: CompoundShapeToGraphics.cpp:49
SurgSim::Math::Shape
Generic rigid shape class defining a shape.
Definition: Shape.h:66
SurgSim::Blocks::CompoundShapeToGraphics::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Blocks::CompoundShapeToGraphics)
SurgSim::Blocks::CompoundShapeToGraphics::getTargetManagerType
int getTargetManagerType() const override
Specifies which manger will handle this behavior.
Definition: CompoundShapeToGraphics.cpp:67
SurgSim::Graphics::Representation
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:40
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
Behavior.h
SurgSim::Blocks::CompoundShapeToGraphics::doWakeUp
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: CompoundShapeToGraphics.cpp:77
SurgSim::Blocks::CompoundShapeToGraphics
Keep a set of Graphics representations in sync with a CompoundShape, the shape can either be set dire...
Definition: CompoundShapeToGraphics.h:53
SurgSim::Blocks::CompoundShapeToGraphics::m_source
std::shared_ptr< Framework::Component > m_source
Source representation if known.
Definition: CompoundShapeToGraphics.h:106
SurgSim::Blocks::CompoundShapeToGraphics::getSource
std::shared_ptr< Framework::Component > getSource() const
Definition: CompoundShapeToGraphics.cpp:145
SurgSim::Blocks::CompoundShapeToGraphics::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: CompoundShapeToGraphics.cpp:72
SurgSim::Blocks::CompoundShapeToGraphics::m_shape
std::shared_ptr< Math::CompoundShape > m_shape
Source shape used for updating.
Definition: CompoundShapeToGraphics.h:103