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 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | using namespace Qt3DCore; |
14 | |
15 | namespace Qt3DRender { |
16 | namespace Render { |
17 | |
18 | TechniqueFilter::TechniqueFilter() |
19 | : FrameGraphNode(FrameGraphNode::TechniqueFilter) |
20 | { |
21 | } |
22 | |
23 | void 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 | |
49 | QList<Qt3DCore::QNodeId> TechniqueFilter::parameters() const |
50 | { |
51 | return m_parameterPack.parameters(); |
52 | } |
53 | |
54 | QList<Qt3DCore::QNodeId> TechniqueFilter::filters() const |
55 | { |
56 | return m_filters; |
57 | } |
58 | |
59 | void TechniqueFilter::appendFilter(QNodeId criterionId) |
60 | { |
61 | if (!m_filters.contains(t: criterionId)) |
62 | m_filters.append(t: criterionId); |
63 | } |
64 | |
65 | void TechniqueFilter::removeFilter(Qt3DCore::QNodeId criterionId) |
66 | { |
67 | m_filters.removeOne(t: criterionId); |
68 | } |
69 | |
70 | } // namespace Render |
71 | } // namespace Qt3DRender |
72 | |
73 | QT_END_NAMESPACE |
74 |