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#include <Qt3DQuickRender/private/quick3draycaster_p.h>
5#include <Qt3DQuickRender/private/quick3draycaster_p_p.h>
6#include <Qt3DCore/private/qscene_p.h>
7
8#include <Qt3DCore/QEntity>
9
10QT_BEGIN_NAMESPACE
11
12namespace Qt3DRender {
13namespace Render {
14namespace Quick {
15
16Quick3DRayCaster::Quick3DRayCaster(QObject *parent)
17 : QRayCaster(*new Quick3DRayCasterPrivate(), qobject_cast<Qt3DCore::QNode *>(object: parent))
18{
19}
20
21QQmlListProperty<Qt3DRender::QLayer> Qt3DRender::Render::Quick::Quick3DRayCaster::qmlLayers()
22{
23 using qt_size_type = qsizetype;
24 using ListContentType = Qt3DRender::QLayer;
25 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *layer) {
26 QAbstractRayCaster *filter = qobject_cast<QAbstractRayCaster *>(object: list->object);
27 if (filter)
28 filter->addLayer(layer);
29 };
30 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
31 QAbstractRayCaster *filter = qobject_cast<QAbstractRayCaster *>(object: list->object);
32 if (filter)
33 return int(filter->layers().size());
34 return 0;
35 };
36 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
37 QAbstractRayCaster *filter = qobject_cast<QAbstractRayCaster *>(object: list->object);
38 if (filter)
39 return filter->layers().at(i: index);
40 return nullptr;
41 };
42 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
43 QAbstractRayCaster *filter = qobject_cast<QAbstractRayCaster *>(object: list->object);
44 if (filter) {
45 const auto layers = filter->layers();
46 for (QLayer *layer : layers)
47 filter->removeLayer(layer);
48 }
49 };
50
51 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
52}
53
54} // namespace Quick
55} // namespace Render
56} // namespace Qt3DRender
57
58QT_END_NAMESPACE
59
60#include "moc_quick3draycaster_p.cpp"
61

source code of qt3d/src/quick3d/quick3drender/items/quick3draycaster.cpp