IGSTK
igstkObjectRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkObjectRepresentation.h,v $
5  Language: C++
6  Date: $Date: 2008-05-13 20:11:57 $
7  Version: $Revision: 1.28 $
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 __igstkObjectRepresentation_h
19 #define __igstkObjectRepresentation_h
20 
21 #ifdef _MSC_VER
22 #pragma warning ( disable : 4786 )
23 #endif
24 
25 #include <vector>
26 #include "itkCommand.h"
27 #include "igstkLogger.h"
28 #include "igstkObject.h"
29 #include "igstkMacros.h"
30 #include "igstkSpatialObject.h"
31 #include "igstkStateMachine.h"
32 #include "igstkCoordinateSystem.h"
33 
34 class vtkProp;
35 
36 namespace igstk
37 {
38 
73  : public Object
74 {
75 
76 public:
77 
80 
81 public:
82 
83  typedef std::vector< vtkProp* > ActorsListType;
84 
86  typedef double ColorScalarType;
87 
89  void SetColor(ColorScalarType r, ColorScalarType g, ColorScalarType b);
90 
92  ColorScalarType GetRed() const;
93  ColorScalarType GetGreen() const;
94  ColorScalarType GetBlue() const;
95 
97  typedef double OpacityType;
98 
100  virtual void SetOpacity(OpacityType alpha);
101  igstkGetMacro( Opacity, OpacityType );
102 
104  virtual void CreateActors()= 0;
105 
107  igstkGetMacro( Actors, ActorsListType );
108 
110  virtual void RequestUpdateRepresentation(
111  const TimeStamp & time,
112  const CoordinateSystem* cs );
113 
114 protected:
115 
116  ObjectRepresentation( void );
117  ~ObjectRepresentation( void );
118 
119  ActorsListType m_Actors;
120 
121  OpacityType m_Opacity;
122 
124  void AddActor( vtkProp * );
125 
127  virtual void DeleteActors();
128 
130  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
131 
133  void RequestSetSpatialObject( const SpatialObject * spatialObject );
134 
139  virtual bool VerifyTimeStamp() const;
140 
143 
144 private:
145 
146  ObjectRepresentation(const Self&); //purposely not implemented
147  void operator=(const Self&); //purposely not implemented
148 
152  virtual void UpdateRepresentationProcessing() = 0;
153 
156  void RequestVerifyTimeStampAndUpdateVisibility();
157 
159  void NoProcessing();
160 
161 
163  void SetSpatialObjectProcessing();
164 
166  void ReportInvalidRequestProcessing();
167 
171  void MakeObjectsInvisibleProcessing();
172 
175  void MakeObjectsVisibleProcessing();
176 
179  void ReceiveSpatialObjectTransformProcessing();
180 
185  void ReceiveTransformNotAvailableProcessing();
186 
190  void RequestGetTransformProcessing();
191 
194  void RequestSetActorVisibility( vtkProp * );
195 
198  void SetActorVisibleProcessing();
199  void SetActorInvisibleProcessing();
200 
203  ColorScalarType m_Color[3];
204 
208  SpatialObject::Pointer m_SpatialObject;
209 
211  SpatialObject::Pointer m_SpatialObjectToAdd;
212 
214  TimeStamp m_TimeToRender;
215 
217  Transform m_SpatialObjectTransform;
218 
222  StateMachineType m_VisibilityStateMachine;
223 
227  CoordinateSystem::ConstPointer m_TargetCoordinateSystem;
228 
230  vtkProp * m_VisibilitySetActor;
231 
233  igstkDeclareInputMacro( NullSpatialObject );
234  igstkDeclareInputMacro( ValidSpatialObject );
235  igstkDeclareInputMacro( UpdateRepresentation );
236  igstkDeclareInputMacro( SpatialObjectTransform );
237  igstkDeclareInputMacro( TransformNotAvailable );
238 
240  igstkDeclareStateMacro( NullSpatialObject );
241  igstkDeclareStateMacro( ValidSpatialObject );
242  igstkDeclareStateMacro( AttemptingGetTransform );
243 
253  igstkEventTransductionMacro(
254  TransformNotAvailable,
255  TransformNotAvailable);
256 
257  // The only event that brings a valid transform.
258  igstkLoadedEventTransductionMacro(
259  CoordinateSystemTransformTo,
260  SpatialObjectTransform );
261 
263  igstkDeclareInputMacro( ValidTimeStamp );
264  igstkDeclareInputMacro( InvalidTimeStamp );
265  igstkDeclareInputMacro( SetActorVisibility );
266 
268  igstkDeclareStateMacro( Visible );
269  igstkDeclareStateMacro( Invisible );
270 
271 };
272 
273 } // end namespace igstk
274 
275 #endif // __igstkObjectRepresentation_h