Medical Imaging Interaction Toolkit  2025.12.02
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 
101 
103  static bool HasFactory();
104 
107 
109  static bool IsInstantiated();
110 
113  void AddRenderWindow(vtkRenderWindow *renderWindow);
114 
116  void RemoveRenderWindow(vtkRenderWindow *renderWindow);
117 
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 
267 
271 
272  ~RenderingManager() override;
273 
277  virtual void ExecutePendingRequests();
278 
279  bool IsRendering() const;
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 
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);
320 
321  void SetShadingValues(float ambient, float diffuse, float specular, float specpower);
322 
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 
425  static RenderingManager::Pointer s_Instance;
427 
428  PropertyList::Pointer m_PropertyList;
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
#define MITKCORE_EXPORT
BaseGeometry Describes the geometry of a data object.
Abstract base class for properties.
Data management class that handles 'was created by' relations.
Factory interface for facilitating the usage of a platform-specific mitk::RenderingManager instance.
Manager for coordinating the rendering process.
void SetShadingValues(float ambient, float diffuse, float specular, float specpower)
itk::SmartPointer< DataStorage > DataStoragePointer
void SetMaximumLOD(unsigned int max)
static Pointer New()
void SetAntiAliasing(AntiAliasing antiAliasing)
virtual void ExecutePendingRequests()
BaseProperty * GetProperty(const char *propertyKey) const
itk::SmartPointer< TimeNavigationController > m_TimeNavigationController
void ExecutePendingHighResRenderingRequest()
void SetClippingPlaneStatus(bool status)
PropertyList::Pointer m_PropertyList
void RequestUpdate(vtkRenderWindow *renderWindow)
virtual void InitializeViewByBoundingObjects(vtkRenderWindow *renderWindow, const DataStorage *dataStorage, bool resetCamera=true)
Initialize the given render window by the aggregated geometry of all objects that are held in the dat...
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool resetCamera=true)
Initialize the render windows specified by "type" to the given geometry.
RenderWindowList m_RenderWindowList
TimeNavigationController * GetTimeNavigationController()
mitkClassMacroItkParent(RenderingManager, itk::Object)
virtual bool InitializeViews(RequestType type=REQUEST_UPDATE_ALL)
Initialize the render windows specified by "type" to the default viewing direction without updating t...
static RenderingManagerFactory * s_RenderingManagerFactory
static bool IsInstantiated()
DataStoragePointer m_DataStorage
const RenderWindowVector & GetAllRegisteredRenderWindows()
RendererBoolMap m_RenderingAbortedMap
virtual void GenerateRenderingRequestEvent()=0
std::vector< float > FloatVector
bool IsRendering() const
virtual void InitializeViewsByBoundingObjects(const DataStorage *dataStorage)
Initialize the render windows by the aggregated geometry of all objects that are held in the data sto...
bool GetShading(unsigned int lod)
const TimeNavigationController * GetTimeNavigationController() const
RenderWindowVector m_AllRenderWindows
void RemoveRenderWindow(vtkRenderWindow *renderWindow)
static void RenderingProgressCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
virtual void DoFinishAbortRendering()
static RenderingManager * GetInstance()
void SetRenderWindowFocus(vtkRenderWindow *focusWindow)
Sets a flag to the given renderwindow to indicated that it has the focus e.g. has been clicked recent...
std::vector< vtkRenderWindow * > RenderWindowVector
std::map< vtkRenderWindow *, RenderWindowCallbacks > RenderWindowCallbacksList
virtual bool InitializeViews(const TimeGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool resetCamera=true)
Initialize the render windows specified by "type" to the given geometry.
static const RenderingManagerFactory * GetFactory()
void SetShading(bool state, unsigned int lod)
void ForceImmediateUpdate(vtkRenderWindow *renderWindow)
void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
static void RenderingEndCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
RenderWindowCallbacksList m_RenderWindowCallbacksList
PropertyList::Pointer GetPropertyList() const
virtual bool InitializeView(vtkRenderWindow *renderWindow, const BaseGeometry *geometry, bool resetCamera=true)
Initialize the specified render window to the given geometry.
void AddRenderWindow(vtkRenderWindow *renderWindow)
void ForceImmediateUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
~RenderingManager() override
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
static bool HasFactory()
void SetDataStorage(DataStorage *storage)
Setter for internal DataStorage.
virtual bool InitializeView(vtkRenderWindow *renderWindow)
Initialize the specified render window to the default viewing direction without updating the geometry...
FloatVector & GetShadingValues()
static void RenderingStartCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
void SetConstrainedPanningZooming(bool constrain)
std::map< BaseRenderer *, bool > RendererBoolMap
std::vector< bool > BoolVector
virtual bool InitializeView(vtkRenderWindow *renderWindow, const TimeGeometry *geometry, bool resetCamera=true)
Initialize the specified render window to the given geometry.
std::map< BaseRenderer *, unsigned int > RendererIntMap
static RenderingManager::Pointer s_Instance
std::map< vtkRenderWindow *, int > RenderWindowList
int GetNextLOD(BaseRenderer *renderer)
virtual void InitializePropertyList()
static void SetFactory(RenderingManagerFactory *factory)
mitkClassMacro(TestingRenderingManager, RenderingManager)
Controls the time-related properties of the time stepper, according to the given input world time geo...
Find image slices visible on a given plane.
itkEventMacroDeclaration(BoundingShapeInteractionEvent, itk::AnyEvent)