Medical Imaging Interaction Toolkit  2018.4.99-4c24e3cb
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 (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 "mitkGradientBackground.h"
14 #include "mitkVtkLayerController.h"
15 
16 #include <vtkRenderWindow.h>
17 #include <vtkRenderer.h>
18 
20 {
21  m_RenderWindow = nullptr;
22  m_Renderer = vtkSmartPointer<vtkRenderer>::New();
23  m_Renderer->InteractiveOff();
24 }
25 
27 {
28  if (m_RenderWindow != nullptr)
29  if (this->IsEnabled())
30  this->Disable();
31 }
32 
38 void mitk::GradientBackground::SetRenderWindow(vtkSmartPointer<vtkRenderWindow> renderWindow)
39 {
40  m_RenderWindow = renderWindow;
41 }
42 
47 vtkSmartPointer<vtkRenderWindow> mitk::GradientBackground::GetRenderWindow()
48 {
49  return m_RenderWindow;
50 }
51 
57 vtkSmartPointer<vtkRenderer> mitk::GradientBackground::GetVtkRenderer()
58 {
59  return m_Renderer;
60 }
61 
66 void mitk::GradientBackground::SetGradientColors(double r1, double g1, double b1, double r2, double g2, double b2)
67 {
68  this->SetLowerColor(r1, g1, b1);
69  this->SetUpperColor(r2, g2, b2);
70 }
71 
73 {
74  this->SetGradientColors(upper[0], upper[1], upper[2], lower[0], lower[1], lower[2]);
75 }
76 
77 void mitk::GradientBackground::SetUpperColor(double r, double g, double b)
78 {
79  m_Renderer->SetBackground(r, g, b);
80 }
81 
82 void mitk::GradientBackground::SetLowerColor(double r, double g, double b)
83 {
84  m_Renderer->SetBackground2(r, g, b);
85 }
86 
88 {
89  this->SetUpperColor(upper[0], upper[1], upper[2]);
90 }
91 
93 {
94  this->SetLowerColor(lower[0], lower[1], lower[2]);
95 }
96 
102 {
103  m_Renderer->GradientBackgroundOn();
105 }
106 
112 {
113  if (this->IsEnabled())
114  {
115  m_Renderer->GradientBackgroundOff();
117  }
118 }
119 
125 {
126  if (m_RenderWindow == nullptr)
127  return false;
128  else
129  return (mitk::VtkLayerController::GetInstance(m_RenderWindow)->IsRendererInserted(m_Renderer));
130 }
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)