Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QVTKQuickItem.h
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 // original copyright below
18 
19 /*========================================================================
20  OpenView -- http://openview.kitware.com
21 
22  Copyright 2012 Kitware, Inc.
23 
24  Licensed under the BSD license. See LICENSE file for details.
25  ========================================================================*/
26 
27 #ifndef __QVTKQuickItem_h
28 #define __QVTKQuickItem_h
29 
30 #include <QQuickFramebufferObject>
31 
32 #include <QOpenGLShaderProgram>
33 
34 #include "vtkSmartPointer.h"
35 #include "vtkNew.h"
36 
37 #include <QMutex>
38 
40 
41 class QOpenGLContext;
42 class QOpenGLFramebufferObject;
44 class QVTKInteractor;
46 class vtkEventQtSlotConnect;
47 class vtkOpenGLRenderWindow;
48 class vtkObject;
49 class vtkContextView;
50 
51 class MITKOPENVIEWCORE_EXPORT QVTKQuickItem : public QQuickFramebufferObject
52 {
53  Q_OBJECT
54 public:
55  QVTKQuickItem(QQuickItem* parent = 0);
56 
57  // Description:
58  // destructor
59  ~QVTKQuickItem();
60 
61  Renderer *createRenderer() const;
62 
63  // Description:
64  // get the render window used with this item
65  vtkOpenGLRenderWindow* GetRenderWindow() const;
66 
67  // Description:
68  // get the render window interactor used with this item
69  // this item enforces its own interactor
70  QVTKInteractor* GetInteractor() const;
71 
72  QMutex m_viewLock;
73 
74  protected slots:
75  // slot called when vtk wants to know if the context is current
76  virtual void IsCurrent(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
77  // slot called when vtk wants to know if a window is direct
78  virtual void IsDirect(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
79  // slot called when vtk wants to know if a window supports OpenGL
80  virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
81  void onTextureFollowsItemSizeChanged(bool follows);
82 
83 protected:
84  // Called ONCE from the render thread before the FBO is first created and while the GUI thread is blocked
85  virtual void init();
86  // Called from the render thread BEFORE each update while the GUI thread blocked
87  virtual bool prepareForRender();
88  // Called from the render thread AFTER each update while the GUI thread is NOT blocked
89  virtual void cleanupAfterRender();
90 
91  // handle item key events
92  virtual void keyPressEvent(QKeyEvent* e);
93  virtual void keyReleaseEvent(QKeyEvent* e);
94 
95  // handle item mouse events
96  virtual void mousePressEvent(QMouseEvent* e);
97  virtual void mouseReleaseEvent(QMouseEvent* e);
98  virtual void mouseDoubleClickEvent(QMouseEvent* e);
99  virtual void mouseMoveEvent(QMouseEvent* e);
100  virtual void geometryChanged(const QRectF & newGeometry, const QRectF & oldGeometry);
101  virtual void wheelEvent(QWheelEvent* e);
102  virtual void hoverEnterEvent(QHoverEvent* e);
103  virtual void hoverLeaveEvent(QHoverEvent* e);
104  virtual void hoverMoveEvent(QHoverEvent* e);
105  QSGNode* updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *nodeData);
106 
107 private:
108  vtkOpenGLRenderWindow *m_win;
109  vtkSmartPointer<QVTKInteractor> m_interactor;
110  QVTKMitkInteractorAdapter* m_interactorAdapter;
111  vtkSmartPointer<vtkEventQtSlotConnect> m_connect;
112 
114 };
115 
116 #endif
QMutex m_viewLock
Definition: QVTKQuickItem.h:72
#define MITKOPENVIEWCORE_EXPORT