Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkVtkGLMapperWrapper.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 "mitkVtkGLMapperWrapper.h"
14 
15 // mitk includes
16 #include "mitkDataNode.h"
17 #include "mitkGL.h"
18 #include "vtkGLMapperProp.h"
19 
20 // constructor LocalStorage
22 {
23  m_GLMapperProp = vtkSmartPointer<vtkGLMapperProp>::New();
24 }
25 // destructor LocalStorage
27 {
28 }
29 
30 // constructor VtkGLMapperWrapper
32 {
33  m_MitkGLMapper = mitkGLMapper;
34 }
35 
36 // destructor
38 {
39 }
40 
41 // returns propassembly
43 {
44  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
45  return ls->m_GLMapperProp;
46 }
47 
49 {
50  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
51  ls->m_GLMapperProp->SetBaseRenderer(renderer);
52  ls->m_GLMapperProp->SetWrappedGLMapper(m_MitkGLMapper);
53 }
54 
56 {
57  m_MitkGLMapper->ApplyColorAndOpacityProperties(renderer, actor);
58 }
59 
61 {
63  return;
64  Enable2DOpenGL(renderer);
65  Superclass::MitkRender(renderer, type);
67 }
68 
70 {
71  Superclass::Update(renderer);
72  m_MitkGLMapper->Update(renderer);
73 }
74 
76 {
77  m_MitkGLMapper->SetDataNode(node);
78 }
79 
81 {
82  return m_MitkGLMapper->GetDataNode();
83 }
84 
91 {
92  GLint vp[4];
93 
94  // Get a copy of the viewport
95  glGetIntegerv(GL_VIEWPORT, vp);
96 
97  // Save a copy of the projection matrix so that we can restore it
98  // when it's time to do 3D rendering again.
99  glMatrixMode(GL_PROJECTION);
100  glPushMatrix();
101  glLoadIdentity();
102 
103  glOrtho(vp[0], vp[2] + vp[0], vp[1], vp[3] + vp[1], -2000, 2000);
104 
105  glMatrixMode(GL_MODELVIEW);
106  glPushMatrix();
107  glLoadIdentity();
108 
109  // Make sure depth testing and lighting are disabled for 2D rendering until
110  // we are finished rendering in 2D
111  glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT);
112  glDisable(GL_DEPTH_TEST);
113  glDisable(GL_LIGHTING);
114  // disable the texturing here so crosshair is painted in the correct colors
115  // vtk will reenable texturing every time it is needed
116  glDisable(GL_TEXTURE_1D);
117  glDisable(GL_TEXTURE_2D);
118  glLineWidth(1.0);
119 }
120 
128 {
129  glPopAttrib();
130  glMatrixMode(GL_PROJECTION);
131  glPopMatrix();
132  glMatrixMode(GL_MODELVIEW);
133  glPopMatrix();
134 }
#define ls
Definition: MitkMCxyz.cpp:57
void Update(BaseRenderer *renderer) override
Calls the time step of the input data for the specified renderer and checks whether the time step is ...
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
DataNode * GetDataNode() const override
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
void SetDataNode(DataNode *node) override
Set the DataNode containing the data to map.
void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor) override
Apply color and opacity properties read from the PropertyList. Called by mapper subclasses.
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.
Organizes the rendering process.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:31
Internal class holding the mapper, actor, etc. for each of the 3 2D render windows.
VtkGLMapperWrapper(GLMapper::Pointer mitkGLMapper)
void Enable2DOpenGL(mitk::BaseRenderer *)
Enable2DOpenGL() and Disable2DOpenGL() are used to switch between 2D rendering (orthographic projecti...
void MitkRender(mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type) override
Determines which geometry should be rendered (opaque, translucent, volumetric, overlay) and calls the...
vtkSmartPointer< vtkGLMapperProp > m_GLMapperProp
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
returns the a prop assembly
void Disable2DOpenGL()
Initialize the VtkPropRenderer.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.