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/quick3dtechniquefilter_p.h>
41
42QT_BEGIN_NAMESPACE
43
44namespace Qt3DRender {
45namespace Render {
46namespace Quick {
47
48Quick3DTechniqueFilter::Quick3DTechniqueFilter(QObject *parent)
49 : QObject(parent)
50{
51}
52
53QQmlListProperty<QFilterKey> Quick3DTechniqueFilter::matchList()
54{
55 return QQmlListProperty<QFilterKey>(this, 0,
56 &Quick3DTechniqueFilter::appendRequire,
57 &Quick3DTechniqueFilter::requiresCount,
58 &Quick3DTechniqueFilter::requireAt,
59 &Quick3DTechniqueFilter::clearRequires);
60}
61
62QQmlListProperty<QParameter> Quick3DTechniqueFilter::parameterList()
63{
64 return QQmlListProperty<QParameter>(this, 0,
65 &Quick3DTechniqueFilter::appendParameter,
66 &Quick3DTechniqueFilter::parametersCount,
67 &Quick3DTechniqueFilter::parameterAt,
68 &Quick3DTechniqueFilter::clearParameterList);
69}
70
71void Quick3DTechniqueFilter::appendRequire(QQmlListProperty<QFilterKey> *list, QFilterKey *criterion)
72{
73 Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object);
74 if (filter) {
75 criterion->setParent(filter->parentTechniqueFilter());
76 filter->parentTechniqueFilter()->addMatch(filterKey: criterion);
77 }
78}
79
80QFilterKey *Quick3DTechniqueFilter::requireAt(QQmlListProperty<QFilterKey> *list, int index)
81{
82 Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object);
83 if (filter)
84 return filter->parentTechniqueFilter()->matchAll().at(i: index);
85 return 0;
86}
87
88int Quick3DTechniqueFilter::requiresCount(QQmlListProperty<QFilterKey> *list)
89{
90 Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object);
91 if (filter)
92 return filter->parentTechniqueFilter()->matchAll().size();
93 return 0;
94}
95
96void Quick3DTechniqueFilter::clearRequires(QQmlListProperty<QFilterKey> *list)
97{
98 Quick3DTechniqueFilter *filter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object);
99 if (filter) {
100 const auto criteria = filter->parentTechniqueFilter()->matchAll();
101 for (QFilterKey *criterion : criteria)
102 filter->parentTechniqueFilter()->removeMatch(filterKey: criterion);
103 }
104}
105
106void Quick3DTechniqueFilter::appendParameter(QQmlListProperty<QParameter> *list, QParameter *param)
107{
108 Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object);
109 techniqueFilter->parentTechniqueFilter()->addParameter(p: param);
110}
111
112QParameter *Quick3DTechniqueFilter::parameterAt(QQmlListProperty<QParameter> *list, int index)
113{
114 Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object);
115 return techniqueFilter->parentTechniqueFilter()->parameters().at(i: index);
116}
117
118int Quick3DTechniqueFilter::parametersCount(QQmlListProperty<QParameter> *list)
119{
120 Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object);
121 return techniqueFilter->parentTechniqueFilter()->parameters().count();
122}
123
124void Quick3DTechniqueFilter::clearParameterList(QQmlListProperty<QParameter> *list)
125{
126 Quick3DTechniqueFilter *techniqueFilter = qobject_cast<Quick3DTechniqueFilter *>(object: list->object);
127 const auto parameters = techniqueFilter->parentTechniqueFilter()->parameters();
128 for (QParameter *p : parameters)
129 techniqueFilter->parentTechniqueFilter()->removeParameter(p);
130}
131
132} // namespace Quick
133} // namespace Render
134} // namespace Qt3DRender
135
136QT_END_NAMESPACE
137

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