Medical Imaging Interaction Toolkit  2016.11.0
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,
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 "mitkVtkGLMapperWrapper.h"
18 
19 // mitk includes
20 #include "mitkDataNode.h"
21 #include "mitkGL.h"
22 #include "vtkGLMapperProp.h"
23 
24 // constructor LocalStorage
26 {
28 }
29 // destructor LocalStorage
31 {
32 }
33 
34 // constructor VtkGLMapperWrapper
36 {
37  m_MitkGLMapper = mitkGLMapper;
38 }
39 
40 // destructor
42 {
43 }
44 
45 // returns propassembly
47 {
48  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
49  return ls->m_GLMapperProp;
50 }
51 
53 {
54  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
55  ls->m_GLMapperProp->SetBaseRenderer(renderer);
56  ls->m_GLMapperProp->SetWrappedGLMapper(m_MitkGLMapper);
57 }
58 
60 {
61  m_MitkGLMapper->ApplyColorAndOpacityProperties(renderer, actor);
62 }
63 
65 {
67  return;
68  Enable2DOpenGL(renderer);
69  Superclass::MitkRender(renderer, type);
71 }
72 
74 {
75  Superclass::Update(renderer);
76  m_MitkGLMapper->Update(renderer);
77 }
78 
80 {
81  m_MitkGLMapper->SetDataNode(node);
82 }
83 
85 {
86  return m_MitkGLMapper->GetDataNode();
87 }
88 
95 {
96  GLint vp[4];
97 
98  // Get a copy of the viewport
99  glGetIntegerv(GL_VIEWPORT, vp);
100 
101  // Save a copy of the projection matrix so that we can restore it
102  // when it's time to do 3D rendering again.
103  glMatrixMode(GL_PROJECTION);
104  glPushMatrix();
105  glLoadIdentity();
106 
107  glOrtho(vp[0], vp[2] + vp[0], vp[1], vp[3] + vp[1], -2000, 2000);
108 
109  glMatrixMode(GL_MODELVIEW);
110  glPushMatrix();
111  glLoadIdentity();
112 
113  // Make sure depth testing and lighting are disabled for 2D rendering until
114  // we are finished rendering in 2D
115  glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_LIGHTING_BIT);
116  glDisable(GL_DEPTH_TEST);
117  glDisable(GL_LIGHTING);
118  // disable the texturing here so crosshair is painted in the correct colors
119  // vtk will reenable texturing every time it is needed
120  glDisable(GL_TEXTURE_1D);
121  glDisable(GL_TEXTURE_2D);
122  glLineWidth(1.0);
123 }
124 
132 {
133  glPopAttrib();
134  glMatrixMode(GL_PROJECTION);
135  glPopMatrix();
136  glMatrixMode(GL_MODELVIEW);
137  glPopMatrix();
138 }
virtual 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.
virtual DataNode * GetDataNode() const override
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
virtual void SetDataNode(DataNode *node) override
Set the DataNode containing the data to map.
virtual 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:35
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
virtual 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:66
virtual void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.