summaryrefslogtreecommitdiffstats
path: root/src/render/geometry
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2018-01-19 07:42:06 +0100
committerPaul Lemire <paul.lemire@kdab.com>2018-01-22 06:08:41 +0000
commit2ca0dbadaac328826807c6b9bf2b46dbb955e3d2 (patch)
tree6aa5007706cfe514cc6dcb16f9c6276fa808576a /src/render/geometry
parentfac6dcc70de922dc3f3dd105e9d725092e6fd808 (diff)
QMesh: add a status property
This will allow to monitor the loading of the mesh. Change-Id: I52ad7a7d556c64bfdb04173be932d6fe79bf5ae2 Task-number: QTBUG-60927 Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/geometry')
-rw-r--r--src/render/geometry/qmesh.cpp54
-rw-r--r--src/render/geometry/qmesh.h14
-rw-r--r--src/render/geometry/qmesh_p.h5
3 files changed, 70 insertions, 3 deletions
diff --git a/src/render/geometry/qmesh.cpp b/src/render/geometry/qmesh.cpp
index 834284547..6df06d723 100644
--- a/src/render/geometry/qmesh.cpp
+++ b/src/render/geometry/qmesh.cpp
@@ -71,6 +71,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, geometryLoader, (QGeometryLoaderFactor
QMeshPrivate::QMeshPrivate()
: QGeometryRendererPrivate()
+ , m_status(QMesh::None)
{
}
@@ -93,6 +94,17 @@ void QMeshPrivate::updateFunctor()
q->setGeometryFactory(QGeometryFactoryPtr(new MeshLoaderFunctor(q, engine)));
}
+void QMeshPrivate::setStatus(QMesh::Status status)
+{
+ if (m_status != status) {
+ Q_Q(QMesh);
+ m_status = status;
+ const bool wasBlocked = q->blockNotifications(true);
+ emit q->statusChanged(status);
+ q->blockNotifications(wasBlocked);
+ }
+}
+
/*!
* \qmltype Mesh
* \instantiates Qt3DRender::QMesh
@@ -138,6 +150,25 @@ void QMeshPrivate::updateFunctor()
*/
/*!
+ \enum QMesh::Status
+
+ This enum identifies the status of shader used.
+
+ \value None A source mesh hasn't been assigned a source yet
+ \value Loading The mesh geometry is loading
+ \value Ready The mesh geometry was successfully loaded
+ \value Error An error occurred while loading the mesh
+*/
+
+/*!
+ \qmlproperty enumeration Mesh::status
+
+ Holds the status of the mesh loading.
+ \sa Qt3DRender::QMesh::Status
+ \readonly
+ */
+
+/*!
* \class Qt3DRender::QMesh
* \inheaderfile Qt3DRender/QMesh
* \inmodule Qt3DRender
@@ -186,6 +217,17 @@ QMesh::QMesh(QMeshPrivate &dd, QNode *parent)
{
}
+/*! \internal */
+void QMesh::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ Q_D(QMesh);
+ if (change->type() == Qt3DCore::PropertyUpdated) {
+ const Qt3DCore::QPropertyUpdatedChangePtr e = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change);
+ if (e->propertyName() == QByteArrayLiteral("status"))
+ d->setStatus(e->value().value<QMesh::Status>());
+ }
+}
+
void QMesh::setSource(const QUrl& source)
{
Q_D(QMesh);
@@ -233,6 +275,18 @@ QString QMesh::meshName() const
}
/*!
+ \property QMesh::status
+
+ Holds the status of the mesh loading.
+ \sa Qt3DRender::QMesh::Status
+ */
+QMesh::Status QMesh::status() const
+{
+ Q_D(const QMesh);
+ return d->m_status;
+}
+
+/*!
* \internal
*/
MeshLoaderFunctor::MeshLoaderFunctor(QMesh *mesh, Qt3DCore::QAspectEngine *engine, const QByteArray &sourceData)
diff --git a/src/render/geometry/qmesh.h b/src/render/geometry/qmesh.h
index 51fdab63a..a7b2747f7 100644
--- a/src/render/geometry/qmesh.h
+++ b/src/render/geometry/qmesh.h
@@ -59,13 +59,23 @@ class QT3DRENDERSHARED_EXPORT QMesh : public QGeometryRenderer
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(QString meshName READ meshName WRITE setMeshName NOTIFY meshNameChanged)
-
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION 11)
public:
explicit QMesh(Qt3DCore::QNode *parent = nullptr);
~QMesh();
+ enum Status {
+ None = 0,
+ Loading,
+ Ready,
+ Error
+ };
+ Q_ENUM(Status) // LCOV_EXCL_LINE
+
+
QUrl source() const;
QString meshName() const;
+ Status status() const;
public Q_SLOTS:
void setSource(const QUrl &source);
@@ -74,9 +84,11 @@ public Q_SLOTS:
Q_SIGNALS:
void sourceChanged(const QUrl &source);
void meshNameChanged(const QString &meshName);
+ void statusChanged(Status status);
protected:
explicit QMesh(QMeshPrivate &dd, Qt3DCore::QNode *parent = nullptr);
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
private:
Q_DECLARE_PRIVATE(QMesh)
diff --git a/src/render/geometry/qmesh_p.h b/src/render/geometry/qmesh_p.h
index e8eccb608..76fc351a8 100644
--- a/src/render/geometry/qmesh_p.h
+++ b/src/render/geometry/qmesh_p.h
@@ -54,14 +54,13 @@
#include <Qt3DCore/private/qdownloadhelperservice_p.h>
#include <Qt3DRender/private/qgeometryrenderer_p.h>
#include <Qt3DRender/private/qt3drender_global_p.h>
+#include <Qt3DRender/qmesh.h>
#include <QUrl>
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QMesh;
-
class QT3DRENDERSHARED_PRIVATE_EXPORT QMeshPrivate : public QGeometryRendererPrivate
{
public:
@@ -72,9 +71,11 @@ public:
void setScene(Qt3DCore::QScene *scene) override;
void updateFunctor();
+ void setStatus(QMesh::Status status);
QUrl m_source;
QString m_meshName;
+ QMesh::Status m_status;
};
class Q_AUTOTEST_EXPORT MeshDownloadRequest : public Qt3DCore::QDownloadRequest