*/
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
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<string> v = ip.getProperties();
- if(v.size() > 0) {
- dump += shift +"#Set up visual properties:\n";
- for(int i = 0; i<v.size(); i++) {
- string prp = ip.getProperty(v[i]);
- dump += shift +"ipar.setProperty(\""+v[i]+"\", \""+prp+"\")\n";
- }
- }
-
- v = ip.getLists();
- if(v.size() > 0) {
- dump += shift +"#Set up lists:\n";
- for(int i = 0; i<v.size(); i++) {
- vector<string> 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<v.size(); i++) {
- vector<string> names = ip.getAllParameterNames(v[i]);
- vector<string> 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";
*/
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
*/
#include "SALOMEDSImpl_AttributeStudyProperties.hxx"
#include "SALOMEDSImpl_AttributeParameter.hxx"
#include "SALOMEDSImpl_ChildIterator.hxx"
+#include "SALOMEDSImpl_IParameters.hxx"
#include <TColStd_SequenceOfExtendedString.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
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
//===========================================================================