IGSTK
|
00001 /*========================================================================= 00002 00003 Program: Image Guided Surgery Software Toolkit 00004 Module: $RCSfile: igstkObjectRepresentation.h,v $ 00005 Language: C++ 00006 Date: $Date: 2008-05-13 20:11:57 $ 00007 Version: $Revision: 1.28 $ 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 __igstkObjectRepresentation_h 00019 #define __igstkObjectRepresentation_h 00020 00021 #ifdef _MSC_VER 00022 #pragma warning ( disable : 4786 ) 00023 #endif 00024 00025 #include <vector> 00026 #include "itkCommand.h" 00027 #include "igstkLogger.h" 00028 #include "igstkObject.h" 00029 #include "igstkMacros.h" 00030 #include "igstkSpatialObject.h" 00031 #include "igstkStateMachine.h" 00032 #include "igstkCoordinateSystem.h" 00033 00034 class vtkProp; 00035 00036 namespace igstk 00037 { 00038 00072 class ObjectRepresentation 00073 : public Object 00074 { 00075 00076 public: 00077 00079 igstkStandardAbstractClassTraitsMacro( ObjectRepresentation, Object ) 00080 00081 public: 00082 00083 typedef std::vector< vtkProp* > ActorsListType; 00084 00086 typedef double ColorScalarType; 00087 00089 void SetColor(ColorScalarType r, ColorScalarType g, ColorScalarType b); 00090 00092 ColorScalarType GetRed() const; 00093 ColorScalarType GetGreen() const; 00094 ColorScalarType GetBlue() const; 00095 00097 typedef double OpacityType; 00098 00100 virtual void SetOpacity(OpacityType alpha); 00101 igstkGetMacro( Opacity, OpacityType ); 00102 00104 virtual void CreateActors()= 0; 00105 00107 igstkGetMacro( Actors, ActorsListType ); 00108 00110 virtual void RequestUpdateRepresentation( 00111 const TimeStamp & time, 00112 const CoordinateSystem* cs ); 00113 00114 protected: 00115 00116 ObjectRepresentation( void ); 00117 ~ObjectRepresentation( void ); 00118 00119 ActorsListType m_Actors; 00120 00121 OpacityType m_Opacity; 00122 00124 void AddActor( vtkProp * ); 00125 00127 virtual void DeleteActors(); 00128 00130 virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const; 00131 00133 void RequestSetSpatialObject( const SpatialObject * spatialObject ); 00134 00139 virtual bool VerifyTimeStamp() const; 00140 00142 TimeStamp GetRenderTimeStamp() const; 00143 00144 private: 00145 00146 ObjectRepresentation(const Self&); //purposely not implemented 00147 void operator=(const Self&); //purposely not implemented 00148 00152 virtual void UpdateRepresentationProcessing() = 0; 00153 00156 void RequestVerifyTimeStampAndUpdateVisibility(); 00157 00159 void NoProcessing(); 00160 00161 00163 void SetSpatialObjectProcessing(); 00164 00166 void ReportInvalidRequestProcessing(); 00167 00171 void MakeObjectsInvisibleProcessing(); 00172 00175 void MakeObjectsVisibleProcessing(); 00176 00179 void ReceiveSpatialObjectTransformProcessing(); 00180 00185 void ReceiveTransformNotAvailableProcessing(); 00186 00190 void RequestGetTransformProcessing(); 00191 00194 void RequestSetActorVisibility( vtkProp * ); 00195 00198 void SetActorVisibleProcessing(); 00199 void SetActorInvisibleProcessing(); 00200 00203 ColorScalarType m_Color[3]; 00204 00208 SpatialObject::Pointer m_SpatialObject; 00209 00211 SpatialObject::Pointer m_SpatialObjectToAdd; 00212 00214 TimeStamp m_TimeToRender; 00215 00217 Transform m_SpatialObjectTransform; 00218 00222 StateMachineType m_VisibilityStateMachine; 00223 00227 CoordinateSystem::ConstPointer m_TargetCoordinateSystem; 00228 00230 vtkProp * m_VisibilitySetActor; 00231 00233 igstkDeclareInputMacro( NullSpatialObject ); 00234 igstkDeclareInputMacro( ValidSpatialObject ); 00235 igstkDeclareInputMacro( UpdateRepresentation ); 00236 igstkDeclareInputMacro( SpatialObjectTransform ); 00237 igstkDeclareInputMacro( TransformNotAvailable ); 00238 00240 igstkDeclareStateMacro( NullSpatialObject ); 00241 igstkDeclareStateMacro( ValidSpatialObject ); 00242 igstkDeclareStateMacro( AttemptingGetTransform ); 00243 00253 igstkEventTransductionMacro( 00254 TransformNotAvailable, 00255 TransformNotAvailable); 00256 00257 // The only event that brings a valid transform. 00258 igstkLoadedEventTransductionMacro( 00259 CoordinateSystemTransformTo, 00260 SpatialObjectTransform ); 00261 00263 igstkDeclareInputMacro( ValidTimeStamp ); 00264 igstkDeclareInputMacro( InvalidTimeStamp ); 00265 igstkDeclareInputMacro( SetActorVisibility ); 00266 00268 igstkDeclareStateMacro( Visible ); 00269 igstkDeclareStateMacro( Invisible ); 00270 00271 }; 00272 00273 } // end namespace igstk 00274 00275 #endif // __igstkObjectRepresentation_h