From bd5a1f69f7ec5912bf7a73cc0e940216d3fa2990 Mon Sep 17 00:00:00 2001 From: srn Date: Tue, 14 Feb 2006 14:56:24 +0000 Subject: [PATCH] Added a method GetDefaultScript --- idl/SALOMEDS.idl | 8 +++ src/SALOMEDS/SALOMEDS_IParameters.cxx | 85 --------------------------- src/SALOMEDS/SALOMEDS_IParameters.hxx | 15 ----- src/SALOMEDS/SALOMEDS_Study_i.cxx | 14 +++++ src/SALOMEDS/SALOMEDS_Study_i.hxx | 3 + 5 files changed, 25 insertions(+), 100 deletions(-) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index c15c9ee94..41e42e58a 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -386,6 +386,14 @@ during each working session. */ AttributeParameter GetModuleParameters(in string theID, in string theModuleName, in long theSavePoint); + +/*! + Returns a default Python script to restore visual parameters for given %theModuleName. + \param theID identifies a common parameters set (Example: "Interface Applicative") + \param theModuleName is a name of the module (Example: "Geometry") +*/ + string GetDefaultScript(in string theID, in string theModuleName); + /*! Private method, returns an implementation of this Study. \param theHostname is a hostname of the caller diff --git a/src/SALOMEDS/SALOMEDS_IParameters.cxx b/src/SALOMEDS/SALOMEDS_IParameters.cxx index cbf6d4e18..6540d9fee 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.cxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.cxx @@ -270,91 +270,6 @@ bool SALOMEDS_IParameters::isDumpPython(_PTR(Study) study, const string& theID) return (bool)ap->GetBool(_AP_DUMP_PYTHON_); } -int SALOMEDS_IParameters::getLastSavePoint(_PTR(Study) study, const string& theID) -{ - string anID; - if(theID == "") anID = getDefaultVisualComponent(); - else anID = theID; - - _PTR(SObject) so = study->FindComponent(anID); - if(!so) return -1; - - _PTR(StudyBuilder) builder = study->NewBuilder(); - _PTR(ChildIterator) anIter ( study->NewChildIterator( so ) ); - int tag = -1; - for(; anIter->More(); anIter->Next()) - { - _PTR(SObject) val( anIter->Value() ); - _PTR(GenericAttribute) genAttr; - if(builder->FindAttribute(val, genAttr, "AttributeParameter")) tag = val->Tag(); - } - - return tag; -} - - -string SALOMEDS_IParameters::getDefaultScript(_PTR(Study) study, - const string& moduleName, - const string& shift, - const string& theID) -{ - string anID; - if(theID == "") anID = getDefaultVisualComponent(); - else anID = theID; - - string dump(""); - - int savePoint = SALOMEDS_IParameters::getLastSavePoint(study, anID); - if(savePoint < 0) return dump; - SALOMEDS_IParameters ip = SALOMEDS_IParameters(study->GetCommonParameters(anID, savePoint)); - if(!isDumpPython(study)) return dump; - - _PTR(AttributeParameter) ap = study->GetModuleParameters(anID, moduleName,savePoint); - ip = SALOMEDS_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]); - _PTR(SObject) so = study->FindObjectID(v[i]); - string so_name(""); - if(so) so_name = so->GetName(); - 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 SALOMEDS_IParameters::getDefaultVisualComponent() { return "Interface Applicative"; diff --git a/src/SALOMEDS/SALOMEDS_IParameters.hxx b/src/SALOMEDS/SALOMEDS_IParameters.hxx index 054bb4ba3..4111e83f9 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.hxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.hxx @@ -124,21 +124,6 @@ public: */ virtual std::string decodeEntry(const std::string& entry); - - /*! - Returns an ID of the last save point - */ - static int getLastSavePoint(_PTR(Study) study, 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(_PTR(Study) study, - const std::string& moduleName, - const std::string& shift, - const std::string& theID = ""); - /*! Enables/Disables the dumping visual parameters */ diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 3e1b546c3..558bb904f 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -38,6 +38,7 @@ #include "SALOMEDSImpl_AttributeStudyProperties.hxx" #include "SALOMEDSImpl_AttributeParameter.hxx" #include "SALOMEDSImpl_ChildIterator.hxx" +#include "SALOMEDSImpl_IParameters.hxx" #include #include @@ -782,6 +783,19 @@ SALOMEDS::AttributeParameter_ptr SALOMEDS_Study_i::GetModuleParameters(const cha return SP->AttributeParameter::_this(); } +//============================================================================ +/*! Function : GetDefaultScript + * Purpose : + */ +//============================================================================ +char* SALOMEDS_Study_i::GetDefaultScript(const char* theModuleName, const char* theShift) +{ + SALOMEDS::Locker lock; + + string script = SALOMEDSImpl_IParameters::getDefaultScript(_impl, theModuleName, theShift); + return CORBA::string_dup(script.c_str()); +} + //=========================================================================== // PRIVATE FUNCTIONS //=========================================================================== diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 0e65bf1e9..609d566ea 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -284,10 +284,13 @@ public: const char* theModuleName, CORBA::Long theSavePoint); + virtual char* GetDefaultScript(const char* theModuleName, const char* theShift); + virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished); virtual Handle(SALOMEDSImpl_Study) GetImpl() { return _impl; } virtual long GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal); + }; #endif -- 2.39.2