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=adda866b86f2e5566fb54bad690fa5a8cecedf82;hb=c38c10811a065cf5b13e8807ed71864d92ca7d80;hpb=c111d3b52022abe32107b0b3737c2a6ff4137164 diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index adda866b8..152edb6ce 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -44,9 +44,13 @@ #include "SMESH_Gen.hxx" #include "GEOM_Client.hxx" -#include "SMESH_Factory.hxx" + +#include +#include +#include #include +#include class SMESH_Mesh_i; class SALOME_LifeCycleCORBA; @@ -120,8 +124,7 @@ private: // ========================================================== class SMESH_Gen_i: public virtual POA_SMESH::SMESH_Gen, - public virtual Engines_Component_i, - public virtual SMESH::Factory + public virtual Engines_Component_i { public: // Get last created instance of the class @@ -209,11 +212,6 @@ public: // **************************************************** // Interface inherited methods (from SALOMEDS::Driver) // **************************************************** - virtual - SALOMEDS::TMPFile* - DumpPython(CORBA::Object_ptr theStudy, - CORBA::Boolean theIsPublished, - CORBA::Boolean& theIsValidScript); // Save SMESH data SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent, @@ -280,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 // ***************************************** @@ -376,7 +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