mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-17 10:10:07 +05:00
"Dump Python". Add GetDumpName(), add global names to script
This commit is contained in:
parent
b4ab5222d6
commit
f724bcc264
@ -368,6 +368,8 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
aScript += "def RebuildData(theStudy):";
|
aScript += "def RebuildData(theStudy):";
|
||||||
aScript += "\n\tgeompy.init_geom(theStudy)";
|
aScript += "\n\tgeompy.init_geom(theStudy)";
|
||||||
|
|
||||||
|
Standard_Integer posToInertGlobalVars = aScript.Length() + 1;
|
||||||
|
|
||||||
Handle(TDataStd_TreeNode) aNode, aRoot;
|
Handle(TDataStd_TreeNode) aNode, aRoot;
|
||||||
Handle(GEOM_Function) aFunction;
|
Handle(GEOM_Function) aFunction;
|
||||||
TColStd_MapOfTransient aMap;
|
TColStd_MapOfTransient aMap;
|
||||||
@ -387,8 +389,6 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
|
|
||||||
Resource_DataMapOfAsciiStringAsciiString aEntry2StEntry, aStEntry2Entry;
|
Resource_DataMapOfAsciiStringAsciiString aEntry2StEntry, aStEntry2Entry;
|
||||||
Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString anEntryToNameIt;
|
Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString anEntryToNameIt;
|
||||||
if ( isPublished )
|
|
||||||
{
|
|
||||||
// build maps entry <-> studyEntry
|
// build maps entry <-> studyEntry
|
||||||
for (anEntryToNameIt.Initialize( theObjectNames );
|
for (anEntryToNameIt.Initialize( theObjectNames );
|
||||||
anEntryToNameIt.More();
|
anEntryToNameIt.More();
|
||||||
@ -407,7 +407,6 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
aStEntry2Entry.Bind( aStudyEntry, aEntry );
|
aStEntry2Entry.Bind( aStudyEntry, aEntry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
|
Handle(TColStd_HSequenceOfInteger) aSeq = FindEntries(aScript);
|
||||||
Standard_Integer aLen = aSeq->Length(), objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
|
Standard_Integer aLen = aSeq->Length(), objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
|
||||||
@ -492,9 +491,41 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
anUpdatedScript += "\n\tpass\n";
|
anUpdatedScript += "\n\tpass\n";
|
||||||
aValidScript = true;
|
aValidScript = true;
|
||||||
|
|
||||||
|
// fill _studyEntry2NameMap and build globalVars
|
||||||
|
TCollection_AsciiString globalVars;
|
||||||
|
_studyEntry2NameMap.Clear();
|
||||||
|
Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString aStEntryToEntryIt;
|
||||||
|
for (aStEntryToEntryIt.Initialize( aStEntry2Entry );
|
||||||
|
aStEntryToEntryIt.More();
|
||||||
|
aStEntryToEntryIt.Next() )
|
||||||
|
{
|
||||||
|
const TCollection_AsciiString & name = theObjectNames( aStEntryToEntryIt.Value() );
|
||||||
|
_studyEntry2NameMap.Bind (aStEntryToEntryIt.Key(), name );
|
||||||
|
if ( !globalVars.IsEmpty() )
|
||||||
|
globalVars += ", ";
|
||||||
|
globalVars += name;
|
||||||
|
}
|
||||||
|
if ( !globalVars.IsEmpty() ) {
|
||||||
|
globalVars.Insert( 1, "\n\tglobal " );
|
||||||
|
anUpdatedScript.Insert( posToInertGlobalVars, globalVars );
|
||||||
|
}
|
||||||
|
|
||||||
return anUpdatedScript;
|
return anUpdatedScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetDumpName
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
const char* GEOM_Engine::GetDumpName (const char* theStudyEntry) const
|
||||||
|
{
|
||||||
|
if ( _studyEntry2NameMap.IsBound( (char*)theStudyEntry ))
|
||||||
|
return _studyEntry2NameMap( (char*)theStudyEntry ).ToCString();
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
// Internal functions
|
// Internal functions
|
||||||
|
@ -69,6 +69,8 @@ class GEOM_Engine
|
|||||||
bool isPublished,
|
bool isPublished,
|
||||||
bool& aValidScript);
|
bool& aValidScript);
|
||||||
|
|
||||||
|
const char* GetDumpName (const char* theStudyEntry) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void SetEngine(GEOM_Engine* theEngine);
|
static void SetEngine(GEOM_Engine* theEngine);
|
||||||
|
|
||||||
@ -78,6 +80,8 @@ class GEOM_Engine
|
|||||||
Interface_DataMapOfIntegerTransient _mapIDDocument;
|
Interface_DataMapOfIntegerTransient _mapIDDocument;
|
||||||
int _UndoLimit;
|
int _UndoLimit;
|
||||||
GEOM_DataMapOfAsciiStringTransient _objects;
|
GEOM_DataMapOfAsciiStringTransient _objects;
|
||||||
|
|
||||||
|
Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user