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 QT3DRENDER_RENDER_LOADSCENEJOB_H |
5 | #define QT3DRENDER_RENDER_LOADSCENEJOB_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/qentity.h> |
20 | #include <Qt3DCore/private/qaspectjob_p.h> |
21 | #include <Qt3DCore/qnodeid.h> |
22 | #include <Qt3DRender/qsceneloader.h> |
23 | #include <QSharedPointer> |
24 | #include <QUrl> |
25 | #include <functional> |
26 | #include <Qt3DRender/private/qt3drender_global_p.h> |
27 | |
28 | QT_BEGIN_NAMESPACE |
29 | |
30 | namespace Qt3DRender { |
31 | |
32 | class QSceneImporter; |
33 | |
34 | namespace Render { |
35 | |
36 | class Scene; |
37 | class NodeManagers; |
38 | |
39 | class LoadSceneJob; |
40 | |
41 | class Q_AUTOTEST_EXPORT LoadSceneJobPrivate : public Qt3DCore::QAspectJobPrivate |
42 | { |
43 | public: |
44 | explicit LoadSceneJobPrivate(LoadSceneJob *q): q_ptr(q) {} |
45 | ~LoadSceneJobPrivate() override {} |
46 | |
47 | void postFrame(Qt3DCore::QAspectManager *manager) override; |
48 | |
49 | std::unique_ptr<Qt3DCore::QEntity> m_sceneSubtree; |
50 | QSceneLoader::Status m_status = QSceneLoader::None; |
51 | |
52 | Q_DECLARE_PUBLIC(LoadSceneJob) |
53 | private: |
54 | LoadSceneJob *q_ptr; |
55 | }; |
56 | |
57 | class Q_3DRENDERSHARED_PRIVATE_EXPORT LoadSceneJob : public Qt3DCore::QAspectJob |
58 | { |
59 | public: |
60 | explicit LoadSceneJob(const QUrl &source, Qt3DCore::QNodeId sceneComponent); |
61 | void setData(const QByteArray &data); |
62 | void setNodeManagers(NodeManagers *managers) { m_managers = managers; } |
63 | void setSceneImporters(const QList<QSceneImporter *> sceneImporters) { m_sceneImporters = sceneImporters; } |
64 | |
65 | NodeManagers *nodeManagers() const; |
66 | QList<QSceneImporter *> sceneImporters() const; |
67 | QUrl source() const; |
68 | Qt3DCore::QNodeId sceneComponentId() const; |
69 | |
70 | void run() override; |
71 | |
72 | private: |
73 | QUrl m_source; |
74 | QByteArray m_data; |
75 | Qt3DCore::QNodeId m_sceneComponent; |
76 | NodeManagers *m_managers; |
77 | QList<QSceneImporter *> m_sceneImporters; |
78 | |
79 | Qt3DCore::QEntity *tryLoadScene(QSceneLoader::Status &finalStatus, |
80 | const QStringList &extensions, |
81 | const std::function<void (QSceneImporter *)> &importerSetupFunc); |
82 | Q_DECLARE_PRIVATE(LoadSceneJob) |
83 | }; |
84 | |
85 | typedef QSharedPointer<LoadSceneJob> LoadSceneJobPtr; |
86 | |
87 | } // namespace Render |
88 | |
89 | } // namespace Qt3DRender |
90 | |
91 | QT_END_NAMESPACE |
92 | |
93 | #endif // LOADSCENEJOB_H |
94 |