Medical Imaging Interaction Toolkit  2018.4.99-07c45cb1
Medical Imaging Interaction Toolkit
mitkBaseRenderer.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 "mitkBaseRenderer.h"
14 #include "mitkMapper.h"
16 
17 // Geometries
18 #include "mitkPlaneGeometry.h"
19 #include "mitkSlicedGeometry3D.h"
20 
21 // Controllers
22 #include "mitkCameraController.h"
25 
26 #include "mitkVtkLayerController.h"
27 
28 #include "mitkInteractionConst.h"
29 #include "mitkProperties.h"
31 
32 // VTK
33 #include <vtkCamera.h>
34 #include <vtkLinearTransform.h>
35 #include <vtkRenderWindow.h>
36 #include <vtkRenderer.h>
37 
38 #include <vtkActor.h>
39 #include <vtkPolyDataMapper.h>
40 #include <vtkProperty.h>
41 
43 
45 {
46  for (auto mapit = baseRendererMap.begin(); mapit != baseRendererMap.end(); ++mapit)
47  {
48  if ((*mapit).first == renWin)
49  return (*mapit).second;
50  }
51  return nullptr;
52 }
53 
54 void mitk::BaseRenderer::AddInstance(vtkRenderWindow *renWin, BaseRenderer *baseRenderer)
55 {
56  if (renWin == nullptr || baseRenderer == nullptr)
57  return;
58 
59  // ensure that no BaseRenderer is managed twice
61 
62  baseRendererMap.insert(BaseRendererMapType::value_type(renWin, baseRenderer));
63 }
64 
65 void mitk::BaseRenderer::RemoveInstance(vtkRenderWindow *renWin)
66 {
67  auto mapit = baseRendererMap.find(renWin);
68  if (mapit != baseRendererMap.end())
69  baseRendererMap.erase(mapit);
70 }
71 
73 {
74  for (auto mapit = baseRendererMap.begin(); mapit != baseRendererMap.end(); ++mapit)
75  {
76  if ((*mapit).second->m_Name == name)
77  return (*mapit).second;
78  }
79  return nullptr;
80 }
81 
82 vtkRenderWindow *mitk::BaseRenderer::GetRenderWindowByName(const std::string &name)
83 {
84  for (auto mapit = baseRendererMap.begin(); mapit != baseRendererMap.end(); ++mapit)
85  {
86  if ((*mapit).second->m_Name == name)
87  return (*mapit).first;
88  }
89  return nullptr;
90 }
91 
93  vtkRenderWindow *renWin)
94  : m_RenderWindow(nullptr),
95  m_VtkRenderer(nullptr),
97  m_DataStorage(nullptr),
99  m_CameraController(nullptr),
102  m_WorldTimeGeometry(nullptr),
103  m_CurrentWorldGeometry(nullptr),
104  m_CurrentWorldPlaneGeometry(nullptr),
105  m_Slice(0),
106  m_TimeStep(),
107  m_CurrentWorldPlaneGeometryUpdateTime(),
108  m_TimeStepUpdateTime(),
109  m_KeepDisplayedRegion(true),
113  m_Name(name),
114  m_EmptyWorldGeometry(true),
116 {
117  m_Bounds[0] = 0;
118  m_Bounds[1] = 0;
119  m_Bounds[2] = 0;
120  m_Bounds[3] = 0;
121  m_Bounds[4] = 0;
122  m_Bounds[5] = 0;
123 
124  if (name != nullptr)
125  {
126  m_Name = name;
127  }
128  else
129  {
130  m_Name = "unnamed renderer";
131  itkWarningMacro(<< "Created unnamed renderer. Bad for serialization. Please choose a name.");
132  }
133 
134  if (renWin != nullptr)
135  {
136  m_RenderWindow = renWin;
137  m_RenderWindow->Register(nullptr);
138  }
139  else
140  {
141  itkWarningMacro(<< "Created mitkBaseRenderer without vtkRenderWindow present.");
142  }
143  // instances.insert( this );
144 
145  // adding this BaseRenderer to the List of all BaseRenderer
146 
147  m_BindDispatcherInteractor = new mitk::BindDispatcherInteractor(GetName());
148 
149  WeakPointerProperty::Pointer rendererProp = WeakPointerProperty::New((itk::Object *)this);
150 
151  m_CurrentWorldPlaneGeometry = mitk::PlaneGeometry::New();
152 
154  m_CurrentWorldPlaneGeometryData->SetPlaneGeometry(m_CurrentWorldPlaneGeometry);
157  m_CurrentWorldPlaneGeometryNode->GetPropertyList()->SetProperty("renderer", rendererProp);
158  m_CurrentWorldPlaneGeometryNode->GetPropertyList()->SetProperty("layer", IntProperty::New(1000));
159 
160  m_CurrentWorldPlaneGeometryNode->SetProperty("reslice.thickslices", mitk::ResliceMethodProperty::New());
161  m_CurrentWorldPlaneGeometryNode->SetProperty("reslice.thickslices.num", mitk::IntProperty::New(1));
162 
164 
166  sliceNavigationController->SetRenderer(this);
167  sliceNavigationController->ConnectGeometrySliceEvent(this);
168  sliceNavigationController->ConnectGeometryUpdateEvent(this);
169  sliceNavigationController->ConnectGeometryTimeEvent(this, false);
170  m_SliceNavigationController = sliceNavigationController;
171 
173  m_CameraRotationController->SetRenderWindow(m_RenderWindow);
174  m_CameraRotationController->AcquireCamera();
175 
177  m_CameraController->SetRenderer(this);
178 
179  m_VtkRenderer = vtkRenderer::New();
180 
181  m_VtkRenderer->UseDepthPeelingOn();
182  m_VtkRenderer->UseDepthPeelingForVolumesOn();
183  m_VtkRenderer->SetMaximumNumberOfPeels(16); // This could be made adjustable in the Preferences
184  m_VtkRenderer->SetOcclusionRatio(0.0);
185 
187  m_VtkRenderer->UseFXAAOn();
188 
191 
193 }
194 
196 {
197  if (m_VtkRenderer != nullptr)
198  {
199  m_VtkRenderer->Delete();
200  m_VtkRenderer = nullptr;
201  }
202 
203  if (m_CameraController.IsNotNull())
204  m_CameraController->SetRenderer(nullptr);
205 
207 
209 
210  m_DataStorage = nullptr;
211 
212  if (m_BindDispatcherInteractor != nullptr)
213  {
214  delete m_BindDispatcherInteractor;
215  }
216 
217  if (m_RenderWindow != nullptr)
218  {
219  m_RenderWindow->Delete();
220  m_RenderWindow = nullptr;
221  }
222 }
223 
225 {
226  this->InvokeEvent(mitk::BaseRenderer::RendererResetEvent());
227 
228  std::list<mitk::BaseLocalStorageHandler *>::iterator it;
229  for (it = m_RegisteredLocalStorageHandlers.begin(); it != m_RegisteredLocalStorageHandlers.end(); ++it)
230  (*it)->ClearLocalStorage(this, false);
232 }
233 
235 {
236  m_RegisteredLocalStorageHandlers.push_back(lsh);
237 }
238 
240 {
241  return m_BindDispatcherInteractor->GetDispatcher();
242 }
243 
245 {
247 }
248 
250 {
251  if (storage != m_DataStorage && storage != nullptr)
252  {
253  m_DataStorage = storage;
254  m_BindDispatcherInteractor->SetDataStorage(m_DataStorage);
255  this->Modified();
256  }
257 }
258 
260 
262 {
263 }
264 
266 {
267 }
268 
269 void mitk::BaseRenderer::Resize(int w, int h)
270 {
271  this->m_RenderWindow->SetSize(w, h);
272 }
273 
274 void mitk::BaseRenderer::InitRenderer(vtkRenderWindow *renderwindow)
275 {
276  if (m_RenderWindow != renderwindow)
277  {
278  if (m_RenderWindow != nullptr)
279  {
280  m_RenderWindow->Delete();
281  }
282  m_RenderWindow = renderwindow;
283  if (m_RenderWindow != nullptr)
284  {
285  m_RenderWindow->Register(nullptr);
286  }
287  }
289 
290  if (m_CameraController.IsNotNull())
291  {
292  m_CameraController->SetRenderer(this);
293  }
294 }
295 
297 {
298  this->m_RenderWindow->SetSize(w, h);
299 }
300 
301 void mitk::BaseRenderer::SetSlice(unsigned int slice)
302 {
303  if (m_Slice != slice)
304  {
305  m_Slice = slice;
306  if (m_WorldTimeGeometry.IsNotNull())
307  {
308  // get world geometry which may be rotated, for the current time step
309  SlicedGeometry3D *slicedWorldGeometry =
310  dynamic_cast<SlicedGeometry3D *>(m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep).GetPointer());
311  if (slicedWorldGeometry != nullptr)
312  {
313  // if slice position is part of the world geometry...
314  if (m_Slice >= slicedWorldGeometry->GetSlices())
315  // set the current worldplanegeomety as the selected 2D slice of the world geometry
316  m_Slice = slicedWorldGeometry->GetSlices() - 1;
317  SetCurrentWorldPlaneGeometry(slicedWorldGeometry->GetPlaneGeometry(m_Slice));
318  SetCurrentWorldGeometry(slicedWorldGeometry);
319  }
320  }
321  else
322  Modified();
323  }
324 }
325 
326 void mitk::BaseRenderer::SetTimeStep(unsigned int timeStep)
327 {
328  if (m_TimeStep != timeStep)
329  {
330  m_TimeStep = timeStep;
331  m_TimeStepUpdateTime.Modified();
332 
333  if (m_WorldTimeGeometry.IsNotNull())
334  {
335  if (m_TimeStep >= m_WorldTimeGeometry->CountTimeSteps())
336  m_TimeStep = m_WorldTimeGeometry->CountTimeSteps() - 1;
337  SlicedGeometry3D *slicedWorldGeometry =
338  dynamic_cast<SlicedGeometry3D *>(m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep).GetPointer());
339  if (slicedWorldGeometry != nullptr)
340  {
341  SetCurrentWorldPlaneGeometry(slicedWorldGeometry->GetPlaneGeometry(m_Slice));
342  SetCurrentWorldGeometry(slicedWorldGeometry);
343  }
344  }
345  else
346  Modified();
347  }
348 }
349 
351 {
352  if ((data == nullptr) || (data->IsInitialized() == false))
353  {
354  return -1;
355  }
356  return data->GetTimeGeometry()->TimePointToTimeStep(GetTime());
357 }
358 
360 {
361  if (m_WorldTimeGeometry.IsNull())
362  {
363  return 0;
364  }
365  else
366  {
367  ScalarType timeInMS = m_WorldTimeGeometry->TimeStepToTimePoint(GetTimeStep());
368  if (timeInMS == itk::NumericTraits<mitk::ScalarType>::NonpositiveMin())
369  return 0;
370  else
371  return timeInMS;
372  }
373 }
374 
376 {
377  assert(geometry != nullptr);
378 
379  itkDebugMacro("setting WorldTimeGeometry to " << geometry);
380  if (m_WorldTimeGeometry != geometry)
381  {
382  if (geometry->GetBoundingBoxInWorld()->GetDiagonalLength2() == 0)
383  return;
384 
385  m_WorldTimeGeometry = geometry;
386  itkDebugMacro("setting WorldTimeGeometry to " << m_WorldTimeGeometry);
387 
388  if (m_TimeStep >= m_WorldTimeGeometry->CountTimeSteps())
389  m_TimeStep = m_WorldTimeGeometry->CountTimeSteps() - 1;
390 
391  BaseGeometry *geometry3d;
392  geometry3d = m_WorldTimeGeometry->GetGeometryForTimeStep(m_TimeStep);
393  SetWorldGeometry3D(geometry3d);
394  }
395 }
396 
398 {
399  itkDebugMacro("setting WorldGeometry3D to " << geometry);
400 
401  if (geometry->GetBoundingBox()->GetDiagonalLength2() == 0)
402  return;
403  const SlicedGeometry3D *slicedWorldGeometry;
404  slicedWorldGeometry = dynamic_cast<const SlicedGeometry3D *>(geometry);
405 
406  PlaneGeometry::ConstPointer geometry2d;
407  if (slicedWorldGeometry != nullptr)
408  {
409  if (m_Slice >= slicedWorldGeometry->GetSlices() && (m_Slice != 0))
410  m_Slice = slicedWorldGeometry->GetSlices() - 1;
411  geometry2d = slicedWorldGeometry->GetPlaneGeometry(m_Slice);
412  if (geometry2d.IsNull())
413  {
415  plane->InitializeStandardPlane(slicedWorldGeometry);
416  geometry2d = plane;
417  }
418  SetCurrentWorldGeometry(slicedWorldGeometry);
419  }
420  else
421  {
422  geometry2d = dynamic_cast<const PlaneGeometry *>(geometry);
423  if (geometry2d.IsNull())
424  {
426  plane->InitializeStandardPlane(geometry);
427  geometry2d = plane;
428  }
429  SetCurrentWorldGeometry(geometry);
430  }
431  SetCurrentWorldPlaneGeometry(geometry2d); // calls Modified()
432 
433  if (m_CurrentWorldPlaneGeometry.IsNull())
434  itkWarningMacro("m_CurrentWorldPlaneGeometry is nullptr");
435 }
436 
438 {
439  if (m_CurrentWorldPlaneGeometry != geometry2d)
440  {
441  m_CurrentWorldPlaneGeometry = geometry2d->Clone();
442  m_CurrentWorldPlaneGeometryData->SetPlaneGeometry(m_CurrentWorldPlaneGeometry);
443  m_CurrentWorldPlaneGeometryUpdateTime.Modified();
444  Modified();
445  }
446 }
447 
449 {
450  m_CurrentWorldPlaneGeometryUpdateTime.Modified();
451 }
452 
454 {
455  return this->m_RenderWindow->GetSize();
456 }
457 
459 {
460  return this->m_VtkRenderer->GetSize();
461 }
462 
464 {
465  m_CurrentWorldGeometry = geometry;
466  if (geometry == nullptr)
467  {
468  m_Bounds[0] = 0;
469  m_Bounds[1] = 0;
470  m_Bounds[2] = 0;
471  m_Bounds[3] = 0;
472  m_Bounds[4] = 0;
473  m_Bounds[5] = 0;
474  m_EmptyWorldGeometry = true;
475  return;
476  }
477  BoundingBox::Pointer boundingBox = m_CurrentWorldGeometry->CalculateBoundingBoxRelativeToTransform(nullptr);
478  const BoundingBox::BoundsArrayType &worldBounds = boundingBox->GetBounds();
479  m_Bounds[0] = worldBounds[0];
480  m_Bounds[1] = worldBounds[1];
481  m_Bounds[2] = worldBounds[2];
482  m_Bounds[3] = worldBounds[3];
483  m_Bounds[4] = worldBounds[4];
484  m_Bounds[5] = worldBounds[5];
485  if (boundingBox->GetDiagonalLength2() <= mitk::eps)
486  m_EmptyWorldGeometry = true;
487  else
488  m_EmptyWorldGeometry = false;
489 }
490 
491 void mitk::BaseRenderer::SetGeometry(const itk::EventObject &geometrySendEvent)
492 {
493  const auto *sendEvent =
494  dynamic_cast<const SliceNavigationController::GeometrySendEvent *>(&geometrySendEvent);
495 
496  assert(sendEvent != nullptr);
497  SetWorldTimeGeometry(sendEvent->GetTimeGeometry());
498 }
499 
500 void mitk::BaseRenderer::UpdateGeometry(const itk::EventObject &geometryUpdateEvent)
501 {
502  const auto *updateEvent =
503  dynamic_cast<const SliceNavigationController::GeometryUpdateEvent *>(&geometryUpdateEvent);
504 
505  if (updateEvent == nullptr)
506  return;
507 
508  if (m_CurrentWorldGeometry.IsNotNull())
509  {
510  auto *slicedWorldGeometry = dynamic_cast<const SlicedGeometry3D *>(m_CurrentWorldGeometry.GetPointer());
511  if (slicedWorldGeometry)
512  {
513  PlaneGeometry *geometry2D = slicedWorldGeometry->GetPlaneGeometry(m_Slice);
514 
515  SetCurrentWorldPlaneGeometry(geometry2D); // calls Modified()
516  }
517  }
518 }
519 
520 void mitk::BaseRenderer::SetGeometrySlice(const itk::EventObject &geometrySliceEvent)
521 {
522  const auto *sliceEvent =
523  dynamic_cast<const SliceNavigationController::GeometrySliceEvent *>(&geometrySliceEvent);
524 
525  assert(sliceEvent != nullptr);
526  SetSlice(sliceEvent->GetPos());
527 }
528 
529 void mitk::BaseRenderer::SetGeometryTime(const itk::EventObject &geometryTimeEvent)
530 {
531  const auto *timeEvent =
532  dynamic_cast<const SliceNavigationController::GeometryTimeEvent *>(&geometryTimeEvent);
533 
534  assert(timeEvent != nullptr);
535  SetTimeStep(timeEvent->GetPos());
536 }
537 
538 const double *mitk::BaseRenderer::GetBounds() const
539 {
540  return m_Bounds;
541 }
542 
544 {
545  MITK_INFO << "BaseRenderer::DrawOverlayMouse()- should be inconcret implementation OpenGLRenderer." << std::endl;
546 }
547 
549 {
552 }
553 
555 {
557 }
558 
560 {
562 }
563 
568 {
569  if (SlicenavigationController == nullptr)
570  return;
571 
572  // copy worldgeometry
573  SlicenavigationController->SetInputWorldTimeGeometry(SlicenavigationController->GetCreatedWorldGeometry());
574  SlicenavigationController->Update();
575 
576  // set new
577  m_SliceNavigationController = SlicenavigationController;
578  m_SliceNavigationController->SetRenderer(this);
579 
580  if (m_SliceNavigationController.IsNotNull())
581  {
582  m_SliceNavigationController->ConnectGeometrySliceEvent(this);
583  m_SliceNavigationController->ConnectGeometryUpdateEvent(this);
584  m_SliceNavigationController->ConnectGeometryTimeEvent(this, false);
585  }
586 }
587 
588 void mitk::BaseRenderer::DisplayToWorld(const Point2D &displayPoint, Point3D &worldIndex) const
589 {
591  {
592  double display[3], *world;
593 
594  // For the rigth z-position in display coordinates, take the focal point, convert it to display and use it for
595  // correct depth.
596  double *displayCoord;
597  double cameraFP[4];
598  // Get camera focal point and position. Convert to display (screen)
599  // coordinates. We need a depth value for z-buffer.
600  this->GetVtkRenderer()->GetActiveCamera()->GetFocalPoint(cameraFP);
601  cameraFP[3] = 0.0;
602  this->GetVtkRenderer()->SetWorldPoint(cameraFP[0], cameraFP[1], cameraFP[2], cameraFP[3]);
603  this->GetVtkRenderer()->WorldToDisplay();
604  displayCoord = this->GetVtkRenderer()->GetDisplayPoint();
605 
606  // now convert the display point to world coordinates
607  display[0] = displayPoint[0];
608  display[1] = displayPoint[1];
609  display[2] = displayCoord[2];
610 
611  this->GetVtkRenderer()->SetDisplayPoint(display);
612  this->GetVtkRenderer()->DisplayToWorld();
613  world = this->GetVtkRenderer()->GetWorldPoint();
614 
615  for (int i = 0; i < 3; i++)
616  {
617  worldIndex[i] = world[i] / world[3];
618  }
619  }
621  {
623  displayPoint,
624  worldIndex); // Seems to be the same code as above, but subclasses may contain different implementations.
625  }
626 
627  return;
628 }
629 
630 void mitk::BaseRenderer::DisplayToPlane(const Point2D &displayPoint, Point2D &planePointInMM) const
631 {
633  {
634  Point3D worldPoint;
635  this->DisplayToWorld(displayPoint, worldPoint);
636  this->m_CurrentWorldPlaneGeometry->Map(worldPoint, planePointInMM);
637  }
639  {
640  MITK_WARN << "No conversion possible with 3D mapper.";
641  return;
642  }
643 
644  return;
645 }
646 
647 void mitk::BaseRenderer::WorldToDisplay(const Point3D &worldIndex, Point2D &displayPoint) const
648 {
649  double world[4], *display;
650 
651  world[0] = worldIndex[0];
652  world[1] = worldIndex[1];
653  world[2] = worldIndex[2];
654  world[3] = 1.0;
655 
656  this->GetVtkRenderer()->SetWorldPoint(world);
657  this->GetVtkRenderer()->WorldToDisplay();
658  display = this->GetVtkRenderer()->GetDisplayPoint();
659 
660  displayPoint[0] = display[0];
661  displayPoint[1] = display[1];
662 
663  return;
664 }
665 
666 void mitk::BaseRenderer::WorldToView(const mitk::Point3D &worldIndex, mitk::Point2D &viewPoint) const
667 {
668  double world[4], *view;
669 
670  world[0] = worldIndex[0];
671  world[1] = worldIndex[1];
672  world[2] = worldIndex[2];
673  world[3] = 1.0;
674 
675  this->GetVtkRenderer()->SetWorldPoint(world);
676  this->GetVtkRenderer()->WorldToView();
677  view = this->GetVtkRenderer()->GetViewPoint();
678  this->GetVtkRenderer()->ViewToNormalizedViewport(view[0], view[1], view[2]);
679 
680  viewPoint[0] = view[0] * this->GetViewportSize()[0];
681  viewPoint[1] = view[1] * this->GetViewportSize()[1];
682 
683  return;
684 }
685 
686 void mitk::BaseRenderer::PlaneToDisplay(const Point2D &planePointInMM, Point2D &displayPoint) const
687 {
688  Point3D worldPoint;
689  this->m_CurrentWorldPlaneGeometry->Map(planePointInMM, worldPoint);
690  this->WorldToDisplay(worldPoint, displayPoint);
691 
692  return;
693 }
694 
695 void mitk::BaseRenderer::PlaneToView(const Point2D &planePointInMM, Point2D &viewPoint) const
696 {
697  Point3D worldPoint;
698  this->m_CurrentWorldPlaneGeometry->Map(planePointInMM, worldPoint);
699  this->WorldToView(worldPoint,viewPoint);
700 
701  return;
702 }
703 
705 {
706  if (this->GetMapperID() == BaseRenderer::Standard2D)
707  {
708  // GetParallelScale returns half of the height of the render window in mm.
709  // Divided by the half size of the Display size in pixel givest the mm per pixel.
710  return this->GetVtkRenderer()->GetActiveCamera()->GetParallelScale() * 2.0 / GetViewportSize()[1];
711  }
712  else
713  return 1.0;
714 }
715 
717 {
718  Point2D dispSizeInMM;
719  dispSizeInMM[0] = GetSizeX() * GetScaleFactorMMPerDisplayUnit();
720  dispSizeInMM[1] = GetSizeY() * GetScaleFactorMMPerDisplayUnit();
721  return dispSizeInMM;
722 }
723 
725 {
726  Point2D dispSizeInMM;
727  dispSizeInMM[0] = GetViewportSize()[0] * GetScaleFactorMMPerDisplayUnit();
728  dispSizeInMM[1] = GetViewportSize()[1] * GetScaleFactorMMPerDisplayUnit();
729  return dispSizeInMM;
730 }
731 
733 {
734  Point2D originPx;
735  originPx[0] = m_VtkRenderer->GetOrigin()[0];
736  originPx[1] = m_VtkRenderer->GetOrigin()[1];
737  Point2D displayGeometryOriginInMM;
738  DisplayToPlane(originPx, displayGeometryOriginInMM); // top left of the render window (Origin)
739  return displayGeometryOriginInMM;
740 }
741 
743 {
744  m_ConstrainZoomingAndPanning = constrain;
746  {
748  }
749 }
750 
752 {
753  // DEPRECATED: Map2DRendererPositionTo3DWorldPosition is deprecated. use DisplayToWorldInstead
754  Point3D position;
755  DisplayToWorld(mousePosition, position);
756  return position;
757 }
758 
759 void mitk::BaseRenderer::PrintSelf(std::ostream &os, itk::Indent indent) const
760 {
761  os << indent << " MapperID: " << m_MapperID << std::endl;
762  os << indent << " Slice: " << m_Slice << std::endl;
763  os << indent << " TimeStep: " << m_TimeStep << std::endl;
764 
765  os << indent << " CurrentWorldPlaneGeometry: ";
766  if (m_CurrentWorldPlaneGeometry.IsNull())
767  os << "nullptr" << std::endl;
768  else
769  m_CurrentWorldPlaneGeometry->Print(os, indent);
770 
771  os << indent << " CurrentWorldPlaneGeometryUpdateTime: " << m_CurrentWorldPlaneGeometryUpdateTime << std::endl;
772  os << indent << " CurrentWorldPlaneGeometryTransformTime: " << m_CurrentWorldPlaneGeometryTransformTime << std::endl;
773 
774  Superclass::PrintSelf(os, indent);
775 }
std::map< vtkRenderWindow *, BaseRenderer * > BaseRendererMapType
PlaneGeometryData::Pointer m_CurrentWorldPlaneGeometryData
void DisplayToWorld(const Point2D &displayPoint, Point3D &worldIndex) const
This method converts a display point to the 3D world index using the geometry of the renderWindow...
virtual const mitk::TimeGeometry * GetCreatedWorldGeometry()
Access the created geometry.
ScalarType GetTime() const
Get the time in ms of the currently displayed content.
BaseRenderer(const char *name=nullptr, vtkRenderWindow *renWin=nullptr)
BoundingBox * GetBoundingBoxInWorld() const
Returns a bounding box that covers all time steps.
Data management class that handles &#39;was created by&#39; relations.
unsigned int GetNumberOfVisibleLODEnabledMappers() const
This Class is used to connect a DataStorage with the Dispatcher.
void SetSliceNavigationController(SliceNavigationController *SlicenavigationController)
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
static vtkRenderWindow * GetRenderWindowByName(const std::string &name)
#define MITK_INFO
Definition: mitkLogMacros.h:18
static Pointer New()
void InsertSceneRenderer(vtkSmartPointer< vtkRenderer > renderer)
Base of all data objects.
Definition: mitkBaseData.h:37
vtkRenderer * GetVtkRenderer() const
void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry)
virtual void SetConstrainZoomingAndPanning(bool constrain)
double ScalarType
virtual void SetDataStorage(DataStorage *storage)
set the datastorage that will be used for rendering
Point2D GetDisplaySizeInMM() const
virtual void Resize(int w, int h)
Called to inform the renderer that the RenderWindow has been resized.
void PlaneToView(const Point2D &planePointInMM, Point2D &viewPoint) const
This method converts a 2D plane coordinate to the point on the viewport using the geometry of the ren...
Organizes the rendering process.
virtual void SetWorldTimeGeometry(const mitk::TimeGeometry *geometry)
double GetScaleFactorMMPerDisplayUnit() const
virtual unsigned int GetSlices() const
Get the number of slices.
std::list< mitk::BaseLocalStorageHandler * > m_RegisteredLocalStorageHandlers
virtual void SetTimeStep(unsigned int timeStep)
Set/Get m_TimeStep which defines together with m_Slice the 2D geometry stored in m_WorldTimeGeometry ...
Interface for accessing (templated) LocalStorageHandler instances.
void DisplayToPlane(const Point2D &displayPoint, Point2D &planePointInMM) const
This method converts a display point to the 2D world index, mapped onto the display plane using the g...
Pointer Clone() const
virtual void SetWorldGeometry3D(const BaseGeometry *geometry)
Set/Get the WorldGeometry (m_WorldGeometry) for 3D and 2D rendering, that describing the (maximal) ar...
static const MapperSlotId defaultMapper
Default mapper id to use.
Constants for most interaction classes, due to the generic StateMachines.
virtual int * GetSize() const
CameraRotationController::Pointer m_CameraRotationController
void PlaneToDisplay(const Point2D &planePointInMM, Point2D &displayPoint) const
This method converts a 2D plane coordinate to the display point using the geometry of the renderWindo...
unsigned long m_LastUpdateTime
Timestamp of last call of Update().
void WorldToDisplay(const Point3D &worldIndex, Point2D &displayPoint) const
This method converts a 3D world index to the display point using the geometry of the renderWindow...
Controls the selection of the slice the associated BaseRenderer will display.
static Pointer New()
static void AddInstance(vtkSmartPointer< vtkRenderWindow > renWin, vtkSmartPointer< vtkRenderer > mitkSceneRenderer)
virtual mitk::PlaneGeometry * GetPlaneGeometry(int s) const
Returns the PlaneGeometry of the slice (s).
void SetDataStorage(DataStorage::Pointer dataStorage)
virtual void SetGeometrySlice(const itk::EventObject &geometrySliceEvent)
SetSlice is called according to the geometrySliceEvent, which is supposed to be a SliceNavigationCont...
const double * GetBounds() const
virtual void UpdateGeometry(const itk::EventObject &geometrySliceEvent)
UpdateWorldGeometry is called to re-read the 2D geometry from the slice navigation controller...
int GetSizeX() const
get the x_size of the RendererWindow
static VtkLayerController * GetInstance(vtkSmartPointer< vtkRenderWindow > renWin)
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:61
#define MITK_WARN
Definition: mitkLogMacros.h:19
virtual void SetSlice(unsigned int slice)
Set/Get m_Slice which defines together with m_TimeStep the 2D geometry stored in m_WorldTimeGeometry ...
int MapperSlotId
MapperSlotId defines which kind of mapper (e.g. 2D or 3D) should be used.
static Pointer New()
static RenderingManager * GetInstance()
virtual unsigned int GetTimeStep() const
virtual TimeStepType TimePointToTimeStep(TimePointType timePoint) const =0
Converts a time point to the corresponding time step.
virtual CameraController * GetCameraController()
static BaseRendererMapType baseRendererMap
virtual void InitSize(int w, int h)
Set the initial size. Called by RenderWindow after it has become visible for the first time...
unsigned long m_CurrentWorldPlaneGeometryTransformTime
test only
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
vtkRenderer * m_VtkRenderer
vtkRenderWindow * m_RenderWindow
virtual int * GetViewportSize() const
virtual void SetGeometry(const itk::EventObject &geometrySliceEvent)
SetWorldGeometry is called according to the geometrySliceEvent, which is supposed to be a SliceNaviga...
void ForceImmediateUpdate(vtkRenderWindow *renderWindow)
virtual void Paint()
Do the rendering and flush the result.
static Pointer New()
unsigned int m_NumberOfVisibleLODEnabledMappers
Describes the geometry of a data object consisting of slices.
virtual void PickWorldPoint(const Point2D &diplayPosition, Point3D &worldPosition) const =0
Perform a picking: find the x,y,z world coordinate of a display x,y coordinate.
void RequestUpdate(vtkRenderWindow *renderWindow)
static Pointer New()
DataStorage::Pointer m_DataStorage
The DataStorage that is used for rendering.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
virtual bool IsInitialized() const
Check whether the data has been initialized, i.e., at least the Geometry and other header data has be...
Dispatcher::Pointer GetDispatcher() const
Returns the Dispatcher which handles Events for this BaseRenderer.
Point2D GetOriginInMM() const
virtual void SetGeometryTime(const itk::EventObject &geometryTimeEvent)
SetTimeStep is called according to the geometrySliceEvent, which is supposed to be a SliceNavigationC...
static Pointer New()
void RegisterLocalStorageHandler(mitk::BaseLocalStorageHandler *lsh)
virtual void Initialize()
Initialize the RenderWindow. Should only be called from RenderWindow.
static BaseRenderer * GetByName(const std::string &name)
MITKCORE_EXPORT const ScalarType eps
virtual void SetCurrentWorldPlaneGeometry(const PlaneGeometry *geometry2d)
Sets m_CurrentWorldPlaneGeometry.
Point2D GetViewportSizeInMM() const
Describes a two-dimensional, rectangular plane.
DataNode::Pointer m_CurrentWorldPlaneGeometryNode
static void RemoveInstance(vtkRenderWindow *renWin)
itk::SmartPointer< CameraController > m_CameraController
CameraController for 3D rendering.
void AdjustCameraToPlane()
AdjustCameraToPlane Moves the camera of a 2D Renderwindow without panning or zooming, eg. only rotate the camera.
MapperSlotId m_MapperID
MapperSlotId to use. Defines which kind of mapper (e.g., 2D or 3D) shoud be used. ...
virtual void Update()
Do the actual creation and send it to the connected observers (renderers)
void WorldToView(const Point3D &worldIndex, Point2D &viewPoint) const
This method converts a 3D world index to the point on the viewport using the geometry of the renderWi...
virtual Point3D Map2DRendererPositionTo3DWorldPosition(const Point2D &mousePosition) const
Provides (1) world coordinates for a given mouse position and (2) translates mousePosition to Display...
SliceNavigationController::Pointer m_SliceNavigationController
void SendUpdateSlice()
Sets timestamp of CurrentWorldPlaneGeometry and forces so reslicing in that renderwindow.
static void AddInstance(vtkRenderWindow *renWin, BaseRenderer *baseRenderer)
virtual void SetCurrentWorldGeometry(const BaseGeometry *geometry)
Sets m_CurrentWorldGeometry.
virtual void InitRenderer(vtkRenderWindow *renderwindow)
Initialize the renderer with a RenderWindow (renderwindow).
BaseGeometry Describes the geometry of a data object.
const char * GetName() const
get the name of the Renderer
int GetSizeY() const
get the y_size of the RendererWindow
static void RemoveInstance(vtkSmartPointer< vtkRenderWindow > renWin)
BoundingBoxType::BoundsArrayType BoundsArrayType
berry::Display * display
[MinimalApplicationClass_StartMethod]
virtual void DrawOverlayMouse(Point2D &p2d)
Draws a point on the widget. Should be used during conferences to show the position of the remote mou...
virtual const BoundingBoxType * GetBoundingBox()
void UnregisterLocalStorageHandler(mitk::BaseLocalStorageHandler *lsh)