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

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