Fraxinus  16.5.0-fx-rc1
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXIGSTKTRACKER_H_
34 #define CXIGSTKTRACKER_H_
35 
36 #include "org_custusx_core_tracking_system_igstk_Export.h"
37 
38 #include <QObject>
39 
40 #include <map>
41 #include <boost/shared_ptr.hpp>
42 #include <igstkLogger.h>
43 #include <igstkTracker.h>
44 #include <igstkPolarisTracker.h>
45 #include <igstkAuroraTracker.h>
46 #include <itkStdStreamLogOutput.h>
47 #ifdef WIN32
48 #include "igstkSerialCommunicationForWindows.h"
49 #else
50 #include "igstkSerialCommunicationForPosix.h"
51 #endif
52 #include "cxTracker.h"
53 #include "cxTool.h"
54 #include "cxDefinitions.h"
55 #include "cxForwardDeclarations.h"
56 #include "cxToolFileParser.h"
57 
58 namespace cx
59 {
66 class IgstkTool;
67 typedef boost::shared_ptr<IgstkTool> IgstkToolPtr;
68 typedef boost::weak_ptr<IgstkTool> IgstkToolWeakPtr;
69 
77 class org_custusx_core_tracking_system_igstk_EXPORT IgstkTracker: public Tracker
78 {
79 Q_OBJECT
80 public:
81 
82 #ifdef WIN32
83 
84  typedef igstk::SerialCommunicationForWindows CommunicationType;
85 #else
86 
87  typedef igstk::SerialCommunicationForPosix CommunicationType;
88 #endif
89  typedef igstk::Tracker TrackerType;
90  typedef igstk::PolarisTracker PolarisTrackerType;
91  typedef igstk::AuroraTracker AuroraTrackerType;
92 
93  /*only used for documentation purposes
94  enum TRACKING_SYSTEM
95  {
96  tsNONE, ///< Not specified
97  tsPOLARIS, ///< NDIs Polaris tracker
98  tsPOLARIS_SPECTRA, ///< NDIs Polaris Spectra tracker
99  tsPOLARIS_VICRA, ///< NDIs Polaris Vicra tracker
100  tsPOLARIS_CLASSIC, ///< NDIs Polaris Classic tracker
101  tsAURORA, ///< NDIs Aurora tracker
102  tsMICRON, ///< Claron Technologys Micron tracker
103  tsCOUNT
104  };*/
105 
106  /*only used for documentation purposes
107  TRACKER_INVALID_REQUEST, ///< internal state machine didn't accept the request
108  TRACKER_OPEN, ///< hardware accepted the tracker as open
109  TRACKER_INITIALIZED, ///< hardware accepted the tracker as initialized
110  TRACKER_TRACKING, ///< tracker is tracking
111  TRACKER_UPDATE_STATUS, ///< tracker got an update event
112  TRACKER_TOOL_TRANSFORM_UPDATED, ///< a tool attached to the tracker got a new transform
113  TRACKER_COMMUNICATION_COMPLETE, ///< communication port completed a task successfully
114  TRACKER_COMMUNICATION_INPUT_OUTPUT_ERROR, ///< communication port failed at completing a task
115  TRACKER_COMMUNICATION_INPUT_OUTPUT_TIMEOUT, ///< communication port timed out
116  TRACKER_COMMUNICATION_OPEN_PORT_ERROR ///< communication port tried to open or close
117  */
118 
120  ~IgstkTracker();
121 
122  TRACKING_SYSTEM getType() const;
123  QString getName() const;
124  QString getUid() const;
125  TrackerType* getPointer() const;
126  void open();
127  void close();
128  void attachTools(std::map<QString, IgstkToolPtr> tools);
129  void detachTools(std::map<QString, IgstkToolPtr> tools);
130  void startTracking();
131  void stopTracking();
132 
133  bool isValid() const;
134  bool isOpen() const;
135  bool isInitialized() const;
136  bool isTracking() const;
137 
138 signals:
139  void initialized(bool);
140  void open(bool);
141  void tracking(bool);
142  void error();
143 
144 protected:
145  typedef itk::ReceptorMemberCommand<IgstkTracker> ObserverType;
146 
147  void trackerTransformCallback(const itk::EventObject &eventVar);
148  void addLogging();
149 
150  void internalOpen(bool value);
151  void internalInitialized(bool value);
152  void internalTracking(bool value);
153  void internalError(bool value);
154 
155  void shutdown();
156 
158  bool mValid;
159  QString mUid;
160  QString mName;
162 
163  PolarisTrackerType::Pointer mTempPolarisTracker;
164  AuroraTrackerType::Pointer mTempAuroraTracker;
165 
166  CommunicationType::Pointer mCommunication;
167  ObserverType::Pointer mTrackerObserver;
168  igstk::Logger::Pointer mTrackerLogger;
169  itk::StdStreamLogOutput::Pointer mTrackerLogOutput;
170 
171  bool mOpen;
173  bool mTracking;
174 
175 private:
176  IgstkTracker() {}
177 };
178 typedef boost::shared_ptr<IgstkTracker> TrackerPtr;
179 typedef boost::weak_ptr<IgstkTracker> TrackerWeakPtr;
180 
184 } //namespace cx
185 
186 #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:63
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