| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QTDATAVIS3D_QABSTRACT3DINPUTHANDLER_H |
| 5 | #define QTDATAVIS3D_QABSTRACT3DINPUTHANDLER_H |
| 6 | |
| 7 | #include <QtDataVisualization/qdatavisualizationglobal.h> |
| 8 | #include <QtDataVisualization/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_DATAVISUALIZATION_EXPORT QAbstract3DInputHandler : public QObject |
| 20 | { |
| 21 | Q_OBJECT |
| 22 | Q_ENUMS(InputView) |
| 23 | Q_PROPERTY(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 | |
| 34 | protected: |
| 35 | explicit QAbstract3DInputHandler(QObject *parent = nullptr); |
| 36 | public: |
| 37 | virtual ~QAbstract3DInputHandler(); |
| 38 | |
| 39 | // Input event listeners |
| 40 | virtual void mouseDoubleClickEvent(QMouseEvent *event); |
| 41 | virtual void touchEvent(QTouchEvent *event); |
| 42 | virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos); |
| 43 | virtual void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos); |
| 44 | virtual void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos); |
| 45 | #if QT_CONFIG(wheelevent) |
| 46 | virtual void wheelEvent(QWheelEvent *event); |
| 47 | #endif |
| 48 | |
| 49 | InputView inputView() const; |
| 50 | void setInputView(InputView inputView); |
| 51 | |
| 52 | QPoint inputPosition() const; |
| 53 | void setInputPosition(const QPoint &position); |
| 54 | |
| 55 | Q3DScene *scene() const; |
| 56 | void setScene(Q3DScene *scene); |
| 57 | |
| 58 | Q_SIGNALS: |
| 59 | void positionChanged(const QPoint &position); |
| 60 | void inputViewChanged(QAbstract3DInputHandler::InputView view); |
| 61 | void sceneChanged(Q3DScene *scene); |
| 62 | |
| 63 | protected: |
| 64 | void setPrevDistance(int distance); |
| 65 | int prevDistance() const; |
| 66 | void setPreviousInputPos(const QPoint &position); |
| 67 | QPoint previousInputPos() const; |
| 68 | |
| 69 | private: |
| 70 | Q_DISABLE_COPY(QAbstract3DInputHandler) |
| 71 | |
| 72 | QScopedPointer<QAbstract3DInputHandlerPrivate> d_ptr; |
| 73 | |
| 74 | friend class Abstract3DController; |
| 75 | friend class QTouch3DInputHandlerPrivate; |
| 76 | }; |
| 77 | |
| 78 | QT_END_NAMESPACE |
| 79 | |
| 80 | #endif |
| 81 | |