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#ifndef QT3DCORE_QSCENE_P_H
5#define QT3DCORE_QSCENE_P_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 <QtCore/QScopedPointer>
19
20#include <Qt3DCore/qnode.h>
21#include <Qt3DCore/private/qabstractfrontendnodemanager_p.h>
22#include <QtCore/qscopedpointer.h>
23#include <Qt3DCore/private/qt3dcore_global_p.h>
24
25QT_BEGIN_NAMESPACE
26
27namespace Qt3DCore {
28
29class QScenePrivate;
30class QAspectEngine;
31class NodePostConstructorInit;
32class QChangeArbiter;
33
34class Q_3DCORE_PRIVATE_EXPORT QScene : public QAbstractFrontEndNodeManager
35{
36public:
37 // Changes made to backend nodes are reported to the Renderer
38 enum DirtyNodeFlag {
39 TransformDirty = 1 << 0,
40 GeometryDirty = 1 << 1,
41 EntityEnabledDirty = 1 << 2,
42 BuffersDirty = 1 << 3,
43 AllDirty = 0xffffff
44 };
45 Q_DECLARE_FLAGS(DirtyNodeSet, DirtyNodeFlag)
46
47 QScene(QAspectEngine *engine = nullptr);
48 ~QScene();
49
50 QAspectEngine *engine() const;
51
52 void addObservable(QNode *observable);
53 void removeObservable(QNode *observable);
54
55 QNode *lookupNode(QNodeId id) const override;
56 QList<QNode *> lookupNodes(const QList<QNodeId> &ids) const override;
57
58 QNode *rootNode() const;
59
60 void setArbiter(QChangeArbiter *arbiter);
61 QChangeArbiter *arbiter() const;
62
63 // Component -> Entities
64 QList<QNodeId> entitiesForComponent(QNodeId id) const;
65 void addEntityForComponent(QNodeId componentUuid, QNodeId entityUuid);
66 void removeEntityForComponent(QNodeId componentUuid, QNodeId entityUuid);
67 bool hasEntityForComponent(QNodeId componentUuid, QNodeId entityUuid);
68
69 NodePostConstructorInit* postConstructorInit() const;
70
71 void markDirty(DirtyNodeSet changes);
72 DirtyNodeSet dirtyBits();
73 void clearDirtyBits();
74
75private:
76 Q_DECLARE_PRIVATE(QScene)
77 QScopedPointer<QScenePrivate> d_ptr;
78
79 void setRootNode(QNode *root);
80 friend class QAspectEnginePrivate;
81};
82
83} // Qt3D
84
85QT_END_NAMESPACE
86
87Q_DECLARE_METATYPE(Qt3DCore::QScene*) // LCOV_EXCL_LINE
88
89#endif // QT3DCORE_QSCENE_P_H
90

source code of qt3d/src/core/qscene_p.h