VTK  9.3.0
QQuickVTKInteractorAdapter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3#ifndef QQuickVTKInteractorAdapter_h
4#define QQuickVTKInteractorAdapter_h
5
6// VTK includes
8#include "vtkDeprecation.h"
9#include "vtkGUISupportQtQuickModule.h" // for export macro
10
11// Qt includes
12#include <QList> // for QList
13#include <QPointer> // for QPointer
14
15// Qt Forward declarations
16class QEnterEvent;
17class QEvent;
18class QFocusEvent;
19class QHoverEvent;
20class QKeyEvent;
21class QMouseEvent;
22class QQuickItem;
23class QQuickWindow;
24class QWheelEvent;
25
26VTK_ABI_NAMESPACE_BEGIN
27// VTK Forward declarations
29class vtkRenderer;
30
36 "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKInteractorAdapter
38{
39 Q_OBJECT
41
42public:
43 QQuickVTKInteractorAdapter(QObject* parent = nullptr);
44
45 void setQQuickWindow(QQuickWindow* win);
46
47 void QueueHoverEvent(QQuickItem* item, QHoverEvent* e);
48 void QueueKeyEvent(QQuickItem* item, QKeyEvent* e);
49 void QueueFocusEvent(QQuickItem* item, QFocusEvent* e);
50 void QueueMouseEvent(QQuickItem* item, QMouseEvent* e);
51 void QueueGeometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
52 void QueueWheelEvent(QQuickItem* item, QWheelEvent* e);
53
55
56 /*
57 * Map the event position to VTK display coordinates
58 * The mapping considers the following:
59 * - VTK widgets expect display coordinates, not viewport/local coordinates
60 * - vtkRenderWindowInteractor flips Y before processing the event.
61 * Because of the inherent flip in the superclass, the mapping does not flip Y implicitly.
62 * To map and flip Y, use mapEventPositionFlipY.
63 *
64 * \sa mapEventPositionFlipY
65 */
66 static QPointF mapEventPosition(QQuickItem* item, const QPointF& localPos);
67
68 /*
69 * Map the event position to VTK display coordinates and flip the Y axis to switch the point from
70 * the Qt coordinate reference system to VTK's.
71 *
72 * \sa mapEventPosition
73 */
74 static QPointF mapEventPositionFlipY(QQuickItem* item, const QPointF& localPos);
75
76protected:
77 void QueueEvent(QEvent* e);
78
79private:
80 QPointer<QQuickWindow> m_qwindow;
81 QList<QEvent*> m_queuedEvents;
82
83 Q_DISABLE_COPY(QQuickVTKInteractorAdapter)
84};
85
86VTK_ABI_NAMESPACE_END
87#endif // QQuickVTKInteractorAdapter_h
Intermediate class that handles relaying Qt events to VTK.
void setQQuickWindow(QQuickWindow *win)
void QueueWheelEvent(QQuickItem *item, QWheelEvent *e)
void ProcessEvents(vtkRenderWindowInteractor *interactor)
QQuickVTKInteractorAdapter(QObject *parent=nullptr)
static QPointF mapEventPosition(QQuickItem *item, const QPointF &localPos)
void QueueEvent(QEvent *e)
void QueueGeometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
void QueueHoverEvent(QQuickItem *item, QHoverEvent *e)
static QPointF mapEventPositionFlipY(QQuickItem *item, const QPointF &localPos)
void QueueKeyEvent(QQuickItem *item, QKeyEvent *e)
void QueueMouseEvent(QQuickItem *item, QMouseEvent *e)
void QueueFocusEvent(QQuickItem *item, QFocusEvent *e)
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition vtkRenderer.h:59
#define VTK_DEPRECATED_IN_9_3_0(reason)