Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197
18 #define MITKRENDERINGMANAGER_H_HEADER_INCLUDED_C135A197
19 
20 #include <MitkCoreExports.h>
21 
22 #include <vtkCallbackCommand.h>
23 
24 #include <itkObject.h>
25 #include <itkObjectFactory.h>
26 #include <string>
27 
28 #include "mitkProperties.h"
29 #include "mitkPropertyList.h"
30 #include "mitkTimeGeometry.h"
31 
32 class vtkRenderWindow;
33 class vtkObject;
34 
35 namespace mitk
36 {
37  class RenderingManager;
38  class RenderingManagerFactory;
39  class BaseGeometry;
40  class SliceNavigationController;
41  class BaseRenderer;
42  class DataStorage;
43 
79  class MITKCORE_EXPORT RenderingManager : public itk::Object
80  {
81  public:
83 
84  typedef std::vector<vtkRenderWindow *> RenderWindowVector;
85  typedef std::vector<float> FloatVector;
86  typedef std::vector<bool> BoolVector;
87 
89 
91  {
92  REQUEST_UPDATE_ALL = 0,
94  REQUEST_UPDATE_3DWINDOWS
95  };
96 
97  static Pointer New();
98 
101  static void SetFactory(RenderingManagerFactory *factory);
102 
105  static const RenderingManagerFactory *GetFactory();
106 
108  static bool HasFactory();
109 
111  static RenderingManager *GetInstance();
112 
114  static bool IsInstantiated();
115 
118  void AddRenderWindow(vtkRenderWindow *renderWindow);
119 
121  void RemoveRenderWindow(vtkRenderWindow *renderWindow);
122 
124  const RenderWindowVector &GetAllRegisteredRenderWindows();
125 
128  void RequestUpdate(vtkRenderWindow *renderWindow);
129 
131  void ForceImmediateUpdate(vtkRenderWindow *renderWindow);
132 
136  void RequestUpdateAll(RequestType type = REQUEST_UPDATE_ALL);
137 
141  void ForceImmediateUpdateAll(RequestType type = REQUEST_UPDATE_ALL);
142 
145  // virtual bool InitializeViews( const DataStorage *storage, const DataNode* node = NULL,
146  // RequestType type = REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace = false );
147 
152  virtual bool InitializeViews(const BaseGeometry *geometry,
153  RequestType type = REQUEST_UPDATE_ALL,
154  bool preserveRoughOrientationInWorldSpace = false);
155  virtual bool InitializeViews(const TimeGeometry *geometry,
156  RequestType type = REQUEST_UPDATE_ALL,
157  bool preserveRoughOrientationInWorldSpace = false);
158 
161  virtual bool InitializeViews(RequestType type = REQUEST_UPDATE_ALL);
162 
166  // virtual bool InitializeView( vtkRenderWindow *renderWindow, const DataStorage* ds, const DataNode* node = NULL,
167  // bool initializeGlobalTimeSNC = false );
168 
172  virtual bool InitializeView(vtkRenderWindow *renderWindow,
173  const BaseGeometry *geometry,
174  bool initializeGlobalTimeSNC = false);
175  virtual bool InitializeView(vtkRenderWindow *renderWindow,
176  const TimeGeometry *geometry,
177  bool initializeGlobalTimeSNC = false);
178 
181  virtual bool InitializeView(vtkRenderWindow *renderWindow);
182 
189  virtual void InitializeViewsByBoundingObjects(const DataStorage *);
190 
193  const SliceNavigationController *GetTimeNavigationController() const;
194 
197  SliceNavigationController *GetTimeNavigationController();
198 
199  virtual ~RenderingManager();
200 
204  virtual void ExecutePendingRequests();
205 
206  bool IsRendering() const;
207  void AbortRendering();
208 
210  itkSetMacro(LODIncreaseBlocked, bool);
211 
213  itkGetMacro(LODIncreaseBlocked, bool);
214 
216  itkBooleanMacro(LODIncreaseBlocked);
217 
219  itkSetMacro(LODAbortMechanismEnabled, bool);
220 
222  itkGetMacro(LODAbortMechanismEnabled, bool);
223 
225  itkBooleanMacro(LODAbortMechanismEnabled);
226 
228  virtual void StartOrResetTimer(){};
229 
231  void ExecutePendingHighResRenderingRequest();
232 
233  virtual void DoStartRendering(){};
234  virtual void DoMonitorRendering(){};
235  virtual void DoFinishAbortRendering(){};
236 
237  int GetNextLOD(BaseRenderer *renderer);
238 
240  void SetMaximumLOD(unsigned int max);
241 
242  void SetShading(bool state, unsigned int lod);
243  bool GetShading(unsigned int lod);
244 
245  void SetClippingPlaneStatus(bool status);
246  bool GetClippingPlaneStatus();
247 
248  void SetShadingValues(float ambient, float diffuse, float specular, float specpower);
249 
250  FloatVector &GetShadingValues();
251 
253  PropertyList::Pointer GetPropertyList() const;
254 
256  BaseProperty *GetProperty(const char *propertyKey) const;
257 
259  void SetProperty(const char *propertyKey, BaseProperty *propertyValue);
260 
271  void SetDataStorage(mitk::DataStorage *storage);
272 
284 
289  void SetRenderWindowFocus(vtkRenderWindow *focusWindow);
290 
291  itkGetMacro(FocusedRenderWindow, vtkRenderWindow *)
292 
293  itkSetMacro(ConstrainedPanningZooming, bool);
294 
295  protected:
296  enum
297  {
298  RENDERING_INACTIVE = 0,
300  RENDERING_INPROGRESS
301  };
302 
304 
307  virtual void GenerateRenderingRequestEvent() = 0;
308 
309  virtual void InitializePropertyList();
310 
312 
313  typedef std::map<BaseRenderer *, unsigned int> RendererIntMap;
314  typedef std::map<BaseRenderer *, bool> RendererBoolMap;
315 
316  RendererBoolMap m_RenderingAbortedMap;
317 
318  RendererIntMap m_NextLODMap;
319 
320  unsigned int m_MaxLOD;
321 
323 
325 
326  BoolVector m_ShadingEnabled;
327 
329 
330  FloatVector m_ShadingValues;
331 
332  static void RenderingStartCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
333  static void RenderingProgressCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
334  static void RenderingEndCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata);
335 
336  typedef std::map<vtkRenderWindow *, int> RenderWindowList;
337 
338  RenderWindowList m_RenderWindowList;
339  RenderWindowVector m_AllRenderWindows;
340 
342  {
343  vtkCallbackCommand *commands[3u];
344  };
345 
346  typedef std::map<vtkRenderWindow *, RenderWindowCallbacks> RenderWindowCallbacksList;
347 
348  RenderWindowCallbacksList m_RenderWindowCallbacksList;
349 
351 
354 
356 
357  DataStoragePointer m_DataStorage;
358 
360 
361  private:
362  void InternalViewInitialization(mitk::BaseRenderer *baseRenderer,
363  const mitk::TimeGeometry *geometry,
364  bool boundingBoxInitialized,
365  int mapperID);
366 
367  vtkRenderWindow *m_FocusedRenderWindow;
368  };
369 
370 #pragma GCC visibility push(default)
371 
372  itkEventMacro(RenderingManagerEvent, itk::AnyEvent);
373  itkEventMacro(RenderingManagerViewsInitializedEvent, RenderingManagerEvent);
374 
375 #pragma GCC visibility pop
376 
377  itkEventMacroDeclaration(FocusChangedEvent, itk::AnyEvent)
378 
379 
386  class MITKCORE_EXPORT TestingRenderingManager : public RenderingManager
387  {
388  public:
389  mitkClassMacro(TestingRenderingManager, RenderingManager);
390  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
391 
392  protected : virtual void GenerateRenderingRequestEvent() override{
393  // ForceImmediateUpdateAll();
394  };
395  };
396 
397 } // namespace mitk
398 
399 #endif /* MITKRenderingManager_H_HEADER_INCLUDED_C135A197 */
itkEventMacroDeclaration(OverlayAddEvent, itk::AnyEvent) class BaseRenderer
RenderWindowList m_RenderWindowList
Data management class that handles 'was created by' relations.
itk::SmartPointer< DataStorage > DataStoragePointer
#define MITKCORE_EXPORT
RendererBoolMap m_RenderingAbortedMap
static RenderingManager::Pointer s_Instance
std::vector< float > FloatVector
Organizes the rendering process.
DataCollection - Class to facilitate loading/accessing structured data.
static mitk::DataStorage::Pointer GetDataStorage()
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:44
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
virtual void GenerateRenderingRequestEvent() override
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:70
std::vector< vtkRenderWindow * > RenderWindowVector
std::map< BaseRenderer *, unsigned int > RendererIntMap
itkEventMacro(ContourModelEvent, itk::AnyEvent)
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
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.