X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM%2FGEOM_Engine.cxx;h=14e81340877fa3440cebdd4940a7b76430b41706;hb=4e59c10eafa5bd8f431a3ce80b81b291fcef0300;hp=ba4976e0049a7111f18ce4f1675bb61f341e1bc6;hpb=5998f517ba7b421bbfbcec30ac822e0a1ee8b324;p=modules%2Fgeom.git diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index ba4976e00..14e813408 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -55,6 +55,7 @@ #include #include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -62,6 +63,9 @@ #define COMMA ',' #define O_BRACKET '(' #define C_BRACKET ')' +#define O_SQR_BRACKET '[' +#define C_SQR_BRACKET ']' +#define PY_NULL "None" #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -71,6 +75,8 @@ static int MYDEBUG = 0; static GEOM_Engine* TheEngine = NULL; +using namespace std; + static TCollection_AsciiString BuildIDFromObject(Handle(GEOM_Object)& theObject) { TCollection_AsciiString anID(theObject->GetDocID()), anEntry; @@ -95,11 +101,11 @@ static Standard_Integer ExtractDocID(TCollection_AsciiString& theID) void ProcessFunction(Handle(GEOM_Function)& theFunction, TCollection_AsciiString& theScript, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, + TVariablesList theVariables, TColStd_MapOfTransient& theProcessed); void ReplaceVariables(TCollection_AsciiString& theCommand, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames); + TVariablesList theVariables); @@ -439,7 +445,7 @@ void GEOM_Engine::Close(int theDocID) //============================================================================= TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, Resource_DataMapOfAsciiStringAsciiString& theObjectNames, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, + TVariablesList theVariables, bool isPublished, bool& aValidScript) { @@ -469,7 +475,7 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID, MESSAGE ( "Null function !!!!" ); continue; } - ProcessFunction(aFunction, aScript,theVariableNames,aMap); + ProcessFunction(aFunction, aScript, theVariables,aMap); } } @@ -694,7 +700,7 @@ Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const //=========================================================================== void ProcessFunction(Handle(GEOM_Function)& theFunction, TCollection_AsciiString& theScript, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames, + TVariablesList theVariables, TColStd_MapOfTransient& theProcessed) { if(theFunction.IsNull() || theProcessed.Contains(theFunction)) return; @@ -719,7 +725,7 @@ void ProcessFunction(Handle(GEOM_Function)& theFunction, if(aDescr == "None") return; //Replace parameter by notebook variables - ReplaceVariables(aDescr,theVariableNames); + ReplaceVariables(aDescr,theVariables); theScript += "\n\t"; theScript += aDescr; @@ -772,132 +778,233 @@ Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theStrin */ //============================================================================= void ReplaceVariables(TCollection_AsciiString& theCommand, - Resource_DataMapOfAsciiStringAsciiString& theVariableNames) + TVariablesList theVariables) { - //Get Entry of the result object - TCollection_AsciiString anEntry = theCommand.Token("=",1); - - //Remove white spaces - anEntry.RightAdjust(); - anEntry.LeftAdjust(); - if(MYDEBUG) - cout<<"Result entry : '" < aVariables; + TVariablesList::const_iterator it = theVariables.find(anEntry); + if( it != theVariables.end() ) + aVariables = (*it).second; + + if(aVariables.empty()) { + if(MYDEBUG) + cout<<"Valiables list empty!!!"<= aVariables.size()) + continue; + + aReplacedParameter = aVariables[iVar].myVariable; + if(aReplacedParameter.IsEmpty()) { + iVar++; + continue; + } + + if(aVariables[iVar].isVariable) { + aReplacedParameter.InsertBefore(1,"'"); + aReplacedParameter.InsertAfter(aReplacedParameter.Length(),"'"); + } + + if(MYDEBUG) + cout<<"aSection before : "<= aVariables.size()) + continue; + + aReplacedVar = aVariables[iVar].myVariable; + if(aReplacedVar.IsEmpty()) { + iVar++; + continue; + } + + if(aVariables[iVar].isVariable) { + aReplacedVar.InsertBefore(1,"\""); + aReplacedVar.InsertAfter(aReplacedVar.Length(),"\""); + } + + aCommand.Remove(aStartPos, aEndPos - aStartPos); + aCommand.Insert(aStartPos, aReplacedVar); iVar++; - continue; } - - aVar.InsertBefore(1,"\""); - aVar.InsertAfter(aVar.Length(),"\""); - theCommand.Remove(aStartPos, aEndPos - aStartPos); - theCommand.Insert(aStartPos,aVar); - iVar++; + theCommand.Remove(aStartCommandPos, aEndCommandPos - aStartCommandPos); + theCommand.Insert(aStartCommandPos, aCommand); + + aCommandIndex++; } + + if (MYDEBUG) + cout<<"Command : "<