IGSTK
|
00001 /*========================================================================= 00002 00003 Program: Image Guided Surgery Software Toolkit 00004 Module: $RCSfile: igstkEvents.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-01-30 18:24:31 $ 00007 Version: $Revision: 1.24 $ 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 #ifndef __igstkEvents_h 00018 #define __igstkEvents_h 00019 00023 #include "igstkTransform.h" 00024 #include "vtkImageData.h" 00025 //#include "vtkPlaneSource.h" 00026 #include "vtkCamera.h" 00027 00028 namespace igstk 00029 { 00030 #define igstkEventMacro( classname, superclassname ) \ 00031 itkEventMacro( classname, superclassname ) 00032 00033 #define igstkLoadedEventMacro( name, superclass, payloadtype ) \ 00034 class name : public superclass \ 00035 { \ 00036 public: \ 00037 typedef name Self; \ 00038 typedef superclass Superclass; \ 00039 typedef payloadtype PayloadType; \ 00040 name() {} \ 00041 virtual ~name() {} \ 00042 virtual const char * GetEventName() const { return #name; } \ 00043 virtual bool CheckEvent(const ::itk::EventObject* e) const \ 00044 { return dynamic_cast<const Self*>(e); } \ 00045 virtual ::itk::EventObject* MakeObject() const \ 00046 { return new Self; } \ 00047 name(const Self&s) :superclass(s){}; \ 00048 const PayloadType & Get() const \ 00049 { return m_Payload; } \ 00050 void Set( const payloadtype & _var ) \ 00051 { m_Payload = _var; } \ 00052 private: \ 00053 void operator=(const Self&); \ 00054 PayloadType m_Payload; \ 00055 }; 00056 00057 namespace EventHelperType 00058 { 00059 typedef itk::Point< double, 3 > PointType; 00060 typedef std::string StringType; 00061 typedef vtkImageData * VTKImagePointerType; 00062 //typedef vtkPlaneSource * VTKPlaneSourcePointerType; 00063 typedef vtkCamera * VTKCameraPointerType; 00064 typedef unsigned int UnsignedIntType; 00065 typedef signed int SignedIntType; 00066 typedef float FloatType; 00067 typedef double DoubleType; 00068 typedef struct { 00069 unsigned int minimum; 00070 unsigned int maximum; 00071 } IntegerBoundsType; 00072 typedef struct { 00073 double xmin; 00074 double xmax; 00075 double ymin; 00076 double ymax; 00077 double zmin; 00078 double zmax; 00079 } ImageBoundsType; 00080 typedef struct { 00081 unsigned int xmin; 00082 unsigned int xmax; 00083 unsigned int ymin; 00084 unsigned int ymax; 00085 unsigned int zmin; 00086 unsigned int zmax; 00087 } ImageExtentType; 00088 } 00089 00090 #define igstkLoadedObjectEventMacro( name, superclass, payloadtype ) \ 00091 class name : public superclass \ 00092 { \ 00093 public: \ 00094 typedef name Self; \ 00095 typedef superclass Superclass; \ 00096 typedef payloadtype PayloadType; \ 00097 name() {} \ 00098 virtual ~name() {} \ 00099 virtual const char * GetEventName() const { return #name; } \ 00100 virtual bool CheckEvent(const ::itk::EventObject* e) const \ 00101 { return dynamic_cast<const Self*>(e); } \ 00102 virtual ::itk::EventObject* MakeObject() const \ 00103 { return new Self; } \ 00104 name(const Self&s) :superclass(s){}; \ 00105 PayloadType* Get() const\ 00106 { return m_Payload.GetPointer(); } \ 00107 void Set( payloadtype * _var ) \ 00108 { m_Payload = _var; } \ 00109 private: \ 00110 void operator=(const Self&); \ 00111 PayloadType::Pointer m_Payload; \ 00112 }; 00113 00114 00115 #define igstkLoadedConstObjectEventMacro( name, superclass, payloadtype ) \ 00116 class name : public superclass \ 00117 { \ 00118 public: \ 00119 typedef name Self; \ 00120 typedef superclass Superclass; \ 00121 typedef payloadtype PayloadType; \ 00122 name() {} \ 00123 virtual ~name() {} \ 00124 virtual const char * GetEventName() const { return #name; } \ 00125 virtual bool CheckEvent(const ::itk::EventObject* e) const \ 00126 { return dynamic_cast<const Self*>(e); } \ 00127 virtual ::itk::EventObject* MakeObject() const \ 00128 { return new Self; } \ 00129 name(const Self&s) :superclass(s){}; \ 00130 const PayloadType* Get() const\ 00131 { return m_Payload.GetPointer(); } \ 00132 void Set( const payloadtype * _var ) \ 00133 { m_Payload = _var; } \ 00134 private: \ 00135 void operator=(const Self&); \ 00136 PayloadType::ConstPointer m_Payload; \ 00137 }; 00138 00139 00140 #define igstkLoadedTemplatedObjectEventMacro( name, superclass, payloadtype ) \ 00141 class name : public superclass \ 00142 { \ 00143 public: \ 00144 typedef name Self; \ 00145 typedef superclass Superclass; \ 00146 typedef payloadtype PayloadType; \ 00147 name() {} \ 00148 virtual ~name() {} \ 00149 virtual const char * GetEventName() const { return #name; } \ 00150 virtual bool CheckEvent(const ::itk::EventObject* e) const \ 00151 { return dynamic_cast<const Self*>(e); } \ 00152 virtual ::itk::EventObject* MakeObject() const \ 00153 { return new Self; } \ 00154 name(const Self&s) :superclass(s){}; \ 00155 PayloadType * Get() const\ 00156 { return m_Payload.GetPointer(); } \ 00157 void Set( payloadtype * _var ) \ 00158 { m_Payload = _var; } \ 00159 private: \ 00160 void operator=(const Self&); \ 00161 typename PayloadType::Pointer m_Payload; \ 00162 }; 00163 00164 #define igstkLoadedTemplatedConstObjectEventMacro( name, superclass,\ 00165 payloadtype ) \ 00166 class name : public superclass \ 00167 { \ 00168 public: \ 00169 typedef name Self; \ 00170 typedef superclass Superclass; \ 00171 typedef payloadtype PayloadType; \ 00172 name() {} \ 00173 virtual ~name() {} \ 00174 virtual const char * GetEventName() const { return #name; } \ 00175 virtual bool CheckEvent(const ::itk::EventObject* e) const \ 00176 { return dynamic_cast<const Self*>(e); } \ 00177 virtual ::itk::EventObject* MakeObject() const \ 00178 { return new Self; } \ 00179 name(const Self&s) :superclass(s){}; \ 00180 const PayloadType * Get() const\ 00181 { return m_Payload.GetPointer(); } \ 00182 void Set( const payloadtype * _var ) \ 00183 { m_Payload = _var; } \ 00184 private: \ 00185 void operator=(const Self&); \ 00186 typename PayloadType::ConstPointer m_Payload; \ 00187 }; 00188 00189 igstkEventMacro( IGSTKEvent, itk::UserEvent ); 00190 igstkEventMacro( IGSTKErrorEvent, IGSTKEvent ); 00191 igstkEventMacro( PulseEvent, IGSTKEvent ); 00192 igstkEventMacro( RefreshEvent, IGSTKEvent ); 00193 igstkEventMacro( CompletedEvent, IGSTKEvent ); 00194 igstkEventMacro( InputOutputErrorEvent, IGSTKErrorEvent ); 00195 igstkEventMacro( InputOutputTimeoutEvent, IGSTKErrorEvent ); 00196 igstkEventMacro( OpenPortErrorEvent, IGSTKErrorEvent ); 00197 igstkEventMacro( ClosePortErrorEvent, IGSTKErrorEvent ); 00198 igstkEventMacro( InvalidRequestErrorEvent, IGSTKErrorEvent ); 00199 igstkEventMacro( TransformNotAvailableEvent, InvalidRequestErrorEvent ); 00200 igstkEventMacro( TransformExpiredErrorEvent, TransformNotAvailableEvent ); 00201 00202 igstkLoadedEventMacro( PointEvent, IGSTKEvent, EventHelperType::PointType ); 00203 igstkLoadedEventMacro( LandmarkRegistrationErrorEvent, IGSTKErrorEvent, 00204 EventHelperType::DoubleType ); 00205 igstkLoadedEventMacro( StringEvent, IGSTKEvent, EventHelperType::StringType ); 00206 igstkLoadedEventMacro( UnsignedIntEvent, IGSTKEvent, 00207 EventHelperType::UnsignedIntType ); 00208 00209 igstkLoadedEventMacro( IntegerBoundsEvent, IGSTKEvent, 00210 EventHelperType::IntegerBoundsType ); 00211 00212 igstkLoadedEventMacro( ImageBoundsEvent, IGSTKEvent, 00213 EventHelperType::ImageBoundsType ); 00214 00215 igstkLoadedEventMacro( ImageExtentEvent, IGSTKEvent, 00216 EventHelperType::ImageExtentType ); 00217 00218 igstkLoadedEventMacro( VTKImageModifiedEvent, IGSTKEvent, 00219 EventHelperType::VTKImagePointerType ); 00220 00221 //igstkLoadedEventMacro( VTKPlaneModifiedEvent, IGSTKEvent, 00222 // EventHelperType::VTKPlaneSourcePointerType ); 00223 00224 igstkLoadedEventMacro( VTKCameraModifiedEvent, IGSTKEvent, 00225 EventHelperType::VTKCameraPointerType ); 00226 00227 igstkLoadedEventMacro( DoubleTypeEvent, IGSTKEvent, 00228 EventHelperType::DoubleType ); 00229 00230 igstkLoadedEventMacro( IGSTKErrorWithStringEvent, IGSTKErrorEvent, 00231 EventHelperType::StringType ); 00232 00233 igstkEventMacro( AxialSliceBoundsEvent, IntegerBoundsEvent ); 00234 igstkEventMacro( SagittalSliceBoundsEvent, IntegerBoundsEvent ); 00235 igstkEventMacro( CoronalSliceBoundsEvent, IntegerBoundsEvent ); 00236 } 00237 #endif