mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-16 21:07:56 +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,25 +389,22 @@ 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
|
||||||
|
for (anEntryToNameIt.Initialize( theObjectNames );
|
||||||
|
anEntryToNameIt.More();
|
||||||
|
anEntryToNameIt.Next())
|
||||||
{
|
{
|
||||||
// build maps entry <-> studyEntry
|
const TCollection_AsciiString& aEntry = anEntryToNameIt.Key();
|
||||||
for (anEntryToNameIt.Initialize( theObjectNames );
|
// look for an object by entry
|
||||||
anEntryToNameIt.More();
|
TDF_Label L;
|
||||||
anEntryToNameIt.Next())
|
TDF_Tool::Label( aDoc->GetData(), aEntry, L );
|
||||||
{
|
if ( L.IsNull() ) continue;
|
||||||
const TCollection_AsciiString& aEntry = anEntryToNameIt.Key();
|
Handle(GEOM_Object) obj = GEOM_Object::GetObject( L );
|
||||||
// look for an object by entry
|
// fill maps
|
||||||
TDF_Label L;
|
if ( !obj.IsNull() ) {
|
||||||
TDF_Tool::Label( aDoc->GetData(), aEntry, L );
|
TCollection_AsciiString aStudyEntry (obj->GetAuxData());
|
||||||
if ( L.IsNull() ) continue;
|
aEntry2StEntry.Bind( aEntry, aStudyEntry);
|
||||||
Handle(GEOM_Object) obj = GEOM_Object::GetObject( L );
|
aStEntry2Entry.Bind( aStudyEntry, aEntry );
|
||||||
// fill maps
|
|
||||||
if ( !obj.IsNull() ) {
|
|
||||||
TCollection_AsciiString aStudyEntry (obj->GetAuxData());
|
|
||||||
aEntry2StEntry.Bind( aEntry, aStudyEntry);
|
|
||||||
aStEntry2Entry.Bind( aStudyEntry, aEntry );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,10 +490,42 @@ 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
|
||||||
|
@ -68,7 +68,9 @@ class GEOM_Engine
|
|||||||
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
||||||
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