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