Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QVTKFramebufferObjectRenderer.cxx
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 
19 #include <vtkgl.h>
20 
21 #include <vtkCubeSource.h>
22 #include <vtkPolyDataMapper.h>
23 #include <vtkActor.h>
24 #include <vtkRenderer.h>
25 #include <vtkProperty.h>
26 #include <vtkMutexLock.h>
27 
28 #include <vtkStructuredPointsReader.h>
29 #include <vtkPiecewiseFunction.h>
30 #include <vtkColorTransferFunction.h>
31 #include <vtkImageClip.h>
32 #include <vtkVolumeProperty.h>
33 #include <vtkFixedPointVolumeRayCastMapper.h>
34 #include <vtkVolume.h>
35 
37 m_vtkRenderWindow(rw),
38 m_neverRendered(true),
39 m_readyToRender(false)
40 {
41  m_vtkRenderWindow->Register(NULL);
43 }
44 
45 QOpenGLFramebufferObject * QVTKFramebufferObjectRenderer::createFramebufferObject(const QSize &size)
46 {
47 
48  QOpenGLFramebufferObjectFormat format;
49  format.setAttachment(QOpenGLFramebufferObject::Depth);
50  format.setTextureTarget(GL_TEXTURE_2D);
51  format.setInternalTextureFormat(GL_RGBA32F_ARB);
52  QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(size, format);
53 
55  return fbo;
56 }
57 
59 {
60  if (!m_readyToRender)
61  {
62  return;
63  }
64 
65  m_vtkQuickItem->m_viewLock.lock();
66  m_vtkRenderWindow->PushState();
67  m_vtkRenderWindow->OpenGLInitState();
70  m_vtkRenderWindow->PopState();
71  m_vtkQuickItem->m_viewLock.unlock();
72 
73 }
74 
75 void QVTKFramebufferObjectRenderer::synchronize(QQuickFramebufferObject * item)
76 {
77  m_vtkQuickItem = static_cast<QVTKQuickItem*>(item);
78 
79  if (m_neverRendered)
80  {
81  m_neverRendered = false;
83  }
85 }
86 
88 {
90  m_vtkRenderWindow->Delete();
91 }
QVTKFramebufferObjectRenderer * QtParentRenderer
QMutex m_viewLock
Definition: QVTKQuickItem.h:72
virtual bool prepareForRender()
virtual void synchronize(QQuickFramebufferObject *item)
vtkInternalOpenGLRenderWindow * m_vtkRenderWindow
QOpenGLFramebufferObject * createFramebufferObject(const QSize &size)
QVTKFramebufferObjectRenderer(vtkInternalOpenGLRenderWindow *rw)
virtual void init()
void SetFramebufferObject(QOpenGLFramebufferObject *fbo)