29 #include <QOpenGLContext>
30 #include <QQuickWindow>
32 #include <QSGSimpleRectNode>
33 #include <QSGSimpleTextureNode>
35 #include "QVTKInteractor.h"
37 #include "vtkGenericOpenGLRenderWindow.h"
38 #include "vtkEventQtSlotConnect.h"
40 #include "vtkOpenGLExtensionManager.h"
41 #include "vtkRenderer.h"
43 #include "vtkCubeSource.h"
44 #include "vtkPolyDataMapper.h"
45 #include "vtkProperty.h"
47 #include <vtkFrameBufferObject2.h>
53 : QQuickFramebufferObject(parent)
55 setAcceptHoverEvents(
true);
56 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton);
63 m_interactor->SetRenderWindow(m_win);
65 m_connect->Connect(m_win, vtkCommand::WindowIsCurrentEvent,
this, SLOT(
IsCurrent(vtkObject*,
unsigned long,
void*,
void*)), NULL, 0.0, Qt::DirectConnection);
66 m_connect->Connect(m_win, vtkCommand::WindowIsDirectEvent,
this, SLOT(
IsDirect(vtkObject*,
unsigned long,
void*,
void*)), NULL, 0.0, Qt::DirectConnection);
67 m_connect->Connect(m_win, vtkCommand::WindowSupportsOpenGLEvent,
this, SLOT(
SupportsOpenGL(vtkObject*,
unsigned long,
void*,
void*)), NULL, 0.0, Qt::DirectConnection);
69 connect(
this, SIGNAL(textureFollowsItemSizeChanged(
bool)),
77 m_connect->Disconnect(m_win, vtkCommand::WindowIsCurrentEvent,
this, SLOT(
IsCurrent(vtkObject*,
unsigned long,
void*,
void*)));
78 m_connect->Disconnect(m_win, vtkCommand::WindowIsDirectEvent,
this, SLOT(
IsDirect(vtkObject*,
unsigned long,
void*,
void*)));
79 m_connect->Disconnect(m_win, vtkCommand::WindowSupportsOpenGLEvent,
this, SLOT(
SupportsOpenGL(vtkObject*,
unsigned long,
void*,
void*)));
87 node = QQuickFramebufferObject::updatePaintNode(node, nodeData);
88 QSGSimpleTextureNode *n =
static_cast<QSGSimpleTextureNode *
>(node);
90 n->setTextureCoordinatesTransform(QSGSimpleTextureNode::MirrorVertically);
93 return QQuickFramebufferObject::updatePaintNode(node, nodeData);
113 bool* ptr =
reinterpret_cast<bool*
>(call_data);
114 *ptr = QOpenGLContext::currentContext() == this->window()->openglContext();
119 int* ptr =
reinterpret_cast<int*
>(call_data);
125 int* ptr =
reinterpret_cast<int*
>(call_data);
133 qWarning(
"QVTKQuickItem: Mouse interaction is not (yet) supported when textureFollowsItemSize==false");
139 QQuickFramebufferObject::geometryChanged(newGeometry, oldGeometry);
140 QSize oldSize(oldGeometry.width(), oldGeometry.height());
141 QSize newSize(newGeometry.width(), newGeometry.height());
142 QResizeEvent e(newSize, oldSize);
143 if (m_interactorAdapter)
217 QEvent e2(QEvent::Enter);
227 QEvent e2(QEvent::Leave);
237 QMouseEvent e2(QEvent::MouseMove, e->pos(), Qt::NoButton, Qt::NoButton, e->modifiers());
246 m_win->OpenGLInitContext();
247 m_win->GetExtensionManager()->LoadExtension(
"GL_VERSION_1_4");
248 m_win->GetExtensionManager()->LoadExtension(
"GL_VERSION_2_0");
virtual void mouseDoubleClickEvent(QMouseEvent *e)
virtual void cleanupAfterRender()
virtual bool prepareForRender()
virtual void mouseMoveEvent(QMouseEvent *e)
virtual void hoverLeaveEvent(QHoverEvent *e)
virtual void IsCurrent(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
virtual void SupportsOpenGL(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
QVTKInteractor * GetInteractor() const
Renderer * createRenderer() const
virtual void keyReleaseEvent(QKeyEvent *e)
virtual void hoverEnterEvent(QHoverEvent *e)
virtual void wheelEvent(QWheelEvent *e)
virtual void mouseReleaseEvent(QMouseEvent *e)
virtual void IsDirect(vtkObject *caller, unsigned long vtk_event, void *client_data, void *call_data)
virtual void keyPressEvent(QKeyEvent *e)
virtual void mousePressEvent(QMouseEvent *e)
bool ProcessEvent(QEvent *e, vtkRenderWindowInteractor *iren)
friend class QVTKFramebufferObjectRenderer
virtual void hoverMoveEvent(QHoverEvent *e)
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
static vtkInternalOpenGLRenderWindow * New()
QSGNode * updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *nodeData)
void onTextureFollowsItemSizeChanged(bool follows)
QVTKQuickItem(QQuickItem *parent=0)
vtkOpenGLRenderWindow * GetRenderWindow() const
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.