VTK  9.3.1
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
16 class QEnterEvent;
17 class QEvent;
18 class QFocusEvent;
19 class QHoverEvent;
20 class QKeyEvent;
21 class QMouseEvent;
22 class QQuickItem;
23 class QQuickWindow;
24 class QWheelEvent;
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 // VTK Forward declarations
29 class vtkRenderer;
30 
36  "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKInteractorAdapter
37  : public QVTKInteractorAdapter
38 {
39  Q_OBJECT
41 
42 public:
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 
54  void ProcessEvents(vtkRenderWindowInteractor* interactor);
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 
76 protected:
77  void QueueEvent(QEvent* e);
78 
79 private:
80  QPointer<QQuickWindow> m_qwindow;
81  QList<QEvent*> m_queuedEvents;
82 
83  Q_DISABLE_COPY(QQuickVTKInteractorAdapter)
84 };
85 
86 VTK_ABI_NAMESPACE_END
87 #endif // QQuickVTKInteractorAdapter_h
abstract specification for renderers
Definition: vtkRenderer.h:61
platform-independent render window interaction including picking and frame rate control.
#define VTK_DEPRECATED_IN_9_3_0(reason)
Intermediate class that handles relaying Qt events to VTK.
QQuickItem that manages a VTK rendering in the QML scenegraph.
Definition: QQuickVTKItem.h:26