TrackIRScaffold.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, 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_DEVICES_TRACKIR_TRACKIRSCAFFOLD_H
17 #define SURGSIM_DEVICES_TRACKIR_TRACKIRSCAFFOLD_H
18 
19 #include <memory>
20 
22 
23 namespace SurgSim
24 {
25 
26 namespace DataStructures
27 {
28 class DataGroup;
29 }
30 
31 namespace Devices
32 {
33 class TrackIRDevice;
34 
39 {
40 public:
43 
46 
50  static std::shared_ptr<TrackIRScaffold> getOrCreateSharedInstance();
51 
52 private:
54  struct StateData;
56  struct DeviceData;
57 
58  friend class TrackIRDevice;
59  friend class TrackIRThread;
60  friend struct StateData;
61 
67  bool registerDevice(TrackIRDevice* device);
73  bool unregisterDevice(const TrackIRDevice* device);
74 
78  void setPositionScale(const TrackIRDevice* device, double scale);
82  void setOrientationScale(const TrackIRDevice* device, double scale);
83 
86  bool initializeSdk();
89  bool finalizeSdk();
90 
94  bool startCamera(DeviceData* info);
98  bool stopCamera(DeviceData* info);
99 
104  bool runInputFrame(DeviceData* info);
105 
109  bool updateDevice(DeviceData* info);
110 
114  bool createPerDeviceThread(DeviceData* data);
119 
122 
124  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
125 
127  std::unique_ptr<StateData> m_state;
128 };
129 
130 }; // namespace Devices
131 }; // namespace SurgSim
132 
133 #endif // SURGSIM_DEVICES_TRACKIR_TRACKIRSCAFFOLD_H
SurgSim::Devices::TrackIRThread
A class implementing the thread context for sampling TrackIR devices.
Definition: TrackIRThread.h:29
SurgSim::Devices::TrackIRScaffold::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Logger used by the scaffold and all devices.
Definition: TrackIRScaffold.h:124
SurgSim::Devices::TrackIRScaffold::unregisterDevice
bool unregisterDevice(const TrackIRDevice *device)
Unregisters the specified device object.
Definition: TrackIRScaffold.cpp:192
SurgSim::Devices::TrackIRScaffold::stopCamera
bool stopCamera(DeviceData *info)
Stop the camera, it will stop sending frames.
Definition: TrackIRScaffold.cpp:362
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Devices::TrackIRScaffold::finalizeSdk
bool finalizeSdk()
Finalizes (de-initializes) the OptiTrack SDK.
Definition: TrackIRScaffold.cpp:321
SurgSim::DataStructures::DataGroup
A collection of NamedData objects.
Definition: DataGroup.h:68
SurgSim::Devices::TrackIRScaffold::destroyPerDeviceThread
bool destroyPerDeviceThread(DeviceData *data)
Destroys the thread associated with the given DeviceData object.
Definition: TrackIRScaffold.cpp:346
Logger.h
SurgSim::Devices::TrackIRDevice
A class implementing the communication with Natural Point TrackIR camera.
Definition: TrackIRDevice.h:44
SurgSim::Devices::TrackIRScaffold::registerDevice
bool registerDevice(TrackIRDevice *device)
Registers the specified device object.
Definition: TrackIRScaffold.cpp:144
SurgSim::Devices::TrackIRScaffold::buildDeviceInputData
static SurgSim::DataStructures::DataGroup buildDeviceInputData()
Builds the data layout for the application input (i.e. device output).
Definition: TrackIRScaffold.cpp:367
SurgSim::Devices::TrackIRScaffold::TrackIRScaffold
TrackIRScaffold()
Constructor.
Definition: TrackIRScaffold.cpp:104
SurgSim::Devices::TrackIRScaffold::DeviceData
Definition: TrackIRScaffold.cpp:49
SurgSim::Devices::TrackIRScaffold
A class that manages Natural Point TRACKIR devices.
Definition: TrackIRScaffold.h:38
SurgSim::Devices::TrackIRScaffold::createPerDeviceThread
bool createPerDeviceThread(DeviceData *data)
Creates a thread for the given DeviceData object.
Definition: TrackIRScaffold.cpp:335
SurgSim::Devices::TrackIRScaffold::startCamera
bool startCamera(DeviceData *info)
Start the camera, it will start sending frames.
Definition: TrackIRScaffold.cpp:357
SurgSim::Devices::TrackIRScaffold::updateDevice
bool updateDevice(DeviceData *info)
Updates the device information for a single device.
Definition: TrackIRScaffold.cpp:254
SurgSim::Devices::TrackIRScaffold::setOrientationScale
void setOrientationScale(const TrackIRDevice *device, double scale)
Sets the orientation scale for the device.
Definition: TrackIRScaffold.cpp:231
SurgSim::Devices::TrackIRScaffold::initializeSdk
bool initializeSdk()
Initializes the OptiTrack SDK.
Definition: TrackIRScaffold.cpp:293
SurgSim::Devices::TrackIRScaffold::m_state
std::unique_ptr< StateData > m_state
Internal scaffold state.
Definition: TrackIRScaffold.h:127
SurgSim::Devices::TrackIRScaffold::~TrackIRScaffold
~TrackIRScaffold()
Destructor.
Definition: TrackIRScaffold.cpp:112
SurgSim::Devices::TrackIRScaffold::getOrCreateSharedInstance
static std::shared_ptr< TrackIRScaffold > getOrCreateSharedInstance()
Gets or creates the scaffold shared by all TrackIRDevice instances.
Definition: TrackIRScaffold.cpp:374
SurgSim::Devices::TrackIRScaffold::runInputFrame
bool runInputFrame(DeviceData *info)
Executes the operations for a single input frame for a single device.
Definition: TrackIRScaffold.cpp:244
SurgSim::Devices::TrackIRScaffold::StateData
Definition: TrackIRScaffold.cpp:80
SurgSim::Devices::TrackIRScaffold::setPositionScale
void setPositionScale(const TrackIRDevice *device, double scale)
Sets the position scale for the device.
Definition: TrackIRScaffold.cpp:218