Medical Imaging Interaction Toolkit  2018.4.99-f51274ea
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 preserveRoughOrientationInWorldSpace = false);
152  virtual bool InitializeViews(const TimeGeometry *geometry,
153  RequestType type = REQUEST_UPDATE_ALL,
154  bool preserveRoughOrientationInWorldSpace = false);
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  virtual bool InitializeView(vtkRenderWindow *renderWindow,
173  const TimeGeometry *geometry,
174  bool initializeGlobalTimeSNC = false);
175 
178  virtual bool InitializeView(vtkRenderWindow *renderWindow);
179 
186  virtual void InitializeViewsByBoundingObjects(const DataStorage *);
187 
190  const SliceNavigationController *GetTimeNavigationController() const;
191 
194  SliceNavigationController *GetTimeNavigationController();
195 
196  ~RenderingManager() override;
197 
201  virtual void ExecutePendingRequests();
202 
203  bool IsRendering() const;
204  void AbortRendering();
205 
207  itkSetMacro(LODIncreaseBlocked, bool);
208 
210  itkGetMacro(LODIncreaseBlocked, bool);
211 
213  itkBooleanMacro(LODIncreaseBlocked);
214 
216  itkSetMacro(LODAbortMechanismEnabled, bool);
217 
219  itkGetMacro(LODAbortMechanismEnabled, bool);
220 
222  itkBooleanMacro(LODAbortMechanismEnabled);
223 
225  virtual void StartOrResetTimer(){};
226 
228  void ExecutePendingHighResRenderingRequest();
229 
230  virtual void DoStartRendering(){};
231  virtual void DoMonitorRendering(){};
232  virtual void DoFinishAbortRendering(){};
233 
234  int GetNextLOD(BaseRenderer *renderer);
235 
237  void SetMaximumLOD(unsigned int max);
238 
239  void SetShading(bool state, unsigned int lod);
240  bool GetShading(unsigned int lod);
241 
242  void SetClippingPlaneStatus(bool status);
243  bool GetClippingPlaneStatus();
244 
245  void SetShadingValues(float ambient, float diffuse, float specular, float specpower);
246 
247  FloatVector &GetShadingValues();
248 
250  PropertyList::Pointer GetPropertyList() const;
251 
253  BaseProperty *GetProperty(const char *propertyKey) const;
254 
256  void SetProperty(const char *propertyKey, BaseProperty *propertyValue);
257 
268  void SetDataStorage(mitk::DataStorage *storage);
269 
280  mitk::DataStorage *GetDataStorage();
281 
286  void SetRenderWindowFocus(vtkRenderWindow *focusWindow);
287 
288  itkGetMacro(FocusedRenderWindow, vtkRenderWindow *);
289 
290  itkSetMacro(ConstrainedPanningZooming, bool);
291 
292  itkGetMacro(AntiAliasing, AntiAliasing);
293 
294  void SetAntiAliasing(AntiAliasing antiAliasing);
295 
296  protected:
297  enum
298  {
299  RENDERING_INACTIVE = 0,
301  RENDERING_INPROGRESS
302  };
303 
305 
308  virtual void GenerateRenderingRequestEvent() = 0;
309 
310  virtual void InitializePropertyList();
311 
313 
314  typedef std::map<BaseRenderer *, unsigned int> RendererIntMap;
315  typedef std::map<BaseRenderer *, bool> RendererBoolMap;
316 
317  RendererBoolMap m_RenderingAbortedMap;
318 
319  RendererIntMap m_NextLODMap;
320 
321  unsigned int m_MaxLOD;
322 
324 
326 
327  BoolVector m_ShadingEnabled;
328 
330 
331  FloatVector m_ShadingValues;
332 
333  static void RenderingStartCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
334  static void RenderingProgressCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
335  static void RenderingEndCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
336 
337  typedef std::map<vtkRenderWindow *, int> RenderWindowList;
338 
339  RenderWindowList m_RenderWindowList;
340  RenderWindowVector m_AllRenderWindows;
341 
343  {
344  vtkCallbackCommand *commands[3u];
345  };
346 
347  typedef std::map<vtkRenderWindow *, RenderWindowCallbacks> RenderWindowCallbacksList;
348 
349  RenderWindowCallbacksList m_RenderWindowCallbacksList;
350 
352 
355 
357 
358  DataStoragePointer m_DataStorage;
359 
361 
362  private:
363  void InternalViewInitialization(mitk::BaseRenderer *baseRenderer,
364  const mitk::TimeGeometry *geometry,
365  bool boundingBoxInitialized,
366  int mapperID);
367 
368  vtkRenderWindow *m_FocusedRenderWindow;
369  AntiAliasing m_AntiAliasing;
370  };
371 
372 #pragma GCC visibility push(default)
373 
374  itkEventMacro(RenderingManagerEvent, itk::AnyEvent);
375  itkEventMacro(RenderingManagerViewsInitializedEvent, RenderingManagerEvent);
376 
377 #pragma GCC visibility pop
378 
379  itkEventMacroDeclaration(FocusChangedEvent, itk::AnyEvent);
380 
389  {
390  public:
392  itkFactorylessNewMacro(Self);
393  itkCloneMacro(Self);
394 
395  protected:
396 
397  void GenerateRenderingRequestEvent() override {};
398  };
399 
400 } // namespace mitk
401 
402 #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)
static RenderingManagerFactory * s_RenderingManagerFactory
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.
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:40
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:49
Factory interface for facilitating the usage of a platform-specific mitk::RenderingManager instance...
DataStoragePointer m_DataStorage
static T max(T x, T y)
Definition: svm.cpp:56
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