1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Data Visualization module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 or (at your option) any later version |
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | #ifndef QABSTRACT3DINPUTHANDLER_H |
31 | #define QABSTRACT3DINPUTHANDLER_H |
32 | |
33 | #include <QtDataVisualization/qdatavisualizationglobal.h> |
34 | #include <QtDataVisualization/q3dscene.h> |
35 | #include <QtCore/QObject> |
36 | #include <QtCore/QPoint> |
37 | #include <QtGui/QWheelEvent> |
38 | #include <QtGui/QMouseEvent> |
39 | #include <QtGui/QTouchEvent> |
40 | |
41 | QT_BEGIN_NAMESPACE_DATAVISUALIZATION |
42 | |
43 | class QAbstract3DInputHandlerPrivate; |
44 | |
45 | class QT_DATAVISUALIZATION_EXPORT QAbstract3DInputHandler : public QObject |
46 | { |
47 | Q_OBJECT |
48 | Q_ENUMS(InputView) |
49 | Q_PROPERTY(InputView inputView READ inputView WRITE setInputView NOTIFY inputViewChanged) |
50 | Q_PROPERTY(QPoint inputPosition READ inputPosition WRITE setInputPosition NOTIFY positionChanged) |
51 | Q_PROPERTY(Q3DScene *scene READ scene WRITE setScene NOTIFY sceneChanged) |
52 | |
53 | public: |
54 | enum InputView { |
55 | InputViewNone = 0, |
56 | InputViewOnPrimary, |
57 | InputViewOnSecondary |
58 | }; |
59 | |
60 | protected: |
61 | explicit QAbstract3DInputHandler(QObject *parent = nullptr); |
62 | public: |
63 | virtual ~QAbstract3DInputHandler(); |
64 | |
65 | // Input event listeners |
66 | virtual void mouseDoubleClickEvent(QMouseEvent *event); |
67 | virtual void touchEvent(QTouchEvent *event); |
68 | virtual void mousePressEvent(QMouseEvent *event, const QPoint &mousePos); |
69 | virtual void mouseReleaseEvent(QMouseEvent *event, const QPoint &mousePos); |
70 | virtual void mouseMoveEvent(QMouseEvent *event, const QPoint &mousePos); |
71 | #if QT_CONFIG(wheelevent) |
72 | virtual void wheelEvent(QWheelEvent *event); |
73 | #endif |
74 | |
75 | InputView inputView() const; |
76 | void setInputView(InputView inputView); |
77 | |
78 | QPoint inputPosition() const; |
79 | void setInputPosition(const QPoint &position); |
80 | |
81 | Q3DScene *scene() const; |
82 | void setScene(Q3DScene *scene); |
83 | |
84 | Q_SIGNALS: |
85 | void positionChanged(const QPoint &position); |
86 | void inputViewChanged(QAbstract3DInputHandler::InputView view); |
87 | void sceneChanged(Q3DScene *scene); |
88 | |
89 | protected: |
90 | void setPrevDistance(int distance); |
91 | int prevDistance() const; |
92 | void setPreviousInputPos(const QPoint &position); |
93 | QPoint previousInputPos() const; |
94 | |
95 | private: |
96 | Q_DISABLE_COPY(QAbstract3DInputHandler) |
97 | |
98 | QScopedPointer<QAbstract3DInputHandlerPrivate> d_ptr; |
99 | |
100 | friend class Abstract3DController; |
101 | friend class QTouch3DInputHandlerPrivate; |
102 | }; |
103 | |
104 | QT_END_NAMESPACE_DATAVISUALIZATION |
105 | |
106 | #endif |
107 |