opensurgsim
CompoundShapeToGraphics.h
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 
23 #include "SurgSim/Framework/Behavior.h"
25 
26 namespace SurgSim
27 {
28 namespace Graphics
29 {
30 class Representation;
31 }
32 
33 namespace Framework
34 {
35 class Component;
36 class Representation;
37 }
38 
39 namespace Math
40 {
41 class CompoundShape;
42 class Shape;
43 }
44 
45 namespace Blocks
46 {
47 
48 SURGSIM_STATIC_REGISTRATION(CompoundShapeToGraphics);
49 
54 {
55 public:
57  explicit CompoundShapeToGraphics(const std::string& name);
58 
60 
63 
64  void update(double dt) override;
65 
66  int getTargetManagerType() const override;
67 
68  bool doInitialize() override;
69 
70  bool doWakeUp() override;
71 
74  void setShape(const std::shared_ptr<Math::Shape>& shape);
75 
79  void setSource(const std::shared_ptr<Framework::Component>& component);
80 
85  void setTargets(const std::vector<std::shared_ptr<Framework::Component>> components);
86 
91  void addTarget(const std::shared_ptr<Framework::Component>& component);
92 
94  std::vector<std::shared_ptr<Framework::Component>> getTargets() const;
95 
97  std::shared_ptr<Math::CompoundShape> getShape() const;
98 
100  std::shared_ptr<Framework::Component> getSource() const;
101 
102 private:
103 
105  std::shared_ptr<Math::CompoundShape> m_shape;
106 
108  std::shared_ptr<Framework::Component> m_source;
109 
111  std::vector<std::pair<std::shared_ptr<Graphics::Representation>, Math::RigidTransform3d>> m_representations;
112 };
113 
114 }
115 }
116 
117 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
Keep a set of Graphics representations in sync with a CompoundShape, the shape can either be set dire...
Definition: CompoundShapeToGraphics.h:53
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
Behaviors perform actions.
Definition: Behavior.h:40