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 "techniquefilternode_p.h"
5#include "qfilterkey.h"
6#include "qtechniquefilter.h"
7#include <Qt3DRender/private/qtechniquefilter_p.h>
8#include <Qt3DRender/private/managers_p.h>
9#include <Qt3DRender/qparameter.h>
10
11QT_BEGIN_NAMESPACE
12
13using namespace Qt3DCore;
14
15namespace Qt3DRender {
16namespace Render {
17
18TechniqueFilter::TechniqueFilter()
19 : FrameGraphNode(FrameGraphNode::TechniqueFilter)
20{
21}
22
23void TechniqueFilter::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
24{
25 const QTechniqueFilter *node = qobject_cast<const QTechniqueFilter *>(object: frontEnd);
26 if (!node)
27 return;
28
29 FrameGraphNode::syncFromFrontEnd(frontEnd, firstTime);
30
31 if (firstTime)
32 m_parameterPack.clear();
33
34 auto parameters = qIdsForNodes(nodes: node->parameters());
35 std::sort(first: std::begin(cont&: parameters), last: std::end(cont&: parameters));
36 if (m_parameterPack.parameters() != parameters) {
37 m_parameterPack.setParameters(parameters);
38 markDirty(changes: AbstractRenderer::FrameGraphDirty);
39 }
40
41 auto filterIds = qIdsForNodes(nodes: node->matchAll());
42 std::sort(first: std::begin(cont&: filterIds), last: std::end(cont&: filterIds));
43 if (m_filters != filterIds) {
44 m_filters = filterIds;
45 markDirty(changes: AbstractRenderer::FrameGraphDirty);
46 }
47}
48
49QList<Qt3DCore::QNodeId> TechniqueFilter::parameters() const
50{
51 return m_parameterPack.parameters();
52}
53
54QList<Qt3DCore::QNodeId> TechniqueFilter::filters() const
55{
56 return m_filters;
57}
58
59void TechniqueFilter::appendFilter(QNodeId criterionId)
60{
61 if (!m_filters.contains(t: criterionId))
62 m_filters.append(t: criterionId);
63}
64
65void TechniqueFilter::removeFilter(Qt3DCore::QNodeId criterionId)
66{
67 m_filters.removeOne(t: criterionId);
68}
69
70} // namespace Render
71} // namespace Qt3DRender
72
73QT_END_NAMESPACE
74

source code of qt3d/src/render/framegraph/techniquefilternode.cpp