Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxIgstkTracker.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXIGSTKTRACKER_H_
13 #define CXIGSTKTRACKER_H_
14 
15 #include "org_custusx_core_tracking_system_igstk_Export.h"
16 
17 #include <QObject>
18 
19 #include <map>
20 #include <boost/shared_ptr.hpp>
21 #include <igstkLogger.h>
22 #include <igstkTracker.h>
23 #include <igstkPolarisTracker.h>
24 #include <igstkAuroraTracker.h>
25 #include <itkStdStreamLogOutput.h>
26 #ifdef WIN32
27 #include "igstkSerialCommunicationForWindows.h"
28 #else
29 #include "igstkSerialCommunicationForPosix.h"
30 #endif
31 #include "cxTracker.h"
32 #include "cxTool.h"
33 #include "cxDefinitions.h"
34 #include "cxForwardDeclarations.h"
35 #include "cxToolFileParser.h"
36 
37 namespace cx
38 {
45 class IgstkTool;
46 typedef boost::shared_ptr<IgstkTool> IgstkToolPtr;
47 typedef boost::weak_ptr<IgstkTool> IgstkToolWeakPtr;
48 
56 class org_custusx_core_tracking_system_igstk_EXPORT IgstkTracker: public Tracker
57 {
58 Q_OBJECT
59 public:
60 
61 #ifdef WIN32
62 
63  typedef igstk::SerialCommunicationForWindows CommunicationType;
64 #else
65 
66  typedef igstk::SerialCommunicationForPosix CommunicationType;
67 #endif
68  typedef igstk::Tracker TrackerType;
69  typedef igstk::PolarisTracker PolarisTrackerType;
70  typedef igstk::AuroraTracker AuroraTrackerType;
71 
72  /*only used for documentation purposes
73  enum TRACKING_SYSTEM
74  {
75  tsNONE, ///< Not specified
76  tsPOLARIS, ///< NDIs Polaris tracker
77  tsPOLARIS_SPECTRA, ///< NDIs Polaris Spectra tracker
78  tsPOLARIS_VICRA, ///< NDIs Polaris Vicra tracker
79  tsPOLARIS_CLASSIC, ///< NDIs Polaris Classic tracker
80  tsAURORA, ///< NDIs Aurora tracker
81  tsMICRON, ///< Claron Technologys Micron tracker
82  tsCOUNT
83  };*/
84 
85  /*only used for documentation purposes
86  TRACKER_INVALID_REQUEST, ///< internal state machine didn't accept the request
87  TRACKER_OPEN, ///< hardware accepted the tracker as open
88  TRACKER_INITIALIZED, ///< hardware accepted the tracker as initialized
89  TRACKER_TRACKING, ///< tracker is tracking
90  TRACKER_UPDATE_STATUS, ///< tracker got an update event
91  TRACKER_TOOL_TRANSFORM_UPDATED, ///< a tool attached to the tracker got a new transform
92  TRACKER_COMMUNICATION_COMPLETE, ///< communication port completed a task successfully
93  TRACKER_COMMUNICATION_INPUT_OUTPUT_ERROR, ///< communication port failed at completing a task
94  TRACKER_COMMUNICATION_INPUT_OUTPUT_TIMEOUT, ///< communication port timed out
95  TRACKER_COMMUNICATION_OPEN_PORT_ERROR ///< communication port tried to open or close
96  */
97 
99  ~IgstkTracker();
100 
101  TRACKING_SYSTEM getType() const;
102  QString getName() const;
103  QString getUid() const;
104  TrackerType* getPointer() const;
105  void open();
106  void close();
107  void attachTools(std::map<QString, IgstkToolPtr> tools);
108  void detachTools(std::map<QString, IgstkToolPtr> tools);
109  void startTracking();
110  void stopTracking();
111 
112  bool isValid() const;
113  bool isOpen() const;
114  bool isInitialized() const;
115  bool isTracking() const;
116 
117 signals:
118  void initialized(bool);
119  void open(bool);
120  void tracking(bool);
121  void error();
122 
123 protected:
124  typedef itk::ReceptorMemberCommand<IgstkTracker> ObserverType;
125 
126  void trackerTransformCallback(const itk::EventObject &eventVar);
127  void addLogging();
128 
129  void internalOpen(bool value);
130  void internalInitialized(bool value);
131  void internalTracking(bool value);
132  void internalError(bool value);
133 
134  void shutdown();
135 
137  bool mValid;
138  QString mUid;
139  QString mName;
140  TrackerType* mTracker;
141 
142  PolarisTrackerType::Pointer mTempPolarisTracker;
143  AuroraTrackerType::Pointer mTempAuroraTracker;
144 
145  CommunicationType::Pointer mCommunication;
146  ObserverType::Pointer mTrackerObserver;
147  igstk::Logger::Pointer mTrackerLogger;
148  itk::StdStreamLogOutput::Pointer mTrackerLogOutput;
149 
150  bool mOpen;
152  bool mTracking;
153 
154 private:
155  IgstkTracker() {}
156 };
157 typedef boost::shared_ptr<IgstkTracker> TrackerPtr;
158 typedef boost::weak_ptr<IgstkTracker> TrackerWeakPtr;
159 
163 } //namespace cx
164 
165 #endif /* CXIGSTKTRACKER_H_ */
bool mTracking
whether or not the tracker is tracking
igstk::SerialCommunicationForPosix CommunicationType
PolarisTrackerType::Pointer mTempPolarisTracker
pointer to a temp polaris tracker
bool mValid
whether this tracker is constructed correctly or not
Class representing the navigation system.
ObserverType::Pointer mTrackerObserver
observer listening for igstk events
boost::shared_ptr< class IgstkTool > IgstkToolPtr
bool mOpen
whether or not the tracker is open
boost::weak_ptr< IgstkTracker > TrackerWeakPtr
TrackerType * mTracker
pointer to the base class of the internal igstk tracker
QString mUid
the trackers unique id
igstk::Tracker TrackerType
itk::ReceptorMemberCommand< IgstkTracker > ObserverType
CommunicationType::Pointer mCommunication
pointer to the serial communication used to communicate with the NDI trackers
boost::weak_ptr< IgstkTool > IgstkToolWeakPtr
Definition: cxIgstkTool.h:42
igstk::Logger::Pointer mTrackerLogger
logging the internal igstk behavior
bool mInitialized
whether or not the tracker is initialized
igstk::AuroraTracker AuroraTrackerType
AuroraTrackerType::Pointer mTempAuroraTracker
pointer to a temp aurora tracker
ToolFileParser::TrackerInternalStructure mInternalStructure
the trackers type
itk::StdStreamLogOutput::Pointer mTrackerLogOutput
output to write the log to
QString mName
the trackers name
igstk::PolarisTracker PolarisTrackerType
boost::shared_ptr< IgstkTracker > TrackerPtr
Namespace for all CustusX production code.