Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkRenderWindowBase.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,
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 #include "mitkRenderWindowBase.h"
18 #include "mitkRenderingManager.h"
19 #include "mitkVtkLayerController.h"
20 #include "vtkRenderer.h"
21 
22 mitk::RenderWindowBase::RenderWindowBase() : m_RenderProp(NULL), m_InResize(false)
23 {
24 }
25 
26 /*
27 * "Member functions, including virtual functions (10.3), can be called during construction or destruction (12.6.2). When
28 a
29 * virtual function is called directly or indirectly from a constructor (including from the mem-initializer for a data
30 member) or from
31 * a destructor, and the object to which the call applies is the object under construction or destruction, the function
32 called is
33 * the one defined in the constructor or destructor's own class or in one of its bases, but not a function overriding it
34 in a class
35 * derived from the constructor or destructor's class, or overriding it in one of the other base classes of the most
36 derived object[..]"
37 
38 * or short: within constructors and destructors classes are not polymorph.
39 */
41  const char *name,
43 {
44  if (renderingManager == NULL)
45  {
46  renderingManager = mitk::RenderingManager::GetInstance();
47  }
48 
49  if (m_Renderer.IsNull())
50  {
51  m_Renderer = mitk::VtkPropRenderer::New(name, GetVtkRenderWindow(), renderingManager, renderingMode);
52  }
53 
54  m_Renderer->InitRenderer(this->GetVtkRenderWindow());
55 
56  mitk::BaseRenderer::AddInstance(GetVtkRenderWindow(), m_Renderer);
57 
58  renderingManager->AddRenderWindow(GetVtkRenderWindow());
59 
60  m_RenderProp = vtkMitkRenderProp::New();
61  m_RenderProp->SetPropRenderer(m_Renderer);
62  m_Renderer->GetVtkRenderer()->AddViewProp(m_RenderProp);
63 
64  if ((this->GetVtkRenderWindow()->GetSize()[0] > 10) && (this->GetVtkRenderWindow()->GetSize()[1] > 10))
65  m_Renderer->InitSize(this->GetVtkRenderWindow()->GetSize()[0], this->GetVtkRenderWindow()->GetSize()[1]);
66 
67  m_InResize = false;
68 }
69 
71 {
72  return m_Renderer->GetDispatcher()->ProcessEvent(interactionEvent);
73 }
74 
76 {
77  m_Renderer->GetRenderingManager()->RemoveRenderWindow(GetVtkRenderWindow());
78  mitk::BaseRenderer::RemoveInstance(GetVtkRenderWindow());
79  m_Renderer->GetVtkRenderer()->RemoveViewProp(m_RenderProp);
80  m_RenderProp->Delete();
81 }
82 
84 {
85 }
86 
88 {
89  return mitk::BaseRenderer::GetInstance(this->GetVtkRenderWindow())->GetSliceNavigationController();
90 }
91 
93 {
94  return mitk::BaseRenderer::GetInstance(this->GetVtkRenderWindow())->GetCameraRotationController();
95 }
96 
98 {
99  mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(GetVtkRenderWindow());
100  switch (renderer->GetMapperID())
101  {
103  return GetSliceNavigationController();
104 
106  return GetCameraRotationController();
107 
108  default:
109  return GetSliceNavigationController();
110  }
111 }
112 
114 {
115  return m_Renderer;
116 }
virtual mitk::CameraRotationController * GetCameraRotationController()
virtual bool HandleEvent(InteractionEvent *interactionEvent)
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
Baseclass for renderer slice-/camera-control.
Organizes the rendering process.
Controls the selection of the slice the associated BaseRenderer will display.
Manager for coordinating the rendering process.
static RenderingManager * GetInstance()
virtual MapperSlotId GetMapperID()
Get the MapperSlotId to use.
virtual CameraRotationController * GetCameraRotationController()
virtual mitk::VtkPropRenderer * GetRenderer()
void AddRenderWindow(vtkRenderWindow *renderWindow)
static vtkMitkRenderProp * New()
static Pointer New(const char *_arga, vtkRenderWindow *_argb, mitk::RenderingManager *_argc)
void Initialize(mitk::RenderingManager *renderingManager=NULL, const char *name="unnamed renderer", mitk::BaseRenderer::RenderingMode::Type renderingMode=mitk::BaseRenderer::RenderingMode::Standard)
virtual SliceNavigationController * GetSliceNavigationController()
virtual mitk::SliceNavigationController * GetSliceNavigationController()
static void RemoveInstance(vtkRenderWindow *renWin)
static void AddInstance(vtkRenderWindow *renWin, BaseRenderer *baseRenderer)
virtual mitk::BaseController * GetController()