diff options
author | Janne Kangas <janne.kangas@qt.io> | 2019-01-07 12:00:21 +0200 |
---|---|---|
committer | Janne Kangas <janne.kangas@qt.io> | 2019-01-10 05:53:15 +0000 |
commit | 755c1185b5cb577feb4220ebfee2f4fc06e99927 (patch) | |
tree | e651311c207ec9ddc017c948582600a9bfb4b621 /src/Authoring/Client/Code/Core | |
parent | 16d80de67db387382e23d2545c7d3f3774a11c8a (diff) |
Enable setting datainput controller from timeline context menu
Add context menu option to set datainput controller for a property of
currently selected timeline object.
Change-Id: I569a5ea501e307228e9c50b654ad9f19a14a7d88
Task-id: QT3DS-2435
Reviewed-by: Tomi Korpipää <tomi.korpipaa@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.cpp | 40 | ||||
-rw-r--r-- | src/Authoring/Client/Code/Core/Doc/Doc.h | 5 | ||||
-rw-r--r-- | src/Authoring/Client/Code/Core/Doc/IDoc.h | 3 |
3 files changed, 48 insertions, 0 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp index fd06cd6f..8659923f 100644 --- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp +++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp @@ -3253,6 +3253,46 @@ void CDoc::ReplaceDatainput(const QString &oldName, const QString &newName, } } +QString CDoc::GetCurrentController(qt3dsdm::Qt3DSDMInstanceHandle instHandle, + qt3dsdm::Qt3DSDMPropertyHandle propHandle) +{ + auto propSys = GetPropertySystem(); + qt3dsdm::SValue currPropVal; + propSys->GetInstancePropertyValue( + instHandle, + propSys->GetAggregateInstancePropertyByName( + instHandle, qt3dsdm::TCharStr(L"controlledproperty")), + currPropVal); + if (!currPropVal.empty()) { + Q3DStudio::CString currPropValStr + = qt3dsdm::get<qt3dsdm::TDataStrPtr>(currPropVal)->GetData(); + + Q3DStudio::CString propName + = propSys->GetName(propHandle).c_str(); + + // Datainput controller name is always prepended with "$". Differentiate + // between datainput and property that has the same name by searching specifically + // for whitespace followed by property name. + long propNamePos = currPropValStr.find(" " + propName); + if ((propNamePos != currPropValStr.ENDOFSTRING) && (propNamePos != 0)) { + long posCtrlr = currPropValStr.substr(0, propNamePos).ReverseFind("$"); + + // adjust pos if this is the first controller - property pair + // in controlledproperty + if (posCtrlr < 0) + posCtrlr = 0; + + // remove $ + posCtrlr++; + return currPropValStr.substr(posCtrlr, propNamePos - posCtrlr).toQString(); + } else { + return {}; + } + } + + return {}; +} + QDebug operator<<(QDebug dbg, const SubPresentationRecord &r) { QDebugStateSaver stateSaver(dbg); diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.h b/src/Authoring/Client/Code/Core/Doc/Doc.h index c6006914..29130a48 100644 --- a/src/Authoring/Client/Code/Core/Doc/Doc.h +++ b/src/Authoring/Client/Code/Core/Doc/Doc.h @@ -247,6 +247,9 @@ public: void ReplaceDatainput(const QString &oldName, const QString &newName, const QList<qt3dsdm::Qt3DSDMInstanceHandle> &instances); + QString GetCurrentController(qt3dsdm::Qt3DSDMInstanceHandle instHandle, + qt3dsdm::Qt3DSDMPropertyHandle propHandle) const; + bool IsModified(); bool IsValid() const; @@ -358,6 +361,8 @@ public: void RemoveDatainputBindings( const QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMPropertyHandle>> *map) override; + QString GetCurrentController(qt3dsdm::Qt3DSDMInstanceHandle instHandle, + qt3dsdm::Qt3DSDMPropertyHandle propHandle) override; Q3DStudio::IDocumentBufferCache &GetBufferCache() override; Q3DStudio::IDocumentReader &GetDocumentReader() override; Q3DStudio::IDocumentEditor &OpenTransaction(const QString &inCmdName, const char *inFile, diff --git a/src/Authoring/Client/Code/Core/Doc/IDoc.h b/src/Authoring/Client/Code/Core/Doc/IDoc.h index 609b91f9..2299ccab 100644 --- a/src/Authoring/Client/Code/Core/Doc/IDoc.h +++ b/src/Authoring/Client/Code/Core/Doc/IDoc.h @@ -114,6 +114,9 @@ public: virtual void RemoveDatainputBindings( const QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMPropertyHandle>> *map) = 0; + + virtual QString GetCurrentController(qt3dsdm::Qt3DSDMInstanceHandle instHandle, + qt3dsdm::Qt3DSDMPropertyHandle propHandle) = 0; // Return an editor to editing the scene graph of the document. // This editor takes care of putting objects into the property slide // as well as updating the world |