IGSTK
igstkTrackerTool.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkTrackerTool.h,v $
5  Language: C++
6  Date: $Date: 2008-11-17 20:12:26 $
7  Version: $Revision: 1.32 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __igstkTrackerTool_h
19 #define __igstkTrackerTool_h
20 
21 #include "igstkObject.h"
22 #include "igstkTransform.h"
23 #include "igstkMacros.h"
24 #include "igstkStateMachine.h"
26 
27 
28 namespace igstk
29 {
30 
31 igstkEventMacro( TrackerToolEvent, StringEvent);
32 igstkEventMacro( TrackerToolErrorEvent, IGSTKErrorWithStringEvent);
33 igstkEventMacro( TrackerToolConfigurationEvent,TrackerToolEvent);
34 igstkEventMacro( TrackerToolConfigurationErrorEvent,TrackerToolErrorEvent);
35 
36 igstkEventMacro( InvalidRequestToAttachTrackerToolErrorEvent,
37  TrackerToolErrorEvent);
38 
39 igstkEventMacro( InvalidRequestToDetachTrackerToolErrorEvent,
40  TrackerToolErrorEvent);
41 
42 igstkEventMacro( TrackerToolAttachmentToTrackerEvent,TrackerToolEvent);
43 igstkEventMacro( TrackerToolAttachmentToTrackerErrorEvent,
44  TrackerToolErrorEvent);
45 igstkEventMacro( TrackerToolDetachmentFromTrackerEvent,TrackerToolEvent);
46 igstkEventMacro( TrackerToolDetachmentFromTrackerErrorEvent,
47  TrackerToolErrorEvent);
48 igstkEventMacro( TrackerToolMadeTransitionToTrackedStateEvent,
49  TrackerToolEvent);
50 igstkEventMacro( TrackerToolNotAvailableToBeTrackedEvent,TrackerToolEvent);
51 igstkEventMacro( ToolTrackingStartedEvent,TrackerToolEvent);
52 igstkEventMacro( ToolTrackingStoppedEvent,TrackerToolEvent);
53 
54 class Tracker;
55 
72 class TrackerTool : public Object
73 {
74 public:
75 
78 
79 public:
80 
82 
83  typedef Tracker TrackerType;
85 
87  igstkGetMacro( CalibrationTransform, TransformType );
88 
90  void SetCalibrationTransform( const TransformType & );
91 
93  igstkGetMacro( Updated, bool );
94 
96  virtual void RequestConfigure( void );
97 
100  virtual void RequestDetachFromTracker( );
101 
103  const std::string GetTrackerToolIdentifier( ) const;
104 
107  virtual void RequestAttachToTracker( TrackerType * );
108 
109 protected:
110 
111  TrackerTool(void);
112 
113  virtual ~TrackerTool(void);
114 
116  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
117 
119  void SetTrackerToolIdentifier( const std::string identifier );
120 
121 private:
122 
123  TrackerTool(const Self&); //purposely not implemented
124  void operator=(const Self&); //purposely not implemented
125 
127  virtual void RequestReportTrackingStarted( );
128 
130  virtual void RequestReportTrackingStopped( );
131 
133  virtual void RequestReportTrackingToolNotAvailable( );
134 
136  virtual void RequestReportTrackingToolVisible( );
137 
139  void RequestReportSuccessfulTrackerToolAttachment();
140 
142  void RequestReportFailedTrackerToolAttachment();
143 
145  igstkGetMacro( RawTransform, TransformType );
146 
148  void SetRawTransform( const TransformType & );
149 
151  void SetCalibratedTransform( const TransformType & );
152 
154  igstkSetMacro( Updated, bool );
155 
158  virtual bool CheckIfTrackerToolIsConfigured( ) const = 0;
159 
161  igstkDeclareInputMacro( ConfigureTool );
162  igstkDeclareInputMacro( ToolConfigurationSuccess );
163  igstkDeclareInputMacro( ToolConfigurationFailure );
164  igstkDeclareInputMacro( AttachToolToTracker );
165  igstkDeclareInputMacro( TrackingStarted );
166  igstkDeclareInputMacro( TrackingStopped );
167  igstkDeclareInputMacro( TrackerToolNotAvailable );
168  igstkDeclareInputMacro( TrackerToolVisible );
169  igstkDeclareInputMacro( DetachTrackerToolFromTracker );
170  igstkDeclareInputMacro( AttachmentToTrackerSuccess );
171  igstkDeclareInputMacro( AttachmentToTrackerFailure );
172  igstkDeclareInputMacro( DetachmentFromTrackerSuccess );
173  igstkDeclareInputMacro( DetachmentFromTrackerFailure );
174 
176  igstkDeclareStateMacro( Idle );
177  igstkDeclareStateMacro( AttemptingToConfigureTrackerTool );
178  igstkDeclareStateMacro( Configured );
179  igstkDeclareStateMacro( AttemptingToAttachTrackerToolToTracker );
180  igstkDeclareStateMacro( Attached );
181  igstkDeclareStateMacro( AttemptingToDetachTrackerToolFromTracker );
182  igstkDeclareStateMacro( NotAvailable );
183  igstkDeclareStateMacro( Tracked );
184 
186  void AttemptToConfigureProcessing( void );
187 
189  void AttemptToAttachTrackerToolToTrackerProcessing( void );
190 
192  void TrackerToolConfigurationSuccessProcessing( void );
193 
195  void TrackerToolConfigurationFailureProcessing( void );
196 
199  void TrackerToolAttachmentToTrackerSuccessProcessing( void );
200 
202  void TrackerToolAttachmentToTrackerFailureProcessing( void );
203 
205  void AttemptToDetachTrackerToolFromTrackerProcessing( void );
206 
209  void TrackerToolDetachmentFromTrackerSuccessProcessing( void );
210 
212  void TrackerToolDetachmentFromTrackerFailureProcessing( void );
213 
215  void ReportTrackerToolVisibleStateProcessing( void );
216 
218  void ReportTrackerToolNotAvailableProcessing( void );
219 
221  void ReportTrackingStartedProcessing( void );
222 
224  void ReportTrackingStoppedProcessing( void );
225 
227  void ReportInvalidRequestProcessing( void );
228 
230  void ReportInvalidRequestToAttachTrackerToolProcessing( void );
231 
233  void ReportInvalidRequestToDetachTrackerToolProcessing( void );
234 
236  void NoProcessing( void );
237 
239  TransformType m_CalibrationTransform;
240 
242  TransformType m_CalibratedTransform;
243 
245  TransformType m_RawTransform;
246 
248  bool m_Updated;
249 
251  std::string m_TrackerToolIdentifier;
252 
254  Tracker * m_TrackerToAttachTo;
255 
258  igstkCoordinateSystemClassInterfaceMacro();
259 
262  CoordinateSystem::Pointer m_CalibrationCoordinateSystem;
263 };
264 
265 std::ostream& operator<<(std::ostream& os, const TrackerTool& o);
266 
267 }
268 
269 #endif //__igstk_TrackerTool_h_