#include <TColStd_HSequenceOfAsciiString.hxx>
#include <map>
+#include <sstream>
class SMESH_Mesh_i;
class SALOME_LifeCycleCORBA;
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,
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
// *****************************************
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 :