Go to the documentation of this file.
18 #ifndef __igstkCoordinateSystemInterfaceMacros_h
19 #define __igstkCoordinateSystemInterfaceMacros_h
25 #include "igstkConfigure.h"
27 #ifdef IGSTK_USE_SceneGraphVisualization
28 #include "igstkSceneGraphObserver.h"
46 #ifdef IGSTK_USE_SceneGraphVisualization
47 #define igstkCoordinateSystemClassInterfaceMacro() \
49 template <class TTargetPointer> \
50 void RequestComputeTransformTo(const TTargetPointer & target) \
52 m_CoordinateSystemDelegator->RequestComputeTransformTo(target);\
54 void RequestGetTransformToParent() \
56 m_CoordinateSystemDelegator->RequestGetTransformToParent(); \
58 void RequestDetachFromParent()\
60 m_CoordinateSystemDelegator->RequestDetachFromParent();\
62 template < class TParentPointer > \
63 void RequestSetTransformAndParent( const ::igstk::Transform & transformToParent,\
64 TParentPointer parent ) \
66 if ( this->IsInternalTransformRequired() == false ) \
68 m_CoordinateSystemDelegator->RequestSetTransformAndParent( \
69 transformToParent, parent); \
73 ::igstk::Transform internalTransform = this->GetInternalTransform(); \
74 ::igstk::Transform transformToParentWithInternalTransform = \
75 ::igstk::Transform::TransformCompose( \
77 internalTransform ); \
78 m_CoordinateSystemDelegator->RequestSetTransformAndParent( \
79 transformToParentWithInternalTransform, parent); \
82 void RequestUpdateTransformToParent( const ::igstk::Transform & transformToParent )\
84 if ( this->IsInternalTransformRequired() == false ) \
86 m_CoordinateSystemDelegator->RequestUpdateTransformToParent( transformToParent );\
90 ::igstk::Transform internalTransform = this->GetInternalTransform(); \
91 ::igstk::Transform transformToParentWithInternalTransform = \
92 ::igstk::Transform::TransformCompose( \
94 internalTransform ); \
95 m_CoordinateSystemDelegator->RequestUpdateTransformToParent( \
96 transformToParentWithInternalTransform); \
99 bool IsCoordinateSystem(const ::igstk::CoordinateSystem* inCS) const \
101 return m_CoordinateSystemDelegator-> \
102 IsCoordinateSystem( inCS ); \
104 void RequestSetCoordinateSystemName(const char * name) \
106 m_CoordinateSystemDelegator->SetName( name ); \
108 const char * RequestGetCoordinateSystemName() const \
110 return m_CoordinateSystemDelegator->GetName(); \
113 virtual bool IsInternalTransformRequired() \
117 virtual ::igstk::Transform GetInternalTransform() const \
119 ::igstk::Transform identity; \
120 identity.SetToIdentity( igstk::TimeStamp::GetLongestPossibleTime() ); \
123 const ::igstk::CoordinateSystem* GetCoordinateSystem() const \
126 igstk::Friends::CoordinateSystemHelper:: \
127 GetCoordinateSystem( \
128 m_CoordinateSystemDelegator.GetPointer() ); \
131 ::igstk::CoordinateSystemDelegator::Pointer \
132 m_CoordinateSystemDelegator; \
133 typedef ::itk::ReceptorMemberCommand< Self > CoordinateSystemObserverType; \
134 CoordinateSystemObserverType::Pointer m_CoordinateSystemObserver; \
135 SceneGraphObserver::Pointer m_SceneGraphObserver; \
136 void ObserverCallback(const ::itk::EventObject & eventvar) \
138 this->InvokeEvent( eventvar ); \
140 igstkFriendClassMacro( igstk::Friends::CoordinateSystemHelper );
144 #define igstkCoordinateSystemClassInterfaceMacro() \
146 template <class TTargetPointer> \
147 void RequestComputeTransformTo(const TTargetPointer & target) \
149 m_CoordinateSystemDelegator->RequestComputeTransformTo(target);\
151 void RequestGetTransformToParent() \
153 m_CoordinateSystemDelegator->RequestGetTransformToParent(); \
155 void RequestDetachFromParent()\
157 m_CoordinateSystemDelegator->RequestDetachFromParent();\
159 template < class TParentPointer > \
160 void RequestSetTransformAndParent( const ::igstk::Transform & transformToParent,\
161 TParentPointer parent ) \
163 std::stringstream tempStream; \
164 tempStream << this->GetNameOfClass() << " 0x"; \
165 tempStream << static_cast<void*>(this); \
166 std::string name = tempStream.str(); \
167 m_CoordinateSystemDelegator->SetName( name.c_str() );\
168 if ( this->IsInternalTransformRequired() == false ) \
170 m_CoordinateSystemDelegator->RequestSetTransformAndParent( \
171 transformToParent, parent); \
175 ::igstk::Transform internalTransform = this->GetInternalTransform(); \
176 ::igstk::Transform transformToParentWithInternalTransform = \
177 ::igstk::Transform::TransformCompose( \
179 internalTransform ); \
180 m_CoordinateSystemDelegator->RequestSetTransformAndParent( \
181 transformToParentWithInternalTransform, parent); \
184 void RequestUpdateTransformToParent( const ::igstk::Transform & transformToParent )\
186 if ( this->IsInternalTransformRequired() == false ) \
188 m_CoordinateSystemDelegator->RequestUpdateTransformToParent( transformToParent );\
192 ::igstk::Transform internalTransform = this->GetInternalTransform(); \
193 ::igstk::Transform transformToParentWithInternalTransform = \
194 ::igstk::Transform::TransformCompose( \
196 internalTransform ); \
197 m_CoordinateSystemDelegator->RequestUpdateTransformToParent( \
198 transformToParentWithInternalTransform); \
201 bool IsCoordinateSystem(const ::igstk::CoordinateSystem* inCS) const \
203 return m_CoordinateSystemDelegator-> \
204 IsCoordinateSystem( inCS ); \
207 virtual bool IsInternalTransformRequired() \
211 virtual ::igstk::Transform GetInternalTransform() const \
213 ::igstk::Transform identity; \
214 identity.SetToIdentity( igstk::TimeStamp::GetLongestPossibleTime() ); \
217 const ::igstk::CoordinateSystem* GetCoordinateSystem() const \
220 igstk::Friends::CoordinateSystemHelper:: \
221 GetCoordinateSystem( \
222 m_CoordinateSystemDelegator.GetPointer() ); \
225 ::igstk::CoordinateSystemDelegator::Pointer \
226 m_CoordinateSystemDelegator; \
227 typedef ::itk::ReceptorMemberCommand< Self > CoordinateSystemObserverType; \
228 CoordinateSystemObserverType::Pointer m_CoordinateSystemObserver; \
229 void ObserverCallback(const ::itk::EventObject & eventvar) \
231 this->InvokeEvent( eventvar ); \
233 igstkFriendClassMacro( igstk::Friends::CoordinateSystemHelper );
242 #ifdef IGSTK_USE_SceneGraphVisualization
243 #define igstkCoordinateSystemClassInterfaceConstructorMacro() \
244 m_CoordinateSystemObserver = CoordinateSystemObserverType::New(); \
245 m_CoordinateSystemObserver->SetCallbackFunction(this, \
246 &Self::ObserverCallback); \
247 m_CoordinateSystemDelegator = \
248 ::igstk::CoordinateSystemDelegator::New(); \
249 m_SceneGraphObserver = SceneGraphObserver::New(); \
250 m_CoordinateSystemDelegator->AddObserver( \
251 ::igstk::CoordinateSystemTransformToNullTargetEvent() \
252 , m_CoordinateSystemObserver ); \
253 m_CoordinateSystemDelegator->AddObserver( \
254 ::igstk::CoordinateSystemSetTransformEvent() \
255 , m_CoordinateSystemObserver); \
256 m_SceneGraphObserver->ObserveTransformEventsFrom(this);\
257 m_CoordinateSystemDelegator->AddObserver( \
258 ::igstk::CoordinateSystemTransformToDisconnectedEvent() \
259 , m_CoordinateSystemObserver ); \
260 m_CoordinateSystemDelegator->AddObserver( \
261 ::igstk::CoordinateSystemNullParentEvent() \
262 , m_CoordinateSystemObserver ); \
263 m_CoordinateSystemDelegator->AddObserver( \
264 ::igstk::CoordinateSystemThisParentEvent() \
265 , m_CoordinateSystemObserver ); \
266 m_CoordinateSystemDelegator->AddObserver( \
267 ::igstk::CoordinateSystemParentCycleEvent() \
268 , m_CoordinateSystemObserver ); \
269 m_CoordinateSystemDelegator->AddObserver( \
270 ::igstk::CoordinateSystemTransformToEvent() \
271 , m_CoordinateSystemObserver ); \
272 std::stringstream tempStream; \
273 tempStream << this->GetNameOfClass() << " 0x"; \
274 tempStream << static_cast<void*>(this); \
275 std::string name = tempStream.str(); \
276 m_CoordinateSystemDelegator->SetType( this->GetNameOfClass() );\
277 m_CoordinateSystemDelegator->SetName( name.c_str() );
281 #define igstkCoordinateSystemClassInterfaceConstructorMacro() \
282 m_CoordinateSystemObserver = CoordinateSystemObserverType::New(); \
283 m_CoordinateSystemObserver->SetCallbackFunction(this, \
284 &Self::ObserverCallback); \
285 m_CoordinateSystemDelegator = \
286 ::igstk::CoordinateSystemDelegator::New(); \
287 m_CoordinateSystemDelegator->AddObserver( \
288 ::igstk::CoordinateSystemTransformToNullTargetEvent() \
289 , m_CoordinateSystemObserver ); \
290 m_CoordinateSystemDelegator->AddObserver( \
291 ::igstk::CoordinateSystemSetTransformEvent() \
292 , m_CoordinateSystemObserver); \
293 m_CoordinateSystemDelegator->AddObserver( \
294 ::igstk::CoordinateSystemTransformToDisconnectedEvent() \
295 , m_CoordinateSystemObserver ); \
296 m_CoordinateSystemDelegator->AddObserver( \
297 ::igstk::CoordinateSystemNullParentEvent() \
298 , m_CoordinateSystemObserver ); \
299 m_CoordinateSystemDelegator->AddObserver( \
300 ::igstk::CoordinateSystemThisParentEvent() \
301 , m_CoordinateSystemObserver ); \
302 m_CoordinateSystemDelegator->AddObserver( \
303 ::igstk::CoordinateSystemParentCycleEvent() \
304 , m_CoordinateSystemObserver ); \
305 m_CoordinateSystemDelegator->AddObserver( \
306 ::igstk::CoordinateSystemTransformToEvent() \
307 , m_CoordinateSystemObserver ); \
308 std::stringstream tempStream; \
309 tempStream << this->GetNameOfClass() << " 0x"; \
310 tempStream << static_cast<void*>(this); \
311 std::string name = tempStream.str(); \
312 m_CoordinateSystemDelegator->SetType( this->GetNameOfClass() );\
313 m_CoordinateSystemDelegator->SetName( name.c_str() );
318 #endif // #ifndef __igstkCoordinateSystemInterfaceMacros_h