From dabae31f54eabdf7ce663990f633c124398bfcee Mon Sep 17 00:00:00 2001 From: srn Date: Thu, 9 Feb 2006 09:00:42 +0000 Subject: [PATCH] Added getDefaultScript static method --- src/SALOMEDS/SALOMEDS_IParameters.cxx | 57 +++++++++++++++++++++++++++ src/SALOMEDS/SALOMEDS_IParameters.hxx | 10 ++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/SALOMEDS/SALOMEDS_IParameters.cxx b/src/SALOMEDS/SALOMEDS_IParameters.cxx index d77287a9a..3ad0f26e0 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.cxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.cxx @@ -241,3 +241,60 @@ int SALOMEDS_IParameters::getLastSavePoint(_PTR(Study) study, const string& theI return tag; } + + +string SALOMEDS_IParameters::getDefaultScript(_PTR(Study) study, + const string& theID, + const string& moduleName, + const string& shift) +{ + + string dump(""); + + int savePoint = SALOMEDS_IParameters::getLastSavePoint(study, theID); + if(savePoint < 0) return dump; + SALOMEDS_IParameters ip = SALOMEDS_IParameters(study->GetCommonParameters(theID, savePoint)); + if(!ip.isDumpPython()) return dump; + + _PTR(AttributeParameter) ap = study->GetModuleParameters(theID, moduleName,savePoint); + ip = SALOMEDS_IParameters(ap); + + + dump += shift +"import iparameters\n"; + dump += shift + "ipar = iparameters.IParameters(salome.myStudy.GetModuleParameters(\""+theID+"\", \""+moduleName+"\", 1))\n\n"; + + vector v = ip.getProperties(); + if(v.size() > 0) { + dump += shift +"#Set up visual properties:\n"; + for(int i = 0; i 0) { + dump += shift +"#Set up lists:\n"; + for(int i = 0; i lst = ip.getValues(v[i]); + dump += shift +"# fill list "+v[i]+"\n"; + for(int j = 0; j < lst.size(); j++) + dump += shift +"ipar.append(\""+v[i]+"\", \""+lst[j]+"\")\n"; + } + } + + v = ip.getEntries(); + if(v.size() > 0) { + dump += shift + "#Set up entries:\n"; + for(int i = 0; i names = ip.getAllParameterNames(v[i]); + vector values = ip.getAllParameterValues(v[i]); + dump += shift + "# set up entity " + v[i] + " parameters" + "\n"; + for(int j = 0; j < names.size() && j < values.size(); j++) + dump += shift + "ipar.setParameter(\"" + v[i] + "\", \"" + names[j] + "\", \"" + values[j] + "\")\n"; + } + } + + return dump; +} + diff --git a/src/SALOMEDS/SALOMEDS_IParameters.hxx b/src/SALOMEDS/SALOMEDS_IParameters.hxx index b1ddc8aa9..e888b8adf 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.hxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.hxx @@ -125,7 +125,15 @@ public: /*! Returns an ID of the last save point */ - static int getLastSavePoint(_PTR(Study) study, const std::string& theID); + static int getLastSavePoint(_PTR(Study) study, const std::string& theID); + + /*! + Returns a default Python script that set ups visual parameters for the given module + */ + static std::string getDefaultScript(_PTR(Study) study, + const std::string& theID, + const std::string& moduleName, + const std::string& shift); private: _PTR(AttributeParameter) _ap; -- 2.39.2