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_QMESH_P_H |
5 | #define QT3DRENDER_QMESH_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 <Qt3DCore/private/qdownloadhelperservice_p.h> |
19 | #include <Qt3DRender/private/qgeometryrenderer_p.h> |
20 | #include <Qt3DRender/private/qt3drender_global_p.h> |
21 | #include <Qt3DRender/qmesh.h> |
22 | #include <QUrl> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | namespace Qt3DCore { |
27 | class QDownloadHelperService; |
28 | } |
29 | |
30 | namespace Qt3DRender { |
31 | |
32 | namespace Render { |
33 | class NodeManagers; |
34 | } |
35 | |
36 | class Q_3DRENDERSHARED_PRIVATE_EXPORT QMeshPrivate : public QGeometryRendererPrivate |
37 | { |
38 | public: |
39 | QMeshPrivate(); |
40 | |
41 | Q_DECLARE_PUBLIC(QMesh) |
42 | static QMeshPrivate *get(QMesh *q); |
43 | |
44 | void setScene(Qt3DCore::QScene *scene) override; |
45 | void updateFunctor(); |
46 | void setStatus(QMesh::Status status); |
47 | |
48 | QUrl m_source; |
49 | QString m_meshName; |
50 | QMesh::Status m_status; |
51 | }; |
52 | |
53 | class Q_AUTOTEST_EXPORT MeshDownloadRequest : public Qt3DCore::QDownloadRequest |
54 | { |
55 | public: |
56 | MeshDownloadRequest(Qt3DCore::QNodeId mesh, QUrl source, Render::NodeManagers *managers); |
57 | |
58 | void onCompleted() override; |
59 | |
60 | private: |
61 | Qt3DCore::QNodeId m_mesh; |
62 | Render::NodeManagers *m_nodeManagers; |
63 | }; |
64 | |
65 | class Q_AUTOTEST_EXPORT MeshLoaderFunctor : public Qt3DCore::QGeometryFactory |
66 | { |
67 | public : |
68 | MeshLoaderFunctor(QMesh *mesh, const QByteArray &sourceData = QByteArray()); |
69 | |
70 | void setNodeManagers(Render::NodeManagers *managers) { m_nodeManagers = managers; } |
71 | Render::NodeManagers *nodeManagers() const { return m_nodeManagers; } |
72 | |
73 | void setDownloaderService(Qt3DCore::QDownloadHelperService *service) { m_downloaderService = service; } |
74 | Qt3DCore::QDownloadHelperService *downloaderService() const { return m_downloaderService; } |
75 | |
76 | void setSourceData(const QByteArray &data) { m_sourceData = data; } |
77 | QByteArray sourceData() const { return m_sourceData; } |
78 | |
79 | QUrl sourcePath() const { return m_sourcePath; } |
80 | Qt3DCore::QNodeId mesh() const { return m_mesh; } |
81 | QString meshName() const { return m_meshName; } |
82 | |
83 | QMesh::Status status() const { return m_status; } |
84 | |
85 | Qt3DCore::QGeometry *operator()() override; |
86 | bool equals(const Qt3DCore::QGeometryFactory &other) const override; |
87 | QT3D_FUNCTOR(MeshLoaderFunctor) |
88 | |
89 | private: |
90 | Qt3DCore::QNodeId m_mesh; |
91 | QUrl m_sourcePath; |
92 | QString m_meshName; |
93 | QByteArray m_sourceData; |
94 | Render::NodeManagers *m_nodeManagers; |
95 | Qt3DCore::QDownloadHelperService *m_downloaderService; |
96 | QMesh::Status m_status; |
97 | }; |
98 | |
99 | |
100 | } // namespace Qt3DRender |
101 | |
102 | QT_END_NAMESPACE |
103 | |
104 | #endif // QT3DRENDER_QMESH_P_H |
105 |