1// Copyright (C) 2014 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/quick3dtechnique_p.h>
5
6QT_BEGIN_NAMESPACE
7
8namespace Qt3DRender {
9namespace Render {
10namespace Quick {
11
12Quick3DTechnique::Quick3DTechnique(QObject *parent)
13 : QObject(parent)
14{
15}
16
17QQmlListProperty<QRenderPass> Quick3DTechnique::renderPassList()
18{
19 using qt_size_type = qsizetype;
20 using ListContentType = QRenderPass;
21 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *renderPass) {
22 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
23 if (technique)
24 technique->parentTechnique()->addRenderPass(pass: renderPass);
25 };
26 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
27 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
28 if (technique)
29 return technique->parentTechnique()->renderPasses().size();
30 return 0;
31 };
32 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
33 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
34 if (technique)
35 return qobject_cast<QRenderPass *>(object: technique->parentTechnique()->renderPasses().at(i: index));
36 return nullptr;
37 };
38 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
39 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
40 if (technique) {
41 const auto passes = technique->parentTechnique()->renderPasses();
42 for (QRenderPass *pass : passes)
43 technique->parentTechnique()->removeRenderPass(pass);
44 }
45 };
46
47 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
48}
49
50QQmlListProperty<QParameter> Quick3DTechnique::parameterList()
51{
52 using qt_size_type = qsizetype;
53 using ListContentType = QParameter;
54 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *param) {
55 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
56 technique->parentTechnique()->addParameter(p: param);
57 };
58 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
59 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
60 return technique->parentTechnique()->parameters().size();
61 };
62 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
63 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
64 return technique->parentTechnique()->parameters().at(i: index);
65 };
66 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
67 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
68 const auto parameters = technique->parentTechnique()->parameters();
69 for (QParameter *p : parameters)
70 technique->parentTechnique()->removeParameter(p);
71 };
72
73 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
74}
75
76QQmlListProperty<QFilterKey> Quick3DTechnique::filterKeyList()
77{
78 using qt_size_type = qsizetype;
79 using ListContentType = QFilterKey;
80 auto appendFunction = [](QQmlListProperty<ListContentType> *list, ListContentType *filterKey) {
81 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
82 if (technique) {
83 if (!filterKey->parent())
84 filterKey->setParent(technique->parentTechnique());
85 technique->parentTechnique()->addFilterKey(filterKey);
86 }
87 };
88 auto countFunction = [](QQmlListProperty<ListContentType> *list) -> qt_size_type {
89 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
90 if (technique)
91 return technique->parentTechnique()->filterKeys().size();
92 return 0;
93 };
94 auto atFunction = [](QQmlListProperty<ListContentType> *list, qt_size_type index) -> ListContentType * {
95 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
96 if (technique)
97 return technique->parentTechnique()->filterKeys().at(i: index);
98 return nullptr;
99 };
100 auto clearFunction = [](QQmlListProperty<ListContentType> *list) {
101 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
102 if (technique) {
103 const auto keys = technique->parentTechnique()->filterKeys();
104 for (QFilterKey *a : keys)
105 technique->parentTechnique()->removeFilterKey(filterKey: a);
106 }
107 };
108
109 return QQmlListProperty<ListContentType>(this, nullptr, appendFunction, countFunction, atFunction, clearFunction);
110}
111
112} // namespace Quick
113} // namespace Render
114} // namespace Qt3DRender
115
116QT_END_NAMESPACE
117
118#include "moc_quick3dtechnique_p.cpp"
119

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