Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkRenderWindowFrame.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 "mitkRenderWindowFrame.h"
18 #include "mitkVtkLayerController.h"
19 #include "vtkMitkRectangleProp.h"
20 
21 #include <vtkRenderWindow.h>
22 #include <vtkRenderer.h>
23 
25 {
26  m_RenderWindow = nullptr;
28 
29  m_IsEnabled = false;
30 }
31 
33 {
34  if (m_RenderWindow != nullptr)
35  if (this->IsEnabled())
36  this->Disable();
37 }
38 
44 void mitk::RenderWindowFrame::SetRenderWindow(vtkSmartPointer<vtkRenderWindow> renderWindow)
45 {
46  m_RenderWindow = renderWindow;
47 }
48 
53 vtkSmartPointer<vtkRenderWindow> mitk::RenderWindowFrame::GetRenderWindow()
54 {
55  return m_RenderWindow;
56 }
57 
63 vtkSmartPointer<vtkRenderer> mitk::RenderWindowFrame::GetVtkRenderer()
64 {
65  return m_RectangleRenderer;
66 }
67 
73 {
74  if (this->IsEnabled())
75  {
76  m_RectangleRenderer->EraseOn();
77  mitk::VtkLayerController::GetInstance(m_RenderWindow)->RemoveRenderer(m_RectangleRenderer);
78  m_IsEnabled = false;
79  }
80 }
81 
86 void mitk::RenderWindowFrame::Enable(float col1, float col2, float col3)
87 {
88  vtkSmartPointer<vtkMitkRectangleProp> rect = vtkSmartPointer<vtkMitkRectangleProp>::New();
89  rect->SetColor(col1, col2, col3);
90 
91  m_RectangleRenderer->AddActor(rect);
92  if (!mitk::VtkLayerController::GetInstance(m_RenderWindow)->IsRendererInserted(m_RectangleRenderer))
93  {
94  m_RectangleRenderer->EraseOff();
95  m_RectangleRenderer->SetInteractive(0);
96 
97  mitk::VtkLayerController::GetInstance(m_RenderWindow)->InsertForegroundRenderer(m_RectangleRenderer, true);
98 
99  m_IsEnabled = true;
100  }
101 }
107 {
108  return m_IsEnabled;
109 }
vtkSmartPointer< vtkRenderWindow > m_RenderWindow
virtual vtkSmartPointer< vtkRenderWindow > GetRenderWindow()
void InsertForegroundRenderer(vtkSmartPointer< vtkRenderer > renderer, bool forceAbsoluteForeground)
virtual vtkSmartPointer< vtkRenderer > GetVtkRenderer()
static VtkLayerController * GetInstance(vtkSmartPointer< vtkRenderWindow > renWin)
vtkSmartPointer< vtkRenderer > m_RectangleRenderer
void RemoveRenderer(vtkSmartPointer< vtkRenderer > renderer)
virtual void SetRenderWindow(vtkSmartPointer< vtkRenderWindow > renderWindow)
virtual void Enable(float col1, float col2, float col3)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.