opensurgsim
VisualizeConstraints.h
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 
19 #include "SurgSim/Framework/BasicSceneElement.h"
20 #include "SurgSim/Framework/Behavior.h"
21 #include "SurgSim/Physics/PhysicsManagerState.h"
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>>
85  m_graphics;
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
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
SceneElement that generates the VisualizeConstraintBehavior and the appropriate graphics Vectorfield...
Definition: VisualizeConstraints.h:93
Behavior to visualize information about the constraints as they are in the physics manager this will ...
Definition: VisualizeConstraints.h:48
Simple concrete implementation of a scene element that does not have any higher logic.
Definition: BasicSceneElement.h:29
Behaviors perform actions.
Definition: Behavior.h:40