1/****************************************************************************
2**
3** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
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 Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QT3DRENDER_QPICKEVENT_H
41#define QT3DRENDER_QPICKEVENT_H
42
43#include <QtCore/QObject>
44#include <QtGui/QVector3D>
45#include <QtCore/QPointF>
46#include <Qt3DRender/qt3drender_global.h>
47
48QT_BEGIN_NAMESPACE
49
50namespace Qt3DCore {
51class QEntity;
52}
53
54namespace Qt3DRender {
55
56class QViewport;
57class QPickEventPrivate;
58
59class QPickEvent;
60typedef QSharedPointer<QPickEvent> QPickEventPtr;
61
62class Q_3DRENDERSHARED_EXPORT QPickEvent : public QObject
63{
64 Q_OBJECT
65 Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted NOTIFY acceptedChanged)
66 Q_PROPERTY(QPointF position READ position CONSTANT)
67 Q_PROPERTY(float distance READ distance CONSTANT)
68 Q_PROPERTY(QVector3D localIntersection READ localIntersection CONSTANT)
69 Q_PROPERTY(QVector3D worldIntersection READ worldIntersection CONSTANT)
70 Q_PROPERTY(Qt3DRender::QPickEvent::Buttons button READ button CONSTANT)
71 Q_PROPERTY(int buttons READ buttons CONSTANT)
72 Q_PROPERTY(int modifiers READ modifiers CONSTANT)
73 Q_PROPERTY(Qt3DRender::QViewport *viewport READ viewport CONSTANT REVISION 14)
74 Q_PROPERTY(Qt3DCore::QEntity *entity READ entity CONSTANT REVISION 14)
75public:
76 enum Buttons {
77 LeftButton = Qt::LeftButton,
78 RightButton = Qt::RightButton,
79 MiddleButton = Qt::MiddleButton,
80 BackButton = Qt::BackButton,
81 NoButton = Qt::NoButton
82 };
83 Q_ENUM(Buttons) // LCOV_EXCL_LINE
84
85 enum Modifiers {
86 NoModifier = Qt::NoModifier,
87 ShiftModifier = Qt::ShiftModifier,
88 ControlModifier = Qt::ControlModifier,
89 AltModifier = Qt::AltModifier,
90 MetaModifier = Qt::MetaModifier,
91 KeypadModifier = Qt::KeypadModifier
92 };
93 Q_ENUM(Modifiers) // LCOV_EXCL_LINE
94
95 QPickEvent();
96 QPickEvent(const QPointF &position, const QVector3D& worldIntersection, const QVector3D& localIntersection, float distance);
97 QPickEvent(const QPointF &position, const QVector3D& worldIntersection, const QVector3D& localIntersection, float distance, Buttons button,
98 int buttons, int modifiers);
99 ~QPickEvent();
100
101 bool isAccepted() const;
102
103public Q_SLOTS:
104 void setAccepted(bool accepted);
105
106public:
107 QPointF position() const;
108 float distance() const;
109 QVector3D worldIntersection() const;
110 QVector3D localIntersection() const;
111 Buttons button() const;
112 int buttons() const;
113 int modifiers() const;
114 QViewport *viewport() const;
115 Qt3DCore::QEntity *entity() const;
116
117Q_SIGNALS:
118 void acceptedChanged(bool accepted);
119
120protected:
121 explicit QPickEvent(QObjectPrivate &dd, QObject *parent = nullptr);
122
123private:
124 Q_DECLARE_PRIVATE(QPickEvent)
125
126 friend class QObjectPickerPrivate;
127};
128
129} // Qt3DRender
130
131QT_END_NAMESPACE
132
133Q_DECLARE_METATYPE(Qt3DRender::QPickEvent*) // LCOV_EXCL_LINE
134
135#endif // QT3DRENDER_QPICKEVENT_H
136

source code of qt3d/src/render/picking/qpickevent.h