diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-06-04 17:50:00 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2019-06-05 11:55:33 +0300 |
commit | 059007c11ca4ed8ed60ab6f9d203e9d81f3e3379 (patch) | |
tree | c7b40b8028af4aaf7917fcc13a9e9dda4f72c577 /src/Runtime | |
parent | 8b8ad9d1245e6ce1f97effa82ee44bd5fca416a0 (diff) |
Add accessors for lists of created elements/materials/meshes
Task-number: QT3DS-3618
Change-Id: I3b58ac2d2099836f142ef1a3b25a333a1023582b
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Jari Karppinen <jari.karppinen@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Pasi Keränen <pasi.keranen@qt.io>
Diffstat (limited to 'src/Runtime')
4 files changed, 144 insertions, 13 deletions
diff --git a/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation.cpp b/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation.cpp index 2f63efda..611daef1 100644 --- a/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation.cpp +++ b/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation.cpp @@ -147,7 +147,7 @@ void Q3DSPresentation::setSource(const QUrl &source) } /*! - \qmlproperty variant Presentation::variantList + \qmlproperty list<string> Presentation::variantList Holds a list of (variant group):(variant) tags that are loaded when the \c{source} property is set. If this list is left empty (default), no variant @@ -839,6 +839,36 @@ void Q3DSPresentation::deleteElements(const QStringList &elementPaths) QStringList *theElementPaths = new QStringList(elementPaths); d_ptr->m_commandQueue->queueCommand(CommandType_DeleteElements, theElementPaths); } + for (const auto &elementPath : elementPaths) + d_ptr->m_createdElements.removeAll(elementPath); +} + +/*! + \qmlproperty list<string> Presentation::createdElements + + This property contains a list of all dynamically created elements on this presentation. + + This property is read-only. + + \note Elements can only be dynamically created via C++ API. + + \sa createElement + \sa createElements +*/ + +/*! + \property Q3DSPresentation::createdElements + + This property contains a list of all dynamically created elements on this presentation. + + This property is read-only. + + \sa createElement + \sa createElements +*/ +QStringList Q3DSPresentation::createdElements() const +{ + return d_ptr->m_createdElements; } /*! @@ -939,6 +969,36 @@ void Q3DSPresentation::deleteMaterials(const QStringList &materialNames) QStringList *theMaterialNames = new QStringList(materialNames); d_ptr->m_commandQueue->queueCommand(CommandType_DeleteMaterials, theMaterialNames); } + for (const auto &name : materialNames) + d_ptr->m_createdMaterials.removeAll(name); +} + +/*! + \qmlproperty list<string> Presentation::createdMaterials + + This property contains a list of all dynamically created materials on this presentation. + + This property is read-only. + + \note Materials can only be dynamically created via C++ API. + + \sa createMaterial + \sa createMaterials +*/ + +/*! + \property Q3DSPresentation::createdMaterials + + This property contains a list of all dynamically created materials on this presentation. + + This property is read-only. + + \sa createMaterial + \sa createMaterials +*/ +QStringList Q3DSPresentation::createdMaterials() const +{ + return d_ptr->m_createdMaterials; } /*! @@ -1017,6 +1077,36 @@ void Q3DSPresentation::deleteMeshes(const QStringList &meshNames) QStringList *theMeshNames = new QStringList(meshNames); d_ptr->m_commandQueue->queueCommand(CommandType_DeleteMeshes, theMeshNames); } + for (const auto &name : meshNames) + d_ptr->m_createdMeshes.removeAll(name); +} + +/*! + \qmlproperty list<string> Presentation::createdMeshes + + This property contains a list of all dynamically created meshes on this presentation. + + This property is read-only. + + \note Meshes can only be dynamically created via C++ API. + + \sa createMesh + \sa createMeshes +*/ + +/*! + \property Q3DSPresentation::createdMeshes + + This property contains a list of all dynamically created meshes on this presentation. + + This property is read-only. + + \sa createMesh + \sa createMeshes +*/ +QStringList Q3DSPresentation::createdMeshes() const +{ + return d_ptr->m_createdMeshes; } /*! @@ -1309,11 +1399,11 @@ void Q3DSPresentationPrivate::setViewerApp(Q3DSViewer::Q3DSViewerApp *app, bool connect(app, &Q3DSViewer::Q3DSViewerApp::SigDataOutputValueUpdated, this, &Q3DSPresentationPrivate::handleDataOutputValueUpdate); connect(app, &Q3DSViewer::Q3DSViewerApp::SigElementsCreated, - q_ptr, &Q3DSPresentation::elementsCreated); + this, &Q3DSPresentationPrivate::handleElementsCreated); connect(app, &Q3DSViewer::Q3DSViewerApp::SigMaterialsCreated, - q_ptr, &Q3DSPresentation::materialsCreated); + this, &Q3DSPresentationPrivate::handleMaterialsCreated); connect(app, &Q3DSViewer::Q3DSViewerApp::SigMeshesCreated, - q_ptr, &Q3DSPresentation::meshesCreated); + this, &Q3DSPresentationPrivate::handleMeshesCreated); } if (oldApp) { disconnect(oldApp, &Q3DSViewer::Q3DSViewerApp::SigSlideEntered, @@ -1325,11 +1415,11 @@ void Q3DSPresentationPrivate::setViewerApp(Q3DSViewer::Q3DSViewerApp *app, bool disconnect(oldApp, &Q3DSViewer::Q3DSViewerApp::SigDataOutputValueUpdated, this, &Q3DSPresentationPrivate::handleDataOutputValueUpdate); disconnect(oldApp, &Q3DSViewer::Q3DSViewerApp::SigElementsCreated, - q_ptr, &Q3DSPresentation::elementsCreated); + this, &Q3DSPresentationPrivate::handleElementsCreated); disconnect(oldApp, &Q3DSViewer::Q3DSViewerApp::SigMaterialsCreated, - q_ptr, &Q3DSPresentation::materialsCreated); + this, &Q3DSPresentationPrivate::handleMaterialsCreated); disconnect(oldApp, &Q3DSViewer::Q3DSViewerApp::SigMeshesCreated, - q_ptr, &Q3DSPresentation::meshesCreated); + this, &Q3DSPresentationPrivate::handleMeshesCreated); } } } @@ -1973,4 +2063,31 @@ void Q3DSPresentationPrivate::handleDataOutputValueUpdate(const QString &name, node->setValue(newValue); } +void Q3DSPresentationPrivate::handleElementsCreated(const QStringList &elementPaths, + const QString &error) +{ + if (error.isEmpty()) + m_createdElements << elementPaths; + + Q_EMIT q_ptr->elementsCreated(elementPaths, error); +} + +void Q3DSPresentationPrivate::handleMaterialsCreated(const QStringList &materialNames, + const QString &error) +{ + if (error.isEmpty()) + m_createdMaterials << materialNames; + + Q_EMIT q_ptr->materialsCreated(materialNames, error); +} + +void Q3DSPresentationPrivate::handleMeshesCreated(const QStringList &meshNames, + const QString &error) +{ + if (error.isEmpty()) + m_createdMeshes << meshNames; + + Q_EMIT q_ptr->meshesCreated(meshNames, error); +} + QT_END_NAMESPACE diff --git a/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation.h b/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation.h index 03283a9e..04faf0d0 100644 --- a/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation.h +++ b/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation.h @@ -55,6 +55,9 @@ class Q_STUDIO3D_EXPORT Q3DSPresentation : public QObject Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(QStringList variantList READ variantList WRITE setVariantList NOTIFY variantListChanged) Q_PROPERTY(bool delayedLoading READ delayedLoading WRITE setDelayedLoading NOTIFY delayedLoadingChanged) + Q_PROPERTY(QStringList createdElements READ createdElements NOTIFY elementsCreated) + Q_PROPERTY(QStringList createdMaterials READ createdMaterials NOTIFY materialsCreated) + Q_PROPERTY(QStringList createdMeshes READ createdMeshes NOTIFY meshesCreated) public: explicit Q3DSPresentation(QObject *parent = nullptr); @@ -101,14 +104,19 @@ public: const QVector<QHash<QString, QVariant>> &properties); void deleteElement(const QString &elementPath); void deleteElements(const QStringList &elementPaths); + QStringList createdElements() const; + void createMaterial(const QString &materialDefinition, const QString &subPresId = {}); void createMaterials(const QStringList &materialDefinitions, const QString &subPresId = {}); void deleteMaterial(const QString &materialName); void deleteMaterials(const QStringList &materialNames); + QStringList createdMaterials() const; + void createMesh(const QString &meshName, const Q3DSGeometry &geometry); void createMeshes(const QHash<QString, const Q3DSGeometry *> &meshData); void deleteMesh(const QString &meshName); void deleteMeshes(const QStringList &meshNames); + QStringList createdMeshes() const; public Q_SLOTS: void setSource(const QUrl &source); diff --git a/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation_p.h b/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation_p.h index c30eb82d..59b9f383 100644 --- a/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation_p.h +++ b/src/Runtime/ogl-runtime/src/api/studio3d/q3dspresentation_p.h @@ -98,6 +98,9 @@ public: public Q_SLOTS: void handleSlideEntered(const QString &elementPath, unsigned int index, const QString &name); void handleDataOutputValueUpdate(const QString &name, const QVariant &newValue); + void handleElementsCreated(const QStringList &elementPaths, const QString &error); + void handleMaterialsCreated(const QStringList &materialNames, const QString &error); + void handleMeshesCreated(const QStringList &meshNames, const QString &error); public: Q3DSPresentation *q_ptr; @@ -112,6 +115,9 @@ private: QStringList m_variantList; ViewerQmlStreamProxy *m_streamProxy; bool m_delayedLoading; + QStringList m_createdElements; + QStringList m_createdMaterials; + QStringList m_createdMeshes; friend class Q3DSStudio3D; }; diff --git a/src/Runtime/ogl-runtime/src/api/studio3dqml/q3dsstudio3d.cpp b/src/Runtime/ogl-runtime/src/api/studio3dqml/q3dsstudio3d.cpp index 3d48babc..5a460895 100644 --- a/src/Runtime/ogl-runtime/src/api/studio3dqml/q3dsstudio3d.cpp +++ b/src/Runtime/ogl-runtime/src/api/studio3dqml/q3dsstudio3d.cpp @@ -372,16 +372,16 @@ QQuickFramebufferObject::Renderer *Q3DSStudio3D::createRenderer() const m_presentation->d_ptr, &Q3DSPresentationPrivate::handleSlideEntered); connect(renderer, &Q3DSRenderer::dataOutputValueUpdated, m_presentation->d_ptr, &Q3DSPresentationPrivate::handleDataOutputValueUpdate); + connect(renderer, &Q3DSRenderer::elementsCreated, + m_presentation->d_ptr, &Q3DSPresentationPrivate::handleElementsCreated); + connect(renderer, &Q3DSRenderer::materialsCreated, + m_presentation->d_ptr, &Q3DSPresentationPrivate::handleMaterialsCreated); + connect(renderer, &Q3DSRenderer::meshesCreated, + m_presentation->d_ptr, &Q3DSPresentationPrivate::handleMeshesCreated); connect(renderer, &Q3DSRenderer::exitSlide, m_presentation, &Q3DSPresentation::slideExited); connect(renderer, &Q3DSRenderer::customSignalEmitted, m_presentation, &Q3DSPresentation::customSignalEmitted); - connect(renderer, &Q3DSRenderer::elementsCreated, - m_presentation, &Q3DSPresentation::elementsCreated); - connect(renderer, &Q3DSRenderer::materialsCreated, - m_presentation, &Q3DSPresentation::materialsCreated); - connect(renderer, &Q3DSRenderer::meshesCreated, - m_presentation, &Q3DSPresentation::meshesCreated); connect(renderer, &Q3DSRenderer::requestResponse, this, &Q3DSStudio3D::requestResponseHandler); connect(renderer, &Q3DSRenderer::presentationLoaded, |