IGSTK
|
00001 /*========================================================================= 00002 00003 Program: Image Guided Surgery Software Toolkit 00004 Module: $RCSfile: igstkView.h,v $ 00005 Language: C++ 00006 Date: $Date: 2008-02-11 01:41:51 $ 00007 Version: $Revision: 1.35 $ 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 #ifndef __igstkView_h 00018 #define __igstkView_h 00019 00020 #ifdef _MSC_VER 00021 #pragma warning ( disable : 4018 ) 00022 //Warning about: identifier was truncated to '255' characters in the debug 00023 //information (MVC6.0 Debug) 00024 #pragma warning( disable : 4284 ) 00025 #endif 00026 00027 // VTK declarations 00028 class vtkRenderWindow; 00029 class vtkCamera; 00030 class vtkProp; 00031 class vtkInteractorStyle; 00032 class vtkRenderer; 00033 class vtkWorldPointPicker; 00034 00035 00036 // ITK headers 00037 #include "itkCommand.h" 00038 00039 // IGSTK headers 00040 #include "igstkLogger.h" 00041 #include "igstkObject.h" 00042 #include "igstkMacros.h" 00043 #include "igstkStateMachine.h" 00044 #include "igstkPulseGenerator.h" 00045 #include "igstkObjectRepresentation.h" 00046 #include "igstkEvents.h" 00047 #include "igstkAnnotation2D.h" 00048 #include "igstkRenderWindowInteractor.h" 00049 00050 #include "igstkCoordinateSystemInterfaceMacros.h" 00051 00052 namespace igstk { 00053 00073 class View : public Object 00074 { 00075 00076 public: 00077 00079 igstkStandardClassTraitsMacro( View, Object ); 00080 00084 void SetRefreshRate( double frequency ); 00085 00088 void RequestAddObject( ObjectRepresentation* object ); 00089 00091 void RequestAddAnnotation2D( Annotation2D::Pointer annotation ); 00092 00095 void RequestRemoveObject( ObjectRepresentation* object ); 00096 00101 void RequestSaveScreenShot( const std::string & filename ); 00102 00104 void Print( std::ostream& os, ::itk::Indent indent=0) const; 00105 00107 igstkLoggerMacro() 00108 00109 00110 void RequestResetCamera(); 00111 00113 void RequestStart(); 00114 00116 void RequestStop(); 00117 00119 void SetCameraPosition( double x, double y, double z); 00120 00122 void SetCameraFocalPoint( double x, double y, double z); 00123 00125 void SetCameraViewUp( double vx, double vy, double vz); 00126 00128 void SetCameraClippingRange( double dNear, double dFar ); 00129 00131 void SetCameraParallelProjection( bool flag ); 00132 00134 void SetRendererBackgroundColor( 00135 double red, double green, double blue ); 00136 00138 void SetCameraZoomFactor( double rate ); 00139 00140 friend class ViewProxyBase; 00141 00142 protected: 00143 00144 View( ); 00145 virtual ~View( void ); 00146 00148 virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const; 00149 00151 void SetInteractorStyle( vtkInteractorStyle * style ); 00152 00154 void RequestSetRenderWindowSize( int width, int height ); 00155 00157 void RequestInitializeRenderWindowInteractor(); 00158 00160 void SetPickedPointCoordinates( double xPosition, double yPosition ); 00161 00162 private: 00163 00165 vtkRenderer * GetRenderer() const; 00166 00168 vtkRenderWindow * GetRenderWindow() const; 00169 00171 RenderWindowInteractor * GetRenderWindowInteractor() const; 00172 00174 void InitializeRenderWindowInteractorProcessing(); 00175 00178 void AddActorProcessing(); 00179 void RemoveActorProcessing(); 00180 00182 void AddAnnotation2DProcessing(); 00183 00185 void AddObjectProcessing(); 00186 void RemoveObjectProcessing(); 00187 00189 void RefreshRender(); 00190 00192 void RequestAddActor( vtkProp * actor ); 00193 00195 void RequestRemoveActor( vtkProp * actor ); 00196 00198 void ReportInvalidRequestProcessing(); 00199 00201 void SaveScreenShotWhileIdleProcessing(); 00202 00205 void SaveScreenShotWhileInteractorInitializedProcessing(); 00206 00209 void SaveScreenShotWhileRefreshingProcessing(); 00210 00215 void SaveScreenShot(); 00216 00218 void ReportInvalidScreenShotFileNameProcessing(); 00219 00221 void SetRenderWindowSizeProcessing(); 00222 00224 void ReportInvalidRenderWindowSizeProcessing(); 00225 00227 void StartProcessing(); 00228 void StopProcessing(); 00229 00231 void ResetCameraProcessing(); 00232 00233 private: 00234 00235 vtkRenderWindow * m_RenderWindow; 00236 vtkRenderer * m_Renderer; 00237 vtkCamera * m_Camera; 00238 vtkWorldPointPicker * m_PointPicker; 00239 00241 RenderWindowInteractor * m_RenderWindowInteractor; 00242 00246 vtkProp * m_ActorToBeAdded; 00247 vtkProp * m_ActorToBeRemoved; 00248 00249 Annotation2D::Pointer m_Annotation2DToBeAdded; 00250 00251 typedef itk::SimpleMemberCommand< Self > ObserverType; 00252 00253 PulseGenerator::Pointer m_PulseGenerator; 00254 ObserverType::Pointer m_PulseObserver; 00255 00257 typedef ObjectRepresentation::Pointer ObjectPointer; 00258 typedef std::list< ObjectPointer > ObjectListType; 00259 typedef ObjectListType::const_iterator ObjectListConstIterator; 00260 00262 ObjectListType m_Objects; 00263 00264 // Arguments for methods to be invoked by the state machine. 00265 ObjectRepresentation::Pointer m_ObjectToBeAdded; 00266 ObjectRepresentation::Pointer m_ObjectToBeRemoved; 00267 ObjectListType::iterator m_IteratorToObjectToBeRemoved; 00268 std::string m_ScreenShotFileName; 00269 int m_RenderWindowWidthToBeSet; 00270 int m_RenderWindowHeightToBeSet; 00271 00273 igstkDeclareInputMacro( ValidAddActor ); 00274 igstkDeclareInputMacro( NullAddActor ); 00275 igstkDeclareInputMacro( ValidRemoveActor ); 00276 igstkDeclareInputMacro( NullRemoveActor ); 00277 igstkDeclareInputMacro( ValidAddObject ); 00278 igstkDeclareInputMacro( NullAddObject ); 00279 igstkDeclareInputMacro( ValidAddAnnotation2D ); 00280 igstkDeclareInputMacro( NullAddAnnotation2D ); 00281 igstkDeclareInputMacro( ExistingAddObject ); 00282 igstkDeclareInputMacro( ValidRemoveObject ); 00283 igstkDeclareInputMacro( InexistingRemoveObject ); 00284 igstkDeclareInputMacro( NullRemoveObject ); 00285 igstkDeclareInputMacro( ResetCamera ); 00286 igstkDeclareInputMacro( StartRefreshing ); 00287 igstkDeclareInputMacro( StopRefreshing ); 00288 igstkDeclareInputMacro( ValidScreenShotFileName ); 00289 igstkDeclareInputMacro( InvalidScreenShotFileName ); 00290 igstkDeclareInputMacro( ValidRenderWindowSize ); 00291 igstkDeclareInputMacro( InValidRenderWindowSize ); 00292 igstkDeclareInputMacro( InitializeInteractor ); 00293 00295 igstkDeclareStateMacro( Idle ); 00296 igstkDeclareStateMacro( InteractorInitialized ); 00297 igstkDeclareStateMacro( Refreshing ); 00298 00299 View(const View& ); // purposely not implemented 00300 View& operator=(const View& ); // purposely not implemented 00301 00303 igstkCoordinateSystemClassInterfaceMacro(); 00304 00308 CoordinateSystem::Pointer m_PickerCoordinateSystem; 00309 }; 00310 00311 std::ostream& operator<<(std::ostream& os, const View& o); 00312 00313 } // end namespace igstk 00314 00315 #endif