1 | // Copyright (C) 2023 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QABSTRACT3DINPUTHANDLER_H |
5 | #define QABSTRACT3DINPUTHANDLER_H |
6 | |
7 | #include <QtGraphs/qgraphsglobal.h> |
8 | #include <QtGraphs/q3dscene.h> |
9 | #include <QtCore/QObject> |
10 | #include <QtCore/QPoint> |
11 | #include <QtGui/QWheelEvent> |
12 | #include <QtGui/QMouseEvent> |
13 | #include <QtGui/QTouchEvent> |
14 | |
15 | QT_BEGIN_NAMESPACE |
16 | |
17 | class QAbstract3DInputHandlerPrivate; |
18 | |
19 | class Q_GRAPHS_EXPORT QAbstract3DInputHandler : public QObject |
20 | { |
21 | Q_OBJECT |
22 | Q_DECLARE_PRIVATE(QAbstract3DInputHandler) |
23 | Q_PROPERTY(QAbstract3DInputHandler::InputView inputView READ inputView WRITE setInputView NOTIFY inputViewChanged) |
24 | Q_PROPERTY(QPoint inputPosition READ inputPosition WRITE setInputPosition NOTIFY positionChanged) |
25 | Q_PROPERTY(Q3DScene *scene READ scene WRITE setScene NOTIFY sceneChanged) |
26 | |
27 | public: |
28 | enum InputView { |
29 | InputViewNone = 0, |
30 | InputViewOnPrimary, |
31 | InputViewOnSecondary |
32 | }; |
33 | Q_ENUM(InputView) |
34 | |
35 | protected: |
36 | explicit QAbstract3DInputHandler(QAbstract3DInputHandlerPrivate *d, QObject *parent = nullptr); |
37 | explicit QAbstract3DInputHandler(QObject *parent = nullptr); |
38 | |
39 | public: |
40 | virtual ~QAbstract3DInputHandler(); |
41 | |
42 | // Input event listeners |
43 | virtual void mouseDoubleClickEvent(QMouseEvent *event); |
44 | virtual void touchEvent(QTouchEvent *event); |
45 | virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos); |
46 | virtual void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos); |
47 | virtual void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos); |
48 | #if QT_CONFIG(wheelevent) |
49 | virtual void wheelEvent(QWheelEvent *event); |
50 | #endif |
51 | |
52 | QAbstract3DInputHandler::InputView inputView() const; |
53 | void setInputView(QAbstract3DInputHandler::InputView inputView); |
54 | |
55 | QPoint inputPosition() const; |
56 | void setInputPosition(const QPoint &position, bool forceSelection = false); |
57 | |
58 | Q3DScene *scene() const; |
59 | void setScene(Q3DScene *scene); |
60 | |
61 | Q_SIGNALS: |
62 | void positionChanged(const QPoint &position); |
63 | void inputViewChanged(QAbstract3DInputHandler::InputView view); |
64 | void sceneChanged(Q3DScene *scene); |
65 | |
66 | public Q_SLOTS: |
67 | void handleSelection(const QPoint &position); |
68 | |
69 | protected: |
70 | QScopedPointer<QAbstract3DInputHandlerPrivate> d_ptr; |
71 | |
72 | void setPrevDistance(int distance); |
73 | int prevDistance() const; |
74 | void setPreviousInputPos(const QPoint &position); |
75 | QPoint previousInputPos() const; |
76 | |
77 | private: |
78 | Q_DISABLE_COPY(QAbstract3DInputHandler) |
79 | |
80 | friend class QQuickGraphsItem; |
81 | friend class Q3DInputHandler; |
82 | friend class Q3DTouchInputHandler; |
83 | }; |
84 | |
85 | QT_END_NAMESPACE |
86 | |
87 | #endif |
88 |