Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkVtkOverlay.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 "mitkVtkOverlay.h"
18 #include <vtkProp.h>
19 #include <vtkProperty.h>
20 
22 {
23 }
24 
26 {
27 }
28 
30 {
31  vtkSmartPointer<vtkProp> prop = GetVtkProp(renderer);
32  if (!IsVisible(renderer))
33  {
34  prop->SetVisibility(false);
35  return;
36  }
37  else
38  {
39  prop->SetVisibility(true);
40  UpdateVtkOverlay(renderer);
41  }
42 }
43 
45 {
46  if (!renderer)
47  return;
48  AddToRenderer(renderer, renderer->GetVtkRenderer());
49 }
50 
51 void mitk::VtkOverlay::AddToRenderer(mitk::BaseRenderer *renderer, vtkRenderer *vtkrenderer)
52 {
53  if (!renderer || !vtkrenderer)
54  return;
55  Update(renderer);
56  vtkSmartPointer<vtkProp> vtkProp = GetVtkProp(renderer);
57  if (renderer && vtkrenderer && !vtkrenderer->HasViewProp(vtkProp))
58  {
59  vtkrenderer->AddViewProp(vtkProp);
60  mitk::RenderingManager::GetInstance()->RequestUpdate(vtkrenderer->GetRenderWindow());
61  }
62 }
63 
65 {
66  if (!renderer)
67  return;
68  RemoveFromRenderer(renderer, renderer->GetVtkRenderer());
69 }
70 
71 void mitk::VtkOverlay::RemoveFromRenderer(mitk::BaseRenderer *renderer, vtkRenderer *vtkrenderer)
72 {
73  if (!renderer || !vtkrenderer)
74  return;
75  vtkSmartPointer<vtkProp> vtkProp = GetVtkProp(renderer);
76  if (vtkrenderer->HasViewProp(vtkProp))
77  {
78  vtkrenderer->RemoveViewProp(vtkProp);
79  mitk::RenderingManager::GetInstance()->RequestUpdate(vtkrenderer->GetRenderWindow());
80  }
81 }
82 
84 {
85  GetVtkProp(renderer)->RenderOpaqueGeometry(renderer->GetVtkRenderer());
86  GetVtkProp(renderer)->RenderOverlay(renderer->GetVtkRenderer());
87 }
virtual ~VtkOverlay()
virtual destructor in order to derive from this class
void AddToBaseRenderer(BaseRenderer *renderer) override
Adds the overlay to the specified renderer. Update Overlay should be called soon in order to apply al...
void RemoveFromRenderer(BaseRenderer *renderer, vtkRenderer *vtkrenderer) override
Removes the overlay from the specified renderer. It is not visible anymore then.
Organizes the rendering process.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
void Paint(BaseRenderer *renderer)
Paints the overlay.
void Update(BaseRenderer *renderer) override
Applies all properties and should be called before the rendering procedure.
VtkOverlay()
explicit constructor which disallows implicit conversions
static RenderingManager * GetInstance()
void RequestUpdate(vtkRenderWindow *renderWindow)
void RemoveFromBaseRenderer(BaseRenderer *renderer) override
Removes the overlay from the specified renderer. It is not visible anymore then.
vtkRenderer * GetVtkRenderer() const
void AddToRenderer(BaseRenderer *renderer, vtkRenderer *vtkrenderer) override
Adds the overlay to the specified renderer. Update Overlay should be called soon in order to apply al...