IGSTK
igstkVideoImagerTool.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkVideoImagerTool.h,v $
5  Language: C++
6  Date: $Date: 2009-06-18 18:40:55 $
7  Version: $Revision: 1.1 $
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 __igstkVideoImagerTool_h
19 #define __igstkVideoImagerTool_h
20 
21 #include "igstkObject.h"
22 #include "igstkTransform.h"
23 #include "igstkFrame.h"
24 #include "igstkMacros.h"
25 #include "igstkStateMachine.h"
27 
28 class vtkImagedata;
29 
30 namespace igstk
31 {
32 
33 igstkEventMacro( VideoImagerToolEvent, StringEvent);
34 igstkEventMacro( VideoImagerToolErrorEvent, IGSTKErrorWithStringEvent);
35 igstkEventMacro( VideoImagerToolConfigurationEvent,VideoImagerToolEvent);
36 igstkEventMacro( VideoImagerToolConfigurationErrorEvent,
37  VideoImagerToolErrorEvent);
38 igstkEventMacro( InvalidRequestToAttachVideoImagerToolErrorEvent,
39  VideoImagerToolErrorEvent);
40 igstkEventMacro( InvalidRequestToDetachVideoImagerToolErrorEvent,
41  VideoImagerToolErrorEvent);
42 igstkEventMacro( VideoImagerToolAttachmentToVideoImagerEvent,
43  VideoImagerToolEvent);
44 igstkEventMacro( VideoImagerToolAttachmentToVideoImagerErrorEvent,
45  VideoImagerToolErrorEvent);
46 igstkEventMacro( VideoImagerToolDetachmentFromVideoImagerEvent,
47  VideoImagerToolEvent);
48 igstkEventMacro( VideoImagerToolDetachmentFromVideoImagerErrorEvent,
49  VideoImagerToolErrorEvent);
50 igstkEventMacro( VideoImagerToolMadeTransitionToStreamingStateEvent,
51  VideoImagerToolEvent);
52 igstkEventMacro( VideoImagerToolNotAvailableEvent,VideoImagerToolEvent);
53 igstkEventMacro( ToolImagingStartedEvent,VideoImagerToolEvent);
54 igstkEventMacro( ToolImagingStoppedEvent,VideoImagerToolEvent);
55 igstkLoadedEventMacro( FrameModifiedEvent, IGSTKEvent, igstk::Frame);
56 
57 class VideoImager;
58 
73 class VideoImagerTool : public Object
74 {
75 public:
76 
79 
80 public:
81 
83 
84  typedef VideoImager VideoImagerType;
86  typedef Frame FrameType;
87 
89  igstkGetMacro( Updated, bool );
90 
92  virtual void RequestConfigure( void );
93 
96  virtual void RequestDetachFromVideoImager( );
97 
99  virtual void RequestGetFrame();
100 
102  const std::string GetVideoImagerToolIdentifier( ) const;
103 
106  virtual void RequestAttachToVideoImager( VideoImagerType * );
107 
109  FrameType* GetInternalFrame( void );
110 
112  void SetInternalFrame( FrameType* );
113 
114  void SetFrameDimensions( unsigned int * );
115  void GetFrameDimensions( unsigned int * );
116 
117  igstkSetMacro( PixelDepth, unsigned int );
118  igstkGetMacro( PixelDepth, unsigned int );
119 
120  igstkSetMacro( Delay, unsigned int );
121  igstkGetMacro( Delay, unsigned int );
122 
123  igstk::Frame* GetFrameFromBuffer(const unsigned int index);
125 
126 protected:
127 
128  VideoImagerTool(void);
129  virtual ~VideoImagerTool(void);
130 
132  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
133 
135  void SetVideoImagerToolIdentifier( const std::string identifier );
136 
137 private:
138 
139  VideoImagerTool(const Self&); //purposely not implemented
140  void operator=(const Self&); //purposely not implemented
141 
143  virtual void RequestReportImagingStarted( );
144 
146  virtual void RequestReportImagingStopped( );
147 
149  virtual void RequestReportImagingToolNotAvailable( );
150 
152  virtual void RequestReportImagingToolStreaming( );
153 
155  void RequestReportSuccessfulVideoImagerToolAttachment();
156 
158  void RequestReportFailedVideoImagerToolAttachment();
159 
161  igstkSetMacro( Updated, bool );
162 
165  virtual bool CheckIfVideoImagerToolIsConfigured( ) const = 0;
166 
168  igstkDeclareInputMacro( ConfigureTool );
169  igstkDeclareInputMacro( ToolConfigurationSuccess );
170  igstkDeclareInputMacro( ToolConfigurationFailure );
171  igstkDeclareInputMacro( AttachToolToVideoImager );
172  igstkDeclareInputMacro( ImagingStarted );
173  igstkDeclareInputMacro( ImagingStopped );
174  igstkDeclareInputMacro( VideoImagerToolNotAvailable );
175  igstkDeclareInputMacro( VideoImagerToolStreaming );
176  igstkDeclareInputMacro( DetachVideoImagerToolFromVideoImager );
177  igstkDeclareInputMacro( AttachmentToVideoImagerSuccess );
178  igstkDeclareInputMacro( AttachmentToVideoImagerFailure );
179  igstkDeclareInputMacro( DetachmentFromVideoImagerSuccess );
180  igstkDeclareInputMacro( DetachmentFromVideoImagerFailure );
181  igstkDeclareInputMacro( GetFrame );
182 
184  igstkDeclareStateMacro( Idle );
185  igstkDeclareStateMacro( AttemptingToConfigureVideoImagerTool );
186  igstkDeclareStateMacro( Configured );
187  igstkDeclareStateMacro( AttemptingToAttachVideoImagerToolToVideoImager );
188  igstkDeclareStateMacro( Attached );
189  igstkDeclareStateMacro( AttemptingToDetachVideoImagerToolFromVideoImager );
190  igstkDeclareStateMacro( NotAvailable );
191  igstkDeclareStateMacro( Streaming );
192 
194  void AttemptToConfigureProcessing( void );
195 
197  void AttemptToAttachVideoImagerToolToVideoImagerProcessing( void );
198 
200  void VideoImagerToolConfigurationSuccessProcessing( void );
201 
203  void VideoImagerToolConfigurationFailureProcessing( void );
204 
207  void VideoImagerToolAttachmentToVideoImagerSuccessProcessing( void );
208 
210  void VideoImagerToolAttachmentToVideoImagerFailureProcessing( void );
211 
213  void AttemptToDetachVideoImagerToolFromVideoImagerProcessing( void );
214 
217  void VideoImagerToolDetachmentFromVideoImagerSuccessProcessing( void );
218 
220  void VideoImagerToolDetachmentFromVideoImagerFailureProcessing( void );
221 
223  void GetFrameProcessing( void );
224 
226  void ReportVideoImagerToolStreamingStateProcessing( void );
227 
229  void ReportVideoImagerToolNotAvailableProcessing( void );
230 
232  void ReportImagingStartedProcessing( void );
233 
235  void ReportImagingStoppedProcessing( void );
236 
238  void ReportInvalidRequestProcessing( void );
239 
241  void ReportInvalidRequestToAttachVideoImagerToolProcessing( void );
242 
244  void ReportInvalidRequestToDetachVideoImagerToolProcessing( void );
245 
247  void NoProcessing( void );
248 
250  void AddFrameToBuffer( igstk::Frame* frame);
251 
253  std::vector< igstk::Frame* > *m_FrameRingBuffer;
254 
256  int m_Index;
257  unsigned int m_NumberOfFramesInBuffer;
258  unsigned int m_MaxBufferSize;
259  unsigned int m_Delay;
260  unsigned int m_FrameDimensions[3];
261  unsigned int m_PixelDepth;
262 
264  bool m_Updated;
265 
267  std::string m_VideoImagerToolIdentifier;
268 
270  VideoImager * m_VideoImagerToAttachTo;
271 
273  igstkCoordinateSystemClassInterfaceMacro();
274 
277  CoordinateSystem::Pointer m_CalibrationCoordinateSystem;
278 };
279 
280 std::ostream& operator<<(std::ostream& os, const VideoImagerTool& o);
281 
282 }
283 
284 #endif //__igstk_VideoImagerTool_h_