From 2d1bd330a141e83a7d79dcb945557d9703995081 Mon Sep 17 00:00:00 2001 From: Janne Kangas Date: Tue, 14 May 2019 11:02:30 +0300 Subject: Make Datainput min and max read-only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove setters and change signals for datainput min and max properties. These properties are not intended to be changed at runtime, and asynchronous separation of QML client side and renderer does not allow trivial tracking of these values. Min and max are now initialized at UIA load. Also fix bug where QML side did not receive UIA-specified min/max values. Change-Id: Ie04e81ea55bc4f4159c9f6989660caf9c36c49ed Task-id: QT3DS-3578 Reviewed-by: Antti Määttä Reviewed-by: Miikka Heikkinen Reviewed-by: Pasi Keränen --- src/Runtime/api/studio3d/q3dsdatainput.cpp | 20 -------------------- src/Runtime/api/studio3d/q3dsdatainput.h | 9 +++------ src/Runtime/api/studio3d/q3dsdatainput_p.h | 1 + src/Runtime/api/studio3d/q3dspresentation.cpp | 9 ++++++--- src/Runtime/api/studio3d/q3dspresentation.h | 1 - src/Runtime/api/studio3dqml/q3dsrenderer.cpp | 14 ++++++++++---- 6 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/Runtime/api/studio3d/q3dsdatainput.cpp b/src/Runtime/api/studio3d/q3dsdatainput.cpp index b084ee4d..d2d82008 100644 --- a/src/Runtime/api/studio3d/q3dsdatainput.cpp +++ b/src/Runtime/api/studio3d/q3dsdatainput.cpp @@ -118,26 +118,6 @@ bool Q3DSDataInput::isValid() const return false; } -void Q3DSDataInput::setMin(float min) -{ - if (!d_ptr->m_presentation) - return; - - d_ptr->m_presentation->setDataInputValue(d_ptr->m_name, min, ValueRole::Min); - d_ptr->m_min = min; - emit minChanged(); -} - -void Q3DSDataInput::setMax(float max) -{ - if (!d_ptr->m_presentation) - return; - - d_ptr->m_presentation->setDataInputValue(d_ptr->m_name, max, ValueRole::Max); - d_ptr->m_max = max; - emit maxChanged(); -} - void Q3DSDataInput::setValue(const QVariant &value) { // Since properties controlled by data inputs can change without the current value being diff --git a/src/Runtime/api/studio3d/q3dsdatainput.h b/src/Runtime/api/studio3d/q3dsdatainput.h index d57b5f18..4504e5d2 100644 --- a/src/Runtime/api/studio3d/q3dsdatainput.h +++ b/src/Runtime/api/studio3d/q3dsdatainput.h @@ -46,8 +46,8 @@ class Q_STUDIO3D_EXPORT Q3DSDataInput : public QObject Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) - Q_PROPERTY(float max READ max WRITE setMax NOTIFY maxChanged) - Q_PROPERTY(float min READ min WRITE setMin NOTIFY minChanged) + Q_PROPERTY(float max READ max CONSTANT) + Q_PROPERTY(float min READ min CONSTANT) public: explicit Q3DSDataInput(QObject *parent = nullptr); explicit Q3DSDataInput(const QString &name, QObject *parent = nullptr); @@ -71,14 +71,10 @@ public: public Q_SLOTS: void setName(const QString &name); void setValue(const QVariant &value); - void setMin(float min); - void setMax(float max); Q_SIGNALS: void nameChanged(); void valueChanged(); - void minChanged(); - void maxChanged(); protected: explicit Q3DSDataInput(Q3DSDataInputPrivate *d, Q3DSPresentation *presentation, @@ -88,6 +84,7 @@ protected: private: Q_DISABLE_COPY(Q3DSDataInput) friend class Q3DSPresentationPrivate; + friend class Q3DSRenderer; }; QT_END_NAMESPACE diff --git a/src/Runtime/api/studio3d/q3dsdatainput_p.h b/src/Runtime/api/studio3d/q3dsdatainput_p.h index 8f5be06f..6107add9 100644 --- a/src/Runtime/api/studio3d/q3dsdatainput_p.h +++ b/src/Runtime/api/studio3d/q3dsdatainput_p.h @@ -75,6 +75,7 @@ protected: float m_min = 0; friend class Q3DSPresentationPrivate; + friend class Q3DSRenderer; }; QT_END_NAMESPACE diff --git a/src/Runtime/api/studio3d/q3dspresentation.cpp b/src/Runtime/api/studio3d/q3dspresentation.cpp index 8370dbb6..5b55608d 100644 --- a/src/Runtime/api/studio3d/q3dspresentation.cpp +++ b/src/Runtime/api/studio3d/q3dspresentation.cpp @@ -672,14 +672,17 @@ void Q3DSPresentationPrivate::requestResponseHandler(CommandType commandType, vo // Check and append to QML-side list if the (UIA) presentation has additional datainputs // that are not explicitly defined in QML code. auto receivedDI = response->at(i).value(); + // For QML behind async command queue, we cache min/max values in addition + // to name, in order to be able to return values initially set in UIA file (in QML + // getters). if (!m_dataInputs.contains(receivedDI->name())) { - // For QML behind async command queue, we cache min/max values in addition - // to name, in order to be able to return values initially set in UIA file (in QML - // setter/getters). auto newDI = new Q3DSDataInput(receivedDI->name(), nullptr); newDI->d_ptr->m_min = receivedDI->d_ptr->m_min; newDI->d_ptr->m_max = receivedDI->d_ptr->m_max; registerDataInput(newDI); + } else { + m_dataInputs[receivedDI->name()]->d_ptr->m_min = receivedDI->d_ptr->m_min; + m_dataInputs[receivedDI->name()]->d_ptr->m_max = receivedDI->d_ptr->m_max; } } delete response; diff --git a/src/Runtime/api/studio3d/q3dspresentation.h b/src/Runtime/api/studio3d/q3dspresentation.h index 6a2a8926..bcdd9c53 100644 --- a/src/Runtime/api/studio3d/q3dspresentation.h +++ b/src/Runtime/api/studio3d/q3dspresentation.h @@ -130,7 +130,6 @@ Q_SIGNALS: void slideExited(const QString &elementPath, unsigned int index, const QString &name); // Indicates that data input and output definitions in the Studio project have been parsed // and datainputs/dataoutputs are available through dataInputs() / getDataInputs(). - // and datainputs are available through dataInputs() / getDataInputs(). void dataInputsReady(); void dataOutputsReady(); void customSignalEmitted(const QString &elementPath, const QString &name); diff --git a/src/Runtime/api/studio3dqml/q3dsrenderer.cpp b/src/Runtime/api/studio3dqml/q3dsrenderer.cpp index a3d7b2d8..bbfee502 100644 --- a/src/Runtime/api/studio3dqml/q3dsrenderer.cpp +++ b/src/Runtime/api/studio3dqml/q3dsrenderer.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -413,11 +414,16 @@ void Q3DSRenderer::processCommands() } case CommandType_RequestDataInputs: { QVariantList *requestData = new QVariantList(); - if (m_presentation) { - const auto diList = m_presentation->dataInputs(); + if (m_runtime) { + const auto diList = m_runtime->dataInputs(); - for (const auto &it : diList) - requestData->append(QVariant::fromValue(it)); + for (const auto &it : diList) { + Q3DSDataInput *newIt = new Q3DSDataInput(it, nullptr); + newIt->d_ptr->m_max = m_runtime->dataInputMax(it); + newIt->d_ptr->m_min = m_runtime->dataInputMin(it); + + requestData->append(QVariant::fromValue(newIt)); + } } Q_EMIT requestResponse(cmd.m_elementPath, cmd.m_commandType, requestData); -- cgit v1.2.3