1/****************************************************************************
2**
3** Copyright (C) 2014 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#include <Qt3DQuickRender/private/quick3dtechnique_p.h>
41
42QT_BEGIN_NAMESPACE
43
44namespace Qt3DRender {
45namespace Render {
46namespace Quick {
47
48Quick3DTechnique::Quick3DTechnique(QObject *parent)
49 : QObject(parent)
50{
51}
52
53QQmlListProperty<QRenderPass> Quick3DTechnique::renderPassList()
54{
55 return QQmlListProperty<QRenderPass>(this, 0,
56 &Quick3DTechnique::appendRenderPass,
57 &Quick3DTechnique::renderPassCount,
58 &Quick3DTechnique::renderPassAt,
59 &Quick3DTechnique::clearRenderPasses);
60}
61
62QQmlListProperty<QParameter> Quick3DTechnique::parameterList()
63{
64 return QQmlListProperty<QParameter>(this, 0,
65 &Quick3DTechnique::appendParameter,
66 &Quick3DTechnique::parametersCount,
67 &Quick3DTechnique::parameterAt,
68 &Quick3DTechnique::clearParameterList);
69}
70
71void Quick3DTechnique::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param)
72{
73 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
74 technique->parentTechnique()->addParameter(p: param);
75}
76
77QParameter *Quick3DTechnique::parameterAt(QQmlListProperty<QParameter> *list, int index)
78{
79 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
80 return technique->parentTechnique()->parameters().at(i: index);
81}
82
83int Quick3DTechnique::parametersCount(QQmlListProperty<QParameter> *list)
84{
85 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
86 return technique->parentTechnique()->parameters().count();
87}
88
89void Quick3DTechnique::clearParameterList(QQmlListProperty<QParameter> *list)
90{
91 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
92 const auto parameters = technique->parentTechnique()->parameters();
93 for (QParameter *p : parameters)
94 technique->parentTechnique()->removeParameter(p);
95}
96
97void Quick3DTechnique::appendRenderPass(QQmlListProperty<QRenderPass> *list, QRenderPass *renderPass)
98{
99 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
100 if (technique) {
101 technique->parentTechnique()->addRenderPass(pass: renderPass);
102 }
103}
104
105QRenderPass *Quick3DTechnique::renderPassAt(QQmlListProperty<QRenderPass> *list, int index)
106{
107 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
108 if (technique)
109 return qobject_cast<QRenderPass *>(object: technique->parentTechnique()->renderPasses().at(i: index));
110 return 0;
111}
112
113int Quick3DTechnique::renderPassCount(QQmlListProperty<QRenderPass> *list)
114{
115 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
116 if (technique)
117 return technique->parentTechnique()->renderPasses().size();
118 return 0;
119}
120
121void Quick3DTechnique::clearRenderPasses(QQmlListProperty<QRenderPass> *list)
122{
123 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
124 if (technique) {
125 const auto passes = technique->parentTechnique()->renderPasses();
126 for (QRenderPass *pass : passes)
127 technique->parentTechnique()->removeRenderPass(pass);
128 }
129}
130
131QQmlListProperty<QFilterKey> Quick3DTechnique::filterKeyList()
132{
133 return QQmlListProperty<QFilterKey>(this, 0,
134 &Quick3DTechnique::appendFilterKey,
135 &Quick3DTechnique::filterKeyCount,
136 &Quick3DTechnique::filterKeyAt,
137 &Quick3DTechnique::clearFilterKeyList);
138}
139
140void Quick3DTechnique::appendFilterKey(QQmlListProperty<QFilterKey> *list, QFilterKey *filterKey)
141{
142 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
143 if (technique) {
144 if (!filterKey->parent())
145 filterKey->setParent(technique->parentTechnique());
146 technique->parentTechnique()->addFilterKey(filterKey);
147 }
148}
149
150QFilterKey *Quick3DTechnique::filterKeyAt(QQmlListProperty<QFilterKey> *list, int index)
151{
152 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
153 if (technique)
154 return technique->parentTechnique()->filterKeys().at(i: index);
155 return 0;
156}
157
158int Quick3DTechnique::filterKeyCount(QQmlListProperty<QFilterKey> *list)
159{
160 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
161 if (technique)
162 return technique->parentTechnique()->filterKeys().size();
163 return 0;
164}
165
166void Quick3DTechnique::clearFilterKeyList(QQmlListProperty<QFilterKey> *list)
167{
168 Quick3DTechnique *technique = qobject_cast<Quick3DTechnique *>(object: list->object);
169 if (technique) {
170 const auto keys = technique->parentTechnique()->filterKeys();
171 for (QFilterKey *a : keys)
172 technique->parentTechnique()->removeFilterKey(filterKey: a);
173 }
174}
175
176} // namespace Quick
177} // namespace Render
178} // namespace Qt3DRender
179
180QT_END_NAMESPACE
181

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