Salome HOME
Fix for problem: SIGSEGV appears if to select group after opening "Edit Group" dialog...
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.hxx
index adda866b86f2e5566fb54bad690fa5a8cecedf82..152edb6cea9a9dae43d351ce34053455c5b9cfa7 100644 (file)
 
 #include "SMESH_Gen.hxx"
 #include "GEOM_Client.hxx"
-#include "SMESH_Factory.hxx"
+
+#include <TCollection_AsciiString.hxx>
+#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
+#include <TColStd_HSequenceOfAsciiString.hxx>
 
 #include <map>
+#include <sstream>
 
 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 <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
   // *****************************************
@@ -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<class T>
+  T
+  DownCast(CORBA::Object_ptr theArg)
+  {
+    return dynamic_cast<T>(SMESH_Gen_i::GetServant(theArg).in());
+  }
+}
+
+
 #endif