Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkRenderingManager.cpp
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 #include "mitkRenderingManager.h"
14 #include "mitkBaseRenderer.h"
15 #include "mitkCameraController.h"
16 #include "mitkNodePredicateNot.h"
20 
21 #include <vtkRenderWindow.h>
22 #include <vtkRendererCollection.h>
23 
24 #include "mitkNumericTypes.h"
25 #include <itkAffineGeometryFrame.h>
26 #include <itkCommand.h>
27 #include <itkScalableAffineTransform.h>
28 #include <mitkVtkPropRenderer.h>
29 
30 #include <algorithm>
31 
32 namespace mitk
33 {
34  itkEventMacroDefinition(FocusChangedEvent, itk::AnyEvent);
35 
37  RenderingManagerFactory *RenderingManager::s_RenderingManagerFactory = nullptr;
38 
40  : m_UpdatePending(false),
41  m_MaxLOD(1),
42  m_LODIncreaseBlocked(false),
43  m_LODAbortMechanismEnabled(false),
44  m_ClippingPlaneEnabled(false),
46  m_DataStorage(nullptr),
47  m_ConstrainedPanningZooming(true),
48  m_FocusedRenderWindow(nullptr),
49  m_AntiAliasing(AntiAliasing::FastApproximate)
50  {
51  m_ShadingEnabled.assign(3, false);
52  m_ShadingValues.assign(4, 0.0);
53 
55  }
56 
58  {
59  // Decrease reference counts of all registered vtkRenderWindows for
60  // proper destruction
61  RenderWindowVector::iterator it;
62  for (it = m_AllRenderWindows.begin(); it != m_AllRenderWindows.end(); ++it)
63  {
64  (*it)->UnRegister(nullptr);
65 
66  auto callbacks_it = this->m_RenderWindowCallbacksList.find(*it);
67 
68  if (callbacks_it != this->m_RenderWindowCallbacksList.end())
69  {
70  (*it)->RemoveObserver(callbacks_it->second.commands[0u]);
71  (*it)->RemoveObserver(callbacks_it->second.commands[1u]);
72  (*it)->RemoveObserver(callbacks_it->second.commands[2u]);
73  }
74  }
75  }
76 
80  {
81  if (RenderingManager::s_RenderingManagerFactory)
82  {
83  return true;
84  }
85  else
86  {
87  return false;
88  }
89  }
90 
92  {
93  const RenderingManagerFactory *factory = GetFactory();
94  if (factory == nullptr)
95  return nullptr;
96  return factory->CreateRenderingManager();
97  }
98 
100  {
101  if (!RenderingManager::s_Instance)
102  {
104  {
106  }
107  }
108 
109  return s_Instance;
110  }
111 
113  {
114  if (RenderingManager::s_Instance)
115  return true;
116  else
117  return false;
118  }
119 
120  void RenderingManager::AddRenderWindow(vtkRenderWindow *renderWindow)
121  {
122  if (renderWindow && (m_RenderWindowList.find(renderWindow) == m_RenderWindowList.end()))
123  {
124  m_RenderWindowList[renderWindow] = RENDERING_INACTIVE;
125  m_AllRenderWindows.push_back(renderWindow);
126 
127  if (m_DataStorage.IsNotNull())
128  mitk::BaseRenderer::GetInstance(renderWindow)->SetDataStorage(m_DataStorage.GetPointer());
129 
130  // Register vtkRenderWindow instance
131  renderWindow->Register(nullptr);
132 
133  // Add callbacks for rendering abort mechanism
134  // BaseRenderer *renderer = BaseRenderer::GetInstance( renderWindow );
135  vtkCallbackCommand *startCallbackCommand = vtkCallbackCommand::New();
136  startCallbackCommand->SetCallback(RenderingManager::RenderingStartCallback);
137  renderWindow->AddObserver(vtkCommand::StartEvent, startCallbackCommand);
138 
139  vtkCallbackCommand *progressCallbackCommand = vtkCallbackCommand::New();
140  progressCallbackCommand->SetCallback(RenderingManager::RenderingProgressCallback);
141  renderWindow->AddObserver(vtkCommand::AbortCheckEvent, progressCallbackCommand);
142 
143  vtkCallbackCommand *endCallbackCommand = vtkCallbackCommand::New();
144  endCallbackCommand->SetCallback(RenderingManager::RenderingEndCallback);
145  renderWindow->AddObserver(vtkCommand::EndEvent, endCallbackCommand);
146 
147  RenderWindowCallbacks callbacks;
148 
149  callbacks.commands[0u] = startCallbackCommand;
150  callbacks.commands[1u] = progressCallbackCommand;
151  callbacks.commands[2u] = endCallbackCommand;
152  this->m_RenderWindowCallbacksList[renderWindow] = callbacks;
153 
154  // Delete vtk variables correctly
155  startCallbackCommand->Delete();
156  progressCallbackCommand->Delete();
157  endCallbackCommand->Delete();
158  }
159  }
160 
161  void RenderingManager::RemoveRenderWindow(vtkRenderWindow *renderWindow)
162  {
163  if (m_RenderWindowList.erase(renderWindow))
164  {
165  auto callbacks_it = this->m_RenderWindowCallbacksList.find(renderWindow);
166  if (callbacks_it != this->m_RenderWindowCallbacksList.end())
167  {
168  renderWindow->RemoveObserver(callbacks_it->second.commands[0u]);
169  renderWindow->RemoveObserver(callbacks_it->second.commands[1u]);
170  renderWindow->RemoveObserver(callbacks_it->second.commands[2u]);
171  this->m_RenderWindowCallbacksList.erase(callbacks_it);
172  }
173 
174  auto rw_it =
175  std::find(m_AllRenderWindows.begin(), m_AllRenderWindows.end(), renderWindow);
176 
177  if (rw_it != m_AllRenderWindows.cend())
178  {
179  // Decrease reference count for proper destruction
180  (*rw_it)->UnRegister(nullptr);
181  m_AllRenderWindows.erase(rw_it);
182  }
183  }
184  }
185 
187  {
188  return m_AllRenderWindows;
189  }
190 
191  void RenderingManager::RequestUpdate(vtkRenderWindow *renderWindow)
192  {
193  // If the renderWindow is not valid, we do not want to inadvertantly create
194  // an entry in the m_RenderWindowList map. It is possible if the user is
195  // regularly calling AddRenderer and RemoveRenderer for a rendering update
196  // to come into this method with a renderWindow pointer that is valid in the
197  // sense that the window does exist within the application, but that
198  // renderWindow has been temporarily removed from this RenderingManager for
199  // performance reasons.
200  if (m_RenderWindowList.find(renderWindow) == m_RenderWindowList.cend())
201  {
202  return;
203  }
204 
205  m_RenderWindowList[renderWindow] = RENDERING_REQUESTED;
206 
207  if (!m_UpdatePending)
208  {
209  m_UpdatePending = true;
211  }
212  }
213 
214  void RenderingManager::ForceImmediateUpdate(vtkRenderWindow *renderWindow)
215  {
216  // If the renderWindow is not valid, we do not want to inadvertantly create
217  // an entry in the m_RenderWindowList map. It is possible if the user is
218  // regularly calling AddRenderer and RemoveRenderer for a rendering update
219  // to come into this method with a renderWindow pointer that is valid in the
220  // sense that the window does exist within the application, but that
221  // renderWindow has been temporarily removed from this RenderingManager for
222  // performance reasons.
223  if (m_RenderWindowList.find(renderWindow) == m_RenderWindowList.cend())
224  {
225  return;
226  }
227 
228  // Erase potentially pending requests for this window
229  m_RenderWindowList[renderWindow] = RENDERING_INACTIVE;
230 
231  m_UpdatePending = false;
232 
233  // Immediately repaint this window (implementation platform specific)
234  // If the size is 0 it crashes
235  int *size = renderWindow->GetSize();
236  if (0 != size[0] && 0 != size[1])
237  {
238  // prepare the camera etc. before rendering
239  // Note: this is a very important step which should be called before the VTK render!
240  // If you modify the camera anywhere else or after the render call, the scene cannot be seen.
241  auto *vPR = dynamic_cast<mitk::VtkPropRenderer *>(mitk::BaseRenderer::GetInstance(renderWindow));
242  if (vPR)
243  vPR->PrepareRender();
244  // Execute rendering
245  renderWindow->Render();
246  }
247  }
248 
250  {
251  RenderWindowList::const_iterator it;
252  for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it)
253  {
254  int id = BaseRenderer::GetInstance(it->first)->GetMapperID();
255  if ((type == REQUEST_UPDATE_ALL) || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1)) ||
256  ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2)))
257  {
258  this->RequestUpdate(it->first);
259  }
260  }
261  }
262 
264  {
265  RenderWindowList::const_iterator it;
266  for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it)
267  {
268  int id = BaseRenderer::GetInstance(it->first)->GetMapperID();
269  if ((type == REQUEST_UPDATE_ALL) || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1)) ||
270  ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2)))
271  {
272  // Immediately repaint this window (implementation platform specific)
273  // If the size is 0, it crashes
274  this->ForceImmediateUpdate(it->first);
275  }
276  }
277  }
278 
280  {
281  if (!ds)
282  return;
283 
284  // get all nodes that have not set "includeInBoundingBox" to false
286  mitk::NodePredicateProperty::New("includeInBoundingBox", mitk::BoolProperty::New(false)));
287 
288  mitk::DataStorage::SetOfObjects::ConstPointer rs = ds->GetSubset(pred);
289  // calculate bounding geometry of these nodes
290  auto bounds = ds->ComputeBoundingGeometry3D(rs, "visible");
291 
292  // initialize the views to the bounding geometry
293  this->InitializeViews(bounds);
294  }
295 
296  // TODO_GOETZ
297  // Remove old function, so only this one is working.
299  RequestType type,
300  bool preserveRoughOrientationInWorldSpace)
301  {
303  propTimeGeometry->Initialize(dynamic_cast<BaseGeometry *>(dataGeometry->Clone().GetPointer()), 1);
304  return InitializeViews(propTimeGeometry, type, preserveRoughOrientationInWorldSpace);
305  }
306 
308  RequestType type,
309  bool /*preserveRoughOrientationInWorldSpace*/)
310  {
311  MITK_DEBUG << "initializing views";
312 
313  bool boundingBoxInitialized = false;
314 
315  TimeGeometry::ConstPointer timeGeometry = dataGeometry;
316  TimeGeometry::Pointer modifiedGeometry = nullptr;
317  if (dataGeometry != nullptr)
318  {
319  modifiedGeometry = dataGeometry->Clone();
320  }
321 
322  int warningLevel = vtkObject::GetGlobalWarningDisplay();
323  vtkObject::GlobalWarningDisplayOff();
324 
325  if ((timeGeometry.IsNotNull()) &&
326  (timeGeometry->GetBoundingBoxInWorld()->GetDiagonalLength2() > mitk::eps))
327  {
328  boundingBoxInitialized = true;
329  }
330 
331  if (timeGeometry.IsNotNull())
332  { // make sure bounding box has an extent bigger than zero in any direction
333  // clone the input geometry
334  // Old Geometry3D::Pointer modifiedGeometry = dynamic_cast<Geometry3D*>( dataGeometry->Clone().GetPointer() );
335  assert(modifiedGeometry.IsNotNull());
336  for (TimeStepType step = 0; step < modifiedGeometry->CountTimeSteps(); ++step)
337  {
338  BaseGeometry::BoundsArrayType newBounds = modifiedGeometry->GetGeometryForTimeStep(step)->GetBounds();
339  for (unsigned int dimension = 0; (2 * dimension) < newBounds.Size(); dimension++)
340  {
341  // check for equality but for an epsilon
342  if (Equal(newBounds[2 * dimension], newBounds[2 * dimension + 1]))
343  {
344  newBounds[2 * dimension + 1] += 1;
345  if (Equal(
346  newBounds[2 * dimension],
347  newBounds[2 * dimension + 1])) // newBounds will still be equal if values are beyond double precision
348  {
349  mitkThrow() << "One dimension of object data has zero length, please make sure you're not using numbers "
350  "beyond double precision as coordinates.";
351  }
352  }
353  }
354  modifiedGeometry->GetGeometryForTimeStep(step)->SetBounds(newBounds);
355  }
356  }
357 
358  timeGeometry = modifiedGeometry;
359  RenderWindowList::const_iterator it;
360  for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it)
361  {
362  mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance(it->first);
363 
365 
366  int id = baseRenderer->GetMapperID();
367  if (((type == REQUEST_UPDATE_ALL) || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1)) ||
368  ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2))))
369  {
370  this->InternalViewInitialization(baseRenderer, timeGeometry, boundingBoxInitialized, id);
371  }
372  }
373 
374  if (boundingBoxInitialized)
375  {
376  m_TimeNavigationController->SetInputWorldTimeGeometry(timeGeometry);
377  }
378  m_TimeNavigationController->Update();
379 
380  this->RequestUpdateAll(type);
381 
382  vtkObject::SetGlobalWarningDisplay(warningLevel);
383 
384  // Inform listeners that views have been initialized
385  this->InvokeEvent(mitk::RenderingManagerViewsInitializedEvent());
386 
387  return boundingBoxInitialized;
388  }
389 
391  {
392  RenderWindowList::const_iterator it;
393  for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it)
394  {
395  mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance(it->first);
396  int id = baseRenderer->GetMapperID();
397  if ((type == REQUEST_UPDATE_ALL) || ((type == REQUEST_UPDATE_2DWINDOWS) && (id == 1)) ||
398  ((type == REQUEST_UPDATE_3DWINDOWS) && (id == 2)))
399  {
401 
402  baseRenderer->GetSliceNavigationController();
403 
404  // Re-initialize view direction
406 
407  // Update the SNC
408  nc->Update();
409  }
410  }
411 
412  this->RequestUpdateAll(type);
413 
414  return true;
415  }
416 
417  bool RenderingManager::InitializeView(vtkRenderWindow *renderWindow,
418  const BaseGeometry *geometry,
419  bool initializeGlobalTimeSNC)
420  {
422  propTimeGeometry->Initialize(dynamic_cast<BaseGeometry *>(geometry->Clone().GetPointer()), 1);
423  return InitializeView(renderWindow, propTimeGeometry, initializeGlobalTimeSNC);
424  }
425 
426  bool RenderingManager::InitializeView(vtkRenderWindow *renderWindow,
427  const TimeGeometry *geometry,
428  bool initializeGlobalTimeSNC)
429  {
430  bool boundingBoxInitialized = false;
431 
432  int warningLevel = vtkObject::GetGlobalWarningDisplay();
433  vtkObject::GlobalWarningDisplayOff();
434 
435  if ((geometry != nullptr) &&
436  (geometry->GetBoundingBoxInWorld()->GetDiagonalLength2() > mitk::eps))
437  {
438  boundingBoxInitialized = true;
439  }
440 
441  mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance(renderWindow);
442 
443  int id = baseRenderer->GetMapperID();
444 
445  this->InternalViewInitialization(baseRenderer, geometry, boundingBoxInitialized, id);
446 
447  if (boundingBoxInitialized && initializeGlobalTimeSNC)
448  {
449  m_TimeNavigationController->SetInputWorldTimeGeometry(geometry);
450  }
451  m_TimeNavigationController->Update();
452 
453  this->RequestUpdate(renderWindow);
454 
455  vtkObject::SetGlobalWarningDisplay(warningLevel);
456 
457  return boundingBoxInitialized;
458  }
459 
460  bool RenderingManager::InitializeView(vtkRenderWindow *renderWindow)
461  {
462  mitk::BaseRenderer *baseRenderer = mitk::BaseRenderer::GetInstance(renderWindow);
463 
465 
466  // Re-initialize view direction
468 
469  // Update the SNC
470  nc->Update();
471 
472  this->RequestUpdate(renderWindow);
473 
474  return true;
475  }
476 
477  void RenderingManager::InternalViewInitialization(mitk::BaseRenderer *baseRenderer,
478  const mitk::TimeGeometry *geometry,
479  bool boundingBoxInitialized,
480  int mapperID)
481  {
483 
484  // Re-initialize view direction
486 
487  if (boundingBoxInitialized)
488  {
489  // Set geometry for NC
490  nc->SetInputWorldTimeGeometry(geometry);
491  nc->Update();
492 
493  if (mapperID == BaseRenderer::Standard2D)
494  {
495  // For 2D SNCs, steppers are set so that the cross is centered
496  // in the image
497  nc->GetSlice()->SetPos(nc->GetSlice()->GetSteps() / 2);
498  }
499 
500  baseRenderer->GetCameraController()->SetViewToAnterior();
501  baseRenderer->GetCameraController()->Fit();
502  }
503  else
504  {
505  nc->Update();
506  }
507  }
508 
510  {
511  return m_TimeNavigationController.GetPointer();
512  }
513 
515  {
516  return m_TimeNavigationController.GetPointer();
517  }
518 
520  {
521  m_UpdatePending = false;
522 
523  // Satisfy all pending update requests
524  RenderWindowList::const_iterator it;
525  int i = 0;
526  for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it, ++i)
527  {
528  if (it->second == RENDERING_REQUESTED)
529  {
530  this->ForceImmediateUpdate(it->first);
531  }
532  }
533  }
534 
535  void RenderingManager::RenderingStartCallback(vtkObject *caller, unsigned long, void *, void *)
536  {
537  auto renderingManager = RenderingManager::GetInstance();
538  auto renderWindow = dynamic_cast<vtkRenderWindow*>(caller);
539 
540  if (nullptr != renderWindow)
541  renderingManager->m_RenderWindowList[renderWindow] = RENDERING_INPROGRESS;
542 
543  renderingManager->m_UpdatePending = false;
544  }
545 
546  void RenderingManager::RenderingProgressCallback(vtkObject *caller, unsigned long, void *, void *)
547  {
548  auto renderingManager = RenderingManager::GetInstance();
549 
550  if (renderingManager->m_LODAbortMechanismEnabled)
551  {
552  auto renderWindow = dynamic_cast<vtkRenderWindow *>(caller);
553 
554  if (nullptr != renderWindow)
555  {
556  auto renderer = BaseRenderer::GetInstance(renderWindow);
557 
558  if (nullptr != renderer && 0 < renderer->GetNumberOfVisibleLODEnabledMappers())
559  renderingManager->DoMonitorRendering();
560  }
561  }
562  }
563 
564  void RenderingManager::RenderingEndCallback(vtkObject *caller, unsigned long, void *, void *)
565  {
566  auto renderWindow = dynamic_cast<vtkRenderWindow*>(caller);
567 
568  if (nullptr != renderWindow)
569  {
570  auto renderer = BaseRenderer::GetInstance(renderWindow);
571 
572  if (nullptr != renderer)
573  {
574  auto renderingManager = RenderingManager::GetInstance();
575  renderingManager->m_RenderWindowList[renderer->GetRenderWindow()] = RENDERING_INACTIVE;
576 
577  if (0 < renderer->GetNumberOfVisibleLODEnabledMappers())
578  {
579  if (0 == renderingManager->m_NextLODMap[renderer])
580  {
581  renderingManager->StartOrResetTimer();
582  }
583  else
584  {
585  renderingManager->m_NextLODMap[renderer] = 0;
586  }
587  }
588  }
589  }
590  }
591 
593  {
594  RenderWindowList::const_iterator it;
595  for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it)
596  {
597  if (it->second == RENDERING_INPROGRESS)
598  {
599  return true;
600  }
601  }
602  return false;
603  }
604 
606  {
607  RenderWindowList::const_iterator it;
608  for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it)
609  {
610  if (it->second == RENDERING_INPROGRESS)
611  {
612  it->first->SetAbortRender(true);
614  }
615  }
616  }
617 
619  {
620  if (renderer != nullptr)
621  {
622  return m_NextLODMap[renderer];
623  }
624  else
625  {
626  return 0;
627  }
628  }
629 
631  {
632  RenderWindowList::const_iterator it;
633  for (it = m_RenderWindowList.cbegin(); it != m_RenderWindowList.cend(); ++it)
634  {
635  BaseRenderer *renderer = BaseRenderer::GetInstance(it->first);
636 
637  if (renderer->GetNumberOfVisibleLODEnabledMappers() > 0)
638  {
639  if (m_NextLODMap[renderer] == 0)
640  {
641  m_NextLODMap[renderer] = 1;
642  RequestUpdate(it->first);
643  }
644  }
645  }
646  }
647 
649  // enable/disable shading
650  void RenderingManager::SetShading(bool state, unsigned int lod)
651  {
652  if (lod > m_MaxLOD)
653  {
654  itkWarningMacro(<< "LOD out of range requested: " << lod << " maxLOD: " << m_MaxLOD);
655  return;
656  }
657  m_ShadingEnabled[lod] = state;
658  }
659 
660  bool RenderingManager::GetShading(unsigned int lod)
661  {
662  if (lod > m_MaxLOD)
663  {
664  itkWarningMacro(<< "LOD out of range requested: " << lod << " maxLOD: " << m_MaxLOD);
665  return false;
666  }
667  return m_ShadingEnabled[lod];
668  }
669 
670  // enable/disable the clipping plane
673  void RenderingManager::SetShadingValues(float ambient, float diffuse, float specular, float specpower)
674  {
675  m_ShadingValues[0] = ambient;
676  m_ShadingValues[1] = diffuse;
677  m_ShadingValues[2] = specular;
678  m_ShadingValues[3] = specpower;
679  }
680 
683  {
684  if (m_PropertyList.IsNull())
685  {
687  }
688 
689  this->SetProperty("coupled-zoom", BoolProperty::New(false));
690  this->SetProperty("coupled-plane-rotation", BoolProperty::New(false));
691  this->SetProperty("MIP-slice-rendering", BoolProperty::New(false));
692  }
693 
695  BaseProperty *RenderingManager::GetProperty(const char *propertyKey) const
696  {
697  return m_PropertyList->GetProperty(propertyKey);
698  }
699 
700  void RenderingManager::SetProperty(const char *propertyKey, BaseProperty *propertyValue)
701  {
702  m_PropertyList->SetProperty(propertyKey, propertyValue);
703  }
704 
706  {
707  if (storage != nullptr)
708  {
709  m_DataStorage = storage;
710 
711  RenderingManager::RenderWindowVector::const_iterator iter;
712  for (iter = m_AllRenderWindows.cbegin(); iter < m_AllRenderWindows.cend(); ++iter)
713  {
715  }
716  }
717  }
718 
720  void RenderingManager::SetRenderWindowFocus(vtkRenderWindow *focusWindow)
721  {
722  if (focusWindow != m_FocusedRenderWindow)
723  {
724  if (!focusWindow || (m_RenderWindowList.find(focusWindow) != m_RenderWindowList.cend()))
725  {
726  m_FocusedRenderWindow = focusWindow;
727  this->InvokeEvent(FocusChangedEvent());
728  return;
729  }
730 
731  MITK_ERROR << "Tried to set a RenderWindow that does not exist.";
732  }
733  }
734 
736  {
737  if (m_AntiAliasing != antiAliasing)
738  {
739  auto renderingManager = mitk::RenderingManager::GetInstance();
740  auto renderWindows = renderingManager->GetAllRegisteredRenderWindows();
741 
742  for (auto renderWindow : renderWindows)
743  {
744  auto renderers = renderWindow->GetRenderers();
745 
746  if (nullptr != renderers)
747  {
748  renderers->InitTraversal();
749  auto renderer = renderers->GetNextItem();
750 
751  while (nullptr != renderer)
752  {
753  renderer->SetUseFXAA(AntiAliasing::FastApproximate == antiAliasing);
754  renderer = renderers->GetNextItem();
755  }
756 
757  renderingManager->RequestUpdate(renderWindow);
758  }
759  }
760 
761  m_AntiAliasing = antiAliasing;
762  }
763  }
764 
765  // Create and register generic RenderingManagerFactory.
767 } // namespace
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
static const RenderingManagerFactory * GetFactory()
mitk::Stepper * GetSlice()
Get the Stepper through the slices.
BoundingBox * GetBoundingBoxInWorld() const
Returns a bounding box that covers all time steps.
RenderWindowList m_RenderWindowList
static void RenderingStartCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Data management class that handles &#39;was created by&#39; relations.
unsigned int GetNumberOfVisibleLODEnabledMappers() const
static Pointer New()
BoundingBoxType::BoundsArrayType BoundsArrayType
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
itkEventMacroDefinition(FocusChangedEvent, itk::AnyEvent)
void RemoveRenderWindow(vtkRenderWindow *renderWindow)
static RenderingManagerFactory * s_RenderingManagerFactory
RendererBoolMap m_RenderingAbortedMap
static void RenderingProgressCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry)
virtual void GenerateRenderingRequestEvent()=0
#define MITK_ERROR
Definition: mitkLogMacros.h:20
virtual void SetConstrainZoomingAndPanning(bool constrain)
TimeGeometry::ConstPointer ComputeBoundingGeometry3D(const SetOfObjects *input, const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry of the input objects.
virtual void SetDataStorage(DataStorage *storage)
set the datastorage that will be used for rendering
static RenderingManager::Pointer s_Instance
void SetMaximumLOD(unsigned int max)
std::vector< float > FloatVector
void SetAntiAliasing(AntiAliasing antiAliasing)
Organizes the rendering process.
PropertyList::Pointer GetPropertyList() const
#define MITK_DEBUG
Definition: mitkLogMacros.h:22
Pointer Clone() const
DataCollection - Class to facilitate loading/accessing structured data.
void SetClippingPlaneStatus(bool status)
RenderWindowVector m_AllRenderWindows
const SliceNavigationController * GetTimeNavigationController() const
itk::SmartPointer< Self > Pointer
Controls the selection of the slice the associated BaseRenderer will display.
static Pointer New()
Abstract base class for properties.
void SetProperty(const char *propertyKey, BaseProperty *propertyValue)
mitk::DataStorage::Pointer m_DataStorage
void SetRenderWindowFocus(vtkRenderWindow *focusWindow)
Sets a flag to the given renderwindow to indicated that it has the focus e.g. has been clicked recent...
Manager for coordinating the rendering process.
RenderWindowCallbacksList m_RenderWindowCallbacksList
void SetShadingValues(float ambient, float diffuse, float specular, float specpower)
static RenderingManager * GetInstance()
virtual CameraController * GetCameraController()
#define mitkThrow()
SetOfObjects::ConstPointer GetSubset(const NodePredicateBase *condition) const
returns a set of data objects that meet the given condition(s)
Factory interface for facilitating the usage of a platform-specific mitk::RenderingManager instance...
static Pointer New(const mitk::NodePredicateBase *_arg)
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
DataStoragePointer m_DataStorage
void SetDataStorage(mitk::DataStorage *storage)
Setter / Getter for internal DataStorage.
std::vcl_size_t TimeStepType
virtual void SetPos(unsigned int pos)
Definition: mitkStepper.h:55
void ForceImmediateUpdate(vtkRenderWindow *renderWindow)
static T max(T x, T y)
Definition: svm.cpp:56
std::vector< vtkRenderWindow * > RenderWindowVector
int GetNextLOD(BaseRenderer *renderer)
static Pointer New(const char *_arg)
virtual RenderingManager::Pointer CreateRenderingManager() const =0
Factory method to create platform specific instances of RenderingManager.
BaseProperty * GetProperty(const char *propertyKey) const
bool GetShading(unsigned int lod)
void RequestUpdate(vtkRenderWindow *renderWindow)
virtual void PrepareRender()
This methods contains all method neceassary before a VTK Render() call.
void AddRenderWindow(vtkRenderWindow *renderWindow)
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
void ForceImmediateUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
void SetShading(bool state, unsigned int lod)
PropertyList::Pointer m_PropertyList
MITKCORE_EXPORT const ScalarType eps
TestingRenderingManagerFactory renderingManagerFactory
virtual unsigned int GetSteps() const
virtual SliceNavigationController * GetSliceNavigationController()
static void RenderingEndCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
mitk::SliceNavigationController * m_TimeNavigationController
Pointer Clone() const
static void SetFactory(RenderingManagerFactory *factory)
mitk::DataStorage * GetDataStorage()
Setter / Getter for internal DataStorage.
void Fit()
Fit Adjust the camera, so that the world bounding box is fully visible.
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
virtual void Update()
Do the actual creation and send it to the connected observers (renderers)
virtual bool InitializeView(vtkRenderWindow *renderWindow, const BaseGeometry *geometry, bool initializeGlobalTimeSNC=false)
const RenderWindowVector & GetAllRegisteredRenderWindows()
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
BaseGeometry Describes the geometry of a data object.
itk::SmartPointer< SliceNavigationController > m_TimeNavigationController