1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QT3DRENDER_QPICKEVENT_H |
5 | #define QT3DRENDER_QPICKEVENT_H |
6 | |
7 | #include <QtCore/QObject> |
8 | #include <QtGui/QVector3D> |
9 | #include <QtCore/QPointF> |
10 | #include <Qt3DCore/qentity.h> |
11 | #include <Qt3DRender/qviewport.h> |
12 | #include <Qt3DRender/qt3drender_global.h> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | namespace Qt3DRender { |
17 | |
18 | class QPickEventPrivate; |
19 | class QPickEvent; |
20 | typedef QSharedPointer<QPickEvent> QPickEventPtr; |
21 | |
22 | class Q_3DRENDERSHARED_EXPORT QPickEvent : public QObject |
23 | { |
24 | Q_OBJECT |
25 | Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted NOTIFY acceptedChanged) |
26 | Q_PROPERTY(QPointF position READ position CONSTANT) |
27 | Q_PROPERTY(float distance READ distance CONSTANT) |
28 | Q_PROPERTY(QVector3D localIntersection READ localIntersection CONSTANT) |
29 | Q_PROPERTY(QVector3D worldIntersection READ worldIntersection CONSTANT) |
30 | Q_PROPERTY(Qt3DRender::QPickEvent::Buttons button READ button CONSTANT) |
31 | Q_PROPERTY(int buttons READ buttons CONSTANT) |
32 | Q_PROPERTY(int modifiers READ modifiers CONSTANT) |
33 | Q_PROPERTY(Qt3DRender::QViewport *viewport READ viewport CONSTANT REVISION 14) |
34 | Q_PROPERTY(Qt3DCore::QEntity *entity READ entity CONSTANT REVISION 14) |
35 | public: |
36 | enum Buttons { |
37 | LeftButton = Qt::LeftButton, |
38 | RightButton = Qt::RightButton, |
39 | MiddleButton = Qt::MiddleButton, |
40 | BackButton = Qt::BackButton, |
41 | NoButton = Qt::NoButton |
42 | }; |
43 | Q_ENUM(Buttons) // LCOV_EXCL_LINE |
44 | |
45 | enum Modifiers { |
46 | NoModifier = Qt::NoModifier, |
47 | ShiftModifier = Qt::ShiftModifier, |
48 | ControlModifier = Qt::ControlModifier, |
49 | AltModifier = Qt::AltModifier, |
50 | MetaModifier = Qt::MetaModifier, |
51 | KeypadModifier = Qt::KeypadModifier |
52 | }; |
53 | Q_ENUM(Modifiers) // LCOV_EXCL_LINE |
54 | |
55 | QPickEvent(); |
56 | QPickEvent(const QPointF &position, const QVector3D& worldIntersection, const QVector3D& localIntersection, float distance); |
57 | QPickEvent(const QPointF &position, const QVector3D& worldIntersection, const QVector3D& localIntersection, float distance, Buttons button, |
58 | int buttons, int modifiers); |
59 | ~QPickEvent(); |
60 | |
61 | bool isAccepted() const; |
62 | |
63 | public Q_SLOTS: |
64 | void setAccepted(bool accepted); |
65 | |
66 | public: |
67 | QPointF position() const; |
68 | float distance() const; |
69 | QVector3D worldIntersection() const; |
70 | QVector3D localIntersection() const; |
71 | Buttons button() const; |
72 | int buttons() const; |
73 | int modifiers() const; |
74 | QViewport *viewport() const; |
75 | Qt3DCore::QEntity *entity() const; |
76 | |
77 | Q_SIGNALS: |
78 | void acceptedChanged(bool accepted); |
79 | |
80 | protected: |
81 | explicit QPickEvent(QObjectPrivate &dd, QObject *parent = nullptr); |
82 | |
83 | private: |
84 | Q_DECLARE_PRIVATE(QPickEvent) |
85 | |
86 | friend class QObjectPickerPrivate; |
87 | }; |
88 | |
89 | } // Qt3DRender |
90 | |
91 | QT_END_NAMESPACE |
92 | |
93 | Q_DECLARE_METATYPE(Qt3DRender::QPickEvent*) // LCOV_EXCL_LINE |
94 | |
95 | #endif // QT3DRENDER_QPICKEVENT_H |
96 | |