Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3druntimeloader_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QQUICK3DRUNTIMELOADER_H
7#define QQUICK3DRUNTIMELOADER_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtQuick3D/private/qquick3dmodel_p.h>
21#include <QtQuick3D/private/qquick3dinstancing_p.h>
22
24
25#include <QtCore/qpointer.h>
26#include <QtCore/qlist.h>
27#if QT_CONFIG(mimetype)
28#include <QtCore/qmimetype.h>
29#endif
30#include <QtCore/qhash.h>
31
33
34class Q_QUICK3DASSETUTILS_EXPORT QQuick3DRuntimeLoader : public QQuick3DNode
35{
36 Q_OBJECT
37
38 QML_NAMED_ELEMENT(RuntimeLoader)
39 QML_ADDED_IN_VERSION(6, 2)
40
41 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
42 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
43 Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
44 Q_PROPERTY(QQuick3DBounds3 bounds READ bounds NOTIFY boundsChanged)
45 Q_PROPERTY(QQuick3DInstancing *instancing READ instancing WRITE setInstancing NOTIFY instancingChanged)
46 Q_PROPERTY(QStringList supportedExtensions READ supportedExtensions CONSTANT REVISION(6, 7))
47#if QT_CONFIG(mimetype)
48 Q_PROPERTY(QList<QMimeType> supportedMimeTypes READ supportedMimeTypes CONSTANT REVISION(6, 7))
49#endif
50
51public:
52 explicit QQuick3DRuntimeLoader(QQuick3DNode *parent = nullptr);
53
54 enum class QueryFilter
55 {
56 Textures,
57 Materials,
58 Nodes,
59 Cameras,
60 Lights,
61 Models,
62 };
63 Q_ENUM(QueryFilter)
64
65 QUrl source() const;
66 void setSource(const QUrl &newSource);
67 void componentComplete() override;
68 Q_REVISION(6, 7) static QStringList supportedExtensions();
69#if QT_CONFIG(mimetype)
70 Q_REVISION(6, 7) static QList<QMimeType> supportedMimeTypes();
71#endif
72
73 enum class Status { Empty, Success, Error };
74 Q_ENUM(Status)
75 Status status() const;
76 QString errorString() const;
77 const QQuick3DBounds3 &bounds() const;
78
79 QQuick3DInstancing *instancing() const;
80 void setInstancing(QQuick3DInstancing *newInstancing);
81
82 Q_REVISION(6, 12) Q_INVOKABLE QQuick3DObject *query(const QString &name) const;
83 Q_REVISION(6, 12) Q_INVOKABLE QList<QQuick3DObject *> queryAll(QueryFilter filter) const;
84
85Q_SIGNALS:
86 void sourceChanged();
87 void statusChanged();
88 void errorStringChanged();
89 void boundsChanged();
90 void instancingChanged();
91
92protected:
93 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
94
95private:
96 void calculateBounds();
97 void loadSource();
98 void updateModels();
99
100 QSSGRuntimeObjectNameMap m_objects;
101 QSSGRuntimeObjectTypeMap m_objectsByType;
102
103 QPointer<QQuick3DNode> m_root;
104 QPointer<QQuick3DNode> m_imported;
105 QString m_assetId; // Used to release runtime assets in the buffer manager.
106 QUrl m_source;
107 Status m_status = Status::Empty;
108 QString m_errorString;
109 bool m_boundsDirty = false;
110 QQuick3DBounds3 m_bounds;
111 QQuick3DInstancing *m_instancing = nullptr;
112 bool m_instancingChanged = false;
113};
114
115QT_END_NAMESPACE
116
117#endif // QQUICK3DRUNTIMELOADER_H
Combined button and popup list for selecting options.
static void boxBoundsRecursive(const QQuick3DNode *baseNode, const QQuick3DNode *node, QQuick3DBounds3 &accBounds)
static void applyToModels(QQuick3DObject *obj, Func &&lambda)
static QSSGRenderGraphObject::BaseType queryFilterToBaseType(QQuick3DRuntimeLoader::QueryFilter filter)