opensurgsim
InputComponent.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_INPUT_INPUTCOMPONENT_H
17 #define SURGSIM_INPUT_INPUTCOMPONENT_H
18 
19 #include <atomic>
20 #include <memory>
21 #include <string>
22 
23 #include "SurgSim/DataStructures/DataGroup.h"
24 #include "SurgSim/Framework/LockedContainer.h"
25 #include "SurgSim/Framework/Representation.h"
26 #include "SurgSim/Input/InputConsumerInterface.h"
27 
28 namespace SurgSim
29 {
30 namespace Input
31 {
32 class DeviceInterface;
33 
34 SURGSIM_STATIC_REGISTRATION(InputComponent);
35 
41 {
42 public:
45  explicit InputComponent(const std::string& name);
46 
48  virtual ~InputComponent();
49 
50  SURGSIM_CLASSNAME(SurgSim::Input::InputComponent);
51 
54  void setDeviceName(const std::string& deviceName);
55 
58  std::string getDeviceName() const;
59 
64 
65  bool doInitialize() override;
66 
67  bool doWakeUp() override;
68 
69  void initializeInput(const std::string& device, const SurgSim::DataStructures::DataGroup& initialData) override;
70 
71  void handleInput(const std::string& device, const SurgSim::DataStructures::DataGroup& inputData) override;
72 
75 
79 
82 
86 
87 private:
89  std::string m_deviceName;
90 
93 
94  SurgSim::Math::RigidTransform3d m_toElementTransform;
95 
96  std::atomic<bool> m_hasInput;
97 };
98 
99 }; // namespace Input
100 }; // namespace SurgSim
101 
102 
103 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
std::string getDeviceName() const
Gets device name.
Definition: InputComponent.cpp:54
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
InputComponent(const std::string &name)
Constructor.
Definition: InputComponent.cpp:29
void initializeInput(const std::string &device, const SurgSim::DataStructures::DataGroup &initialData) override
Set the initial input data group.
Definition: InputComponent.cpp:77
void setToElementTransform(const SurgSim::Math::RigidTransform3d &val)
Sets the offset of the device to the element origin.
Definition: InputComponent.cpp:105
void getData(SurgSim::DataStructures::DataGroup *dataGroup)
Gets the input data.
Definition: InputComponent.cpp:59
SurgSim::Math::RigidTransform3d getToDeviceTransform() const
Definition: InputComponent.cpp:90
InputComponents connect devices to SceneElements, facilitating data transfer from a device to SceneEl...
Definition: InputComponent.h:40
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: InputComponent.cpp:67
SurgSim::Math::RigidTransform3d getToElementTransform() const
Definition: InputComponent.cpp:100
void setToDeviceTransform(const SurgSim::Math::RigidTransform3d &val)
Sets the offset of the device pose to the scene.
Definition: InputComponent.cpp:95
Interface for a consumer that monitors device and signal state updates (pose, buttons, etc).
Definition: InputConsumerInterface.h:33
void handleInput(const std::string &device, const SurgSim::DataStructures::DataGroup &inputData) override
Notifies the consumer that the application input coming from the device has been updated.
Definition: InputComponent.cpp:84
A collection of NamedData objects.
Definition: DataGroup.h:68
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
void setDeviceName(const std::string &deviceName)
Set name of the device this input component connects to.
Definition: InputComponent.cpp:49
virtual ~InputComponent()
Destructor.
Definition: InputComponent.cpp:45
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: InputComponent.cpp:72