Salome HOME
Update copyright notes (for 2010)
[modules/smesh.git] / src / SMESH_I / SMESH_DumpPython.cxx
index 0dfffcdd65ed3e43d58ae91c6a46ccabff4e0b28..5be4f5de485e2773b1ace1ca89e82fdcbe9a4ef7 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File    : SMESH_Gen_i_DumpPython.cxx
 // Created : Thu Mar 24 17:17:59 2005
 // Author  : Julia DOROVSKIKH
@@ -66,8 +67,8 @@ namespace SMESH
       TCollection_AsciiString aCollection(Standard_CString(aString.c_str()));
       SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
       if(!aStudy->_is_nil() && !aCollection.IsEmpty()){
-       aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection);
-       if(MYDEBUG) MESSAGE(aString);
+        aSMESHGen->AddToPythonScript(aStudy->StudyId(),aCollection);
+        if(MYDEBUG) MESSAGE(aString);
       }
     }
   }
@@ -208,6 +209,32 @@ namespace SMESH
     return *this;
   }
 
+  TPythonDump& 
+  TPythonDump::
+  operator<<(SMESH::SMESH_Hypothesis_ptr theArg)
+  {
+    SALOMEDS::Study_var aStudy = SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy();
+    SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+    if(aSObject->_is_nil() && !CORBA::is_nil(theArg))
+      myStream << "hyp_" << theArg->GetId();
+    else
+      *this << CORBA::Object_ptr( theArg );
+    return *this;
+  }
+
+  TPythonDump& 
+  TPythonDump::
+  operator<<(SMESH::SMESH_IDSource_ptr theArg)
+  {
+    SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+    SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
+    SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
+    if(!aSObject->_is_nil() || CORBA::is_nil( theArg ))
+      return *this << aSObject;
+    SMESH::long_array_var anElementsId = theArg->GetIDs();
+    return *this << anElementsId;
+  }
+
   TPythonDump& 
   TPythonDump::
   operator<<(SMESH::FilterLibrary_i* theArg)
@@ -484,9 +511,7 @@ Engines::TMPFile* SMESH_Gen_i::DumpPython (CORBA::Object_ptr theStudy,
   TCollection_AsciiString aSavedTrace (oldValue);
 
   // Add trace of API methods calls and replace study entries by names
-  TCollection_AsciiString aScript =
-   "#!/usr/bin/python\n# -*- coding: iso-8859-1 -*-\n"
-    "### This file is generated by SALOME automatically by dump python functionality of SMESH component\n\n";
+  TCollection_AsciiString aScript;
   aScript += DumpPython_impl(aStudy, aMap, aMapNames,
                              isPublished, isValidScript, aSavedTrace);
 
@@ -587,8 +612,8 @@ Handle(TColStd_HSequenceOfInteger) FindEntries (TCollection_AsciiString& theStri
  
       isFound = Standard_False;
       while((j < aLen) && ( isdigit(c) || c == ':' )) { //Check if it is an entry
-       c = (int)arr[j++];  
-       if(c == ':') isFound = Standard_True;
+        c = (int)arr[j++];  
+        if(c == ':') isFound = Standard_True;
       }
 
       if (isFound) {
@@ -786,7 +811,7 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
   }
 
   // set initial part of aSript
-  TCollection_AsciiString initPart = "import salome, SMESH\n";
+  TCollection_AsciiString initPart = "import salome, SMESH, SALOMEDS\n";
   initPart += helper + "import " + aSmeshpy + "\n\n";
   if ( importGeom )
   {
@@ -821,7 +846,7 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
       if( !CORBA::is_nil(aGroup) )
       {
         SALOMEDS::Color aColor = aGroup->GetColor();
-        if ( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 )
+        if ( aColor.R >= 0 || aColor.G >= 0 || aColor.B >= 0 )
         {
           CORBA::String_var anEntry = aSObj->GetID();
           anUpdatedScript += SMESH_Comment("\n\t")