forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QVTKGraphicsItem.h
114 lines (94 loc) · 4.15 KB
/
QVTKGraphicsItem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*=========================================================================
Program: Visualization Toolkit
Module: QVTKGraphicsItem.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2010 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
// .NAME QVTKGraphicsItem - provides a way to view a VTK scene as an item in QGraphicsView
//
// .SECTION Description
//
#ifndef QVTKGraphicsItem_hpp
#define QVTKGraphicsItem_hpp
#include "vtkGUISupportQtOpenGLModule.h" // For export macro
#include <QGLContext>
#include <QGraphicsWidget>
#include <vtkSmartPointer.h>
#include "QVTKWin32Header.h"
class vtkEventQtSlotConnect;
class QGLFramebufferObject;
class QVTKInteractorAdapter;
class QVTKInteractor;
class vtkGenericOpenGLRenderWindow;
class vtkObject;
class VTKGUISUPPORTQTOPENGL_EXPORT QVTKGraphicsItem : public QGraphicsWidget
{
Q_OBJECT
public:
// Description:
// constructor. Takes a QGLContext to use which the QGraphicsView is using.
QVTKGraphicsItem(QGLContext* ctx, QGraphicsItem* p = 0);
// Description:
// destructor
~QVTKGraphicsItem();
// Description:
// set the render window to use with this item
void SetRenderWindow(vtkGenericOpenGLRenderWindow* win);
// Description:
// get the render window used with this item
vtkGenericOpenGLRenderWindow* GetRenderWindow() const;
// Description:
// get the render window interactor used with this item
// this item enforces its own interactor
QVTKInteractor* GetInteractor() const;
public Q_SLOTS:
// Description:
// update this item in the view (this does not cause the vtk render window to draw)
// it just causes the current contents in the window to draw to the QGraphicsScene
virtual void Update();
protected Q_SLOTS:
// slot to make this vtk render window current
virtual void MakeCurrent();
// slot called when vtk render window starts to draw
virtual void Start();
// slot called when vtk render window is done drawing
virtual void End();
// slot called when vtk wants to know if the context is current
virtual void IsCurrent(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
// slot called when vtk wants to know if a window is direct
virtual void IsDirect(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
// slot called when vtk wants to know if a window supports OpenGL
virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
protected:
// handle item key events
void keyPressEvent(QKeyEvent* e);
void keyReleaseEvent(QKeyEvent* e);
// handle item mouse events
void mousePressEvent(QGraphicsSceneMouseEvent* e);
void mouseReleaseEvent(QGraphicsSceneMouseEvent* e);
void mouseMoveEvent(QGraphicsSceneMouseEvent* e);
void resizeEvent(QGraphicsSceneResizeEvent* e);
void moveEvent(QGraphicsSceneMoveEvent* e);
void wheelEvent(QGraphicsSceneWheelEvent* e);
void hoverEnterEvent(QGraphicsSceneHoverEvent* e);
void hoverLeaveEvent(QGraphicsSceneHoverEvent* e);
void hoverMoveEvent(QGraphicsSceneHoverEvent* e);
// handle item paint event
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QGLContext* mContext;
QGLFramebufferObject* mFBO;
vtkSmartPointer<vtkGenericOpenGLRenderWindow> mWin;
vtkSmartPointer<QVTKInteractor> mIren;
QVTKInteractorAdapter* mIrenAdapter;
vtkSmartPointer<vtkEventQtSlotConnect> mConnect;
};
#endif