mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-06-08 01:57:49 +05:00
Dump Python extension.
This commit is contained in:
parent
5cde5a8e17
commit
d5e2b6c529
@ -96,10 +96,12 @@ static Standard_Integer ExtractDocID(TCollection_AsciiString& theID)
|
|||||||
void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
||||||
TCollection_AsciiString& theScript,
|
TCollection_AsciiString& theScript,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
||||||
|
TColStd_HSequenceOfAsciiString& theStudyVariables,
|
||||||
TColStd_MapOfTransient& theProcessed);
|
TColStd_MapOfTransient& theProcessed);
|
||||||
|
|
||||||
void ReplaceVariables(TCollection_AsciiString& theCommand,
|
void ReplaceVariables(TCollection_AsciiString& theCommand,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theVariableNames);
|
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
||||||
|
TColStd_HSequenceOfAsciiString& theStudyVariables);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -440,6 +442,7 @@ void GEOM_Engine::Close(int theDocID)
|
|||||||
TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
||||||
|
TColStd_HSequenceOfAsciiString& theStudyVariables,
|
||||||
bool isPublished,
|
bool isPublished,
|
||||||
bool& aValidScript)
|
bool& aValidScript)
|
||||||
{
|
{
|
||||||
@ -469,7 +472,7 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
MESSAGE ( "Null function !!!!" );
|
MESSAGE ( "Null function !!!!" );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ProcessFunction(aFunction, aScript,theVariableNames,aMap);
|
ProcessFunction(aFunction, aScript, theVariableNames, theStudyVariables ,aMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -695,6 +698,7 @@ Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const
|
|||||||
void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
||||||
TCollection_AsciiString& theScript,
|
TCollection_AsciiString& theScript,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
||||||
|
TColStd_HSequenceOfAsciiString& theStudyVariables,
|
||||||
TColStd_MapOfTransient& theProcessed)
|
TColStd_MapOfTransient& theProcessed)
|
||||||
{
|
{
|
||||||
if(theFunction.IsNull() || theProcessed.Contains(theFunction)) return;
|
if(theFunction.IsNull() || theProcessed.Contains(theFunction)) return;
|
||||||
@ -719,7 +723,7 @@ void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
|||||||
if(aDescr == "None") return;
|
if(aDescr == "None") return;
|
||||||
|
|
||||||
//Replace parameter by notebook variables
|
//Replace parameter by notebook variables
|
||||||
ReplaceVariables(aDescr,theVariableNames);
|
ReplaceVariables(aDescr,theVariableNames,theStudyVariables);
|
||||||
theScript += "\n\t";
|
theScript += "\n\t";
|
||||||
theScript += aDescr;
|
theScript += aDescr;
|
||||||
|
|
||||||
@ -772,11 +776,12 @@ Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theStrin
|
|||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
void ReplaceVariables(TCollection_AsciiString& theCommand,
|
void ReplaceVariables(TCollection_AsciiString& theCommand,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theVariableNames)
|
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
||||||
|
TColStd_HSequenceOfAsciiString& theStudyVariables)
|
||||||
{
|
{
|
||||||
//Get Entry of the result object
|
//Get Entry of the result object
|
||||||
TCollection_AsciiString anEntry = theCommand.Token("=",1);
|
TCollection_AsciiString anEntry = theCommand.Token("=",1);
|
||||||
|
|
||||||
//Remove white spaces
|
//Remove white spaces
|
||||||
anEntry.RightAdjust();
|
anEntry.RightAdjust();
|
||||||
anEntry.LeftAdjust();
|
anEntry.LeftAdjust();
|
||||||
@ -874,11 +879,6 @@ void ReplaceVariables(TCollection_AsciiString& theCommand,
|
|||||||
aEndPos = theCommand.Location(i, COMMA, 1, theCommand.Length());
|
aEndPos = theCommand.Location(i, COMMA, 1, theCommand.Length());
|
||||||
}
|
}
|
||||||
|
|
||||||
TCollection_AsciiString aParameter = theCommand.SubString(aStartPos, aStartPos);
|
|
||||||
|
|
||||||
if(MYDEBUG)
|
|
||||||
cout<<"Current parameter "<<aParameter<<endl;
|
|
||||||
|
|
||||||
aVar = aVarSeq.Value(iVar);
|
aVar = aVarSeq.Value(iVar);
|
||||||
|
|
||||||
//If parameter is entry, skip it
|
//If parameter is entry, skip it
|
||||||
@ -892,9 +892,17 @@ void ReplaceVariables(TCollection_AsciiString& theCommand,
|
|||||||
iVar++;
|
iVar++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
aVar.InsertBefore(1,"\"");
|
bool isVar = false;
|
||||||
aVar.InsertAfter(aVar.Length(),"\"");
|
for(Standard_Integer i = 1; i <= theStudyVariables.Length();i++)
|
||||||
|
if(theStudyVariables.Value(i).IsEqual(aVar)) {
|
||||||
|
isVar = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(isVar) {
|
||||||
|
aVar.InsertBefore(1,"\"");
|
||||||
|
aVar.InsertAfter(aVar.Length(),"\"");
|
||||||
|
}
|
||||||
|
|
||||||
theCommand.Remove(aStartPos, aEndPos - aStartPos);
|
theCommand.Remove(aStartPos, aEndPos - aStartPos);
|
||||||
theCommand.Insert(aStartPos,aVar);
|
theCommand.Insert(aStartPos,aVar);
|
||||||
|
@ -85,6 +85,7 @@ class GEOM_Engine
|
|||||||
Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID,
|
Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
Resource_DataMapOfAsciiStringAsciiString& theVariableNames,
|
||||||
|
TColStd_HSequenceOfAsciiString& theStudyVariables,
|
||||||
bool isPublished,
|
bool isPublished,
|
||||||
bool& aValidScript);
|
bool& aValidScript);
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ class GEOM_Engine
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
Standard_EXPORT static void SetEngine(GEOM_Engine* theEngine);
|
Standard_EXPORT static void SetEngine(GEOM_Engine* theEngine);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Handle(GEOM_Application) _OCAFApp;
|
Handle(GEOM_Application) _OCAFApp;
|
||||||
|
@ -59,7 +59,7 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
|
|||||||
CORBA::String_var aName = aValue->GetName();
|
CORBA::String_var aName = aValue->GetName();
|
||||||
CORBA::String_var anEntry = GO->GetEntry();
|
CORBA::String_var anEntry = GO->GetEntry();
|
||||||
aMap.Bind( (char*)anEntry.in(), (char*)aName.in() );
|
aMap.Bind( (char*)anEntry.in(), (char*)aName.in() );
|
||||||
|
|
||||||
//Find attribute with list of used notebook variables
|
//Find attribute with list of used notebook variables
|
||||||
SALOMEDS::GenericAttribute_var anAttr;
|
SALOMEDS::GenericAttribute_var anAttr;
|
||||||
SALOMEDS::AttributeString_var anAttrStr;
|
SALOMEDS::AttributeString_var anAttrStr;
|
||||||
@ -73,10 +73,18 @@ Engines::TMPFile* GEOM_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get Study variables
|
||||||
|
SALOMEDS::ListOfStrings_var aListOfVars = aStudy->GetVariableNames();
|
||||||
|
TColStd_HSequenceOfAsciiString aStudyVariables;
|
||||||
|
for(int i = 0;i < aListOfVars->length();i++)
|
||||||
|
{
|
||||||
|
aStudyVariables.Append(aListOfVars[i].in());
|
||||||
|
}
|
||||||
|
|
||||||
TCollection_AsciiString aScript =
|
TCollection_AsciiString aScript =
|
||||||
"### This file is generated by SALOME automatically by dump python functionality\n"
|
"### This file is generated by SALOME automatically by dump python functionality\n"
|
||||||
"### of GEOM component\n\n";
|
"### of GEOM component\n\n";
|
||||||
aScript += _impl->DumpPython(aStudy->StudyId(), aMap, aVariableMap, isPublished, isValidScript);
|
aScript += _impl->DumpPython(aStudy->StudyId(), aMap, aVariableMap, aStudyVariables, isPublished, isValidScript);
|
||||||
|
|
||||||
if (isPublished)
|
if (isPublished)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user