Medical Imaging Interaction Toolkit  2021.10.99-1c4db16f
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_HEADER_INCLUDED_C135A197
14 #define MITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197
15 
16 #include <MitkCoreExports.h>
17 
18 #include <vtkCallbackCommand.h>
19 
20 #include <itkObject.h>
21 #include <itkObjectFactory.h>
22 #include <string>
23 
24 #include "mitkProperties.h"
25 #include "mitkPropertyList.h"
26 #include "mitkTimeGeometry.h"
27 #include <mitkAntiAliasing.h>
28 
29 class vtkRenderWindow;
30 class vtkObject;
31 
32 namespace mitk
33 {
34  class RenderingManager;
35  class RenderingManagerFactory;
36  class BaseGeometry;
37  class SliceNavigationController;
38  class BaseRenderer;
39  class DataStorage;
40 
76  class MITKCORE_EXPORT RenderingManager : public itk::Object
77  {
78  public:
80 
81  typedef std::vector<vtkRenderWindow *> RenderWindowVector;
82  typedef std::vector<float> FloatVector;
83  typedef std::vector<bool> BoolVector;
84 
86 
88  {
89  REQUEST_UPDATE_ALL = 0,
91  REQUEST_UPDATE_3DWINDOWS
92  };
93 
94  static Pointer New();
95 
98  static void SetFactory(RenderingManagerFactory *factory);
99 
102  static const RenderingManagerFactory *GetFactory();
103 
105  static bool HasFactory();
106 
108  static RenderingManager *GetInstance();
109 
111  static bool IsInstantiated();
112 
115  void AddRenderWindow(vtkRenderWindow *renderWindow);
116 
118  void RemoveRenderWindow(vtkRenderWindow *renderWindow);
119 
121  const RenderWindowVector &GetAllRegisteredRenderWindows();
122 
125  void RequestUpdate(vtkRenderWindow *renderWindow);
126 
128  void ForceImmediateUpdate(vtkRenderWindow *renderWindow);
129 
133  void RequestUpdateAll(RequestType type = REQUEST_UPDATE_ALL);
134 
138  void ForceImmediateUpdateAll(RequestType type = REQUEST_UPDATE_ALL);
139 
142  // virtual bool InitializeViews( const DataStorage *storage, const DataNode* node = nullptr,
143  // RequestType type = REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace = false );
144 
149  virtual bool InitializeViews(const BaseGeometry *geometry,
150  RequestType type = REQUEST_UPDATE_ALL,
151  bool resetCamera = true);
152  virtual bool InitializeViews(const TimeGeometry *geometry,
153  RequestType type = REQUEST_UPDATE_ALL,
154  bool resetCamera = true);
155 
158  virtual bool InitializeViews(RequestType type = REQUEST_UPDATE_ALL);
159 
163  // virtual bool InitializeView( vtkRenderWindow *renderWindow, const DataStorage* ds, const DataNode* node = nullptr,
164  // bool initializeGlobalTimeSNC = false );
165 
169  virtual bool InitializeView(vtkRenderWindow *renderWindow,
170  const BaseGeometry *geometry,
171  bool initializeGlobalTimeSNC = false,
172  bool resetCamera = true);
173  virtual bool InitializeView(vtkRenderWindow *renderWindow,
174  const TimeGeometry *geometry,
175  bool initializeGlobalTimeSNC = false,
176  bool resetCamera = true);
177 
180  virtual bool InitializeView(vtkRenderWindow *renderWindow);
181 
188  virtual void InitializeViewsByBoundingObjects(const DataStorage *dataStorage);
189 
192  const SliceNavigationController *GetTimeNavigationController() const;
193 
196  SliceNavigationController *GetTimeNavigationController();
197 
198  ~RenderingManager() override;
199 
203  virtual void ExecutePendingRequests();
204 
205  bool IsRendering() const;
206  void AbortRendering();
207 
209  itkSetMacro(LODIncreaseBlocked, bool);
210 
212  itkGetMacro(LODIncreaseBlocked, bool);
213 
215  itkBooleanMacro(LODIncreaseBlocked);
216 
218  itkSetMacro(LODAbortMechanismEnabled, bool);
219 
221  itkGetMacro(LODAbortMechanismEnabled, bool);
222 
224  itkBooleanMacro(LODAbortMechanismEnabled);
225 
227  virtual void StartOrResetTimer(){};
228 
230  void ExecutePendingHighResRenderingRequest();
231 
232  virtual void DoStartRendering(){};
233  virtual void DoMonitorRendering(){};
234  virtual void DoFinishAbortRendering(){};
235 
236  int GetNextLOD(BaseRenderer *renderer);
237 
239  void SetMaximumLOD(unsigned int max);
240 
241  void SetShading(bool state, unsigned int lod);
242  bool GetShading(unsigned int lod);
243 
244  void SetClippingPlaneStatus(bool status);
245  bool GetClippingPlaneStatus();
246 
247  void SetShadingValues(float ambient, float diffuse, float specular, float specpower);
248 
249  FloatVector &GetShadingValues();
250 
252  PropertyList::Pointer GetPropertyList() const;
253 
255  BaseProperty *GetProperty(const char *propertyKey) const;
256 
258  void SetProperty(const char *propertyKey, BaseProperty *propertyValue);
259 
270  void SetDataStorage(mitk::DataStorage *storage);
271 
282  mitk::DataStorage *GetDataStorage();
283 
288  void SetRenderWindowFocus(vtkRenderWindow *focusWindow);
289 
290  itkGetMacro(FocusedRenderWindow, vtkRenderWindow *);
291 
292  itkSetMacro(ConstrainedPanningZooming, bool);
293 
294  itkGetMacro(AntiAliasing, AntiAliasing);
295 
296  void SetAntiAliasing(AntiAliasing antiAliasing);
297 
298  protected:
299  enum
300  {
301  RENDERING_INACTIVE = 0,
303  RENDERING_INPROGRESS
304  };
305 
307 
310  virtual void GenerateRenderingRequestEvent() = 0;
311 
312  virtual void InitializePropertyList();
313 
315 
316  typedef std::map<BaseRenderer *, unsigned int> RendererIntMap;
317  typedef std::map<BaseRenderer *, bool> RendererBoolMap;
318 
319  RendererBoolMap m_RenderingAbortedMap;
320 
321  RendererIntMap m_NextLODMap;
322 
323  unsigned int m_MaxLOD;
324 
326 
328 
329  BoolVector m_ShadingEnabled;
330 
332 
333  FloatVector m_ShadingValues;
334 
335  static void RenderingStartCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
336  static void RenderingProgressCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
337  static void RenderingEndCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
338 
339  typedef std::map<vtkRenderWindow *, int> RenderWindowList;
340 
341  RenderWindowList m_RenderWindowList;
342  RenderWindowVector m_AllRenderWindows;
343 
345  {
346  vtkCallbackCommand *commands[3u];
347  };
348 
349  typedef std::map<vtkRenderWindow *, RenderWindowCallbacks> RenderWindowCallbacksList;
350 
351  RenderWindowCallbacksList m_RenderWindowCallbacksList;
352 
354 
357 
359 
360  DataStoragePointer m_DataStorage;
361 
363 
364  private:
365  void InternalViewInitialization(mitk::BaseRenderer *baseRenderer,
366  const mitk::TimeGeometry *geometry,
367  bool boundingBoxInitialized,
368  int mapperID,
369  bool resetCamera);
370 
371  vtkRenderWindow *m_FocusedRenderWindow;
372  AntiAliasing m_AntiAliasing;
373  };
374 
375 #pragma GCC visibility push(default)
376 
377  itkEventMacro(RenderingManagerEvent, itk::AnyEvent);
378  itkEventMacro(RenderingManagerViewsInitializedEvent, RenderingManagerEvent);
379 
380 #pragma GCC visibility pop
381 
382  itkEventMacroDeclaration(FocusChangedEvent, itk::AnyEvent);
383 
392  {
393  public:
395  itkFactorylessNewMacro(Self);
396  itkCloneMacro(Self);
397 
398  protected:
399 
400  void GenerateRenderingRequestEvent() override {};
401  };
402 
403 } // namespace mitk
404 
405 #endif /* MITKRenderingManager_H_HEADER_INCLUDED_C135A197 */
RenderWindowList m_RenderWindowList
Data management class that handles &#39;was created by&#39; relations.
itk::SmartPointer< DataStorage > DataStoragePointer
#define MITKCORE_EXPORT
itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent)
RendererBoolMap m_RenderingAbortedMap
static RenderingManager::Pointer s_Instance
std::vector< float > FloatVector
itkEventMacroDeclaration(FocusChangedEvent, itk::AnyEvent)
Organizes the rendering process.
DataCollection - Class to facilitate loading/accessing structured data.
static RenderingManagerFactory * s_RenderingManagerFactory
RenderWindowVector m_AllRenderWindows
Controls the selection of the slice the associated BaseRenderer will display.
Abstract base class for properties.
Manager for coordinating the rendering process.
RenderWindowCallbacksList m_RenderWindowCallbacksList
std::map< vtkRenderWindow *, int > RenderWindowList
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
Factory interface for facilitating the usage of a platform-specific mitk::RenderingManager instance...
DataStoragePointer m_DataStorage
std::vector< vtkRenderWindow * > RenderWindowVector
std::map< BaseRenderer *, unsigned int > RendererIntMap
std::map< vtkRenderWindow *, RenderWindowCallbacks > RenderWindowCallbacksList
PropertyList::Pointer m_PropertyList
virtual void DoFinishAbortRendering()
BaseGeometry Describes the geometry of a data object.
std::vector< bool > BoolVector
std::map< BaseRenderer *, bool > RendererBoolMap
itk::SmartPointer< SliceNavigationController > m_TimeNavigationController