Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkVtkPropRenderer.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 "mitkVtkPropRenderer.h"
14 
15 // MAPPERS
16 #include "mitkCameraController.h"
17 #include "mitkImageVtkMapper2D.h"
18 #include "mitkMapper.h"
20 #include "mitkVtkMapper.h"
21 
23 #include <mitkGeometry3D.h>
24 #include <mitkImageSliceSelector.h>
25 #include <mitkLevelWindow.h>
27 #include <mitkPlaneGeometry.h>
28 #include <mitkProperties.h>
29 #include <mitkRenderingManager.h>
30 #include <mitkSurface.h>
31 #include <mitkVtkInteractorStyle.h>
32 
33 // VTK
34 #include <vtkAssemblyNode.h>
35 #include <vtkAssemblyPath.h>
36 #include <vtkCamera.h>
37 #include <vtkCellPicker.h>
38 #include <vtkInteractorStyleTrackballCamera.h>
39 #include <vtkInformation.h>
40 #include <vtkLight.h>
41 #include <vtkLightKit.h>
42 #include <vtkLinearTransform.h>
43 #include <vtkMapper.h>
44 #include <vtkPointPicker.h>
45 #include <vtkProp.h>
46 #include <vtkRenderWindow.h>
47 #include <vtkRenderWindowInteractor.h>
48 #include <vtkRenderer.h>
49 #include <vtkRendererCollection.h>
50 #include <vtkSmartPointer.h>
51 #include <vtkTextActor.h>
52 #include <vtkTextProperty.h>
53 #include <vtkTransform.h>
54 #include <vtkWorldPointPicker.h>
55 
56 mitk::VtkPropRenderer::VtkPropRenderer(const char *name, vtkRenderWindow *renWin)
57  : BaseRenderer(name, renWin),
58  m_CameraInitializedForMapperID(0)
59 {
60  didCount = false;
61 
62  m_WorldPointPicker = vtkWorldPointPicker::New();
63 
64  m_PointPicker = vtkPointPicker::New();
65  m_PointPicker->SetTolerance(0.0025);
66 
67  m_CellPicker = vtkCellPicker::New();
68  m_CellPicker->SetTolerance(0.0025);
69 
71  m_CurrentWorldPlaneGeometryMapper = geometryMapper;
72  m_CurrentWorldPlaneGeometryNode->SetMapper(2, geometryMapper);
73 
74  m_LightKit = vtkLightKit::New();
75  m_LightKit->AddLightsToRenderer(m_VtkRenderer);
76  m_PickingMode = WorldPointPicking;
77 
78  m_TextRenderer = vtkRenderer::New();
79  m_TextRenderer->SetRenderWindow(renWin);
80  m_TextRenderer->SetInteractive(0);
81  m_TextRenderer->SetErase(0);
82 }
83 
88 {
89  // Workaround for GLDisplayList Bug
90  {
91  m_MapperID = 0;
92  checkState();
93  }
94 
95  if (m_LightKit != nullptr)
96  m_LightKit->Delete();
97 
98  if (m_VtkRenderer != nullptr)
99  {
100  m_CameraController = nullptr;
101 
102  m_VtkRenderer->Delete();
103 
104  m_VtkRenderer = nullptr;
105  }
106  else
107  m_CameraController = nullptr;
108 
109  if (m_WorldPointPicker != nullptr)
110  m_WorldPointPicker->Delete();
111  if (m_PointPicker != nullptr)
112  m_PointPicker->Delete();
113  if (m_CellPicker != nullptr)
114  m_CellPicker->Delete();
115  if (m_TextRenderer != nullptr)
116  m_TextRenderer->Delete();
117 }
118 
120 {
121  if (storage == nullptr || storage == m_DataStorage)
122  return;
123 
125 
126  static_cast<mitk::PlaneGeometryDataVtkMapper3D *>(m_CurrentWorldPlaneGeometryMapper.GetPointer())
127  ->SetDataStorageForTexture(m_DataStorage.GetPointer());
128 
129  // Compute the geometry from the current data tree bounds and set it as world geometry
131 }
132 
134 {
135  if (m_DataStorage.IsNull())
136  return false;
137 
138  // initialize world geometry
139  auto geometry = m_DataStorage->ComputeVisibleBoundingGeometry3D(nullptr, "includeInBoundingBox");
140 
141  if (geometry.IsNull())
142  return false;
143 
144  this->SetWorldTimeGeometry(geometry);
145  this->GetVtkRenderer()->ResetCamera();
146  this->GetCameraController()->Fit();
147  this->Modified();
148  return true;
149 }
150 
157 {
158  // Do we have objects to render?
159  if (this->GetEmptyWorldGeometry())
160  return 0;
161 
162  if (m_DataStorage.IsNull())
163  return 0;
164 
165  // Update mappers and prepare mapper queue
166  if (type == VtkPropRenderer::Opaque)
167  {
168  this->PrepareMapperQueue();
169  // Share vtkInformation, there might be new mappers
170  this->PropagateRenderInfoToMappers();
171  }
172 
173  // go through the generated list and let the sorted mappers paint
174  for (auto it = m_MappersMap.cbegin(); it != m_MappersMap.cend(); it++)
175  {
176  Mapper *mapper = (*it).second;
177  mapper->MitkRender(this, type);
178  }
179 
180  // Render text
181  if (type == VtkPropRenderer::Overlay)
182  {
183  if (m_TextCollection.size() > 0)
184  {
185  m_TextRenderer->SetViewport(this->GetVtkRenderer()->GetViewport());
186  for (auto it = m_TextCollection.begin(); it != m_TextCollection.end(); ++it)
187  m_TextRenderer->AddViewProp((*it).second);
188  m_TextRenderer->Render();
189  }
190  }
191  return 1;
192 }
193 
200 void mitk::VtkPropRenderer::PrepareMapperQueue()
201 {
202  // variable for counting LOD-enabled mappers
204 
205  // Do we have to update the mappers ?
206  if (m_LastUpdateTime < GetMTime() || m_LastUpdateTime < this->GetCurrentWorldPlaneGeometry()->GetMTime())
207  {
208  Update();
209  }
210  else if (m_MapperID >= 1 && m_MapperID < 6)
211  Update();
212 
213  // remove all text properties before mappers will add new ones
214  m_TextRenderer->RemoveAllViewProps();
215 
216  for (unsigned int i = 0; i < m_TextCollection.size(); i++)
217  {
218  m_TextCollection[i]->Delete();
219  }
220  m_TextCollection.clear();
221 
222  // clear priority_queue
223  m_MappersMap.clear();
224 
225  int mapperNo = 0;
226 
227  // DataStorage
228  if (m_DataStorage.IsNull())
229  return;
230 
231  DataStorage::SetOfObjects::ConstPointer allObjects = m_DataStorage->GetAll();
232 
233  for (DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin(); it != allObjects->End(); ++it)
234  {
235  const DataNode::Pointer node = it->Value();
236  if (node.IsNull())
237  continue;
238  const mitk::Mapper::Pointer mapper = node->GetMapper(m_MapperID);
239 
240  if (mapper.IsNull())
241  continue;
242 
243  bool visible = true;
244  node->GetVisibility(visible, this, "visible");
245 
246  // The information about LOD-enabled mappers is required by RenderingManager
247  if (mapper->IsLODEnabled(this) && visible)
248  {
250  }
251  // mapper without a layer property get layer number 1
252  int layer = 1;
253  node->GetIntProperty("layer", layer, this);
254  int nr = (layer << 16) + mapperNo;
255  m_MappersMap.insert(std::pair<int, Mapper *>(nr, mapper));
256  mapperNo++;
257  }
258 }
259 
261 {
262  if (info == m_VtkRenderInfo)
263  return;
264 
265  m_VtkRenderInfo = info;
266  this->PropagateRenderInfoToMappers();
267 }
268 
269 void mitk::VtkPropRenderer::PropagateRenderInfoToMappers()
270 {
271  if (m_VtkRenderInfo == nullptr)
272  return;
273 
274  for (const auto &mapEntry : m_MappersMap)
275  {
276  auto vtkMapper = dynamic_cast<mitk::VtkMapper*>(mapEntry.second);
277 
278  if (nullptr != vtkMapper)
279  {
280  auto prop = vtkMapper->GetVtkProp(this);
281 
282  if (nullptr != prop)
283  prop->SetPropertyKeys(m_VtkRenderInfo);
284  }
285  }
286 }
287 
289 {
290  if (datatreenode != nullptr)
291  {
292  mitk::Mapper::Pointer mapper = datatreenode->GetMapper(m_MapperID);
293  if (mapper.IsNotNull())
294  {
296  {
297  mapper->Update(this);
298  {
299  auto *vtkmapper = dynamic_cast<VtkMapper *>(mapper.GetPointer());
300  if (vtkmapper != nullptr)
301  {
302  vtkmapper->UpdateVtkTransform(this);
303  }
304  }
305  }
306  }
307  }
308 }
309 
311 {
312  if (m_DataStorage.IsNull())
313  return;
314 
315  mitk::DataStorage::SetOfObjects::ConstPointer all = m_DataStorage->GetAll();
316  for (mitk::DataStorage::SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it)
317  Update(it->Value());
318 
319  Modified();
320  m_LastUpdateTime = GetMTime();
321 }
322 
328 void mitk::VtkPropRenderer::InitRenderer(vtkRenderWindow *renderWindow)
329 {
330  BaseRenderer::InitRenderer(renderWindow);
331 
332  vtkCallbackCommand *renderCallbackCommand = vtkCallbackCommand::New();
333  renderCallbackCommand->SetCallback(VtkPropRenderer::RenderingCallback);
334  renderWindow->GetInteractor()->AddObserver(vtkCommand::RenderEvent, renderCallbackCommand);
335  renderCallbackCommand->Delete();
336 
337  if (renderWindow == nullptr)
338  {
339  m_InitNeeded = false;
340  m_ResizeNeeded = false;
341  return;
342  }
343 
344  m_InitNeeded = true;
345  m_ResizeNeeded = true;
346 
347  m_LastUpdateTime = 0;
348 }
349 
350 void mitk::VtkPropRenderer::RenderingCallback(vtkObject *caller, unsigned long, void *, void *)
351 {
352  auto *renderWindowInteractor = dynamic_cast<vtkRenderWindowInteractor *>(caller);
353  if (!renderWindowInteractor)
354  return;
355  mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(renderWindowInteractor->GetRenderWindow());
356  if (renderer)
357  renderer->RequestUpdate();
358 }
359 
364 {
365  BaseRenderer::Resize(w, h);
367 }
368 
370 {
371  m_RenderWindow->SetSize(w, h);
372  Superclass::InitSize(w, h);
373  Modified();
374  Update();
375  if (m_VtkRenderer != nullptr)
376  {
377  int w = vtkObject::GetGlobalWarningDisplay();
378  vtkObject::GlobalWarningDisplayOff();
379  m_VtkRenderer->ResetCamera();
380  vtkObject::SetGlobalWarningDisplay(w);
381  }
382  this->GetCameraController()->Fit();
383 }
384 
386  std::string text, double posX, double posY, double color1, double color2, double color3, float opacity)
387 {
388  this->GetVtkRenderer()->ViewToDisplay();
389  if (!text.empty())
390  {
391  Point2D p;
392  vtkTextActor *textActor = vtkTextActor::New();
393 
394  textActor->SetDisplayPosition(posX, posY);
395  textActor->SetInput(text.c_str());
396  textActor->SetTextScaleModeToNone();
397  textActor->GetTextProperty()->SetColor(color1, color2, color3); // TODO: Read color from node property
398  textActor->GetTextProperty()->SetOpacity(opacity);
399  int text_id = m_TextCollection.size();
400  m_TextCollection.insert(TextMapType::value_type(text_id, textActor));
401  return text_id;
402  }
403  else
404  {
405  return -1;
406  }
407 }
408 
410 {
411  if (m_MapperID != mapperId)
412  Superclass::SetMapperID(mapperId);
413 
414  // Workaround for GL Displaylist Bug
415  checkState();
416 }
417 
422 {
423  if (m_RenderWindow != nullptr)
424  m_RenderWindow->MakeCurrent();
425 }
426 
427 void mitk::VtkPropRenderer::PickWorldPoint(const mitk::Point2D &displayPoint, mitk::Point3D &worldPoint) const
428 {
429  if (this->GetRenderWindow()->GetNeverRendered() != 0)
430  return; // somebody called picking before we ever rendered; cannot have enough information yet
431 
432  switch (m_PickingMode)
433  {
434  case (WorldPointPicking):
435  {
436  m_WorldPointPicker->Pick(displayPoint[0], displayPoint[1], 0, m_VtkRenderer);
437  vtk2itk(m_WorldPointPicker->GetPickPosition(), worldPoint);
438  break;
439  }
440  case (PointPicking):
441  {
442  m_PointPicker->Pick(displayPoint[0], displayPoint[1], 0, m_VtkRenderer);
443  vtk2itk(m_PointPicker->GetPickPosition(), worldPoint);
444  break;
445  }
446  case (CellPicking):
447  {
448  m_CellPicker->Pick(displayPoint[0], displayPoint[1], 0, m_VtkRenderer);
449  vtk2itk(m_CellPicker->GetPickPosition(), worldPoint);
450  break;
451  }
452  }
453  // todo: is this picking in 2D renderwindows?
454  // Superclass::PickWorldPoint(displayPoint, worldPoint);
455 }
456 
457 mitk::DataNode *mitk::VtkPropRenderer::PickObject(const Point2D &displayPosition, Point3D &worldPosition) const
458 {
459  m_CellPicker->InitializePickList();
460 
461  // Iterate over all DataStorage objects to determine all vtkProps intended
462  // for picking
463  DataStorage::SetOfObjects::ConstPointer allObjects = m_DataStorage->GetAll();
464  for (DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin(); it != allObjects->End(); ++it)
465  {
466  const DataNode *node = it->Value();
467  if (node == nullptr)
468  continue;
469 
470  bool pickable = false;
471  node->GetBoolProperty("pickable", pickable);
472  if (!pickable)
473  continue;
474 
475  auto *mapper = dynamic_cast<VtkMapper *>(node->GetMapper(m_MapperID));
476  if (mapper == nullptr)
477  continue;
478 
479  vtkProp *prop = mapper->GetVtkProp((mitk::BaseRenderer *)this);
480  if (prop == nullptr)
481  continue;
482 
483  m_CellPicker->AddPickList(prop);
484  }
485 
486  // Do the picking and retrieve the picked vtkProp (if any)
487  m_CellPicker->PickFromListOn();
488  m_CellPicker->Pick(displayPosition[0], displayPosition[1], 0.0, m_VtkRenderer);
489  m_CellPicker->PickFromListOff();
490 
491  vtk2itk(m_CellPicker->GetPickPosition(), worldPosition);
492  vtkProp *prop = m_CellPicker->GetViewProp();
493 
494  if (prop == nullptr)
495  {
496  return nullptr;
497  }
498 
499  // Iterate over all DataStorage objects to determine if the retrieved
500  // vtkProp is owned by any associated mapper.
501  for (DataStorage::SetOfObjects::ConstIterator it = allObjects->Begin(); it != allObjects->End(); ++it)
502  {
503  DataNode::Pointer node = it->Value();
504  if (node.IsNull())
505  continue;
506 
507  mitk::Mapper *mapper = node->GetMapper(m_MapperID);
508  if (mapper == nullptr)
509  continue;
510 
511  auto *vtkmapper = dynamic_cast<VtkMapper *>(mapper);
512 
513  if (vtkmapper)
514  {
515  // if vtk-based, then ...
516  if (vtkmapper->HasVtkProp(prop, const_cast<mitk::VtkPropRenderer *>(this)))
517  {
518  return node;
519  }
520  }
521  }
522  return nullptr;
523 }
524 // todo: is this 2D renderwindow picking?
525 // return Superclass::PickObject( displayPosition, worldPosition );
526 
527 vtkTextProperty *mitk::VtkPropRenderer::GetTextLabelProperty(int text_id)
528 {
529  return this->m_TextCollection[text_id]->GetTextProperty();
530 }
531 
533 {
534  if (m_DataStorage.IsNotNull())
535  {
536  this->UpdatePaths();
537  this->m_Paths->InitTraversal();
538  }
539 }
540 
542 {
543  if (m_DataStorage.IsNull())
544  {
545  return;
546  }
547 
548  if (GetMTime() > m_PathTime || (m_Paths != nullptr && m_Paths->GetMTime() > m_PathTime))
549  {
550  // Create the list to hold all the paths
551  m_Paths = vtkSmartPointer<vtkAssemblyPaths>::New();
552 
553  DataStorage::SetOfObjects::ConstPointer objects = m_DataStorage->GetAll();
554  for (auto iter = objects->begin(); iter != objects->end(); ++iter)
555  {
556  vtkSmartPointer<vtkAssemblyPath> onePath = vtkSmartPointer<vtkAssemblyPath>::New();
557  Mapper *mapper = (*iter)->GetMapper(BaseRenderer::Standard3D);
558  if (mapper)
559  {
560  auto *vtkmapper = dynamic_cast<VtkMapper *>(mapper);
561 
562  if (nullptr != vtkmapper)
563  {
564  vtkProp *prop = vtkmapper->GetVtkProp(this);
565  if (prop && prop->GetVisibility())
566  {
567  // add to assembly path
568  onePath->AddNode(prop, prop->GetMatrix());
569  m_Paths->AddItem(onePath);
570  }
571  }
572  }
573  }
574 
575  m_PathTime.Modified();
576  }
577 }
578 
580 {
581  UpdatePaths();
582  return m_Paths->GetNumberOfItems();
583 }
584 
586 {
587  return m_Paths ? m_Paths->GetNextItem() : nullptr;
588 }
589 
591 {
592  if (m_DataStorage.IsNull())
593  return;
594 
595  DataStorage::SetOfObjects::ConstPointer allObjects = m_DataStorage->GetAll();
596  for (auto iter = allObjects->begin(); iter != allObjects->end(); ++iter)
597  {
598  DataNode::Pointer node = *iter;
599  if (node.IsNull())
600  continue;
601 
602  Mapper *mapper = node->GetMapper(m_MapperID);
603 
604  if (mapper)
605  {
606  auto *vtkmapper = dynamic_cast<VtkMapper *>(mapper);
607 
608  if (vtkmapper)
609  vtkmapper->ReleaseGraphicsResources(this);
610  }
611  }
612 }
613 
614 const vtkWorldPointPicker *mitk::VtkPropRenderer::GetWorldPointPicker() const
615 {
616  return m_WorldPointPicker;
617 }
618 
619 const vtkPointPicker *mitk::VtkPropRenderer::GetPointPicker() const
620 {
621  return m_PointPicker;
622 }
623 
624 const vtkCellPicker *mitk::VtkPropRenderer::GetCellPicker() const
625 {
626  return m_CellPicker;
627 }
628 
630 {
631  return m_MappersMap;
632 }
633 
634 // Workaround for GL Displaylist bug
635 static int glWorkAroundGlobalCount = 0;
636 
638 {
639  return glWorkAroundGlobalCount > 1;
640 }
641 
642 void mitk::VtkPropRenderer::checkState()
643 {
644  if (m_MapperID == Standard3D)
645  {
646  if (!didCount)
647  {
648  didCount = true;
650 
651  if (glWorkAroundGlobalCount == 2)
652  {
653  MITK_INFO << "Multiple 3D Renderwindows active...: turning Immediate Rendering ON for legacy mappers";
654  // vtkMapper::GlobalImmediateModeRenderingOn();
655  }
656  }
657  }
658  else
659  {
660  if (didCount)
661  {
662  didCount = false;
664  if (glWorkAroundGlobalCount == 1)
665  {
666  MITK_INFO << "Single 3D Renderwindow active...: turning Immediate Rendering OFF for legacy mappers";
667  // vtkMapper::GlobalImmediateModeRenderingOff();
668  }
669  }
670  }
671 }
672 
673 //### Contains all methods which are neceassry before each VTK Render() call
675 {
676  if (this->GetMapperID() != m_CameraInitializedForMapperID)
677  {
678  Initialize2DvtkCamera(); // Set parallel projection etc.
679  }
681 }
682 
683 bool mitk::VtkPropRenderer::Initialize2DvtkCamera()
684 {
685  if (this->GetMapperID() == Standard3D)
686  {
687  // activate parallel projection for 2D
688  this->GetVtkRenderer()->GetActiveCamera()->SetParallelProjection(false);
689  vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
690  vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
691  this->GetRenderWindow()->GetInteractor()->SetInteractorStyle(style);
692  this->GetRenderWindow()->GetInteractor()->EnableRenderOff();
693  m_CameraInitializedForMapperID = Standard3D;
694  }
695  else if (this->GetMapperID() == Standard2D)
696  {
697  // activate parallel projection for 2D
698  this->GetVtkRenderer()->GetActiveCamera()->SetParallelProjection(true);
699  // turn the light out in the scene in order to render correct grey values.
700  // TODO Implement a property for light in the 2D render windows (in another method)
701  this->GetVtkRenderer()->RemoveAllLights();
702 
703  vtkSmartPointer<mitkVtkInteractorStyle> style = vtkSmartPointer<mitkVtkInteractorStyle>::New();
704  this->GetRenderWindow()->GetInteractor()->SetInteractorStyle(style);
705  this->GetRenderWindow()->GetInteractor()->EnableRenderOff();
706  m_CameraInitializedForMapperID = Standard2D;
707  }
708  return true;
709 }
vtkTextProperty * GetTextLabelProperty(int text_id)
CGetTextLabelProperty an be used in order to get a vtkTextProperty for a specific text_id...
static int glWorkAroundGlobalCount
mitk::DataNode * PickObject(const Point2D &displayPosition, Point3D &worldPosition) const override
Determines the object (mitk::DataNode) closest to the current position by means of picking...
std::map< int, Mapper * > MappersMapType
Data management class that handles &#39;was created by&#39; relations.
bool SetWorldGeometryToDataStorageBounds() override
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
#define MITK_INFO
Definition: mitkLogMacros.h:18
virtual void MakeCurrent()
Activates the current renderwindow.
vtkRenderer * GetVtkRenderer() const
void SetDataStorage(mitk::DataStorage *storage) override
set the datastorage that will be used for rendering
virtual void SetDataStorage(DataStorage *storage)
set the datastorage that will be used for rendering
virtual void Resize(int w, int h)
Called to inform the renderer that the RenderWindow has been resized.
void InitSize(int w, int h) override
Set the initial size. Called by RenderWindow after it has become visible for the first time...
Organizes the rendering process.
int WriteSimpleText(std::string text, double posX, double posY, double color1=0.0, double color2=1.0, double color3=0.0, float opacity=1.0)
WriteSimpleText Write a text in a renderwindow.
~VtkPropRenderer() override
Destructs the VtkPropRenderer.
void InitRenderer(vtkRenderWindow *renderwindow) override
This method is called from the two Constructors.
virtual void SetWorldTimeGeometry(const mitk::TimeGeometry *geometry)
void PickWorldPoint(const Point2D &displayPoint, Point3D &worldPoint) const override
Perform a picking: find the x,y,z world coordinate of a display x,y coordinate.
int Render(RenderType type)
Called by the vtkMitkRenderProp in order to start MITK rendering process.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
Base class of all Vtk Mappers in order to display primitives by exploiting Vtk functionality.
Definition: mitkVtkMapper.h:48
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
unsigned long m_LastUpdateTime
Timestamp of last call of Update().
Base class of all mappers, Vtk as well as OpenGL mappers.
Definition: mitkMapper.h:49
static void info(const char *fmt,...)
Definition: svm.cpp:86
int MapperSlotId
MapperSlotId defines which kind of mapper (e.g. 2D or 3D) should be used.
static RenderingManager * GetInstance()
void SetPropertyKeys(vtkInformation *info)
Store/propagate vtkInformation during rendering.
virtual CameraController * GetCameraController()
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer)=0
virtual void InitSize(int w, int h)
Set the initial size. Called by RenderWindow after it has become visible for the first time...
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
virtual void SetMapperID(MapperSlotId _arg)
Set the MapperSlotId to use.
void InitPathTraversal()
Used by vtkPointPicker/vtkPicker. This will query a list of all objects in MITK and provide every vtk...
vtkRenderer * m_VtkRenderer
void vtk2itk(const Tin &in, Tout &out)
vtkRenderWindow * m_RenderWindow
virtual bool GetEmptyWorldGeometry()
virtual void UpdateVtkTransform(mitk::BaseRenderer *renderer)
Set the vtkTransform of the m_Prop3D for the current time step of renderer.
static void RenderingCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
unsigned int m_NumberOfVisibleLODEnabledMappers
Vtk-based mapper to display a PlaneGeometry in a 3D windowUses a PlaneGeometryDataToSurfaceFilter obj...
virtual bool IsValid() const
Is this BaseGeometry in a state that is valid?
void RequestUpdate(vtkRenderWindow *renderWindow)
mitk::Mapper * GetMapper(MapperSlotId id) const
vtkRenderWindow * GetRenderWindow() const
Access the RenderWindow into which this renderer renders.
virtual void PrepareRender()
This methods contains all method neceassary before a VTK Render() call.
virtual void MitkRender(mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type)=0
Responsible for calling the appropriate render functions. To be implemented in sub-classes.
static bool useImmediateModeRendering()
DataStorage::Pointer m_DataStorage
The DataStorage that is used for rendering.
const vtkPointPicker * GetPointPicker() const
virtual void ReleaseGraphicsResources(mitk::BaseRenderer *)
Release vtk-based graphics resources that are being consumed by this mapper.
virtual void ReleaseGraphicsResources(vtkWindow *renWin)
Release vtk-based graphics resources. Called by vtkMitkRenderProp::ReleaseGraphicsResources.
void SetMapperID(const MapperSlotId mapperId) override
Set the MapperSlotId to use.
void Update() override
Call update of all mappers. To be implemented in subclasses.
void Resize(int w, int h) override
Resize the OpenGL Window.
DataNode::Pointer m_CurrentWorldPlaneGeometryNode
VtkPropRenderer(const char *name="VtkPropRenderer", vtkRenderWindow *renWin=nullptr)
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.
void Fit()
Fit Adjust the camera, so that the world bounding box is fully visible.
MapperSlotId m_MapperID
MapperSlotId to use. Defines which kind of mapper (e.g., 2D or 3D) shoud be used. ...
MappersMapType GetMappersMap() const
const vtkWorldPointPicker * GetWorldPointPicker() const
virtual void InitRenderer(vtkRenderWindow *renderwindow)
Initialize the renderer with a RenderWindow (renderwindow).
vtkAssemblyPath * GetNextPath()
Used by vtkPointPicker/vtkPicker. This will query a list of all objects in MITK and provide every vtk...
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
const vtkCellPicker * GetCellPicker() const