IGSTK
igstkView.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkView.h,v $
5  Language: C++
6  Date: $Date: 2008-02-11 01:41:51 $
7  Version: $Revision: 1.35 $
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 #ifndef __igstkView_h
18 #define __igstkView_h
19 
20 #ifdef _MSC_VER
21 #pragma warning ( disable : 4018 )
22 //Warning about: identifier was truncated to '255' characters in the debug
23 //information (MVC6.0 Debug)
24 #pragma warning( disable : 4284 )
25 #endif
26 
27 // VTK declarations
28 class vtkRenderWindow;
29 class vtkCamera;
30 class vtkProp;
31 class vtkInteractorStyle;
32 class vtkRenderer;
33 class vtkWorldPointPicker;
34 
35 
36 // ITK headers
37 #include "itkCommand.h"
38 
39 // IGSTK headers
40 #include "igstkLogger.h"
41 #include "igstkObject.h"
42 #include "igstkMacros.h"
43 #include "igstkStateMachine.h"
44 #include "igstkPulseGenerator.h"
46 #include "igstkEvents.h"
47 #include "igstkAnnotation2D.h"
49 
51 
52 namespace igstk {
53 
73 class View : public Object
74 {
75 
76 public:
77 
80 
84  void SetRefreshRate( double frequency );
85 
88  void RequestAddObject( ObjectRepresentation* object );
89 
92 
96 
101  void RequestSaveScreenShot( const std::string & filename );
102 
104  void Print( std::ostream& os, ::itk::Indent indent=0) const;
105 
108 
109 
110  void RequestResetCamera();
111 
113  void RequestStart();
114 
116  void RequestStop();
117 
119  void SetCameraPosition( double x, double y, double z);
120 
122  void SetCameraFocalPoint( double x, double y, double z);
123 
125  void SetCameraViewUp( double vx, double vy, double vz);
126 
128  void SetCameraClippingRange( double dNear, double dFar );
129 
131  void SetCameraParallelProjection( bool flag );
132 
135  double red, double green, double blue );
136 
138  void SetCameraZoomFactor( double rate );
139 
140  friend class ViewProxyBase;
141 
142 protected:
143 
144  View( );
145  virtual ~View( void );
146 
148  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
149 
151  void SetInteractorStyle( vtkInteractorStyle * style );
152 
154  void RequestSetRenderWindowSize( int width, int height );
155 
158 
160  void SetPickedPointCoordinates( double xPosition, double yPosition );
161 
162 private:
163 
165  vtkRenderer * GetRenderer() const;
166 
168  vtkRenderWindow * GetRenderWindow() const;
169 
171  RenderWindowInteractor * GetRenderWindowInteractor() const;
172 
174  void InitializeRenderWindowInteractorProcessing();
175 
178  void AddActorProcessing();
179  void RemoveActorProcessing();
180 
182  void AddAnnotation2DProcessing();
183 
185  void AddObjectProcessing();
186  void RemoveObjectProcessing();
187 
189  void RefreshRender();
190 
192  void RequestAddActor( vtkProp * actor );
193 
195  void RequestRemoveActor( vtkProp * actor );
196 
198  void ReportInvalidRequestProcessing();
199 
201  void SaveScreenShotWhileIdleProcessing();
202 
205  void SaveScreenShotWhileInteractorInitializedProcessing();
206 
209  void SaveScreenShotWhileRefreshingProcessing();
210 
215  void SaveScreenShot();
216 
218  void ReportInvalidScreenShotFileNameProcessing();
219 
221  void SetRenderWindowSizeProcessing();
222 
224  void ReportInvalidRenderWindowSizeProcessing();
225 
227  void StartProcessing();
228  void StopProcessing();
229 
231  void ResetCameraProcessing();
232 
233 private:
234 
235  vtkRenderWindow * m_RenderWindow;
236  vtkRenderer * m_Renderer;
237  vtkCamera * m_Camera;
238  vtkWorldPointPicker * m_PointPicker;
239 
241  RenderWindowInteractor * m_RenderWindowInteractor;
242 
246  vtkProp * m_ActorToBeAdded;
247  vtkProp * m_ActorToBeRemoved;
248 
249  Annotation2D::Pointer m_Annotation2DToBeAdded;
250 
251  typedef itk::SimpleMemberCommand< Self > ObserverType;
252 
253  PulseGenerator::Pointer m_PulseGenerator;
254  ObserverType::Pointer m_PulseObserver;
255 
257  typedef ObjectRepresentation::Pointer ObjectPointer;
258  typedef std::list< ObjectPointer > ObjectListType;
259  typedef ObjectListType::const_iterator ObjectListConstIterator;
260 
262  ObjectListType m_Objects;
263 
264  // Arguments for methods to be invoked by the state machine.
265  ObjectRepresentation::Pointer m_ObjectToBeAdded;
266  ObjectRepresentation::Pointer m_ObjectToBeRemoved;
267  ObjectListType::iterator m_IteratorToObjectToBeRemoved;
268  std::string m_ScreenShotFileName;
269  int m_RenderWindowWidthToBeSet;
270  int m_RenderWindowHeightToBeSet;
271 
273  igstkDeclareInputMacro( ValidAddActor );
274  igstkDeclareInputMacro( NullAddActor );
275  igstkDeclareInputMacro( ValidRemoveActor );
276  igstkDeclareInputMacro( NullRemoveActor );
277  igstkDeclareInputMacro( ValidAddObject );
278  igstkDeclareInputMacro( NullAddObject );
279  igstkDeclareInputMacro( ValidAddAnnotation2D );
280  igstkDeclareInputMacro( NullAddAnnotation2D );
281  igstkDeclareInputMacro( ExistingAddObject );
282  igstkDeclareInputMacro( ValidRemoveObject );
283  igstkDeclareInputMacro( InexistingRemoveObject );
284  igstkDeclareInputMacro( NullRemoveObject );
285  igstkDeclareInputMacro( ResetCamera );
286  igstkDeclareInputMacro( StartRefreshing );
287  igstkDeclareInputMacro( StopRefreshing );
288  igstkDeclareInputMacro( ValidScreenShotFileName );
289  igstkDeclareInputMacro( InvalidScreenShotFileName );
290  igstkDeclareInputMacro( ValidRenderWindowSize );
291  igstkDeclareInputMacro( InValidRenderWindowSize );
292  igstkDeclareInputMacro( InitializeInteractor );
293 
295  igstkDeclareStateMacro( Idle );
296  igstkDeclareStateMacro( InteractorInitialized );
297  igstkDeclareStateMacro( Refreshing );
298 
299  View(const View& ); // purposely not implemented
300  View& operator=(const View& ); // purposely not implemented
301 
304 
308  CoordinateSystem::Pointer m_PickerCoordinateSystem;
309 };
310 
311 std::ostream& operator<<(std::ostream& os, const View& o);
312 
313 } // end namespace igstk
314 
315 #endif