Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkOpenIGTLinkTrackingDevice.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkOpenIGTLinkTrackingDevice_h
14 #define mitkOpenIGTLinkTrackingDevice_h
15 
16 #include <mitkIGTConfig.h>
17 #include <mitkTrackingDevice.h>
19 #include <mitkIGTLClient.h>
20 #include <mitkIGTLDeviceSource.h>
22 #include <igtlQuaternionTrackingDataMessage.h>
23 #include <igtlTrackingDataMessage.h>
24 #include <igtlTransformMessage.h>
26 
27 namespace mitk
28 {
35  class MITKIGT_EXPORT OpenIGTLinkTrackingDevice : public TrackingDevice
36  {
37  public:
39  itkFactorylessNewMacro(Self);
40  itkCloneMacro(Self);
41 
43  void SetPortNumber(int portNumber);
44 
46  void SetHostname(std::string hostname);
47 
48  int GetPortNumber();
49 
50  std::string GetHostname();
51 
57  bool StartTracking() override;
58 
63  bool StopTracking() override;
64 
69  bool OpenConnection() override;
70 
74  bool CloseConnection() override;
75 
79  unsigned int GetToolCount() const override;
80 
86  TrackingTool* GetTool(unsigned int toolNumber) const override;
87 
95  bool DiscoverTools(int WaitingTime = 10000);
96 
105  mitk::TrackingTool* AddTool(const char* toolName, const char* fileName);
106 
108  bool AutoDetectToolsAvailable() override;
109 
114  mitk::NavigationToolStorage::Pointer AutoDetectTools() override;
115 
116  bool IsDeviceInstalled() override;
117 
118  itkSetMacro(UpdateRate, int);
119  itkGetConstMacro(UpdateRate, int);
120 
121  protected:
123  ~OpenIGTLinkTrackingDevice() override;
124 
131  bool InternalAddTool(OpenIGTLinkTrackingTool::Pointer tool);
132 
134  void UpdateTools();
136 
139  mitk::IGTLMessage::Pointer ReceiveMessage(int waitingTime);
140 
144  std::vector<OpenIGTLinkTrackingTool::Pointer> GetAllTools();
145 
146  //OpenIGTLink connection class
147  mitk::IGTLClient::Pointer m_OpenIGTLinkClient;
148 
149  //OpenIGTLink pipeline
150  mitk::IGTLTrackingDataDeviceSource::Pointer m_IGTLDeviceSource;
151  mitk::IGTLMessageToNavigationDataFilter::Pointer m_IGTLMsgToNavDataFilter;
152 
153  std::vector<OpenIGTLinkTrackingTool::Pointer> m_AllTools;
154 
156 
157  private:
158  enum TrackingMessageType
159  {
160  TDATA, TRANSFORM, QTDATA, UNKNOWN
161  };
162 
163  mitk::OpenIGTLinkTrackingDevice::TrackingMessageType GetMessageTypeFromString(const char* messageTypeString);
164 
167  mitk::NavigationToolStorage::Pointer DiscoverToolsAndConvertToNavigationTools(mitk::OpenIGTLinkTrackingDevice::TrackingMessageType type, int NumberOfMessagesToWait = 50);
168 
169  void AddNewToolForName(std::string name, int i);
170 
171  mitk::NavigationTool::Pointer ConstructDefaultOpenIGTLinkTool(std::string name, std::string identifier);
172  };
173 }//mitk
174 #endif
mitkOpenIGTLinkTrackingTool.h
mitk::OpenIGTLinkTrackingDevice::m_AllTools
std::vector< OpenIGTLinkTrackingTool::Pointer > m_AllTools
vector holding all tools
Definition: mitkOpenIGTLinkTrackingDevice.h:153
mitk::OpenIGTLinkTrackingDevice::m_IGTLDeviceSource
mitk::IGTLTrackingDataDeviceSource::Pointer m_IGTLDeviceSource
Definition: mitkOpenIGTLinkTrackingDevice.h:150
mitk::OpenIGTLinkTrackingDevice::m_IGTLMsgToNavDataFilter
mitk::IGTLMessageToNavigationDataFilter::Pointer m_IGTLMsgToNavDataFilter
Definition: mitkOpenIGTLinkTrackingDevice.h:151
mitk::OpenIGTLinkTrackingDevice::m_OpenIGTLinkClient
mitk::IGTLClient::Pointer m_OpenIGTLinkClient
Definition: mitkOpenIGTLinkTrackingDevice.h:147
mitk::OpenIGTLinkTrackingDevice::m_MessageReceivedObserverTag
unsigned long m_MessageReceivedObserverTag
Definition: mitkOpenIGTLinkTrackingDevice.h:135
mitkIGTLClient.h
mitk::OpenIGTLinkTrackingDevice
An object of this class represents the MicronTracker device. You can add tools to this device,...
Definition: mitkOpenIGTLinkTrackingDevice.h:35
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::TrackingDevice
Interface for all Tracking Devices.
Definition: mitkTrackingDevice.h:34
mitkIGTLMessageToNavigationDataFilter.h
mitk::OpenIGTLinkTrackingDevice::m_UpdateRate
int m_UpdateRate
holds the update rate in FPS (will be set automatically when the OpenIGTLink connection is establishe...
Definition: mitkOpenIGTLinkTrackingDevice.h:155
mitkIGTLTrackingDataDeviceSource.h
mitk::TrackingTool
Interface for all Tracking Tools.
Definition: mitkTrackingTool.h:42
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitkTrackingDevice.h
mitkIGTLDeviceSource.h