Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkRenderWindow.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 "mitkRenderWindow.h"
18 
19 #include "mitkRenderingManager.h"
20 #include "mitkVtkEventProvider.h"
21 #include "mitkVtkLayerController.h"
22 #include "vtkRenderWindowInteractor.h"
23 #include "vtkRenderer.h"
24 
25 mitk::RenderWindow::RenderWindow(vtkRenderWindow *renWin,
26  const char *name,
29  : m_vtkRenderWindow(renWin), m_vtkRenderWindowInteractor(NULL), m_vtkMitkEventProvider(NULL)
30 {
31  if (m_vtkRenderWindow == NULL)
32  {
34 
36  {
37  m_vtkRenderWindow->SetMultiSamples(0);
38  m_vtkRenderWindow->SetAlphaBitPlanes(1);
39  }
41  {
42  m_vtkRenderWindow->SetMultiSamples(8);
43  }
45  {
46  m_vtkRenderWindow->SetMultiSamples(0);
47  }
48  }
49 
50  if (m_vtkRenderWindow->GetSize()[0] <= 10)
51  {
52  m_vtkRenderWindow->SetSize(100, 100);
53  }
54 
57  m_vtkRenderWindowInteractor->Initialize();
58 
59  // initialize from RenderWindowBase
60  Initialize(rm, name, rmtype);
61 
66 }
67 
69 {
70  Destroy();
71  m_vtkRenderWindow->Delete();
72  m_vtkRenderWindowInteractor->Delete();
73  m_vtkMitkEventProvider->Delete();
74 }
75 
77 {
78  return m_vtkRenderWindow;
79 }
80 
82 {
83  return m_vtkRenderWindowInteractor;
84 }
85 
86 void mitk::RenderWindow::SetSize(int width, int height)
87 {
88  this->GetVtkRenderWindow()->SetSize(width, height);
89 }
90 
92 {
93  m_vtkMitkEventProvider->SetEnabled(0);
94  m_vtkMitkEventProvider->SetInteractor(this->GetVtkRenderWindowInteractor());
95  m_vtkMitkEventProvider->SetMitkRenderWindow(this);
96  m_vtkMitkEventProvider->SetEnabled(1);
97 }
virtual vtkRenderWindow * GetVtkRenderWindow() override
virtual void SetInteractor(vtkRenderWindowInteractor *iren) override
RenderWindow(vtkRenderWindow *existingRenderWindow=NULL, const char *name="unnamed renderer", mitk::RenderingManager *rm=NULL, mitk::BaseRenderer::RenderingMode::Type rmtype=mitk::BaseRenderer::RenderingMode::Standard)
virtual void SetEnabled(int) override
static vtkEventProvider * New()
Manager for coordinating the rendering process.
virtual void SetMitkRenderWindow(mitk::RenderWindow *renWin)
virtual vtkRenderWindowInteractor * GetVtkRenderWindowInteractor() override
vtkRenderWindowInteractor * m_vtkRenderWindowInteractor
void Initialize(mitk::RenderingManager *renderingManager=NULL, const char *name="unnamed renderer", mitk::BaseRenderer::RenderingMode::Type renderingMode=mitk::BaseRenderer::RenderingMode::Standard)
vtkEventProvider * m_vtkMitkEventProvider
vtkRenderWindow * m_vtkRenderWindow
void ReinitEventProvider()
Initializes the mitkVtkEventProvider to listen to the currently used vtkInteractorStyle.
void SetSize(int width, int height)
Convenience method to set the size of an mitkRenderWindow.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.