VisualizeConstraints.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_BLOCKS_VISUALIZECONSTRAINTS_H
17 #define SURGSIM_BLOCKS_VISUALIZECONSTRAINTS_H
18 
22 
23 namespace SurgSim
24 {
25 
26 namespace Physics
27 {
28 class PhysicsManager;
29 }
30 
31 namespace Framework
32 {
33 class Logger;
34 }
35 
36 namespace Graphics
37 {
38 class VectorFieldRepresentation;
39 }
40 
41 namespace Blocks
42 {
43 SURGSIM_STATIC_REGISTRATION(VisualizeConstraintsBehavior);
49 {
50 public:
51  explicit VisualizeConstraintsBehavior(const std::string& name);
52 
54 
58  void setVectorField(Physics::ConstraintGroupType constraintType,
59  const std::shared_ptr<Framework::Component>& vectorField);
60 
61  typedef std::vector<std::pair<int, std::shared_ptr<Framework::Component>>> FieldsType;
62 
65  void setVectorFields(const FieldsType& fields);
66 
68  FieldsType getVectorFields() const;
69 
70  void update(double dt) override;
71 
72  int getTargetManagerType() const override;
73 
74 private:
75 
76 
77  bool doInitialize() override;
78 
79  bool doWakeUp() override;
80 
82  std::weak_ptr<SurgSim::Physics::PhysicsManager> m_manager;
83 
84  std::map<SurgSim::Physics::ConstraintGroupType, std::shared_ptr<SurgSim::Graphics::VectorFieldRepresentation>>
86 
87  boost::mutex m_graphicsMutex;
88 
89  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
90 };
91 
94 {
95 public:
96  explicit VisualizeConstraints(const std::string& name = "ConstraintVisualization");
97 };
98 
99 }; // namespace Blocks
100 
101 }; // namespace SurgSim
102 
103 #endif // SURGSIM_BLOCKS_VISUALIZECONSTRAINTS_H
Definition: CompoundShapeToGraphics.cpp:29
std::map< SurgSim::Physics::ConstraintGroupType, std::shared_ptr< SurgSim::Graphics::VectorFieldRepresentation > > m_graphics
Definition: VisualizeConstraints.h:85
SceneElement that generates the VisualizeConstraintBehavior and the appropriate graphics Vectorfield...
Definition: VisualizeConstraints.h:93
ConstraintGroupType
Definition: PhysicsManagerState.h:41
Behavior to visualize information about the constraints as they are in the physics manager this will ...
Definition: VisualizeConstraints.h:48
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Definition: VisualizeConstraints.h:89
Simple concrete implementation of a scene element that does not have any higher logic.
Definition: BasicSceneElement.h:29
boost::mutex m_graphicsMutex
Definition: VisualizeConstraints.h:87
std::weak_ptr< SurgSim::Physics::PhysicsManager > m_manager
Need reference to physics manager for introspection into the state.
Definition: VisualizeConstraints.h:82
std::vector< std::pair< int, std::shared_ptr< Framework::Component > > > FieldsType
Definition: VisualizeConstraints.h:61
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
Behaviors perform actions.
Definition: Behavior.h:40