Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197
00020 #define MITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197
00021
00022 #include "mitkCommon.h"
00023
00024 #include <vtkCallbackCommand.h>
00025
00026 #include <string>
00027 #include <itkObject.h>
00028 #include <itkObjectFactory.h>
00029
00030 #include "mitkPropertyList.h"
00031 #include "mitkProperties.h"
00032
00033 class vtkRenderWindow;
00034 class vtkObject;
00035
00036 namespace mitk
00037 {
00038
00039 class RenderingManager;
00040 class RenderingManagerFactory;
00041 class Geometry3D;
00042 class SliceNavigationController;
00043 class BaseRenderer;
00044 class DataStorage;
00045 class GlobalInteraction;
00046
00082 class MITK_CORE_EXPORT RenderingManager : public itk::Object
00083 {
00084 public:
00085
00086 mitkClassMacro(RenderingManager,itk::Object);
00087
00088 typedef std::vector< vtkRenderWindow* > RenderWindowVector;
00089 typedef std::vector< float > FloatVector;
00090 typedef std::vector< bool > BoolVector;
00091
00092 typedef itk::SmartPointer< DataStorage > DataStoragePointer;
00093 typedef itk::SmartPointer< GlobalInteraction > GlobalInteractionPointer;
00094
00095 enum RequestType
00096 {
00097 REQUEST_UPDATE_ALL = 0,
00098 REQUEST_UPDATE_2DWINDOWS,
00099 REQUEST_UPDATE_3DWINDOWS
00100 };
00101
00102
00103 static Pointer New();
00104
00107 static void SetFactory( RenderingManagerFactory *factory );
00108
00111 static const RenderingManagerFactory *GetFactory();
00112
00114 static bool HasFactory();
00115
00117 static RenderingManager *GetInstance();
00118
00120 static bool IsInstantiated();
00121
00124 void AddRenderWindow( vtkRenderWindow *renderWindow );
00125
00127 void RemoveRenderWindow( vtkRenderWindow *renderWindow );
00128
00130 const RenderWindowVector &GetAllRegisteredRenderWindows();
00131
00134 void RequestUpdate( vtkRenderWindow *renderWindow );
00135
00137 void ForceImmediateUpdate( vtkRenderWindow *renderWindow );
00138
00142 void RequestUpdateAll( RequestType type = REQUEST_UPDATE_ALL );
00143
00144
00148 void ForceImmediateUpdateAll( RequestType type = REQUEST_UPDATE_ALL );
00149
00152
00153
00154
00157 virtual bool InitializeViews( const Geometry3D *geometry,
00158 RequestType type = REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace = false );
00159
00160
00163 virtual bool InitializeViews( RequestType type = REQUEST_UPDATE_ALL );
00164
00165
00169
00170
00174 virtual bool InitializeView( vtkRenderWindow *renderWindow, const Geometry3D *geometry, bool initializeGlobalTimeSNC = false);
00175
00178 virtual bool InitializeView( vtkRenderWindow *renderWindow );
00179
00180
00183 void SetTimeNavigationController( SliceNavigationController *nc );
00184
00187 const SliceNavigationController *GetTimeNavigationController() const;
00188
00191 SliceNavigationController *GetTimeNavigationController();
00192
00193 virtual ~RenderingManager();
00194
00198 virtual void ExecutePendingRequests();
00199
00200 bool IsRendering() const;
00201 void AbortRendering();
00202
00204 itkSetMacro( LODIncreaseBlocked, bool );
00205
00207 itkGetMacro( LODIncreaseBlocked, bool );
00208
00210 itkBooleanMacro( LODIncreaseBlocked );
00211
00212
00214 itkSetMacro( LODAbortMechanismEnabled, bool );
00215
00217 itkGetMacro( LODAbortMechanismEnabled, bool );
00218
00220 itkBooleanMacro( LODAbortMechanismEnabled );
00221
00223 void SetDepthPeelingEnabled(bool enabled);
00225 void SetMaxNumberOfPeels(int maxNumber);
00226
00227
00228 virtual void DoStartRendering() {};
00229 virtual void DoMonitorRendering() {};
00230 virtual void DoFinishAbortRendering() {};
00231
00232 int GetNextLOD( BaseRenderer* renderer );
00233
00235 void SetNextLOD( unsigned int lod, BaseRenderer *renderer = NULL );
00236 void SetMaximumLOD( unsigned int max );
00237
00238 void SetShading( bool state, unsigned int lod );
00239 bool GetShading( unsigned int lod );
00240
00241 void SetClippingPlaneStatus( bool status );
00242 bool GetClippingPlaneStatus();
00243
00244 void SetShadingValues( float ambient, float diffuse,
00245 float specular, float specpower );
00246
00247 FloatVector &GetShadingValues();
00248
00250 PropertyList::Pointer GetPropertyList() const;
00251
00253 BaseProperty* GetProperty(const char *propertyKey) const;
00254
00256 void SetProperty(const char *propertyKey, BaseProperty* propertyValue);
00257
00268 void SetDataStorage( mitk::DataStorage* storage );
00269
00280 mitk::DataStorage* GetDataStorage();
00281
00282
00290 void SetGlobalInteraction( mitk::GlobalInteraction* globalInteraction );
00291
00299 mitk::GlobalInteraction* GetGlobalInteraction();
00300
00301
00302 protected:
00303 enum
00304 {
00305 RENDERING_INACTIVE = 0,
00306 RENDERING_REQUESTED,
00307 RENDERING_INPROGRESS
00308 };
00309
00310 RenderingManager();
00311
00314 virtual void GenerateRenderingRequestEvent() = 0;
00315
00316 virtual void InitializePropertyList();
00317
00318 bool m_UpdatePending;
00319
00320 typedef std::map< BaseRenderer *, unsigned int > RendererIntMap;
00321 typedef std::map< BaseRenderer *, bool > RendererBoolMap;
00322
00323
00324 RendererBoolMap m_RenderingAbortedMap;
00325
00326 RendererIntMap m_NextLODMap;
00327
00328 unsigned int m_MaxLOD;
00329
00330 bool m_LODIncreaseBlocked;
00331
00332 bool m_LODAbortMechanismEnabled;
00333
00334 BoolVector m_ShadingEnabled;
00335
00336 bool m_ClippingPlaneEnabled;
00337
00338 FloatVector m_ShadingValues;
00339
00340 static void RenderingStartCallback(
00341 vtkObject *caller, unsigned long eid, void *clientdata, void *calldata );
00342 static void RenderingProgressCallback(
00343 vtkObject *caller, unsigned long eid, void *clientdata, void *calldata );
00344 static void RenderingEndCallback(
00345 vtkObject *caller, unsigned long eid, void *clientdata, void *calldata );
00346
00347 typedef std::map< vtkRenderWindow *, int > RenderWindowList;
00348
00349 RenderWindowList m_RenderWindowList;
00350 RenderWindowVector m_AllRenderWindows;
00351
00352 struct RenderWindowCallbacks
00353 {
00354 vtkCallbackCommand* commands[3u];
00355 };
00356
00357 typedef std::map<vtkRenderWindow*, RenderWindowCallbacks> RenderWindowCallbacksList;
00358
00359 RenderWindowCallbacksList m_RenderWindowCallbacksList;
00360
00361 SliceNavigationController *m_TimeNavigationController;
00362
00363 static RenderingManager::Pointer s_Instance;
00364 static RenderingManagerFactory *s_RenderingManagerFactory;
00365
00366 PropertyList::Pointer m_PropertyList;
00367
00368 DataStoragePointer m_DataStorage;
00369
00370 GlobalInteractionPointer m_GlobalInteraction;
00371
00372 private:
00373
00374 void InternalViewInitialization(
00375 mitk::BaseRenderer *baseRenderer, const mitk::Geometry3D *geometry,
00376 bool boundingBoxInitialized, int mapperID );
00377
00378 };
00379
00380 itkEventMacro( RenderingManagerEvent, itk::AnyEvent );
00381 itkEventMacro( RenderingManagerViewsInitializedEvent, RenderingManagerEvent );
00382
00383
00391 class MITK_CORE_EXPORT TestingRenderingManager : public RenderingManager
00392 {
00393 public:
00394 mitkClassMacro(TestingRenderingManager,RenderingManager);
00395 itkNewMacro(Self);
00396
00397 protected:
00398 virtual void GenerateRenderingRequestEvent()
00399 {
00400 };
00401
00402 };
00403
00404
00405 }
00406
00407 #endif