00001 /*========================================================================= 00002 00003 Program: Image Guided Surgery Software Toolkit 00004 Module: $RCSfile: igstkCoordinateSystemDelegator.h,v $ 00005 Language: C++ 00006 Date: $Date: 2008-11-18 01:31:52 $ 00007 Version: $Revision: 1.2 $ 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 __igstkCoordinateSystemDelegator_h 00019 #define __igstkCoordinateSystemDelegator_h 00020 00021 #include "igstkCoordinateSystem.h" 00022 #include "igstkCoordinateSystemTransformToResult.h" 00023 #include "igstkCoordinateSystemTransformToErrorResult.h" 00024 00025 namespace igstk 00026 { 00027 00047 class CoordinateSystemDelegator : public Object 00048 { 00049 public: 00050 00052 igstkStandardClassTraitsMacro( CoordinateSystemDelegator, Object ) 00053 00054 00057 template < class TParentPointer > 00058 void RequestSetTransformAndParent( const Transform & transformToParent, 00059 TParentPointer parent ) 00060 { 00061 if( !(parent) ) // This expression must be suitable for both 00062 // Smart and Raw pointers. 00063 { 00064 igstkPushInputMacro( NullParent ); 00065 m_StateMachine.ProcessInputs(); 00066 return; 00067 } 00068 else 00069 { 00070 const CoordinateSystem* parentReferenceSystem = 00071 igstk::Friends::CoordinateSystemHelper 00072 ::GetCoordinateSystem( parent ); 00073 00075 this->m_CoordinateSystem->RequestSetTransformAndParent( 00076 transformToParent, 00077 parentReferenceSystem); 00078 00079 return; 00080 } 00081 } 00082 00083 // This method updates the transform between this object and its parent 00084 void RequestUpdateTransformToParent( const Transform & transformToParent ) 00085 { 00086 this->m_CoordinateSystem->RequestUpdateTransformToParent( 00087 transformToParent); 00088 } 00089 00091 void RequestGetTransformToParent(); 00092 00094 void RequestDetachFromParent() 00095 { 00096 this->m_CoordinateSystem->RequestDetachFromParent(); 00097 } 00098 00110 template <class TTarget> 00111 void RequestComputeTransformTo(const TTarget & target) 00112 { 00113 if( !(target) ) 00114 { 00115 igstkPushInputMacro( NullTarget ); 00116 m_StateMachine.ProcessInputs(); 00117 return; 00118 } 00119 00121 const CoordinateSystem* targetCoordSys = 00122 igstk::Friends::CoordinateSystemHelper:: 00123 GetCoordinateSystem( target ); 00124 00126 this->m_CoordinateSystem->RequestComputeTransformTo( 00127 targetCoordSys); 00128 } 00129 00131 typedef igstk::CoordinateSystem CoordinateSystemType; 00132 00138 bool IsCoordinateSystem( const CoordinateSystemType* ) const; 00139 00141 void PrintSelf( std::ostream& os, itk::Indent indent ) const; 00142 00144 void SetName( const char* name ); 00145 void SetName( const std::string& name ); 00146 const char* GetName() const; 00147 00148 protected: 00149 CoordinateSystemDelegator(); 00150 ~CoordinateSystemDelegator(); 00151 00152 private: 00154 CoordinateSystemDelegator(const CoordinateSystemDelegator& ); 00155 00157 CoordinateSystemDelegator& operator=(const CoordinateSystemDelegator&); 00158 00160 igstkDeclareStateMacro( Idle ); 00161 00163 igstkDeclareInputMacro( NullParent ); 00164 igstkDeclareInputMacro( NullTarget ); 00165 00169 igstkFriendClassMacro( igstk::Friends::CoordinateSystemHelper ); 00170 00176 const CoordinateSystem * GetCoordinateSystem() const; 00177 00181 CoordinateSystem::Pointer m_CoordinateSystem; 00182 00184 void NullParentProcessing(); 00185 00187 void NullTargetProcessing(); 00188 00192 typedef ::itk::ReceptorMemberCommand< Self > CoordinateSystemObserverType; 00193 00195 CoordinateSystemObserverType::Pointer m_CoordinateSystemObserver; 00196 00200 void ObserverCallback(const ::itk::EventObject & eventvar); 00201 00202 }; // class CoordinateSystemDelegator 00203 00204 } 00205 00206 #endif