IGSTK
/build/buildd/igstk-4.4.0/Source/igstkVideoImagerTool.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Image Guided Surgery Software Toolkit
00004   Module:    $RCSfile: igstkVideoImagerTool.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-06-18 18:40:55 $
00007   Version:   $Revision: 1.1 $
00008 
00009   Copyright (c) ISC  Insight Software Consortium.  All rights reserved.
00010   See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __igstkVideoImagerTool_h
00019 #define __igstkVideoImagerTool_h
00020 
00021 #include "igstkObject.h"
00022 #include "igstkTransform.h"
00023 #include "igstkFrame.h"
00024 #include "igstkMacros.h"
00025 #include "igstkStateMachine.h"
00026 #include "igstkCoordinateSystemInterfaceMacros.h"
00027 
00028 class vtkImagedata;
00029 
00030 namespace igstk
00031 {
00032 
00033 igstkEventMacro( VideoImagerToolEvent, StringEvent);
00034 igstkEventMacro( VideoImagerToolErrorEvent, IGSTKErrorWithStringEvent);
00035 igstkEventMacro( VideoImagerToolConfigurationEvent,VideoImagerToolEvent);
00036 igstkEventMacro( VideoImagerToolConfigurationErrorEvent,
00037                                                      VideoImagerToolErrorEvent);
00038 igstkEventMacro( InvalidRequestToAttachVideoImagerToolErrorEvent,
00039                                                      VideoImagerToolErrorEvent);
00040 igstkEventMacro( InvalidRequestToDetachVideoImagerToolErrorEvent,
00041                                                      VideoImagerToolErrorEvent);
00042 igstkEventMacro( VideoImagerToolAttachmentToVideoImagerEvent,
00043                                                           VideoImagerToolEvent);
00044 igstkEventMacro( VideoImagerToolAttachmentToVideoImagerErrorEvent,
00045                                                      VideoImagerToolErrorEvent);
00046 igstkEventMacro( VideoImagerToolDetachmentFromVideoImagerEvent,
00047                                                           VideoImagerToolEvent);
00048 igstkEventMacro( VideoImagerToolDetachmentFromVideoImagerErrorEvent,
00049                                                      VideoImagerToolErrorEvent);
00050 igstkEventMacro( VideoImagerToolMadeTransitionToStreamingStateEvent,
00051                                                           VideoImagerToolEvent);
00052 igstkEventMacro( VideoImagerToolNotAvailableEvent,VideoImagerToolEvent);
00053 igstkEventMacro( ToolImagingStartedEvent,VideoImagerToolEvent);
00054 igstkEventMacro( ToolImagingStoppedEvent,VideoImagerToolEvent);
00055 igstkLoadedEventMacro( FrameModifiedEvent, IGSTKEvent, igstk::Frame);
00056 
00057 class VideoImager;
00058 
00073 class VideoImagerTool : public Object
00074 {
00075 public:
00076 
00078   igstkStandardAbstractClassTraitsMacro( VideoImagerTool, Object )
00079 
00080 public:
00081 
00082   igstkFriendClassMacro( VideoImager );
00083 
00084   typedef VideoImager       VideoImagerType;
00085   typedef Transform         TransformType;
00086   typedef Frame             FrameType;
00087 
00089   igstkGetMacro( Updated, bool );
00090 
00092   virtual void RequestConfigure( void );
00093 
00096   virtual void RequestDetachFromVideoImager( );
00097 
00099   virtual void RequestGetFrame();
00100 
00102   const std::string GetVideoImagerToolIdentifier( ) const;
00103 
00106   virtual void RequestAttachToVideoImager( VideoImagerType * );
00107 
00109   FrameType* GetInternalFrame( void );
00110 
00112   void SetInternalFrame( FrameType* );
00113 
00114   void SetFrameDimensions( unsigned int * );
00115   void GetFrameDimensions( unsigned int * );
00116 
00117   igstkSetMacro( PixelDepth, unsigned int );
00118   igstkGetMacro( PixelDepth, unsigned int );
00119 
00120   igstkSetMacro( Delay, unsigned int );
00121   igstkGetMacro( Delay, unsigned int );
00122 
00123   igstk::Frame* GetFrameFromBuffer(const unsigned int index);
00124   igstk::Frame* GetTemporalCalibratedFrame();
00125 
00126 protected:
00127 
00128   VideoImagerTool(void);
00129   virtual ~VideoImagerTool(void);
00130 
00132   virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
00133 
00135   void SetVideoImagerToolIdentifier( const std::string identifier );
00136 
00137 private:
00138 
00139   VideoImagerTool(const Self&);       //purposely not implemented
00140   void operator=(const Self&);    //purposely not implemented
00141 
00143   virtual void RequestReportImagingStarted( );
00144 
00146   virtual void RequestReportImagingStopped( );
00147 
00149   virtual void RequestReportImagingToolNotAvailable( );
00150 
00152   virtual void RequestReportImagingToolStreaming( );
00153 
00155   void RequestReportSuccessfulVideoImagerToolAttachment();
00156 
00158   void RequestReportFailedVideoImagerToolAttachment();
00159 
00161   igstkSetMacro( Updated, bool );
00162 
00165   virtual bool CheckIfVideoImagerToolIsConfigured( ) const = 0;
00166 
00168   igstkDeclareInputMacro( ConfigureTool );
00169   igstkDeclareInputMacro( ToolConfigurationSuccess );
00170   igstkDeclareInputMacro( ToolConfigurationFailure );
00171   igstkDeclareInputMacro( AttachToolToVideoImager );
00172   igstkDeclareInputMacro( ImagingStarted );
00173   igstkDeclareInputMacro( ImagingStopped );
00174   igstkDeclareInputMacro( VideoImagerToolNotAvailable );
00175   igstkDeclareInputMacro( VideoImagerToolStreaming );
00176   igstkDeclareInputMacro( DetachVideoImagerToolFromVideoImager );
00177   igstkDeclareInputMacro( AttachmentToVideoImagerSuccess );
00178   igstkDeclareInputMacro( AttachmentToVideoImagerFailure );
00179   igstkDeclareInputMacro( DetachmentFromVideoImagerSuccess );
00180   igstkDeclareInputMacro( DetachmentFromVideoImagerFailure );
00181   igstkDeclareInputMacro( GetFrame );
00182 
00184   igstkDeclareStateMacro( Idle );
00185   igstkDeclareStateMacro( AttemptingToConfigureVideoImagerTool );
00186   igstkDeclareStateMacro( Configured );
00187   igstkDeclareStateMacro( AttemptingToAttachVideoImagerToolToVideoImager );
00188   igstkDeclareStateMacro( Attached );
00189   igstkDeclareStateMacro( AttemptingToDetachVideoImagerToolFromVideoImager );
00190   igstkDeclareStateMacro( NotAvailable );
00191   igstkDeclareStateMacro( Streaming );
00192 
00194   void AttemptToConfigureProcessing( void );
00195 
00197   void AttemptToAttachVideoImagerToolToVideoImagerProcessing( void );
00198 
00200   void VideoImagerToolConfigurationSuccessProcessing( void );
00201 
00203   void VideoImagerToolConfigurationFailureProcessing( void );
00204 
00207   void VideoImagerToolAttachmentToVideoImagerSuccessProcessing( void );
00208 
00210   void VideoImagerToolAttachmentToVideoImagerFailureProcessing( void );
00211 
00213   void AttemptToDetachVideoImagerToolFromVideoImagerProcessing( void );
00214 
00217   void VideoImagerToolDetachmentFromVideoImagerSuccessProcessing( void );
00218 
00220   void VideoImagerToolDetachmentFromVideoImagerFailureProcessing( void );
00221 
00223   void GetFrameProcessing( void );
00224 
00226   void ReportVideoImagerToolStreamingStateProcessing( void );
00227 
00229   void ReportVideoImagerToolNotAvailableProcessing( void );
00230 
00232   void ReportImagingStartedProcessing( void );
00233 
00235   void ReportImagingStoppedProcessing( void );
00236 
00238   void ReportInvalidRequestProcessing( void );
00239 
00241   void ReportInvalidRequestToAttachVideoImagerToolProcessing( void );
00242 
00244   void ReportInvalidRequestToDetachVideoImagerToolProcessing( void );
00245 
00247   void NoProcessing( void );
00248 
00250   void AddFrameToBuffer( igstk::Frame* frame);
00251 
00253   std::vector< igstk::Frame* > *m_FrameRingBuffer;
00254 
00256   int                           m_Index;
00257   unsigned int                  m_NumberOfFramesInBuffer;
00258   unsigned int                  m_MaxBufferSize;
00259   unsigned int                  m_Delay;
00260   unsigned int                  m_FrameDimensions[3];
00261   unsigned int                  m_PixelDepth;
00262 
00264   bool                          m_Updated;
00265 
00267   std::string        m_VideoImagerToolIdentifier;
00268 
00270   VideoImager        * m_VideoImagerToAttachTo;
00271 
00273   igstkCoordinateSystemClassInterfaceMacro();
00274 
00277   CoordinateSystem::Pointer   m_CalibrationCoordinateSystem;
00278 };
00279 
00280 std::ostream& operator<<(std::ostream& os, const VideoImagerTool& o);
00281 
00282 }
00283 
00284 #endif //__igstk_VideoImagerTool_h_