From: srn Date: Wed, 15 Feb 2006 09:09:42 +0000 (+0000) Subject: Added method decodeEntry X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8b1d7aa68f7f41c549ebabf0de32b1ad67bcf6b9;p=modules%2Fkernel.git Added method decodeEntry --- diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx index 140e80ca3..02115abab 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx @@ -38,10 +38,14 @@ SALOMEDSImpl_IParameters::SALOMEDSImpl_IParameters(const Handle(SALOMEDSImpl_Att { if(ap.IsNull()) return; _ap = ap; + Handle(SALOMEDSImpl_SObject) so = _ap->GetSObject(); + _study = so->GetStudy(); } SALOMEDSImpl_IParameters::~SALOMEDSImpl_IParameters() -{} +{ + _compNames.clear(); +} int SALOMEDSImpl_IParameters::append(const string& listName, const string& value) { @@ -187,6 +191,28 @@ vector SALOMEDSImpl_IParameters::getProperties() return _ap->GetStrArray(_AP_PROPERTIES_LIST_); } +string SALOMEDSImpl_IParameters::decodeEntry(const string& entry) +{ + if(!_study) return entry; + int pos = entry.rfind("_"); + if(pos < 0 || pos >= entry.length()) return entry; + + string compName(entry, 0, pos), compID, tail(entry, pos+1, entry.length()-1); + + if(_compNames.find(compName) == _compNames.end()) { + Handle(SALOMEDSImpl_SObject) so = _study->FindComponent((char*)compName.c_str()); + if(!so) return entry; + compID = so->GetID().ToCString(); + _compNames[compName] = compID; + } + else compID = _compNames[compName]; + + string newEntry(compID); + newEntry += (":"+tail); + + return newEntry; +} + bool SALOMEDSImpl_IParameters::isDumpPython(const Handle(SALOMEDSImpl_Study)& study, const string& theID) { @@ -313,7 +339,8 @@ string SALOMEDSImpl_IParameters::getDefaultScript(const Handle(SALOMEDSImpl_Stud for(int i = 0; i names = ip.getAllParameterNames(v[i]); vector values = ip.getAllParameterValues(v[i]); - Handle(SALOMEDSImpl_SObject) so = study->FindObjectID((char*)v[i].c_str()); + string decodedEntry = ip.decodeEntry(v[i]); + Handle(SALOMEDSImpl_SObject) so = study->FindObjectID((char*)decodedEntry.c_str()); string so_name(""); if(!so.IsNull()) so_name = so->GetName().ToCString(); dump += shift + "# set up entry " + v[i] +" ("+so_name+")" + " parameters" + "\n"; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx index 68e88ec67..4e6d5050b 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx @@ -21,6 +21,7 @@ #include #include +#include #include "SALOMEDSImpl_AttributeParameter.hxx" #include "SALOMEDSImpl_Study.hxx" @@ -107,6 +108,11 @@ public: */ virtual std::vector getProperties(); + /*! + Returns decoded entry that is an absolute entry + */ + virtual std::string decodeEntry(const std::string& entry); + /*! Returns whether there is the dumping visual parameters @@ -139,6 +145,8 @@ public: private: Handle(SALOMEDSImpl_AttributeParameter) _ap; + Handle(SALOMEDSImpl_Study) _study; + std::map _compNames; };