1// Copyright (C) 2018 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_QABSTRACTRAYCASTER_H
5#define QT3DRENDER_QABSTRACTRAYCASTER_H
6
7#include <Qt3DCore/qcomponent.h>
8#include <Qt3DRender/qraycasterhit.h>
9#include <Qt3DRender/qt3drender_global.h>
10
11#include <QtGui/QVector3D>
12
13QT_BEGIN_NAMESPACE
14
15namespace Qt3DRender {
16
17class QAbstractRayCasterPrivate;
18class QLayer;
19
20class Q_3DRENDERSHARED_EXPORT QAbstractRayCaster : public Qt3DCore::QComponent
21{
22 Q_OBJECT
23 Q_PROPERTY(RunMode runMode READ runMode WRITE setRunMode NOTIFY runModeChanged)
24 Q_PROPERTY(FilterMode filterMode READ filterMode WRITE setFilterMode NOTIFY filterModeChanged)
25 Q_PROPERTY(Hits hits READ hits NOTIFY hitsChanged)
26public:
27 enum RunMode {
28 Continuous,
29 SingleShot
30 };
31 Q_ENUM(RunMode)
32
33 enum FilterMode {
34 AcceptAnyMatchingLayers = 0,
35 AcceptAllMatchingLayers,
36 DiscardAnyMatchingLayers,
37 DiscardAllMatchingLayers,
38 };
39 Q_ENUM(FilterMode) // LOVC_EXLC_LINE
40
41 using Hits = QList<QRayCasterHit>;
42
43 explicit QAbstractRayCaster(QNode *parent = nullptr);
44 ~QAbstractRayCaster();
45
46 RunMode runMode() const;
47 FilterMode filterMode() const;
48 Hits hits() const;
49
50 void addLayer(QLayer *layer);
51 void removeLayer(QLayer *layer);
52 QList<QLayer *> layers() const;
53
54public Q_SLOTS:
55 void setRunMode(RunMode runMode);
56 void setFilterMode(FilterMode filterMode);
57
58Q_SIGNALS:
59 void runModeChanged(Qt3DRender::QAbstractRayCaster::RunMode runMode);
60 void hitsChanged(const Qt3DRender::QAbstractRayCaster::Hits &hits);
61 void filterModeChanged(Qt3DRender::QAbstractRayCaster::FilterMode filterMode);
62
63protected:
64 explicit QAbstractRayCaster(QAbstractRayCasterPrivate &dd, QNode *parent = nullptr);
65
66private:
67 Q_DECLARE_PRIVATE(QAbstractRayCaster)
68};
69
70} // Qt3D
71
72QT_END_NAMESPACE
73
74Q_DECLARE_METATYPE(Qt3DRender::QAbstractRayCaster::Hits) // LCOV_EXCL_LINE
75
76#endif // QT3DRENDER_QABSTRACTRAYCASTER_H
77

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