Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkGradientBackground.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 "mitkGradientBackground.h"
18 #include "mitkVtkLayerController.h"
19 
20 #include <vtkRenderWindow.h>
21 #include <vtkRenderer.h>
22 
24 {
25  m_RenderWindow = nullptr;
27  m_Renderer->InteractiveOff();
28 }
29 
31 {
32  if (m_RenderWindow != nullptr)
33  if (this->IsEnabled())
34  this->Disable();
35 }
36 
42 void mitk::GradientBackground::SetRenderWindow(vtkSmartPointer<vtkRenderWindow> renderWindow)
43 {
44  m_RenderWindow = renderWindow;
45 }
46 
51 vtkSmartPointer<vtkRenderWindow> mitk::GradientBackground::GetRenderWindow()
52 {
53  return m_RenderWindow;
54 }
55 
61 vtkSmartPointer<vtkRenderer> mitk::GradientBackground::GetVtkRenderer()
62 {
63  return m_Renderer;
64 }
65 
70 void mitk::GradientBackground::SetGradientColors(double r1, double g1, double b1, double r2, double g2, double b2)
71 {
72  this->SetLowerColor(r1, g1, b1);
73  this->SetUpperColor(r2, g2, b2);
74 }
75 
77 {
78  this->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]);
79 }
80 
81 void mitk::GradientBackground::SetUpperColor(double r, double g, double b)
82 {
83  m_Renderer->SetBackground(r, g, b);
84 }
85 
86 void mitk::GradientBackground::SetLowerColor(double r, double g, double b)
87 {
88  m_Renderer->SetBackground2(r, g, b);
89 }
90 
92 {
93  this->SetUpperColor(upper[0], upper[1], upper[2]);
94 }
95 
97 {
98  this->SetLowerColor(lower[0], lower[1], lower[2]);
99 }
100 
106 {
107  m_Renderer->GradientBackgroundOn();
108  mitk::VtkLayerController::GetInstance(m_RenderWindow)->InsertBackgroundRenderer(m_Renderer, true);
109 }
110 
116 {
117  if (this->IsEnabled())
118  {
119  m_Renderer->GradientBackgroundOff();
120  mitk::VtkLayerController::GetInstance(m_RenderWindow)->RemoveRenderer(m_Renderer);
121  }
122 }
123 
129 {
130  if (m_RenderWindow == nullptr)
131  return false;
132  else
133  return (mitk::VtkLayerController::GetInstance(m_RenderWindow)->IsRendererInserted(m_Renderer));
134 }
virtual void SetLowerColor(double r, double g, double b)
virtual void SetRenderWindow(vtkSmartPointer< vtkRenderWindow > renderWindow)
vtkSmartPointer< vtkRenderer > m_Renderer
virtual void SetGradientColors(double r1, double g1, double b1, double r2, double g2, double b2)
static VtkLayerController * GetInstance(vtkSmartPointer< vtkRenderWindow > renWin)
vtkSmartPointer< vtkRenderWindow > m_RenderWindow
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
void RemoveRenderer(vtkSmartPointer< vtkRenderer > renderer)
virtual vtkSmartPointer< vtkRenderWindow > GetRenderWindow()
virtual vtkSmartPointer< vtkRenderer > GetVtkRenderer()
void InsertBackgroundRenderer(vtkSmartPointer< vtkRenderer > renderer, bool forceAbsoluteBackground)
virtual void SetUpperColor(double r, double g, double b)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.