From 266ee8913395630f9802b15811e34074a3c42329 Mon Sep 17 00:00:00 2001 From: srn Date: Tue, 14 Feb 2006 14:55:20 +0000 Subject: [PATCH] Added a method getDefaultScript --- src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx | 62 +++++++++++++++++++ src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx | 9 +++ 2 files changed, 71 insertions(+) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx index 71254c62f..140e80ca3 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx @@ -264,6 +264,68 @@ string SALOMEDSImpl_IParameters::getStudyScript(const Handle(SALOMEDSImpl_Study) return dump; } +string SALOMEDSImpl_IParameters::getDefaultScript(const Handle(SALOMEDSImpl_Study)& study, + const string& moduleName, + const string& shift, + const string& theID) +{ + string anID; + if(theID == "") anID = getDefaultVisualComponent(); + else anID = theID; + + string dump(""); + + int savePoint = SALOMEDSImpl_IParameters::getLastSavePoint(study, anID); + if(savePoint < 0) return dump; + SALOMEDSImpl_IParameters ip = SALOMEDSImpl_IParameters(study->GetCommonParameters(anID.c_str(), savePoint)); + if(!isDumpPython(study)) return dump; + + Handle(SALOMEDSImpl_AttributeParameter) ap = study->GetModuleParameters(anID.c_str(), moduleName.c_str(), savePoint); + ip = SALOMEDSImpl_IParameters(ap); + + + dump += shift +"import iparameters\n"; + dump += shift + "ipar = iparameters.IParameters(theStudy.GetModuleParameters(\""+anID+"\", \""+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]); + Handle(SALOMEDSImpl_SObject) so = study->FindObjectID((char*)v[i].c_str()); + string so_name(""); + if(!so.IsNull()) so_name = so->GetName().ToCString(); + dump += shift + "# set up entry " + v[i] +" ("+so_name+")" + " 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; +} + + string SALOMEDSImpl_IParameters::getDefaultVisualComponent() { return "Interface Applicative"; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx index d41f21ef3..68e88ec67 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.hxx @@ -123,6 +123,15 @@ public: */ static std::string getStudyScript(const Handle(SALOMEDSImpl_Study)& study, int savePoint, const std::string& theID = ""); + /*! + Returns a default Python script that set ups visual parameters for the given module + shift is a string that contain spaces to make valid Python script indentaion + */ + static std::string getDefaultScript(const Handle(SALOMEDSImpl_Study)& study, + const std::string& moduleName, + const std::string& shift, + const std::string& theID = ""); + /*! Returns a default name of the component where the visula parameters are stored. */ -- 2.39.2