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 "layerfilternode_p.h" |
5 | #include "qlayerfilter.h" |
6 | #include <Qt3DRender/private/qlayerfilter_p.h> |
7 | #include <algorithm> |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | using namespace Qt3DCore; |
12 | |
13 | namespace Qt3DRender { |
14 | namespace Render { |
15 | |
16 | LayerFilterNode::LayerFilterNode() |
17 | : FrameGraphNode(FrameGraphNode::LayerFilter) |
18 | , m_filterMode(QLayerFilter::AcceptAnyMatchingLayers) |
19 | { |
20 | } |
21 | |
22 | void LayerFilterNode::syncFromFrontEnd(const QNode *frontEnd, bool firstTime) |
23 | { |
24 | const QLayerFilter *node = qobject_cast<const QLayerFilter *>(object: frontEnd); |
25 | if (!node) |
26 | return; |
27 | |
28 | FrameGraphNode::syncFromFrontEnd(frontEnd, firstTime); |
29 | |
30 | if (m_filterMode != node->filterMode()) { |
31 | m_filterMode = node->filterMode(); |
32 | markDirty(changes: AbstractRenderer::FrameGraphDirty|AbstractRenderer::LayersDirty); |
33 | } |
34 | |
35 | auto layerIds = qIdsForNodes(nodes: node->layers()); |
36 | std::sort(first: std::begin(cont&: layerIds), last: std::end(cont&: layerIds)); |
37 | if (m_layerIds != layerIds) { |
38 | m_layerIds = layerIds; |
39 | markDirty(changes: AbstractRenderer::FrameGraphDirty|AbstractRenderer::LayersDirty); |
40 | } |
41 | } |
42 | |
43 | QNodeIdVector LayerFilterNode::layerIds() const |
44 | { |
45 | return m_layerIds; |
46 | } |
47 | |
48 | void LayerFilterNode::setLayerIds(const QNodeIdVector &list) |
49 | { |
50 | m_layerIds = list; |
51 | } |
52 | |
53 | QLayerFilter::FilterMode LayerFilterNode::filterMode() const |
54 | { |
55 | return m_filterMode; |
56 | } |
57 | |
58 | } // namespace Render |
59 | } // namespace Qt3DRender |
60 | |
61 | QT_END_NAMESPACE |
62 |