mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 17:30:35 +05:00
Dump Python. Add AddToCurrentPyScript(), AddArray(), AddObject()
This commit is contained in:
parent
6ba05a8550
commit
8661759d9c
@ -50,6 +50,7 @@
|
||||
#include <TColStd_HSequenceOfAsciiString.hxx>
|
||||
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
class SMESH_Mesh_i;
|
||||
class SALOME_LifeCycleCORBA;
|
||||
@ -277,12 +278,18 @@ public:
|
||||
return aResultSO._retn();
|
||||
}
|
||||
|
||||
// ============
|
||||
// Dump python
|
||||
// ============
|
||||
|
||||
virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
|
||||
CORBA::Boolean isPublished,
|
||||
CORBA::Boolean& isValidScript);
|
||||
|
||||
void AddToPythonScript (int theStudyID, const TCollection_AsciiString& theString);
|
||||
|
||||
static void AddToCurrentPyScript (const TCollection_AsciiString& theString);
|
||||
|
||||
void SavePython (SALOMEDS::Study_ptr theStudy);
|
||||
|
||||
TCollection_AsciiString DumpPython_impl (int theStudyID,
|
||||
@ -295,6 +302,29 @@ public:
|
||||
|
||||
void CleanPythonTrace (int theStudyID);
|
||||
|
||||
// Dump python comfort methods
|
||||
|
||||
static TCollection_AsciiString& AddObject(TCollection_AsciiString& theStr,
|
||||
CORBA::Object_ptr theObject);
|
||||
// add object to script string
|
||||
|
||||
template <class _array>
|
||||
static TCollection_AsciiString& AddArray(TCollection_AsciiString& theStr,
|
||||
const _array & array)
|
||||
// put array contents into theStr like this: "[ 1, 2, 5 ]"
|
||||
{
|
||||
ostringstream sout; // can convert long int, and TCollection_AsciiString cant
|
||||
sout << "[ ";
|
||||
for (int i = 1; i <= array.length(); i++) {
|
||||
sout << array[i-1];
|
||||
if ( i < array.length() )
|
||||
sout << ", ";
|
||||
}
|
||||
sout << " ]";
|
||||
theStr += (char*) sout.str().c_str();
|
||||
return theStr;
|
||||
}
|
||||
|
||||
// *****************************************
|
||||
// Internal methods
|
||||
// *****************************************
|
||||
|
@ -80,6 +80,46 @@ void SMESH_Gen_i::AddToPythonScript (int theStudyID, const TCollection_AsciiStri
|
||||
myPythonScripts[theStudyID]->Append(theString);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddToCurrentPyScript
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void SMESH_Gen_i::AddToCurrentPyScript (const TCollection_AsciiString& theString)
|
||||
{
|
||||
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
|
||||
aSMESHGen->AddToPythonScript(aSMESHGen->GetCurrentStudy()->StudyId(), theString);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AddObject
|
||||
//purpose : add object to script string
|
||||
//=======================================================================
|
||||
|
||||
TCollection_AsciiString& SMESH_Gen_i::AddObject(TCollection_AsciiString& theStr,
|
||||
CORBA::Object_ptr theObject)
|
||||
{
|
||||
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( theObject );
|
||||
if ( !geomObj->_is_nil() ) {
|
||||
theStr += "salome.IDToObject(\"";
|
||||
theStr += geomObj->GetStudyEntry();
|
||||
theStr += "\")";
|
||||
}
|
||||
else {
|
||||
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
|
||||
SALOMEDS::SObject_var aSO =
|
||||
aSMESHGen->ObjectToSObject(aSMESHGen->GetCurrentStudy(), theObject);
|
||||
if ( !aSO->_is_nil() )
|
||||
theStr += aSO->GetID();
|
||||
else if ( !CORBA::is_nil( theObject ) )
|
||||
theStr += aSMESHGen->GetORB()->object_to_string( theObject );
|
||||
else
|
||||
theStr += "None";
|
||||
}
|
||||
return theStr;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SavePython
|
||||
//purpose :
|
||||
|
Loading…
Reference in New Issue
Block a user