IGSTK
igstkCoordinateSystemDelegator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkCoordinateSystemDelegator.h,v $
5  Language: C++
6  Date: $Date: 2009-02-02 21:00:06 $
7  Version: $Revision: 1.5 $
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 
18 #ifndef __igstkCoordinateSystemDelegator_h
19 #define __igstkCoordinateSystemDelegator_h
20 
21 #include "igstkCoordinateSystem.h"
25 
26 namespace igstk
27 {
28 
49 {
50 public:
51 
54 
55 
58  template < class TParentPointer >
59  void RequestSetTransformAndParent( const Transform & transformToParent,
60  TParentPointer parent )
61  {
62  if( !(parent) ) // This expression must be suitable for both
63  // Smart and Raw pointers.
64  {
65  igstkPushInputMacro( NullParent );
66  m_StateMachine.ProcessInputs();
67  return;
68  }
69  else
70  {
71  const CoordinateSystem* parentReferenceSystem =
73  ::GetCoordinateSystem( parent );
74 
76  this->m_CoordinateSystem->RequestSetTransformAndParent(
77  transformToParent,
78  parentReferenceSystem);
79 
80  return;
81  }
82  }
83 
84  // This method updates the transform between this object and its parent
85  void RequestUpdateTransformToParent( const Transform & transformToParent )
86  {
87  this->m_CoordinateSystem->RequestUpdateTransformToParent(
88  transformToParent);
89  }
90 
92  void RequestGetTransformToParent();
93 
96  {
97  this->m_CoordinateSystem->RequestDetachFromParent();
98  }
99 
111  template <class TTarget>
112  void RequestComputeTransformTo(const TTarget & target)
113  {
114  if( !(target) )
115  {
116  igstkPushInputMacro( NullTarget );
117  m_StateMachine.ProcessInputs();
118  return;
119  }
120 
122  const CoordinateSystem* targetCoordSys =
124  GetCoordinateSystem( target );
125 
127  this->m_CoordinateSystem->RequestComputeTransformTo(
128  targetCoordSys);
129  }
130 
133 
139  bool IsCoordinateSystem( const CoordinateSystemType* ) const;
140 
142  void PrintSelf( std::ostream& os, itk::Indent indent ) const;
143 
145  void SetName( const char* name );
146  void SetName( const std::string& name );
147  const char* GetName() const;
148 
150  void SetType( const char* type );
151  void SetType( const std::string& type );
152  const char* GetType() const;
153 
154 protected:
157 
158 private:
161 
164 
166  igstkDeclareStateMacro( Idle );
167 
169  igstkDeclareInputMacro( NullParent );
170  igstkDeclareInputMacro( NullTarget );
171 
176 
182  const CoordinateSystem * GetCoordinateSystem() const;
183 
187  CoordinateSystem::Pointer m_CoordinateSystem;
188 
190  void NullParentProcessing();
191 
193  void NullTargetProcessing();
194 
198  typedef ::itk::ReceptorMemberCommand< Self > CoordinateSystemObserverType;
199 
201  CoordinateSystemObserverType::Pointer m_CoordinateSystemObserver;
202 
206  void ObserverCallback(const ::itk::EventObject & eventvar);
207 
208 }; // class CoordinateSystemDelegator
209 
210 }
211 
212 #endif
#define igstkFriendClassMacro(type)
Create a Macro for friend class.
Definition: igstkMacros.h:137
const char * GetType() const
static const CoordinateSystem * GetCoordinateSystem(const T &input)
Templated method to extract the CoordinateSystem from a holder class.
Base class for all the IGSTK classes.
Definition: igstkObject.h:40
#define igstkPushInputMacro(inputname)
Convenience macro for pushing an input in the queue of the State Machine.
Definition: igstkMacros.h:257
igstkStandardClassTraitsMacro(CoordinateSystemDelegator, Object) template< class TParentPointer > void RequestSetTransformAndParent(const Transform &transformToParent
Macro with standard traits declarations.
A proxy that ensures the encapsulation of the CoordinateSystem.
void RequestDetachFromParent()
Detach from its parents.
Encapsulates common logic for handling coordinate reference system calls on objects with CoordinateSy...
::itk::SmartPointer< Self > Pointer
Definition: igstkObject.h:50
A class representing a 3D Rigid transform.
void SetName(const char *name)
Set/Get the name of the coordinate system.
void RequestComputeTransformTo(const TTarget &target)
Tries to compute the transformation from this coordinate system to another coordinate system...
igstk::CoordinateSystem CoordinateSystemType
Typedef for coordinate system.
const char * GetName() const
void PrintSelf(std::ostream &os, itk::Indent indent) const
Print out object information.
This class represents the frame of a coordinate reference system.
bool IsCoordinateSystem(const CoordinateSystemType *) const
Allows another object to verify which coordinate system an object owns.
void SetType(const char *type)
Set/Get the type of the coordinate system.