1// Copyright (C) 2016 Paul Lemire
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DRENDER_RENDER_FILTERLAYERENTITYJOB_H
5#define QT3DRENDER_RENDER_FILTERLAYERENTITYJOB_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <Qt3DCore/qaspectjob.h>
19#include <Qt3DCore/qnodeid.h>
20#include <Qt3DRender/private/qt3drender_global_p.h>
21#include <Qt3DRender/qlayerfilter.h>
22
23QT_BEGIN_NAMESPACE
24
25namespace Qt3DRender {
26
27namespace Render {
28
29class Entity;
30class NodeManagers;
31
32class Q_3DRENDERSHARED_PRIVATE_EXPORT FilterLayerEntityJob : public Qt3DCore::QAspectJob
33{
34public:
35 FilterLayerEntityJob();
36
37 inline void setManager(NodeManagers *manager) noexcept { m_manager = manager; }
38 inline void setLayerFilters(const Qt3DCore::QNodeIdVector &layerIds) noexcept { m_layerFilterIds = layerIds; }
39 inline std::vector<Entity *> &filteredEntities() noexcept { return m_filteredEntities; }
40
41 inline bool hasLayerFilter() const noexcept { return !m_layerFilterIds.isEmpty(); }
42 inline Qt3DCore::QNodeIdVector layerFilters() const { return m_layerFilterIds; }
43
44 // QAspectJob interface
45 void run() final;
46
47 void filterEntityAgainstLayers(Entity *entity, const Qt3DCore::QNodeIdVector &layerIds, const QLayerFilter::FilterMode filterMode);
48 void filterAcceptAnyMatchingLayers(Entity *entity, const Qt3DCore::QNodeIdVector &layerIds);
49 void filterAcceptAllMatchingLayers(Entity *entity, const Qt3DCore::QNodeIdVector &layerIds);
50 void filterDiscardAnyMatchingLayers(Entity *entity, const Qt3DCore::QNodeIdVector &layerIds);
51 void filterDiscardAllMatchingLayers(Entity *entity, const Qt3DCore::QNodeIdVector &layerIds);
52
53private:
54 void filterLayerAndEntity();
55 void selectAllEntities();
56
57 NodeManagers *m_manager;
58 Qt3DCore::QNodeIdVector m_layerFilterIds;
59 std::vector<Entity *> m_filteredEntities;
60};
61
62typedef QSharedPointer<FilterLayerEntityJob> FilterLayerEntityJobPtr;
63
64} // Render
65
66} // Qt3DRender
67
68QT_END_NAMESPACE
69
70#endif // QT3DRENDER_RENDER_FILTERLAYERENTITYJOB_H
71

source code of qt3d/src/render/jobs/filterlayerentityjob_p.h