00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __igstkEvents_h
00018 #define __igstkEvents_h
00019
00023 #include "igstkTransform.h"
00024 #include "vtkImageData.h"
00025
00026 namespace igstk
00027 {
00028 #define igstkEventMacro( classname, superclassname ) \
00029 itkEventMacro( classname, superclassname )
00030
00031 #define igstkLoadedEventMacro( name, superclass, payloadtype ) \
00032 class name : public superclass \
00033 { \
00034 public: \
00035 typedef name Self; \
00036 typedef superclass Superclass; \
00037 typedef payloadtype PayloadType; \
00038 name() {} \
00039 virtual ~name() {} \
00040 virtual const char * GetEventName() const { return #name; } \
00041 virtual bool CheckEvent(const ::itk::EventObject* e) const \
00042 { return dynamic_cast<const Self*>(e); } \
00043 virtual ::itk::EventObject* MakeObject() const \
00044 { return new Self; } \
00045 name(const Self&s) :superclass(s){}; \
00046 const PayloadType & Get() const \
00047 { return m_Payload; } \
00048 void Set( const payloadtype & _var ) \
00049 { m_Payload = _var; } \
00050 private: \
00051 void operator=(const Self&); \
00052 PayloadType m_Payload; \
00053 };
00054
00055 namespace EventHelperType
00056 {
00057 typedef itk::Point< double, 3 > PointType;
00058 typedef std::string StringType;
00059 typedef vtkImageData * VTKImagePointerType;
00060 typedef unsigned int UnsignedIntType;
00061 typedef signed int SignedIntType;
00062 typedef float FloatType;
00063 typedef double DoubleType;
00064 typedef struct {
00065 unsigned int minimum;
00066 unsigned int maximum;
00067 } IntegerBoundsType;
00068 }
00069
00070 #define igstkLoadedObjectEventMacro( name, superclass, payloadtype ) \
00071 class name : public superclass \
00072 { \
00073 public: \
00074 typedef name Self; \
00075 typedef superclass Superclass; \
00076 typedef payloadtype PayloadType; \
00077 name() {} \
00078 virtual ~name() {} \
00079 virtual const char * GetEventName() const { return #name; } \
00080 virtual bool CheckEvent(const ::itk::EventObject* e) const \
00081 { return dynamic_cast<const Self*>(e); } \
00082 virtual ::itk::EventObject* MakeObject() const \
00083 { return new Self; } \
00084 name(const Self&s) :superclass(s){}; \
00085 PayloadType* Get() const\
00086 { return m_Payload.GetPointer(); } \
00087 void Set( payloadtype * _var ) \
00088 { m_Payload = _var; } \
00089 private: \
00090 void operator=(const Self&); \
00091 PayloadType::Pointer m_Payload; \
00092 };
00093
00094
00095 #define igstkLoadedConstObjectEventMacro( name, superclass, payloadtype ) \
00096 class name : public superclass \
00097 { \
00098 public: \
00099 typedef name Self; \
00100 typedef superclass Superclass; \
00101 typedef payloadtype PayloadType; \
00102 name() {} \
00103 virtual ~name() {} \
00104 virtual const char * GetEventName() const { return #name; } \
00105 virtual bool CheckEvent(const ::itk::EventObject* e) const \
00106 { return dynamic_cast<const Self*>(e); } \
00107 virtual ::itk::EventObject* MakeObject() const \
00108 { return new Self; } \
00109 name(const Self&s) :superclass(s){}; \
00110 const PayloadType* Get() const\
00111 { return m_Payload.GetPointer(); } \
00112 void Set( const payloadtype * _var ) \
00113 { m_Payload = _var; } \
00114 private: \
00115 void operator=(const Self&); \
00116 PayloadType::ConstPointer m_Payload; \
00117 };
00118
00119
00120 #define igstkLoadedTemplatedObjectEventMacro( name, superclass, payloadtype ) \
00121 class name : public superclass \
00122 { \
00123 public: \
00124 typedef name Self; \
00125 typedef superclass Superclass; \
00126 typedef payloadtype PayloadType; \
00127 name() {} \
00128 virtual ~name() {} \
00129 virtual const char * GetEventName() const { return #name; } \
00130 virtual bool CheckEvent(const ::itk::EventObject* e) const \
00131 { return dynamic_cast<const Self*>(e); } \
00132 virtual ::itk::EventObject* MakeObject() const \
00133 { return new Self; } \
00134 name(const Self&s) :superclass(s){}; \
00135 PayloadType * Get() const\
00136 { return m_Payload.GetPointer(); } \
00137 void Set( payloadtype * _var ) \
00138 { m_Payload = _var; } \
00139 private: \
00140 void operator=(const Self&); \
00141 typename PayloadType::Pointer m_Payload; \
00142 };
00143
00144 #define igstkLoadedTemplatedConstObjectEventMacro( name, superclass,\
00145 payloadtype ) \
00146 class name : public superclass \
00147 { \
00148 public: \
00149 typedef name Self; \
00150 typedef superclass Superclass; \
00151 typedef payloadtype PayloadType; \
00152 name() {} \
00153 virtual ~name() {} \
00154 virtual const char * GetEventName() const { return #name; } \
00155 virtual bool CheckEvent(const ::itk::EventObject* e) const \
00156 { return dynamic_cast<const Self*>(e); } \
00157 virtual ::itk::EventObject* MakeObject() const \
00158 { return new Self; } \
00159 name(const Self&s) :superclass(s){}; \
00160 const PayloadType * Get() const\
00161 { return m_Payload.GetPointer(); } \
00162 void Set( const payloadtype * _var ) \
00163 { m_Payload = _var; } \
00164 private: \
00165 void operator=(const Self&); \
00166 typename PayloadType::ConstPointer m_Payload; \
00167 };
00168
00169 igstkEventMacro( IGSTKEvent, itk::UserEvent );
00170 igstkEventMacro( IGSTKErrorEvent, IGSTKEvent );
00171 igstkEventMacro( PulseEvent, IGSTKEvent );
00172 igstkEventMacro( RefreshEvent, IGSTKEvent );
00173 igstkEventMacro( CompletedEvent, IGSTKEvent );
00174 igstkEventMacro( InputOutputErrorEvent, IGSTKErrorEvent );
00175 igstkEventMacro( InputOutputTimeoutEvent, IGSTKErrorEvent );
00176 igstkEventMacro( OpenPortErrorEvent, IGSTKErrorEvent );
00177 igstkEventMacro( ClosePortErrorEvent, IGSTKErrorEvent );
00178 igstkEventMacro( InvalidRequestErrorEvent, IGSTKErrorEvent );
00179 igstkEventMacro( TransformNotAvailableEvent, InvalidRequestErrorEvent );
00180 igstkEventMacro( TransformExpiredErrorEvent, TransformNotAvailableEvent );
00181
00182 igstkLoadedEventMacro( PointEvent, IGSTKEvent, EventHelperType::PointType );
00183 igstkLoadedEventMacro( LandmarkRegistrationErrorEvent, IGSTKErrorEvent,
00184 EventHelperType::DoubleType );
00185 igstkLoadedEventMacro( StringEvent, IGSTKEvent, EventHelperType::StringType );
00186 igstkLoadedEventMacro( UnsignedIntEvent, IGSTKEvent,
00187 EventHelperType::UnsignedIntType );
00188 igstkLoadedEventMacro( IntegerBoundsEvent, IGSTKEvent,
00189 EventHelperType::IntegerBoundsType );
00190 igstkLoadedEventMacro( VTKImageModifiedEvent, IGSTKEvent,
00191 EventHelperType::VTKImagePointerType );
00192 igstkLoadedEventMacro( DoubleTypeEvent, IGSTKEvent,
00193 EventHelperType::DoubleType );
00194
00195 igstkLoadedEventMacro( IGSTKErrorWithStringEvent, IGSTKErrorEvent,
00196 EventHelperType::StringType );
00197
00198 igstkEventMacro( AxialSliceBoundsEvent, IntegerBoundsEvent );
00199 igstkEventMacro( SagittalSliceBoundsEvent, IntegerBoundsEvent );
00200 igstkEventMacro( CoronalSliceBoundsEvent, IntegerBoundsEvent );
00201 }
00202 #endif