Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
mitkRenderingManager.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkRenderingManager_h
14 #define mitkRenderingManager_h
15 
16 #include <MitkCoreExports.h>
17 
18 #include <vtkCallbackCommand.h>
19 
20 #include <itkObject.h>
21 #include <itkObjectFactory.h>
22 
23 #include <mitkProperties.h>
24 #include <mitkPropertyList.h>
25 #include <mitkTimeGeometry.h>
26 #include <mitkAntiAliasing.h>
27 
28 class vtkRenderWindow;
29 class vtkObject;
30 
31 namespace mitk
32 {
33  class RenderingManagerFactory;
34  class BaseGeometry;
35  class TimeNavigationController;
36  class BaseRenderer;
37  class DataStorage;
38 
74  class MITKCORE_EXPORT RenderingManager : public itk::Object
75  {
76  public:
78 
79  typedef std::vector<vtkRenderWindow *> RenderWindowVector;
80  typedef std::vector<float> FloatVector;
81  typedef std::vector<bool> BoolVector;
82 
84 
86  {
87  REQUEST_UPDATE_ALL = 0,
89  REQUEST_UPDATE_3DWINDOWS
90  };
91 
92  static Pointer New();
93 
96  static void SetFactory(RenderingManagerFactory *factory);
97 
100  static const RenderingManagerFactory *GetFactory();
101 
103  static bool HasFactory();
104 
106  static RenderingManager *GetInstance();
107 
109  static bool IsInstantiated();
110 
113  void AddRenderWindow(vtkRenderWindow *renderWindow);
114 
116  void RemoveRenderWindow(vtkRenderWindow *renderWindow);
117 
119  const RenderWindowVector &GetAllRegisteredRenderWindows();
120 
123  void RequestUpdate(vtkRenderWindow *renderWindow);
124 
126  void ForceImmediateUpdate(vtkRenderWindow *renderWindow);
127 
131  void RequestUpdateAll(RequestType type = REQUEST_UPDATE_ALL);
132 
136  void ForceImmediateUpdateAll(RequestType type = REQUEST_UPDATE_ALL);
137 
144  virtual void InitializeViewsByBoundingObjects(const DataStorage* dataStorage);
145 
158  virtual void InitializeViewByBoundingObjects(vtkRenderWindow* renderWindow,
159  const DataStorage* dataStorage,
160  bool resetCamera = true);
161 
181  virtual bool InitializeViews(const BaseGeometry *geometry,
182  RequestType type = REQUEST_UPDATE_ALL,
183  bool resetCamera = true);
184 
204  virtual bool InitializeViews(const TimeGeometry *geometry,
205  RequestType type = REQUEST_UPDATE_ALL,
206  bool resetCamera = true);
207 
220  virtual bool InitializeViews(RequestType type = REQUEST_UPDATE_ALL);
221 
235  virtual bool InitializeView(vtkRenderWindow *renderWindow,
236  const BaseGeometry *geometry,
237  bool resetCamera = true);
238 
252  virtual bool InitializeView(vtkRenderWindow *renderWindow,
253  const TimeGeometry *geometry,
254  bool resetCamera = true);
255 
262  virtual bool InitializeView(vtkRenderWindow *renderWindow);
263 
266  const TimeNavigationController* GetTimeNavigationController() const;
267 
270  TimeNavigationController* GetTimeNavigationController();
271 
272  ~RenderingManager() override;
273 
277  virtual void ExecutePendingRequests();
278 
279  bool IsRendering() const;
280  void AbortRendering();
281 
283  itkSetMacro(LODIncreaseBlocked, bool);
284 
286  itkGetMacro(LODIncreaseBlocked, bool);
287 
289  itkBooleanMacro(LODIncreaseBlocked);
290 
292  itkSetMacro(LODAbortMechanismEnabled, bool);
293 
295  itkGetMacro(LODAbortMechanismEnabled, bool);
296 
298  itkBooleanMacro(LODAbortMechanismEnabled);
299 
301  virtual void StartOrResetTimer(){};
302 
304  void ExecutePendingHighResRenderingRequest();
305 
306  virtual void DoStartRendering(){};
307  virtual void DoMonitorRendering(){};
308  virtual void DoFinishAbortRendering(){};
309 
310  int GetNextLOD(BaseRenderer *renderer);
311 
313  void SetMaximumLOD(unsigned int max);
314 
315  void SetShading(bool state, unsigned int lod);
316  bool GetShading(unsigned int lod);
317 
318  void SetClippingPlaneStatus(bool status);
319  bool GetClippingPlaneStatus();
320 
321  void SetShadingValues(float ambient, float diffuse, float specular, float specpower);
322 
323  FloatVector &GetShadingValues();
324 
326  PropertyList::Pointer GetPropertyList() const;
327 
329  BaseProperty *GetProperty(const char *propertyKey) const;
330 
332  void SetProperty(const char *propertyKey, BaseProperty *propertyValue);
333 
344  void SetDataStorage(DataStorage *storage);
345 
352  itkGetMacro(DataStorage, DataStorage*);
353  itkGetConstMacro(DataStorage, DataStorage*);
354 
359  void SetRenderWindowFocus(vtkRenderWindow *focusWindow);
360  itkGetMacro(FocusedRenderWindow, vtkRenderWindow *);
361 
362  void SetConstrainedPanningZooming(bool constrain);
363  itkGetConstMacro(ConstrainedPanningZooming, bool);
364 
365  void SetAntiAliasing(AntiAliasing antiAliasing);
366  itkGetConstMacro(AntiAliasing, AntiAliasing);
367 
368  protected:
369  enum
370  {
371  RENDERING_INACTIVE = 0,
373  RENDERING_INPROGRESS
374  };
375 
377 
380  virtual void GenerateRenderingRequestEvent() = 0;
381 
382  virtual void InitializePropertyList();
383 
385 
386  typedef std::map<BaseRenderer *, unsigned int> RendererIntMap;
387  typedef std::map<BaseRenderer *, bool> RendererBoolMap;
388 
390 
392 
393  unsigned int m_MaxLOD;
394 
396 
398 
400 
402 
404 
405  static void RenderingStartCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
406  static void RenderingProgressCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
407  static void RenderingEndCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
408 
409  typedef std::map<vtkRenderWindow *, int> RenderWindowList;
410 
413 
415  {
416  vtkCallbackCommand *commands[3u];
417  };
418 
419  typedef std::map<vtkRenderWindow *, RenderWindowCallbacks> RenderWindowCallbacksList;
420 
422 
424 
427 
429 
431 
433 
434  private:
435 
454  void InternalViewInitialization(BaseRenderer *baseRenderer,
455  const TimeGeometry *geometry,
456  bool boundingBoxInitialized,
457  int mapperID,
458  bool resetCamera);
459 
467  bool ExtendGeometryForBoundingBox(const TimeGeometry* originalGeometry, TimeGeometry::Pointer& modifiedGeometry);
468 
469  vtkRenderWindow *m_FocusedRenderWindow;
470  AntiAliasing m_AntiAliasing;
471  };
472 
473 #pragma GCC visibility push(default)
474 
475  itkEventMacroDeclaration(RenderingManagerEvent, itk::AnyEvent);
476  itkEventMacroDeclaration(RenderingManagerViewsInitializedEvent, RenderingManagerEvent);
477 
478 #pragma GCC visibility pop
479 
480  itkEventMacroDeclaration(FocusChangedEvent, itk::AnyEvent);
481 
490  {
491  public:
493  itkFactorylessNewMacro(Self);
494  itkCloneMacro(Self);
495 
496  protected:
497 
498  void GenerateRenderingRequestEvent() override {};
499  };
500 
501 } // namespace mitk
502 
503 #endif
mitk::TimeNavigationController
Controls the time-related properties of the time stepper, according to the given input world time geo...
Definition: mitkTimeNavigationController.h:69
mitk::TimeGeometry
Definition: mitkTimeGeometry.h:45
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:36
mitk::RenderingManager::m_RenderWindowList
RenderWindowList m_RenderWindowList
Definition: mitkRenderingManager.h:411
mitk::RenderingManager::m_ConstrainedPanningZooming
bool m_ConstrainedPanningZooming
Definition: mitkRenderingManager.h:432
mitk::RenderingManager::m_PropertyList
PropertyList::Pointer m_PropertyList
Definition: mitkRenderingManager.h:428
mitk::RenderingManager::m_DataStorage
DataStoragePointer m_DataStorage
Definition: mitkRenderingManager.h:430
mitk::RenderingManager::RenderWindowCallbacksList
std::map< vtkRenderWindow *, RenderWindowCallbacks > RenderWindowCallbacksList
Definition: mitkRenderingManager.h:419
mitk::RenderingManager::DataStoragePointer
itk::SmartPointer< DataStorage > DataStoragePointer
Definition: mitkRenderingManager.h:83
mitk::RenderingManager::BoolVector
std::vector< bool > BoolVector
Definition: mitkRenderingManager.h:81
mitk::RenderingManager::RendererIntMap
std::map< BaseRenderer *, unsigned int > RendererIntMap
Definition: mitkRenderingManager.h:386
mitk::RenderingManager::m_ClippingPlaneEnabled
bool m_ClippingPlaneEnabled
Definition: mitkRenderingManager.h:401
mitkAntiAliasing.h
mitk::RenderingManager::RenderWindowList
std::map< vtkRenderWindow *, int > RenderWindowList
Definition: mitkRenderingManager.h:409
mitk::AntiAliasing
AntiAliasing
Definition: mitkAntiAliasing.h:18
itk::SmartPointer< DataStorage >
mitk::RenderingManager::m_UpdatePending
bool m_UpdatePending
Definition: mitkRenderingManager.h:384
mitk::TestingRenderingManager
Definition: mitkRenderingManager.h:489
mitkTimeGeometry.h
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::RenderingManager::RENDERING_REQUESTED
@ RENDERING_REQUESTED
Definition: mitkRenderingManager.h:372
mitk::RenderingManager
Manager for coordinating the rendering process.
Definition: mitkRenderingManager.h:74
mitk::RenderingManager::DoFinishAbortRendering
virtual void DoFinishAbortRendering()
Definition: mitkRenderingManager.h:308
mitk::RenderingManager::s_RenderingManagerFactory
static RenderingManagerFactory * s_RenderingManagerFactory
Definition: mitkRenderingManager.h:426
mitk::RenderingManager::StartOrResetTimer
virtual void StartOrResetTimer()
Definition: mitkRenderingManager.h:301
MitkCoreExports.h
mitk::BaseGeometry
BaseGeometry Describes the geometry of a data object.
Definition: mitkBaseGeometry.h:94
mitk::RenderingManager::FloatVector
std::vector< float > FloatVector
Definition: mitkRenderingManager.h:80
mitk::RenderingManager::m_LODAbortMechanismEnabled
bool m_LODAbortMechanismEnabled
Definition: mitkRenderingManager.h:397
mitk::RenderingManager::s_Instance
static RenderingManager::Pointer s_Instance
Definition: mitkRenderingManager.h:425
mitkPropertyList.h
mitk::RenderingManager::m_RenderingAbortedMap
RendererBoolMap m_RenderingAbortedMap
Definition: mitkRenderingManager.h:389
mitk::TestingRenderingManager::GenerateRenderingRequestEvent
void GenerateRenderingRequestEvent() override
Definition: mitkRenderingManager.h:498
mitk::RenderingManager::DoStartRendering
virtual void DoStartRendering()
Definition: mitkRenderingManager.h:306
mitk::RenderingManager::m_LODIncreaseBlocked
bool m_LODIncreaseBlocked
Definition: mitkRenderingManager.h:395
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
mitk::RenderingManager::RenderWindowCallbacks
Definition: mitkRenderingManager.h:414
mitk::RenderingManager::RequestType
RequestType
Definition: mitkRenderingManager.h:85
mitk::RenderingManager::m_MaxLOD
unsigned int m_MaxLOD
Definition: mitkRenderingManager.h:393
mitk::RenderingManager::m_TimeNavigationController
itk::SmartPointer< TimeNavigationController > m_TimeNavigationController
Definition: mitkRenderingManager.h:423
mitk::RenderingManager::m_ShadingEnabled
BoolVector m_ShadingEnabled
Definition: mitkRenderingManager.h:399
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS
@ REQUEST_UPDATE_2DWINDOWS
Definition: mitkRenderingManager.h:88
mitk::BaseRenderer
Definition: mitkBaseRenderer.h:56
mitk::RenderingManagerFactory
Factory interface for facilitating the usage of a platform-specific mitk::RenderingManager instance.
Definition: mitkRenderingManagerFactory.h:40
mitk::RenderingManager::RenderWindowVector
std::vector< vtkRenderWindow * > RenderWindowVector
Definition: mitkRenderingManager.h:77
mitk::RenderingManager::m_ShadingValues
FloatVector m_ShadingValues
Definition: mitkRenderingManager.h:403
mitk::RenderingManager::m_AllRenderWindows
RenderWindowVector m_AllRenderWindows
Definition: mitkRenderingManager.h:412
mitk::RenderingManager::m_NextLODMap
RendererIntMap m_NextLODMap
Definition: mitkRenderingManager.h:391
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitkProperties.h
mitk::itkEventMacroDeclaration
itkEventMacroDeclaration(BoundingShapeInteractionEvent, itk::AnyEvent)
mitk::RenderingManager::DoMonitorRendering
virtual void DoMonitorRendering()
Definition: mitkRenderingManager.h:307
mitk::RenderingManager::m_RenderWindowCallbacksList
RenderWindowCallbacksList m_RenderWindowCallbacksList
Definition: mitkRenderingManager.h:421
mitk::RenderingManager::RendererBoolMap
std::map< BaseRenderer *, bool > RendererBoolMap
Definition: mitkRenderingManager.h:387