IGSTK
igstkEvents.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkEvents.h,v $
5  Language: C++
6  Date: $Date: 2009-01-30 18:24:31 $
7  Version: $Revision: 1.24 $
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 #ifndef __igstkEvents_h
18 #define __igstkEvents_h
19 
23 #include "igstkTransform.h"
24 #include "vtkImageData.h"
25 //#include "vtkPlaneSource.h"
26 #include "vtkCamera.h"
27 
28 namespace igstk
29 {
30 #define igstkEventMacro( classname, superclassname ) \
31  itkEventMacro( classname, superclassname )
32 
33 #define igstkLoadedEventMacro( name, superclass, payloadtype ) \
34 class name : public superclass \
35 { \
36 public: \
37  typedef name Self; \
38  typedef superclass Superclass; \
39  typedef payloadtype PayloadType; \
40  name() {} \
41  virtual ~name() {} \
42  virtual const char * GetEventName() const { return #name; } \
43  virtual bool CheckEvent(const ::itk::EventObject* e) const \
44  { return dynamic_cast<const Self*>(e); } \
45  virtual ::itk::EventObject* MakeObject() const \
46  { return new Self; } \
47  name(const Self&s) :superclass(s){}; \
48  const PayloadType & Get() const \
49  { return m_Payload; } \
50  void Set( const payloadtype & _var ) \
51  { m_Payload = _var; } \
52 private: \
53  void operator=(const Self&); \
54  PayloadType m_Payload; \
55 };
56 
57 namespace EventHelperType
58 {
59 typedef itk::Point< double, 3 > PointType;
60 typedef std::string StringType;
61 typedef vtkImageData * VTKImagePointerType;
62 //typedef vtkPlaneSource * VTKPlaneSourcePointerType;
63 typedef vtkCamera * VTKCameraPointerType;
64 typedef unsigned int UnsignedIntType;
65 typedef signed int SignedIntType;
66 typedef float FloatType;
67 typedef double DoubleType;
68 typedef struct {
69  unsigned int minimum;
70  unsigned int maximum;
72 typedef struct {
73  double xmin;
74  double xmax;
75  double ymin;
76  double ymax;
77  double zmin;
78  double zmax;
80 typedef struct {
81  unsigned int xmin;
82  unsigned int xmax;
83  unsigned int ymin;
84  unsigned int ymax;
85  unsigned int zmin;
86  unsigned int zmax;
88 }
89 
90 #define igstkLoadedObjectEventMacro( name, superclass, payloadtype ) \
91 class name : public superclass \
92 { \
93 public: \
94  typedef name Self; \
95  typedef superclass Superclass; \
96  typedef payloadtype PayloadType; \
97  name() {} \
98  virtual ~name() {} \
99  virtual const char * GetEventName() const { return #name; } \
100  virtual bool CheckEvent(const ::itk::EventObject* e) const \
101  { return dynamic_cast<const Self*>(e); } \
102  virtual ::itk::EventObject* MakeObject() const \
103  { return new Self; } \
104  name(const Self&s) :superclass(s){}; \
105  PayloadType* Get() const\
106  { return m_Payload.GetPointer(); } \
107  void Set( payloadtype * _var ) \
108  { m_Payload = _var; } \
109 private: \
110  void operator=(const Self&); \
111  PayloadType::Pointer m_Payload; \
112 };
113 
114 
115 #define igstkLoadedConstObjectEventMacro( name, superclass, payloadtype ) \
116 class name : public superclass \
117 { \
118 public: \
119  typedef name Self; \
120  typedef superclass Superclass; \
121  typedef payloadtype PayloadType; \
122  name() {} \
123  virtual ~name() {} \
124  virtual const char * GetEventName() const { return #name; } \
125  virtual bool CheckEvent(const ::itk::EventObject* e) const \
126  { return dynamic_cast<const Self*>(e); } \
127  virtual ::itk::EventObject* MakeObject() const \
128  { return new Self; } \
129  name(const Self&s) :superclass(s){}; \
130  const PayloadType* Get() const\
131  { return m_Payload.GetPointer(); } \
132  void Set( const payloadtype * _var ) \
133  { m_Payload = _var; } \
134 private: \
135  void operator=(const Self&); \
136  PayloadType::ConstPointer m_Payload; \
137 };
138 
139 
140 #define igstkLoadedTemplatedObjectEventMacro( name, superclass, payloadtype ) \
141 class name : public superclass \
142 { \
143 public: \
144  typedef name Self; \
145  typedef superclass Superclass; \
146  typedef payloadtype PayloadType; \
147  name() {} \
148  virtual ~name() {} \
149  virtual const char * GetEventName() const { return #name; } \
150  virtual bool CheckEvent(const ::itk::EventObject* e) const \
151  { return dynamic_cast<const Self*>(e); } \
152  virtual ::itk::EventObject* MakeObject() const \
153  { return new Self; } \
154  name(const Self&s) :superclass(s){}; \
155  PayloadType * Get() const\
156  { return m_Payload.GetPointer(); } \
157  void Set( payloadtype * _var ) \
158  { m_Payload = _var; } \
159 private: \
160  void operator=(const Self&); \
161  typename PayloadType::Pointer m_Payload; \
162 };
163 
164 #define igstkLoadedTemplatedConstObjectEventMacro( name, superclass,\
165  payloadtype ) \
166 class name : public superclass \
167 { \
168 public: \
169  typedef name Self; \
170  typedef superclass Superclass; \
171  typedef payloadtype PayloadType; \
172  name() {} \
173  virtual ~name() {} \
174  virtual const char * GetEventName() const { return #name; } \
175  virtual bool CheckEvent(const ::itk::EventObject* e) const \
176  { return dynamic_cast<const Self*>(e); } \
177  virtual ::itk::EventObject* MakeObject() const \
178  { return new Self; } \
179  name(const Self&s) :superclass(s){}; \
180  const PayloadType * Get() const\
181  { return m_Payload.GetPointer(); } \
182  void Set( const payloadtype * _var ) \
183  { m_Payload = _var; } \
184 private: \
185  void operator=(const Self&); \
186  typename PayloadType::ConstPointer m_Payload; \
187 };
188 
189 igstkEventMacro( IGSTKEvent, itk::UserEvent );
190 igstkEventMacro( IGSTKErrorEvent, IGSTKEvent );
191 igstkEventMacro( PulseEvent, IGSTKEvent );
192 igstkEventMacro( RefreshEvent, IGSTKEvent );
193 igstkEventMacro( CompletedEvent, IGSTKEvent );
194 igstkEventMacro( InputOutputErrorEvent, IGSTKErrorEvent );
195 igstkEventMacro( InputOutputTimeoutEvent, IGSTKErrorEvent );
196 igstkEventMacro( OpenPortErrorEvent, IGSTKErrorEvent );
197 igstkEventMacro( ClosePortErrorEvent, IGSTKErrorEvent );
198 igstkEventMacro( InvalidRequestErrorEvent, IGSTKErrorEvent );
199 igstkEventMacro( TransformNotAvailableEvent, InvalidRequestErrorEvent );
200 igstkEventMacro( TransformExpiredErrorEvent, TransformNotAvailableEvent );
201 
202 igstkLoadedEventMacro( PointEvent, IGSTKEvent, EventHelperType::PointType );
203 igstkLoadedEventMacro( LandmarkRegistrationErrorEvent, IGSTKErrorEvent,
205 igstkLoadedEventMacro( StringEvent, IGSTKEvent, EventHelperType::StringType );
206 igstkLoadedEventMacro( UnsignedIntEvent, IGSTKEvent,
208 
209 igstkLoadedEventMacro( IntegerBoundsEvent, IGSTKEvent,
210  EventHelperType::IntegerBoundsType );
211 
212 igstkLoadedEventMacro( ImageBoundsEvent, IGSTKEvent,
213  EventHelperType::ImageBoundsType );
214 
215 igstkLoadedEventMacro( ImageExtentEvent, IGSTKEvent,
216  EventHelperType::ImageExtentType );
217 
218 igstkLoadedEventMacro( VTKImageModifiedEvent, IGSTKEvent,
220 
221 //igstkLoadedEventMacro( VTKPlaneModifiedEvent, IGSTKEvent,
222 // EventHelperType::VTKPlaneSourcePointerType );
223 
224 igstkLoadedEventMacro( VTKCameraModifiedEvent, IGSTKEvent,
226 
227 igstkLoadedEventMacro( DoubleTypeEvent, IGSTKEvent,
229 
230 igstkLoadedEventMacro( IGSTKErrorWithStringEvent, IGSTKErrorEvent,
232 
233 igstkEventMacro( AxialSliceBoundsEvent, IntegerBoundsEvent );
234 igstkEventMacro( SagittalSliceBoundsEvent, IntegerBoundsEvent );
235 igstkEventMacro( CoronalSliceBoundsEvent, IntegerBoundsEvent );
236 }
237 #endif