From: srn Date: Tue, 14 Feb 2006 13:09:48 +0000 (+0000) Subject: Changed method DumpStudy X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6bd8b86a043860fdcbfd37491777964a01380705;p=modules%2Fkernel.git Changed method DumpStudy --- diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 3eb2b0541..c15c9ee94 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -369,7 +369,7 @@ during each working session. void UndoPostponed(in long theWay); - boolean DumpStudy(in string thePath, in string theBaseName, in boolean isPublished, in string thePrefix); + boolean DumpStudy(in string thePath, in string theBaseName, in boolean isPublished); /*! Returns an AttributeParameter used to store common parameters for given %theSavePoint. diff --git a/src/SALOMEDS/SALOMEDS_IParameters.cxx b/src/SALOMEDS/SALOMEDS_IParameters.cxx index 278adfb3b..cbf6d4e18 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.cxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.cxx @@ -218,19 +218,6 @@ vector SALOMEDS_IParameters::parseValue(const string& value, const char return v; } -void SALOMEDS_IParameters::setDumpPython(bool isDumping) -{ - if(!_ap) return; - _ap->SetBool(_AP_DUMP_PYTHON_, isDumping); -} - -bool SALOMEDS_IParameters::isDumpPython() -{ - if(!_ap) return false; - if(!_ap->IsSet(_AP_DUMP_PYTHON_, PT_BOOLEAN)) return false; - return (bool)_ap->GetBool(_AP_DUMP_PYTHON_); -} - string SALOMEDS_IParameters::encodeEntry(const string& entry, const string& compName) { string tail(entry, 6, entry.length()-1); @@ -261,10 +248,35 @@ string SALOMEDS_IParameters::decodeEntry(const string& entry) return newEntry; } +void SALOMEDS_IParameters::setDumpPython(_PTR(Study) study, const string& theID) +{ + string anID; + if(theID == "") anID = getDefaultVisualComponent(); + else anID = theID; + + _PTR(AttributeParameter) ap = study->GetCommonParameters(anID, 0); + ap->SetBool(_AP_DUMP_PYTHON_, true); +} + +bool SALOMEDS_IParameters::isDumpPython(_PTR(Study) study, const string& theID) +{ + string anID; + if(theID == "") anID = getDefaultVisualComponent(); + else anID = theID; + + _PTR(AttributeParameter) ap = study->GetCommonParameters(anID, 0); + if(!ap) return false; + if(!ap->IsSet(_AP_DUMP_PYTHON_, PT_BOOLEAN)) return false; + return (bool)ap->GetBool(_AP_DUMP_PYTHON_); +} int SALOMEDS_IParameters::getLastSavePoint(_PTR(Study) study, const string& theID) { - _PTR(SObject) so = study->FindComponent(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(); @@ -282,24 +294,27 @@ int SALOMEDS_IParameters::getLastSavePoint(_PTR(Study) study, const string& theI string SALOMEDS_IParameters::getDefaultScript(_PTR(Study) study, - const string& theID, const string& moduleName, - const string& shift) + const string& shift, + const string& theID) { + string anID; + if(theID == "") anID = getDefaultVisualComponent(); + else anID = theID; string dump(""); - int savePoint = SALOMEDS_IParameters::getLastSavePoint(study, theID); + int savePoint = SALOMEDS_IParameters::getLastSavePoint(study, anID); if(savePoint < 0) return dump; - SALOMEDS_IParameters ip = SALOMEDS_IParameters(study->GetCommonParameters(theID, savePoint)); - if(!ip.isDumpPython()) return dump; + SALOMEDS_IParameters ip = SALOMEDS_IParameters(study->GetCommonParameters(anID, savePoint)); + if(!isDumpPython(study)) return dump; - _PTR(AttributeParameter) ap = study->GetModuleParameters(theID, moduleName,savePoint); + _PTR(AttributeParameter) ap = study->GetModuleParameters(anID, moduleName,savePoint); ip = SALOMEDS_IParameters(ap); dump += shift +"import iparameters\n"; - dump += shift + "ipar = iparameters.IParameters(theStudy.GetModuleParameters(\""+theID+"\", \""+moduleName+"\", 1))\n\n"; + dump += shift + "ipar = iparameters.IParameters(theStudy.GetModuleParameters(\""+anID+"\", \""+moduleName+"\", 1))\n\n"; vector v = ip.getProperties(); if(v.size() > 0) { @@ -339,37 +354,11 @@ string SALOMEDS_IParameters::getDefaultScript(_PTR(Study) study, return dump; } -string SALOMEDS_IParameters::getStudyScript(_PTR(Study) study, const std::string& theID, int savePoint) -{ - _PTR(AttributeParameter) ap = study->GetCommonParameters(theID, savePoint); - SALOMEDS_IParameters ip(ap); - ip.setDumpPython(true); //Enable DumpPython of visual parameters for modules. - string dump(""); +string SALOMEDS_IParameters::getDefaultVisualComponent() +{ + return "Interface Applicative"; +} - dump += "import iparameters\n"; - dump += "ipar = iparameters.IParameters(salome.myStudy.GetCommonParameters(\""+theID+"\", 1))\n\n"; - - - vector v = ip.getProperties(); - if(v.size() > 0) { - dump += "#Set up visual properties:\n"; - for(int i = 0; i 0) { - dump += "#Set up lists:\n"; - for(int i = 0; i lst = ip.getValues(v[i]); - dump += "# fill list "+v[i]+"\n"; - for(int j = 0; j < lst.size(); j++) - dump += "ipar.append(\""+v[i]+"\", \""+lst[j]+"\")\n"; - } - } - return dump; -} diff --git a/src/SALOMEDS/SALOMEDS_IParameters.hxx b/src/SALOMEDS/SALOMEDS_IParameters.hxx index bbb8c4ec1..054bb4ba3 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.hxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.hxx @@ -40,118 +40,119 @@ public: Returns a number of the added value. Note: the name of the list MUST be unique */ - int append(const std::string& listName, const std::string& value); + virtual int append(const std::string& listName, const std::string& value); /*! Returns a number elements in the list */ - int nbValues(const std::string& listName); + virtual int nbValues(const std::string& listName); /*! Returns a list of values in the list */ - std::vector getValues(const std::string& listName); + virtual std::vector getValues(const std::string& listName); /*! Returns a value with given %index, where %index is in range [0:nbValues-1] */ - std::string getValue(const std::string& listName, int index); + virtual std::string getValue(const std::string& listName, int index); /*! Returns a list all entries lists */ - std::vector getLists(); + virtual std::vector getLists(); /*! Sets a new named parameter value for the given entry */ - void setParameter(const std::string& entry, const std::string& parameterName, const std::string& value); + virtual void setParameter(const std::string& entry, const std::string& parameterName, const std::string& value); /*! Gets a named parameter value for the given entry */ - std::string getParameter(const std::string& entry, const std::string& parameterName); + virtual std::string getParameter(const std::string& entry, const std::string& parameterName); /*! Returns all parameter names of the given entry */ - std::vector SALOMEDS_IParameters::getAllParameterNames(const std::string& entry); + virtual std::vector getAllParameterNames(const std::string& entry); /*! Returns all parameter values of the given entry */ - std::vector SALOMEDS_IParameters::getAllParameterValues(const std::string& entry); + virtual std::vector getAllParameterValues(const std::string& entry); /*! Returns a number of parameters of the given entry */ - int getNbParameters(const std::string& entry); + virtual int getNbParameters(const std::string& entry); /*! Returns a list all entries */ - std::vector getEntries(); + virtual std::vector getEntries(); /*! Sets a global named property value */ - void setProperty(const std::string& name, const std::string& value); + virtual void setProperty(const std::string& name, const std::string& value); /*! Gets a value of global named property */ - std::string getProperty(const std::string& name); + virtual std::string getProperty(const std::string& name); /*! Returns a list all properties */ - std::vector getProperties(); + virtual std::vector getProperties(); /*! Breaks a value string in two parts which is divided by %separator. If fromEnd is True the search of separator starts from the end of the string */ - std::vector parseValue(const std::string& value, const char separator, bool fromEnd = true); + virtual std::vector parseValue(const std::string& value, const char separator, bool fromEnd = true); - /*! - Enables/Disables the dumping visual parameters - */ - void setDumpPython(bool isDumping); - - /*! - Returns whether there is the dumping visual parameters - */ - bool isDumpPython(); - /*! Returns encoded entry that is a relative entry for the component */ - std::string encodeEntry(const std::string& entry, const std::string& compName); + virtual std::string encodeEntry(const std::string& entry, const std::string& compName); /*! Returns decoded entry that is an absolute entry */ - std::string decodeEntry(const std::string& entry); + 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); + 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& theID, const std::string& moduleName, - const std::string& shift); + const std::string& shift, + const std::string& theID = ""); + + /*! + Enables/Disables the dumping visual parameters + */ + static void setDumpPython(_PTR(Study) study, const std::string& theID = ""); + + /*! + Returns whether there is the dumping visual parameters + */ + static bool isDumpPython(_PTR(Study) study, const std::string& theID = ""); /*! - Returns a Python script for the study, which sets up visual parameters + Returns a default name of the component where the visula parameters are stored. */ - static std::string getStudyScript(_PTR(Study) study, const std::string& theID, int savePoint); + static std::string getDefaultVisualComponent(); private: _PTR(AttributeParameter) _ap; diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index db5e7f721..67220592e 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -636,10 +636,10 @@ void SALOMEDS_Study::EnableUseCaseAutoFilling(bool isEnabled) else _corba_impl->EnableUseCaseAutoFilling(isEnabled); } -bool SALOMEDS_Study::DumpStudy(const string& thePath, const string& theBaseName, bool isPublished, const string& thePrefix) +bool SALOMEDS_Study::DumpStudy(const string& thePath, const string& theBaseName, bool isPublished) { //SRN: Pure CORBA DumpStudy as it does more cleaning than the local one - bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished, thePrefix.c_str()); + bool ret = _corba_impl->DumpStudy(thePath.c_str(), theBaseName.c_str(), isPublished); return ret; } @@ -688,7 +688,7 @@ SALOMEDS::Study_ptr SALOMEDS_Study::GetStudy() _PTR(AttributeParameter) SALOMEDS_Study::GetCommonParameters(const string& theID, int theSavePoint) { SALOMEDSClient_AttributeParameter* AP = NULL; - if(theSavePoint > 0) { + if(theSavePoint >= 0) { if (_isLocal) { SALOMEDS::Locker lock; AP = new SALOMEDS_AttributeParameter(_local_impl->GetCommonParameters(theID.c_str(), theSavePoint)); diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index c6f0dd0e1..8ac27aa70 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -86,7 +86,7 @@ public: virtual _PTR(UseCaseBuilder) GetUseCaseBuilder(); virtual void Close(); virtual void EnableUseCaseAutoFilling(bool isEnabled); - virtual bool DumpStudy(const std::string& thePath,const std::string& theBaseName,bool isPublished,const std::string& thePrefix); + virtual bool DumpStudy(const std::string& thePath,const std::string& theBaseName,bool isPublished); virtual _PTR(AttributeParameter) GetCommonParameters(const std::string& theID, int theSavePoint); virtual _PTR(AttributeParameter) GetModuleParameters(const std::string& theID, const std::string& theModuleName, int theSavePoint); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index ca0027de9..3e1b546c3 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -741,14 +741,13 @@ void SALOMEDS_Study_i::UndoPostponed(CORBA::Long theWay) //============================================================================ CORBA::Boolean SALOMEDS_Study_i::DumpStudy(const char* thePath, const char* theBaseName, - CORBA::Boolean isPublished, - const char* thePrefix) + CORBA::Boolean isPublished) { SALOMEDS::Locker lock; - TCollection_AsciiString aPath((char*)thePath), aBaseName((char*)theBaseName), aPrefix((char*)thePrefix); + TCollection_AsciiString aPath((char*)thePath), aBaseName((char*)theBaseName); SALOMEDS_DriverFactory_i* factory = new SALOMEDS_DriverFactory_i(_orb); - CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory, aPrefix); + CORBA::Boolean ret = _impl->DumpStudy(aPath, aBaseName, isPublished, factory); delete factory; return ret; } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 96914aecf..0e65bf1e9 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -284,7 +284,7 @@ public: const char* theModuleName, CORBA::Long theSavePoint); - virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished, const char* thePrefix); + virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished); virtual Handle(SALOMEDSImpl_Study) GetImpl() { return _impl; } diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index f37fc6fb2..d9873090c 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -82,8 +82,7 @@ public: virtual void EnableUseCaseAutoFilling(bool isEnabled) = 0; virtual bool DumpStudy(const std::string& thePath, const std::string& theBaseName, - bool isPublished, - const std::string& thePrefix) = 0; + bool isPublished) = 0; virtual _PTR(AttributeParameter) GetCommonParameters(const std::string& theID, int theSavePoint) = 0; virtual _PTR(AttributeParameter) GetModuleParameters(const std::string& theID, const std::string& theModuleName, int theSavePoint) = 0;