summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Client/Code/Core
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-11-23 09:55:09 +0200
committerJanne Kangas <janne.kangas@qt.io>2018-12-17 05:17:02 +0000
commitcc6d431587587a5d0164df90a60d3772a5e26a3b (patch)
tree61e791095b8eed786fbef2e4f1d84c0158e18d0e /src/Authoring/Client/Code/Core
parent4f0ce05554e1511cf28c44568eb0b3caf6b38ef6 (diff)
Update datainput map more efficiently
When a single object changes property control bindings, do not recurse through the entire scene to update datainput binding status. Instead just update datainput entries associated with the specific object. Change-Id: I230577adfd5d1b28c3bdd858a2d5c576bf73a8ea Task-id: QT3DS-2549 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Client/Code/Core')
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.cpp50
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.h1
2 files changed, 47 insertions, 4 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
index 15240e2a..fd06cd6f 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
@@ -1353,10 +1353,7 @@ void CDoc::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
->GetAggregateInstancePropertyByName(inInstance, L"controlledproperty")) {
// we need to rebuild the datainput map as we do not know what exactly
// happened with controlledproperty property
- // TODO: implement a pre-change signal that can be used to extract
- // controlledproperty string before and after the change, so we know exactly
- // what happened to the element
- UpdateDatainputMap();
+ UpdateDatainputMapForInstance(inInstance);
}
}
@@ -3024,6 +3021,51 @@ void CDoc::UpdateDatainputMap(QMultiMap<QString,
UpdateDatainputMapRecursive(GetSceneInstance(), outMap);
}
+// Update global datainput map for all datainput bindings for a single instance.
+void CDoc::UpdateDatainputMapForInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance)
+{
+ auto propSystem = GetPropertySystem();
+
+ qt3dsdm::Qt3DSDMPropertyHandle ctrldPropHandle
+ = propSystem->GetAggregateInstancePropertyByName(inInstance, L"controlledproperty");
+
+ if (propSystem->HasAggregateInstanceProperty(inInstance, ctrldPropHandle)) {
+ qt3dsdm::SValue ctrldPropVal;
+ propSystem->GetInstancePropertyValue(inInstance, ctrldPropHandle, ctrldPropVal);
+ Q3DStudio::CString currCtrldPropsStr
+ = qt3dsdm::get<qt3dsdm::TDataStrPtr>(ctrldPropVal)->GetData();
+ QStringList splitStr = currCtrldPropsStr.toQString().split(QLatin1Char(' '));
+
+ // There is no way to detect a case where control is removed i.e. a controller-property
+ // pair simply disappears from controlledproperty string. We need to do a complete
+ // rebuild for inInstance references in the global map, but still avoid doing
+ // a scene-wide datainput map update.
+ for (auto &it : qAsConst(g_StudioApp.m_dataInputDialogItems))
+ it->removeControlFromInstance(inInstance);
+
+ // Rebuild controlled element items and append them to global datainput map.
+ for (int i = 0; i < splitStr.size() - 1; i += 2) {
+ // Check for '$' because Qt3DS v1.1 did not differentiate datainput
+ // names with it
+ QString diName = splitStr[i].startsWith(QLatin1Char('$'))
+ ? splitStr[i].remove(0, 1) : splitStr[i];
+ QString propName = splitStr[i+1];
+ auto propHandle = propSystem->GetAggregateInstancePropertyByName(
+ inInstance, propName.toStdWString().c_str());
+ auto propType = propSystem->GetDataType(propHandle);
+ CDataInputDialogItem::ControlledItem item(inInstance, propHandle);
+ if (propType)
+ item.dataType = {propType, false};
+ else if (propName == QLatin1String("@slide"))
+ item.dataType = {qt3dsdm::DataModelDataType::Value::String, true};
+ else if (propName == QLatin1String("@timeline"))
+ item.dataType = {qt3dsdm::DataModelDataType::Value::RangedNumber, true};
+
+ g_StudioApp.m_dataInputDialogItems[diName]->ctrldElems.append(item);
+ }
+ }
+}
+
void CDoc::UpdateDatainputMapRecursive(
const qt3dsdm::Qt3DSDMInstanceHandle inInstance,
QMultiMap<QString,
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.h b/src/Authoring/Client/Code/Core/Doc/Doc.h
index a85b405d..c6006914 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.h
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.h
@@ -242,6 +242,7 @@ public:
QMultiMap<QString,
QPair<qt3dsdm::Qt3DSDMInstanceHandle,
qt3dsdm::Qt3DSDMPropertyHandle>> *outMap = nullptr);
+ void UpdateDatainputMapForInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance);
bool VerifyControlledProperties(const qt3dsdm::Qt3DSDMInstanceHandle inInstance);
void ReplaceDatainput(const QString &oldName, const QString &newName,
const QList<qt3dsdm::Qt3DSDMInstanceHandle> &instances);