From a89a2b8bc32c440ee5515911a4a120fe232111a9 Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Tue, 11 Apr 2017 11:26:32 +0100 Subject: Add download service and use for remote meshes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new QDownloadHelpService. Can be provided with QDownloadRequests which will trigger downloads and return the data in a QByteArray. Downloads are triggered in a separate thread and requests have the opportunity to do long running operations there (it will block other requests though). Implemented for downloading meshes. When the functor is triggered, it checks the url and submits a request for download. When that completes, it’ll save the data in the functor and mark the component as dirty that that a job will run again to complete the parsing. LATER (5.10): - status property, progress maybe Task-number: QTBUG-57614 Change-Id: I05abe9610e12670a368d480b2fb3115987201e6b Reviewed-by: Sean Harmer --- src/render/geometry/qmesh_p.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/render/geometry/qmesh_p.h') diff --git a/src/render/geometry/qmesh_p.h b/src/render/geometry/qmesh_p.h index a621525cc..f7f8079eb 100644 --- a/src/render/geometry/qmesh_p.h +++ b/src/render/geometry/qmesh_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include #include #include @@ -66,23 +67,40 @@ public: QMeshPrivate(); Q_DECLARE_PUBLIC(QMesh) + static QMeshPrivate *get(QMesh *q); + + void setScene(Qt3DCore::QScene *scene) override; + void updateFunctor(); QUrl m_source; QString m_meshName; }; +class Q_AUTOTEST_EXPORT MeshDownloadRequest : public Qt3DCore::QDownloadRequest +{ +public: + MeshDownloadRequest(Qt3DCore::QNodeId mesh, QUrl source, Qt3DCore::QAspectEngine *engine); + + void onCompleted() Q_DECL_OVERRIDE; -class Q_AUTOTEST_EXPORT MeshFunctor : public QGeometryFactory +private: + Qt3DCore::QNodeId m_mesh; + Qt3DCore::QAspectEngine *m_engine; +}; + +class Q_AUTOTEST_EXPORT MeshLoaderFunctor : public QGeometryFactory { public : - MeshFunctor(const QUrl &sourcePath, const QString &meshName = QString()); + MeshLoaderFunctor(QMesh *mesh, Qt3DCore::QAspectEngine *engine, const QByteArray &sourceData = QByteArray()); QGeometry *operator()() Q_DECL_OVERRIDE; bool operator ==(const QGeometryFactory &other) const Q_DECL_OVERRIDE; - QT3D_FUNCTOR(MeshFunctor) + QT3D_FUNCTOR(MeshLoaderFunctor) -private: + Qt3DCore::QNodeId m_mesh; QUrl m_sourcePath; QString m_meshName; + Qt3DCore::QAspectEngine *m_engine; + QByteArray m_sourceData; }; -- cgit v1.2.3