X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Gen_i.hxx;h=152edb6cea9a9dae43d351ce34053455c5b9cfa7;hp=a9330165364c232e7c74da62819508ca51d88957;hb=73c48bae5a35eb335ace2c74c116bd14e357ed19;hpb=e4737e85f0da6d3f90fd08f6be1c2825195fe16f diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index a93301653..152edb6ce 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -45,7 +45,12 @@ #include "SMESH_Gen.hxx" #include "GEOM_Client.hxx" +#include +#include +#include + #include +#include class SMESH_Mesh_i; class SALOME_LifeCycleCORBA; @@ -273,6 +278,56 @@ 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); + + void RemoveLastFromPythonScript (int theStudyID); + + static void AddToCurrentPyScript (const TCollection_AsciiString& theString); + + void SavePython (SALOMEDS::Study_ptr theStudy); + + TCollection_AsciiString DumpPython_impl (int theStudyID, + Resource_DataMapOfAsciiStringAsciiString& theObjectNames, + Resource_DataMapOfAsciiStringAsciiString& theNames, + bool isPublished, + bool& aValidScript, + const TCollection_AsciiString& theSavedTrace); + + TCollection_AsciiString GetNewPythonLines (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 + 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 // ***************************************** @@ -369,6 +424,21 @@ private: GEOM_Client* myShapeReader; // Shape reader SALOMEDS::Study_var myCurrentStudy; // Current study + + // Dump Python: trace of API methods calls + std::map < int, Handle(TColStd_HSequenceOfAsciiString) > myPythonScripts; }; + +namespace SMESH +{ + template + T + DownCast(CORBA::Object_ptr theArg) + { + return dynamic_cast(SMESH_Gen_i::GetServant(theArg).in()); + } +} + + #endif