]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Dump Python
authorsrn <srn@opencascade.com>
Thu, 17 Mar 2005 07:55:14 +0000 (07:55 +0000)
committersrn <srn@opencascade.com>
Thu, 17 Mar 2005 07:55:14 +0000 (07:55 +0000)
14 files changed:
src/ENGINE/VISU_Engine_i.cc
src/ENGINE/VISU_Engine_i.hh
src/VISU_I/Makefile.in
src/VISU_I/VISUConfig.cc
src/VISU_I/VISUConfig.hh
src/VISU_I/VISU_DumpPython.cc [new file with mode: 0644]
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_Gen_i.hh
src/VISU_I/VISU_Mesh_i.hh
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh
src/VISU_I/VISU_ScalarMap_i.hh
src/VISU_I/VISU_Table_i.cc
src/VISU_I/VISU_Table_i.hh

index 0edb9acc90f9f451edcb151180b283946f728754..03ddbf9f4f0ef043e806c037b659a8e3a1347be0 100644 (file)
@@ -351,4 +351,11 @@ namespace VISU{
     return myVisuGen->PasteInto(theStream,theObjectID,theObject);
   }
 
+  Engines::TMPFile* VISU_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
+                                           CORBA::Boolean theIsPublished,
+                                          CORBA::Boolean& theIsValidScript)
+  {
+    return myVisuGen->DumpPython(theStudy, theIsPublished, theIsValidScript);
+  }     
+
 };
index 8ad9db0f2b0812b61ed0e4d6ed6b9a689b1754ca..86c135cad4840788d45d3ab089096ff3709cc547 100644 (file)
@@ -131,6 +131,12 @@ namespace VISU{
     SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
                                    CORBA::Long theObjectID,
                                    SALOMEDS::SObject_ptr theObject);
+
+    // inherited methods from Engines::Component
+    virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
+                                        CORBA::Boolean theIsPublished,
+                                        CORBA::Boolean& theIsValidScript);   
+
   };
 };
 
index 1489eb26e8c9c9e4202ceb4948c0c429d7c03001..24f947b6e114081223fb5d39d21086d0fc8e88f4 100644 (file)
@@ -23,7 +23,8 @@ LIB_SRC = VISUConfig.cc VISU_Gen_i.cc VISU_Result_i.cc \
        VISU_IsoSurfaces_i.cc VISU_DeformedShape_i.cc \
        VISU_CutPlanes_i.cc VISU_CutLines_i.cc \
        VISU_Vectors_i.cc VISU_StreamLines_i.cc \
-       VISU_TimeAnimation.cxx VISU_CorbaMedConvertor.cxx
+       VISU_TimeAnimation.cxx VISU_CorbaMedConvertor.cxx \
+       VISU_DumpPython.cc
 
 LIB_MOC = VISU_TimeAnimation.h
 
index c137e26ffaf98b7315e97967a535fa73cb3f627e..ee36c44f84641f7f667c9353f2c5580612f35b0b 100644 (file)
@@ -93,7 +93,7 @@ namespace VISU{
   }
   
   void Storable::StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap){
-    if(0 && MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
+    if(MYDEBUG) MESSAGE("Storable::StrToMap : string="<<theStr);
     QStringList strList = QStringList::split( ";", theStr, false );
     for ( int i = 0; i < strList.count(); i++ ) {
       QString next = strList[ i ];
@@ -134,6 +134,7 @@ namespace VISU{
                   + QString::number( theVal );
     theStr<<output.latin1()<<";";
   }
+
   Storable* Storable::Create(SALOMEDS::SObject_ptr theSObject,
                             const string& thePrefix, const string& theLocalPersistentID) 
   {
@@ -157,17 +158,21 @@ namespace VISU{
     return NULL;
   }
   
-  const QString& Storable::FindValue(const TRestoringMap& theMap, const string& theArg, bool* isFind)
+  QString Storable::FindValue(const TRestoringMap& theMap, const string& theArg, bool* isFind)
   {
     TRestoringMap::const_iterator i = theMap.find(theArg);
+
     if(i == theMap.end()) {
       if(MYDEBUG) MESSAGE("Storable::Init >> there is no value for "<<theArg);
-      if(isFind != NULL) *isFind = false;
-      //throw std::logic_error(string("Storable::Init >> there is no value for ") + theArg);
+      if(isFind != NULL) 
+       *isFind = false;
       static QString BAD_VALUE("NULL");
       return BAD_VALUE;
     }
-    if(isFind != NULL) *isFind = true;
+
+    if(isFind != NULL)
+      *isFind = true;
+
     return i->second;
   }
   
index ca83125f74ec778ed596969614168b2017bb9cc8..1d80e7cbb5d2da69d3b79f1cd0cc82176239a719 100644 (file)
@@ -106,7 +106,7 @@ namespace VISU{
     typedef std::map<std::string,TStorableEngine> TCallbackMap;
     static void Registry(const char* theComment, TStorableEngine theEngine);
     static Storable* Create(SALOMEDS::SObject_ptr, const std::string& thePrefix, const std::string& theString); 
-    static const QString& FindValue(const TRestoringMap& theMap, const std::string& theArg, bool* isFind = NULL);
+    static QString FindValue(const TRestoringMap& theMap, const std::string& theArg, bool* isFind = NULL);
     static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap);
     static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject);
     static void DataToStream(std::ostringstream& theStr, const QString& theName, const QString& theVal);
diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc
new file mode 100644 (file)
index 0000000..0b5fd9f
--- /dev/null
@@ -0,0 +1,1191 @@
+//  VISU OBJECT : interactive object for VISU entities implementation
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//  File   : VISU_DumpPython.cc
+//  Author : Alexey PETROV
+//  Module : VISU
+
+#include "VISU_Gen_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_PrsObject_i.hh"
+
+#include "VISU_Prs3d_i.hh"
+#include "VISU_Mesh_i.hh"
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_IsoSurfaces_i.hh"
+#include "VISU_DeformedShape_i.hh"
+#include "VISU_CutPlanes_i.hh"
+#include "VISU_CutLines_i.hh"
+#include "VISU_Vectors_i.hh"
+#include "VISU_StreamLines_i.hh"
+#include "VISU_Table_i.hh"
+
+#include "utilities.h"
+
+#include <cctype>      
+#include <strstream>   
+#include <functional>  
+
+#include <qstring.h>
+#include <qfileinfo.h>
+
+//#define COUT
+
+using namespace std;
+
+namespace VISU{
+  static std::string PREFIX("  ");
+
+  typedef std::map<std::string,std::string> TName2EntryMap;
+  typedef std::map<std::string,std::string> TEntry2NameMap;
+
+  inline
+  std::string 
+  GenerateName(std::string theName, 
+              SALOMEDS::SObject_ptr theSObject,
+              TName2EntryMap& theName2EntryMap,
+              TEntry2NameMap& theEntry2NameMap,
+              char theSuffix)
+  {
+    if(theName2EntryMap.find(theName) != theName2EntryMap.end()){
+      theName = GenerateName(theName + theSuffix, theSObject, theName2EntryMap, theEntry2NameMap, theSuffix);
+    }else{
+      CORBA::String_var anID = theSObject->GetID();
+      theName2EntryMap[theName] = anID.in();
+      theEntry2NameMap[anID.in()] = theName;
+      //cout<<"GenerateName - "<<theName<<" => "<<anID.in()<<endl;
+    }
+
+    return theName;
+  }
+
+  struct TReplacePredicate{
+    bool operator()(char theChar) const
+    {
+      return !(isdigit(theChar) || isalpha(theChar) || theChar == '_');
+    }
+  };
+
+  inline
+  std::string 
+  GetName(SALOMEDS::SObject_ptr theSObject)
+  {
+    CORBA::String_var aString = theSObject->GetName();
+
+    std::string aName = QString(aString.in()).simplifyWhiteSpace().latin1();
+
+    //replace_if(aName.begin(),aName.end(),not1(ptr_fun(isxdigit)),'_');
+    replace_if(aName.begin(),aName.end(),TReplacePredicate(),'_');
+
+    return aName;
+  }
+
+  inline
+  std::string 
+  GenerateName(SALOMEDS::SObject_ptr theSObject,
+              TName2EntryMap& theName2EntryMap,
+              TEntry2NameMap& theEntry2NameMap)
+  {
+    std::string aName = GetName(theSObject);
+
+    return GenerateName(aName,theSObject,theName2EntryMap,theEntry2NameMap,'X');
+  }
+
+
+  //===========================================================================
+  typedef void (*TDumpToPython)(SALOMEDS::Study_ptr theStudy,
+                               CORBA::Boolean theIsPublished,
+                               CORBA::Boolean& theIsValidScript,
+                               SALOMEDS::SObject_ptr theSObject,
+                               std::ostream& theStr,
+                               TName2EntryMap& theName2EntryMap,
+                               TEntry2NameMap& theEntry2NameMap,
+                               std::string theArgumentName,
+                               std::string thePrefix);
+
+
+  void
+  DumpToPython(SALOMEDS::Study_ptr theStudy,
+              CORBA::Boolean theIsPublished,
+              CORBA::Boolean& theIsValidScript,
+              SALOMEDS::SObject_ptr theSObject,
+              std::ostream& theStr,
+              TName2EntryMap& theName2EntryMap,
+              TEntry2NameMap& theEntry2NameMap,
+              std::string theArgumentName,
+              std::string thePrefix);
+
+
+  //===========================================================================
+  std::string
+  ScalarMapToPython(SALOMEDS::SObject_ptr theSObject,
+                   VISU::ScalarMap_i* theServant, 
+                   std::ostream& theStr,
+                   std::string& theName,
+                   const std::string& theConstructorName,
+                   const std::string& theArgumentName,
+                   std::string thePrefix)
+  {
+    std::string aParam;
+    switch(theServant->GetEntity()){
+    case NODE:
+      aParam = "VISU.NODE";
+      break;
+    case EDGE:
+      aParam = "VISU.EDGE";
+      break;
+    case FACE:
+      aParam = "VISU.FACE";
+      break;
+    case CELL:
+      aParam = "VISU.CELL";
+      break;
+    }
+
+    theStr<<thePrefix<<theName<<" = aVisu."<<theConstructorName<<"("<<theArgumentName<<
+      ",'"<<theServant->GetMeshName()<<"'"<<
+      ","<<aParam<<
+      ",'"<<theServant->GetFieldName()<<"'"<<
+      ","<<theServant->GetIteration()<<
+      ")"<<endl;
+
+    theStr<<thePrefix<<"if "<<theName<<":"<<endl;
+    thePrefix += PREFIX;
+
+    theStr<<thePrefix<<"aName2ObjectMap['"<<theName<<"'] = "<<theName<<endl;
+
+    theStr<<thePrefix<<theName<<".SetScalarMode("<<theServant->GetScalarMode()<<")"<<endl;
+    
+    switch(theServant->GetScaling()){
+    case LINEAR:
+      aParam = "VISU.LINEAR";
+      break;
+    case LOGARITHMIC:
+      aParam = "VISU.LOGARITHMIC";
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetScaling("<<aParam<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<","<<theServant->GetMax()<<")"<<endl;
+    
+    switch(theServant->GetBarOrientation()){
+    case ScalarMap::HORIZONTAL:
+      aParam = "VISU.ScalarMap.HORIZONTAL";
+      break;
+    case ScalarMap::VERTICAL:
+      aParam = "VISU.ScalarMap.VERTICAL";
+      break;
+    }
+    theStr<<thePrefix<<theName<<".SetBarOrientation("<<aParam<<")"<<endl;
+    
+    theStr<<thePrefix<<theName<<".SetPosition("<<theServant->GetPosX()<<","<<theServant->GetPosY()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetSize("<<theServant->GetWidth()<<","<<theServant->GetHeight()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetNbColors("<<theServant->GetNbColors()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetLabels("<<theServant->GetLabels()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".SetTitle('"<<theServant->GetTitle()<<"')"<<endl;
+
+    return thePrefix;
+  }
+
+
+  //===========================================================================
+  std::string
+  DeformedShapeToPython(SALOMEDS::SObject_ptr theSObject,
+                       VISU::DeformedShape_i* theServant, 
+                       std::ostream& theStr,
+                       std::string& theName,
+                       const std::string& theConstructorName,
+                       const std::string& theArgumentName,
+                       std::string thePrefix)
+  {
+    thePrefix = ScalarMapToPython(theSObject,theServant,theStr,theName,theConstructorName,theArgumentName,thePrefix);
+    theStr<<thePrefix<<theName<<".SetScale("<<theServant->GetScale()<<")"<<endl;
+    theStr<<thePrefix<<theName<<".ShowColored("<<theServant->IsColored()<<")"<<endl;
+    SALOMEDS::Color aColor = theServant->GetColor();
+    theStr<<thePrefix<<theName<<".SetColor(SALOMEDS.Color("<<
+      aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+
+    return thePrefix;
+  }
+
+  
+  //===========================================================================
+  template<class TTableAttr>
+  void
+  TableAttrToPython(SALOMEDS::Study_ptr theStudy,
+                   CORBA::Boolean theIsPublished,
+                   CORBA::Boolean& theIsValidScript,
+                   SALOMEDS::SObject_ptr theSObject,
+                   TTableAttr theTableAttr,
+                   const std::string& theAttrName,
+                   std::ostream& theStr,
+                   TName2EntryMap& theName2EntryMap,
+                   TEntry2NameMap& theEntry2NameMap,
+                   std::string theArgumentName,
+                   std::string thePrefix)
+  {
+    SALOMEDS::GenericAttribute_var anAttr; 
+    SALOMEDS::SObject_var aFatherSObject = theSObject->GetFather();
+    if(aFatherSObject->FindAttribute(anAttr,"AttributeComment")){
+      SALOMEDS::AttributeComment_var aComment = 
+       SALOMEDS::AttributeComment::_narrow(anAttr);
+      CORBA::String_var aValue = aComment->Value();
+      Storable::TRestoringMap aMap;      
+      Storable::StrToMap(aValue.in(),aMap);
+      bool anIsExist;
+      QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
+      if(anIsExist){
+       if(strcmp(aMethodName.latin1(),"ImportTables") == 0){
+         return;
+       }
+      }
+    }
+
+    std::string aSObjectName = GetName(theSObject);
+    theStr<<thePrefix<<aSObjectName<<" = aBuilder.NewObject(aSComponent)"<<endl;
+    theStr<<thePrefix<<"if "<<aSObjectName<<":"<<endl;
+    thePrefix += PREFIX;
+
+    std::string aName = "aTableAttr";
+    theStr<<thePrefix<<aName<<" = aBuilder.FindOrCreateAttribute("<<
+      aSObjectName<<",'"<<theAttrName<<"')"<<endl;
+
+    theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+    std::string aPrefix = thePrefix;
+    thePrefix += PREFIX;
+
+    CORBA::String_var aString = theTableAttr->GetTitle();
+    theStr<<thePrefix<<aName<<".SetTitle('"<<aString.in()<<"')"<<endl;
+
+    CORBA::Long aNbColumns = theTableAttr->GetNbColumns();
+    theStr<<thePrefix<<aName<<".SetNbColumns("<<aNbColumns<<")"<<endl;
+
+    CORBA::Long aNbRows = theTableAttr->GetNbRows();
+    theStr<<thePrefix<<aName<<".SetNbRows("<<aNbRows<<")"<<endl;
+
+    for(CORBA::Long i = 1; i <= aNbColumns; i++){
+      for(CORBA::Long j = 1; j <= aNbRows; j++){
+       if(theTableAttr->HasValue(i,j)){
+         CORBA::Double aValue = theTableAttr->GetValue(i,j);
+         theStr<<thePrefix<<aName<<".PutValue("<<aValue<<","<<i<<","<<j<<")"<<endl;
+       }
+      }
+    }
+    
+    SALOMEDS::StringSeq_var aRowTitles = theTableAttr->GetRowTitles();
+    SALOMEDS::StringSeq_var aRowUnits = theTableAttr->GetRowUnits();
+    for(CORBA::Long j = 1; j <= aNbRows; j++){
+      theStr<<thePrefix<<aName<<".SetRowTitle("<<j<<",'"<<aRowTitles[j-1]<<"')"<<endl;
+      theStr<<thePrefix<<aName<<".SetRowUnit("<<j<<",'"<<aRowUnits[j-1]<<"')"<<endl;
+    }
+    
+    SALOMEDS::StringSeq_var aColumnTitles = theTableAttr->GetColumnTitles();
+    for(CORBA::Long i = 1; i <= aNbColumns; i++){
+      theStr<<thePrefix<<aName<<".SetColumnTitle("<<i<<",'"<<aColumnTitles[i-1]<<"')"<<endl;
+    }
+
+    if(theSObject->FindAttribute(anAttr,"AttributeIOR")){
+      theStr<<endl;
+      std::string aName = "aTable";
+      theStr<<thePrefix<<"anID = "<<aSObjectName<<".GetID()"<<endl;
+      theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
+      theArgumentName = aName;
+      
+      theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+      std::string aPrefix2 = thePrefix + PREFIX;
+
+      DumpChildrenToPython(theStudy,
+                          theIsPublished,
+                          theIsValidScript,
+                          theSObject,
+                          theStr,
+                          theName2EntryMap,
+                          theEntry2NameMap,
+                          theArgumentName,
+                          aPrefix2);
+
+      theStr<<aPrefix2<<"pass"<<endl<<endl;
+    }
+
+    theStr<<thePrefix<<"pass"<<endl<<endl;
+    theStr<<aPrefix<<"pass"<<endl<<endl;
+  }
+
+
+  //===========================================================================
+  void
+  DumpChildrenToPython(SALOMEDS::Study_ptr theStudy,
+                      CORBA::Boolean theIsPublished,
+                      CORBA::Boolean& theIsValidScript,
+                      SALOMEDS::SObject_ptr theSObject,
+                      std::ostream& theStr,
+                      TName2EntryMap& theName2EntryMap,
+                      TEntry2NameMap& theEntry2NameMap,
+                      std::string theArgumentName,
+                      std::string thePrefix)
+  {
+    SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
+    for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
+      SALOMEDS::SObject_var aSObject = aChildItet->Value();
+      DumpToPython(theStudy,
+                  theIsPublished,
+                  theIsValidScript,
+                  aSObject,
+                  theStr,
+                  theName2EntryMap,
+                  theEntry2NameMap,
+                  theArgumentName,
+                  thePrefix);
+    }
+  }
+
+
+  //===========================================================================
+  void
+  DumpTableAttrToPython(SALOMEDS::Study_ptr theStudy,
+                       CORBA::Boolean theIsPublished,
+                       CORBA::Boolean& theIsValidScript,
+                       SALOMEDS::SObject_ptr theSObject,
+                       std::ostream& theStr,
+                       TName2EntryMap& theName2EntryMap,
+                       TEntry2NameMap& theEntry2NameMap,
+                       std::string theArgumentName,
+                       std::string thePrefix)
+  {
+    SALOMEDS::GenericAttribute_var anAttr;
+    if(theSObject->FindAttribute(anAttr,"AttributeTableOfInteger")){
+      SALOMEDS::AttributeTableOfInteger_var aTableAttr =  
+       SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
+      
+      TableAttrToPython(theStudy,
+                       theIsPublished,
+                       theIsValidScript,
+                       theSObject,
+                       aTableAttr,
+                       "AttributeTableOfInteger",
+                       theStr,
+                       theName2EntryMap,
+                       theEntry2NameMap,
+                       theArgumentName,
+                       thePrefix);
+      
+    }else if(theSObject->FindAttribute(anAttr,"AttributeTableOfReal")){
+      SALOMEDS::AttributeTableOfReal_var aTableAttr =  
+       SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
+      
+      TableAttrToPython(theStudy,
+                       theIsPublished,
+                       theIsValidScript,
+                       theSObject,
+                       aTableAttr,
+                       "AttributeTableOfReal",
+                       theStr,
+                       theName2EntryMap,
+                       theEntry2NameMap,
+                       theArgumentName,
+                       thePrefix);
+    }
+  }
+
+
+  //===========================================================================
+  void
+  NewSObjectDumpToPython(SALOMEDS::Study_ptr theStudy,
+                        CORBA::Boolean theIsPublished,
+                        CORBA::Boolean& theIsValidScript,
+                        SALOMEDS::SObject_ptr theSObject,
+                        TDumpToPython theDumpToPython,
+                        std::ostream& theStr,
+                        TName2EntryMap& theName2EntryMap,
+                        TEntry2NameMap& theEntry2NameMap,
+                        std::string theArgumentName,
+                        std::string thePrefix)
+  {
+    SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
+    std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
+    theStr<<thePrefix<<theArgumentName<<" = aBuilder.NewObject(aSComponent)"<<endl;
+    theStr<<thePrefix<<"if "<<theArgumentName<<":"<<endl;
+    thePrefix += PREFIX;
+    
+    (*theDumpToPython)(theStudy,
+                      theIsPublished,
+                      theIsValidScript,
+                      theSObject,
+                      theStr,
+                      theName2EntryMap,
+                      theEntry2NameMap,
+                      theArgumentName,
+                      thePrefix);
+    
+    theStr<<thePrefix<<"pass"<<endl<<endl;
+    return;
+  }
+
+
+  //===========================================================================
+  void
+  DumpToPython(SALOMEDS::Study_ptr theStudy,
+              CORBA::Boolean theIsPublished,
+              CORBA::Boolean& theIsValidScript,
+              SALOMEDS::SObject_ptr theSObject,
+              std::ostream& theStr,
+              TName2EntryMap& theName2EntryMap,
+              TEntry2NameMap& theEntry2NameMap,
+              std::string theArgumentName,
+              std::string thePrefix)
+  {
+    std::string aName = GetName(theSObject);
+    if(aName == "")
+      return;
+
+    CORBA::Object_var anObj = SObjectToObject(theSObject);
+    if(!CORBA::is_nil(anObj)){
+      VISU::Base_var aBase = VISU::Base::_narrow(anObj);
+      if(!CORBA::is_nil(aBase)){
+       std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
+       CORBA::String_var anID = theSObject->GetID();
+
+        VISU::VISUType aType = aBase->GetType();
+        switch(aType){
+        case VISU::TRESULT:
+          if(Result_i* aServant = dynamic_cast<Result_i*>(GetServant(anObj).in())){
+           std::string aFileName = aServant->GetFileName();
+           Result_i::ECreationId anId = aServant->GetCreationId();
+           if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){
+             switch(anId){
+             case Result_i::eImportFile:
+               theStr<<thePrefix<<aName<<" = aVisu.ImportFile('"<<aFileName<<"')"<<endl;
+               break;
+             case Result_i::eCopyAndImportFile: 
+               theStr<<thePrefix<<aName<<" = aVisu.CopyAndImportFile('"<<aFileName<<"')"<<endl;
+               break;
+             }
+
+             theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+             thePrefix += PREFIX;
+             
+             theArgumentName = aName;
+             DumpChildrenToPython(theStudy,
+                                  theIsPublished,
+                                  theIsValidScript,
+                                  theSObject,
+                                  theStr,
+                                  theName2EntryMap,
+                                  theEntry2NameMap,
+                                  theArgumentName,
+                                  thePrefix);
+             
+             theStr<<thePrefix<<"pass"<<endl<<endl;
+           }else{
+             SALOMEDS::SObject_var aRefSObj;
+             if(theSObject->FindSubObject(1,aRefSObj)){
+               SALOMEDS::SObject_var aTargetRefSObj;
+               if(aRefSObj->ReferencedObject(aTargetRefSObj)){
+                 CORBA::String_var aString = aTargetRefSObj->GetName();
+                 theStr<<thePrefix<<"aSObject = theStudy.FindObject('"<<aString.in()<<"')"<<endl;
+                 theStr<<thePrefix<<"if aSObject:"<<endl;
+                 thePrefix += PREFIX;
+                 theStr<<thePrefix<<"anObject = aSObject.GetObject()"<<endl;
+                 theStr<<thePrefix<<"if anObject:"<<endl;
+                 std::string aPrefix1 = thePrefix;
+                 thePrefix += PREFIX;
+
+                 switch(anId){
+                 case Result_i::eImportMed: 
+                   theStr<<thePrefix<<aName<<" = aVisu.ImportMed(aSObject)"<<endl;
+                   break;
+                 case Result_i::eImportMedField:
+                   theStr<<thePrefix<<aName<<" = aVisu.ImportMedField(anObject)"<<endl;
+                   break;
+                 }
+
+                 theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+                 std::string aPrefix2 = thePrefix;
+                 thePrefix += PREFIX;
+                 
+                 theArgumentName = aName;
+                 DumpChildrenToPython(theStudy,
+                                      theIsPublished,
+                                      theIsValidScript,
+                                      theSObject,
+                                      theStr,
+                                      theName2EntryMap,
+                                      theEntry2NameMap,
+                                      theArgumentName,
+                                      thePrefix);
+             
+                 theStr<<thePrefix<<"pass"<<endl<<endl;
+                 theStr<<aPrefix2<<"pass"<<endl<<endl;
+                 theStr<<aPrefix1<<"pass"<<endl<<endl;
+               }
+             }
+           }
+          }
+          return;
+        case VISU::TMESH:
+          if(Mesh_i* aServant = dynamic_cast<Mesh_i*>(GetServant(anObj).in())){
+           VISU::Entity anEntity = aServant->GetEntity();
+           const std::string& aSubMeshName = aServant->GetSubMeshName();
+           if(anEntity >= 0){
+             std::string aParam;
+             switch(anEntity){
+             case NODE:
+               aParam = "VISU.NODE";
+               break;
+             case EDGE:
+               aParam = "VISU.EDGE";
+               break;
+             case FACE:
+               aParam = "VISU.FACE";
+               break;
+             case CELL:
+               aParam = "VISU.CELL";
+               break;
+             }
+             
+             if(aSubMeshName == "")
+               theStr<<thePrefix<<aName<<" = aVisu.MeshOnEntity("<<theArgumentName<<
+                 ",'"<<aServant->GetMeshName()<<"'"<<
+                 ","<<aParam<<
+                 ")"<<endl;
+             else
+               theStr<<thePrefix<<aName<<" = aVisu.FamilyMeshOnEntity("<<theArgumentName<<
+                 ",'"<<aServant->GetMeshName()<<"'"<<
+                 ","<<aParam<<
+                 ",'"<<aSubMeshName<<"'"<<
+                 ")"<<endl;
+           }else
+             theStr<<thePrefix<<aName<<" = aVisu.GroupMesh("<<theArgumentName<<
+               ",'"<<aServant->GetMeshName()<<"'"<<
+               ",'"<<aSubMeshName<<"'"<<
+               ")"<<endl;
+           
+           theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+           thePrefix += PREFIX;
+
+           theStr<<thePrefix<<"aName2ObjectMap['"<<aName<<"'] = "<<aName<<endl;
+
+           SALOMEDS::Color aColor;
+           aColor = aServant->GetCellColor();
+           theStr<<thePrefix<<aName<<".SetCellColor(SALOMEDS.Color("<<
+             aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+           
+           aColor = aServant->GetNodeColor();
+           theStr<<thePrefix<<aName<<".SetNodeColor(SALOMEDS.Color("<<
+             aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+           
+           aColor = aServant->GetLinkColor();
+           theStr<<thePrefix<<aName<<".SetLinkColor(SALOMEDS.Color("<<
+             aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+           
+           std::string aParam;
+           switch(aServant->GetPresentationType()){
+           case POINT:
+             aParam = "VISU.POINT";
+             break;
+           case WIREFRAME:
+             aParam = "VISU.WIREFRAME";
+             break;
+           case SHADED:
+             aParam = "VISU.SHADED";
+             break;
+           case INSIDEFRAME:
+             aParam = "VISU.INSIDEFRAME";
+             break;
+           case SURFACEFRAME:
+             aParam = "VISU.SURFACEFRAME";
+             break;
+           case SHRINK:
+             aParam = "VISU.SHRINK";
+             break;
+           }
+           theStr<<thePrefix<<aName<<".SetPresentationType("<<aParam<<")"<<endl;
+           theStr<<endl;
+
+           DumpChildrenToPython(theStudy,
+                                theIsPublished,
+                                theIsValidScript,
+                                theSObject,
+                                theStr,
+                                theName2EntryMap,
+                                theEntry2NameMap,
+                                theArgumentName,
+                                thePrefix);
+             
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+           return;
+          }
+          break;
+        case VISU::TSCALARMAP:
+          if(ScalarMap_i* aServant = dynamic_cast<ScalarMap_i*>(GetServant(anObj).in())){
+           thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"ScalarMapOnField",theArgumentName,thePrefix);
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
+        case VISU::TDEFORMEDSHAPE:
+          if(DeformedShape_i* aServant = dynamic_cast<DeformedShape_i*>(GetServant(anObj).in())){
+           thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"DeformedShapeOnField",theArgumentName,thePrefix);
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
+        case VISU::TSTREAMLINES:
+          if(StreamLines_i* aServant = dynamic_cast<StreamLines_i*>(GetServant(anObj).in())){
+           thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"StreamLinesOnField",theArgumentName,thePrefix);
+           
+           std::string aParam;
+           switch(aServant->GetDirection()){
+           case StreamLines::FORWARD:
+             aParam = "VISU.StreamLines.FORWARD";
+             break;
+           case StreamLines::BACKWARD:
+             aParam = "VISU.StreamLines.BACKWARD";
+             break;
+           case StreamLines::BOTH:
+             aParam = "VISU.StreamLines.BOTH";
+             break;
+           }
+
+           theStr<<thePrefix<<"aPrs3d = None"<<endl;
+           VISU::Prs3d_var aPrs3d = aServant->GetSource();
+           if(!CORBA::is_nil(aPrs3d)){
+             if(Prs3d_i* aServant3d = dynamic_cast<Prs3d_i*>(GetServant(aPrs3d).in())){
+               SALOMEDS::SObject_var aSObject = aServant3d->GetSObject();
+               CORBA::String_var anID = aSObject->GetID();
+               std::string anArg = theEntry2NameMap[anID.in()];
+               theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
+               thePrefix += PREFIX;
+               theStr<<thePrefix<<"aPrs3d = aName2ObjectMap['"<<anArg<<"']"<<endl;
+             }
+           }
+           
+           theStr<<thePrefix<<aName<<".SetParams("<<
+             aServant->GetIntegrationStep()<<","<<
+             aServant->GetPropagationTime()<<","<<
+             aServant->GetStepLength()<<","<<
+             "aPrs3d"<<","<<
+             aServant->GetUsedPoints()<<","<<
+             aParam<<
+             ")"<<endl;
+
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
+        case VISU::TVECTORS:
+          if(Vectors_i* aServant = dynamic_cast<Vectors_i*>(GetServant(anObj).in())){
+           thePrefix = DeformedShapeToPython(theSObject,aServant,theStr,aName,"VectorsOnField",theArgumentName,thePrefix);
+           
+           theStr<<thePrefix<<aName<<".SetLineWidth("<<aServant->GetLineWidth()<<")"<<endl;
+           
+           std::string aParam;
+           switch(aServant->GetGlyphType()){
+           case Vectors::ARROW:
+             aParam = "VISU.Vectors.ARROW";
+             break;
+           case Vectors::CONE2:
+             aParam = "VISU.Vectors.CONE2";
+             break;
+           case Vectors::CONE6:
+             aParam = "VISU.Vectors.CONE6";
+             break;
+           case Vectors::NONE:
+             aParam = "VISU.Vectors.NONE";
+             break;
+           }
+           theStr<<thePrefix<<aName<<".SetGlyphType("<<aParam<<")"<<endl;
+           
+           switch(aServant->GetGlyphPos()){
+           case Vectors::CENTER:
+             aParam = "VISU.Vectors.CENTER";
+             break;
+           case Vectors::TAIL:
+             aParam = "VISU.Vectors.TAIL";
+             break;
+           case Vectors::HEAD:
+             aParam = "VISU.Vectors.HEAD";
+             break;
+           }
+           theStr<<thePrefix<<aName<<".SetGlyphPos("<<aParam<<")"<<endl;
+
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
+        case VISU::TISOSURFACE:
+          if(IsoSurfaces_i* aServant = dynamic_cast<IsoSurfaces_i*>(GetServant(anObj).in())){
+           thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"IsoSurfacesOnField",theArgumentName,thePrefix);
+           theStr<<thePrefix<<aName<<".SetNbSurfaces("<<aServant->GetNbSurfaces()<<")"<<endl;
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
+        case VISU::TCUTPLANES:
+          if(CutPlanes_i* aServant = dynamic_cast<CutPlanes_i*>(GetServant(anObj).in())){
+           thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutPlanesOnField",theArgumentName,thePrefix);
+           
+           std::string aParam;
+           switch(aServant->GetOrientationType()){
+           case CutPlanes::XY:
+             aParam = "VISU.CutPlanes.XY";
+             break;
+           case CutPlanes::YZ:
+             aParam = "VISU.CutPlanes.YZ";
+             break;
+           case CutPlanes::ZX:
+             aParam = "VISU.CutPlanes.ZX";
+             break;
+           }
+           theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
+           
+           theStr<<thePrefix<<aName<<".SetDisplacement("<<aServant->GetDisplacement()<<")"<<endl;
+           CORBA::Long aNbPlanes = aServant->GetNbPlanes();
+           theStr<<thePrefix<<aName<<".SetNbPlanes("<<aNbPlanes<<")"<<endl;
+           
+           for(CORBA::Long anId = 0; anId < aNbPlanes; anId++){
+             if(!aServant->IsDefault(anId))
+               theStr<<thePrefix<<aName<<".SetPlanePosition("<<anId<<","<<aServant->GetPlanePosition(anId)<<")"<<endl;
+           }
+
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
+        case VISU::TCUTLINES:
+          if(CutLines_i* aServant = dynamic_cast<CutLines_i*>(GetServant(anObj).in())){
+           thePrefix = ScalarMapToPython(theSObject,aServant,theStr,aName,"CutLinesOnField",theArgumentName,thePrefix);
+           
+           std::string aParam;
+           switch(aServant->GetOrientationType()){
+           case CutPlanes::XY:
+             aParam = "VISU.CutPlanes.XY";
+             break;
+           case CutPlanes::YZ:
+             aParam = "VISU.CutPlanes.YZ";
+             break;
+           case CutPlanes::ZX:
+             aParam = "VISU.CutPlanes.ZX";
+             break;
+           }
+           theStr<<thePrefix<<aName<<".SetOrientation("<<aParam<<","<<aServant->GetRotateX()<<","<<aServant->GetRotateY()<<")"<<endl;
+           
+           switch(aServant->GetOrientationType2()){
+           case CutPlanes::XY:
+             aParam = "VISU.CutPlanes.XY";
+             break;
+           case CutPlanes::YZ:
+             aParam = "VISU.CutPlanes.YZ";
+             break;
+           case CutPlanes::ZX:
+             aParam = "VISU.CutPlanes.ZX";
+             break;
+           }
+           theStr<<thePrefix<<aName<<".SetOrientation2("<<aParam<<","<<aServant->GetRotateX2()<<","<<aServant->GetRotateY2()<<")"<<endl;
+           
+           theStr<<thePrefix<<aName<<".SetDisplacement("<<aServant->GetDisplacement()<<")"<<endl;
+           theStr<<thePrefix<<aName<<".SetDisplacement2("<<aServant->GetDisplacement2()<<")"<<endl;
+           
+           if(!aServant->IsDefault())
+             theStr<<thePrefix<<aName<<".SetBasePlanePosition("<<aServant->GetBasePlanePosition()<<")"<<endl;
+           
+           CORBA::Long aNbLines = aServant->GetNbLines();
+           theStr<<thePrefix<<aName<<".SetNbLines("<<aNbLines<<")"<<endl;
+           for(CORBA::Long anId = 0; anId < aNbLines; anId++){
+             if(!aServant->IsDefaultPosition(anId))
+               theStr<<thePrefix<<aName<<".SetLinePosition("<<anId<<","<<aServant->GetLinePosition(anId)<<")"<<endl;
+           }
+
+           theStr<<endl;
+
+           theArgumentName = aName;
+           DumpChildrenToPython(theStudy,
+                                theIsPublished,
+                                theIsValidScript,
+                                theSObject,
+                                theStr,
+                                theName2EntryMap,
+                                theEntry2NameMap,
+                                theArgumentName,
+                                thePrefix);
+
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+          return;
+        case VISU::TCURVE:
+          if(Curve_i* aServant = dynamic_cast<Curve_i*>(GetServant(anObj).in())){
+           theStr<<thePrefix<<aName<<" = aVisu.CreateCurve("<<theArgumentName<<
+             ","<<aServant->GetHRow()<<
+             ","<<aServant->GetVRow()<<
+             ")"<<endl;
+           
+           theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+           thePrefix += PREFIX;
+
+           theStr<<thePrefix<<"aName2ObjectMap['"<<aName<<"'] = "<<aName<<endl;
+
+           theStr<<thePrefix<<aName<<".SetTitle('"<<aServant->GetTitle()<<"')"<<endl;
+           
+           SALOMEDS::Color aColor = aServant->GetColor();
+           theStr<<thePrefix<<aName<<".SetColor(SALOMEDS.Color("<<
+             aColor.R<<","<<aColor.G<<","<<aColor.B<<"))"<<endl;
+           
+           std::string aParam;
+           switch(aServant->GetMarker()){
+           case Curve::NONE:
+             aParam = "VISU.Curve.NONE";
+             break;
+           case Curve::CIRCLE:
+             aParam = "VISU.Curve.CIRCLE";
+             break;
+           case Curve::RECTANGLE:
+             aParam = "VISU.Curve.RECTANGLE";
+             break;
+           case Curve::DIAMOND:
+             aParam = "VISU.Curve.DIAMOND";
+             break;
+           case Curve::DTRIANGLE:
+             aParam = "VISU.Curve.DTRIANGLE";
+             break;
+           case Curve::UTRIANGLE:
+             aParam = "VISU.Curve.UTRIANGLE";
+             break;
+           case Curve::LTRIANGLE:
+             aParam = "VISU.Curve.LTRIANGLE";
+             break;
+           case Curve::RTRIANGLE:
+             aParam = "VISU.Curve.RTRIANGLE";
+             break;
+           case Curve::CROSS:
+             aParam = "VISU.Curve.CROSS";
+             break;
+           case Curve::XCROSS:
+             aParam = "VISU.Curve.XCROSS";
+             break;
+           }
+           theStr<<thePrefix<<aName<<".SetMarker("<<aParam<<")"<<endl;
+           
+           switch(aServant->GetLine()){
+           case Curve::VOIDLINE:
+             aParam = "VISU.Curve.VOIDLINE";
+             break;
+           case Curve::SOLIDLINE:
+             aParam = "VISU.Curve.SOLIDLINE";
+             break;
+           case Curve::DASHLINE:
+             aParam = "VISU.Curve.DASHLINE";
+             break;
+           case Curve::DOTLINE:
+             aParam = "VISU.Curve.DOTLINE";
+             break;
+           case Curve::DASHDOTLINE:
+             aParam = "VISU.Curve.DASHDOTLINE";
+             break;
+           case Curve::DASHDOTDOTLINE:
+             aParam = "VISU.Curve.DASHDOTDOTLINE";
+             break;
+           }
+           theStr<<thePrefix<<aName<<".SetLine("<<aParam<<","<<aServant->GetLineWidth()<<")"<<endl;
+
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+          }
+         return;
+        case VISU::TTABLE:
+          if(Table_i* aServant = dynamic_cast<Table_i*>(GetServant(anObj).in())){
+           SALOMEDS::SObject_var aSObject = aServant->GetSObject();
+           SALOMEDS::GenericAttribute_var anAttr;
+           if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+             using namespace SALOMEDS;
+             AttributeComment_var aComment = AttributeComment::_narrow(anAttr);
+             CORBA::String_var aValue = aComment->Value();
+             Storable::TRestoringMap aMap;       
+             Storable::StrToMap(aValue.in(),aMap);
+             bool anIsExist;
+             QString aSourceId = VISU::Storable::FindValue(aMap,"mySourceId",&anIsExist);
+             if(anIsExist){
+               if(strcmp(aSourceId.latin1(),"CutLines") == 0){
+                 theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<theArgumentName<<"'):"<<endl;
+                 thePrefix += PREFIX;
+
+                 theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<theArgumentName<<"']"<<endl;
+                 theStr<<thePrefix<<"anIOR = anObject.GetID()"<<endl;
+                 theStr<<thePrefix<<"aSObject = theStudy.FindObjectIOR(anIOR)"<<endl;
+                 theStr<<thePrefix<<"if aSObject:"<<endl;
+                 std::string aPrefix = thePrefix;
+                 thePrefix += PREFIX;
+
+                 theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
+                 theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
+                 theStr<<endl;
+                 
+                 theArgumentName = aName;
+                 DumpChildrenToPython(theStudy,
+                                      theIsPublished,
+                                      theIsValidScript,
+                                      theSObject,
+                                      theStr,
+                                      theName2EntryMap,
+                                      theEntry2NameMap,
+                                      theArgumentName,
+                                      thePrefix);
+                 
+                 theStr<<thePrefix<<"pass"<<endl<<endl;
+                 theStr<<aPrefix<<"pass"<<endl<<endl;
+               }else if(strcmp(aSourceId.latin1(),"TableFile") == 0){
+                 CORBA::Short aTag = theSObject->Tag();
+                 theStr<<thePrefix<<"anIsFound, aSObject = "<<theArgumentName<<".FindSubObject("<<aTag<<")"<<endl;
+                 theStr<<thePrefix<<"if anIsFound:"<<endl;
+                 thePrefix += PREFIX;
+                 
+                 theStr<<thePrefix<<"anID = aSObject.GetID()"<<endl;
+                 theStr<<thePrefix<<aName<<" = aVisu.CreateTable(anID)"<<endl;
+                 theStr<<endl;
+
+                 theArgumentName = aName;
+                 DumpChildrenToPython(theStudy,
+                                      theIsPublished,
+                                      theIsValidScript,
+                                      theSObject,
+                                      theStr,
+                                      theName2EntryMap,
+                                      theEntry2NameMap,
+                                      theArgumentName,
+                                      thePrefix);
+                 
+                 theStr<<thePrefix<<"pass"<<endl<<endl;
+               }else if(strcmp(aSourceId.latin1(),"TableAttr") == 0){
+                 theArgumentName = aName;
+                 DumpTableAttrToPython(theStudy,
+                                       theIsPublished,
+                                       theIsValidScript,
+                                       theSObject,
+                                       theStr,
+                                       theName2EntryMap,
+                                       theEntry2NameMap,
+                                       theArgumentName,
+                                       thePrefix);
+               }
+             }
+           }
+          }
+          return;
+       }
+      }
+    }else{
+      SALOMEDS::GenericAttribute_var anAttr;
+      if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+       SALOMEDS::AttributeComment_var aComment = 
+         SALOMEDS::AttributeComment::_narrow(anAttr);
+       CORBA::String_var aValue = aComment->Value();
+       Storable::TRestoringMap aMap;     
+       Storable::StrToMap(aValue.in(),aMap);
+       bool anIsExist;
+       QString aTypeName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
+       if(anIsExist){
+         if(strcmp(aTypeName.latin1(),"ImportTables") == 0){
+           QString aFileName = VISU::Storable::FindValue(aMap,"myFileName",&anIsExist);
+           if(anIsExist){
+             std::string aName = GenerateName(theSObject,theName2EntryMap,theEntry2NameMap);
+             theStr<<thePrefix<<aName<<" = aVisu.ImportTables('"<<aFileName.latin1()<<"')"<<endl;
+             theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+             thePrefix += PREFIX;
+
+             theArgumentName = aName;
+             DumpChildrenToPython(theStudy,
+                                  theIsPublished,
+                                  theIsValidScript,
+                                  theSObject,
+                                  theStr,
+                                  theName2EntryMap,
+                                  theEntry2NameMap,
+                                  theArgumentName,
+                                  thePrefix);
+                 
+             theStr<<thePrefix<<"pass"<<endl<<endl;
+             return;
+           }
+         }else if(strcmp(aTypeName.latin1(),"VIEW3D") == 0){
+           std::string aName = GetName(theSObject);
+           theStr<<thePrefix<<aName<<" = aBuilder.NewObject(aSComponent)"<<endl;
+
+           theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+           thePrefix += PREFIX;
+
+           theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeName')"<<endl;
+           theStr<<thePrefix<<"anAttr.SetValue('"<<aName<<"')"<<endl;
+
+           theStr<<thePrefix<<"anAttr = aBuilder.FindOrCreateAttribute("<<aName<<",'AttributeComment')"<<endl;
+           theStr<<thePrefix<<"anAttr.SetValue('"<<aValue.in()<<"')"<<endl;
+
+           theStr<<thePrefix<<"pass"<<endl<<endl;
+           return;
+         }
+       }
+      }else{
+       DumpTableAttrToPython(theStudy,
+                             theIsPublished,
+                             theIsValidScript,
+                             theSObject,
+                             theStr,
+                             theName2EntryMap,
+                             theEntry2NameMap,
+                             theArgumentName,
+                             thePrefix);
+      }
+    }
+
+    DumpChildrenToPython(theStudy,
+                        theIsPublished,
+                        theIsValidScript,
+                        theSObject,
+                        theStr,
+                        theName2EntryMap,
+                        theEntry2NameMap,
+                        theArgumentName,
+                        thePrefix);
+  }
+
+
+  //===========================================================================
+  void
+  DumpCurveToPython(SALOMEDS::Study_ptr theStudy,
+                   CORBA::Boolean theIsPublished,
+                   CORBA::Boolean& theIsValidScript,
+                   SALOMEDS::SObject_ptr theSObject,
+                   std::ostream& theStr,
+                   TName2EntryMap& theName2EntryMap,
+                   TEntry2NameMap& theEntry2NameMap,
+                   std::string theArgumentName,
+                   std::string thePrefix)
+  {
+    SALOMEDS::SObject_var aTargetRefSObj;
+    if(theSObject->ReferencedObject(aTargetRefSObj)){
+      CORBA::Object_var anObj = SObjectToObject(aTargetRefSObj);
+      if(CORBA::is_nil(anObj)) 
+       return;
+      
+      VISU::Base_var aBase = VISU::Base::_narrow(anObj);
+      if(CORBA::is_nil(aBase)) 
+       return;
+      
+      if(aBase->GetType() == VISU::TCURVE){
+       CORBA::String_var anID = aTargetRefSObj->GetID();
+       std::string anArg = theEntry2NameMap[anID.in()];
+       theStr<<thePrefix<<"if aName2ObjectMap.has_key('"<<anArg<<"'):"<<endl;
+       thePrefix += PREFIX;
+       theStr<<thePrefix<<"anObject = aName2ObjectMap['"<<anArg<<"']"<<endl;
+       theStr<<thePrefix<<theArgumentName<<".AddCurve(anObject)"<<endl;
+       theStr<<thePrefix<<"pass"<<endl<<endl;
+      }
+    }
+  }
+
+
+  //===========================================================================
+  void
+  DumpContainersToPython(SALOMEDS::Study_ptr theStudy,
+                        CORBA::Boolean theIsPublished,
+                        CORBA::Boolean& theIsValidScript,
+                        SALOMEDS::SObject_ptr theSObject,
+                        std::ostream& theStr,
+                        TName2EntryMap& theName2EntryMap,
+                        TEntry2NameMap& theEntry2NameMap,
+                        std::string theArgumentName,
+                        std::string thePrefix)
+  {
+    SALOMEDS::ChildIterator_var aChildItet = theStudy->NewChildIterator(theSObject);
+    for(aChildItet->InitEx(false); aChildItet->More(); aChildItet->Next()){
+      SALOMEDS::SObject_var aSObject = aChildItet->Value();
+      CORBA::Object_var anObj = SObjectToObject(aSObject);
+      if(CORBA::is_nil(anObj)) 
+       continue;
+
+      VISU::Base_var aBase = VISU::Base::_narrow(anObj);
+      if(CORBA::is_nil(aBase)) 
+       continue;
+
+      if(aBase->GetType() == VISU::TCONTAINER){
+       theStr<<endl;
+       std::string aName = GenerateName(aSObject,theName2EntryMap,theEntry2NameMap);
+       theStr<<thePrefix<<aName<<" = aVisu.CreateContainer()"<<endl;
+       theStr<<thePrefix<<"if "<<aName<<":"<<endl;
+       std::string aPrefix = thePrefix + PREFIX;
+       theArgumentName = aName;
+
+       SALOMEDS::ChildIterator_var aCurveIter = theStudy->NewChildIterator(aSObject);
+       for(aCurveIter->InitEx(false); aCurveIter->More(); aCurveIter->Next()){
+         SALOMEDS::SObject_var aRefSObj = aCurveIter->Value();
+         DumpCurveToPython(theStudy,theIsPublished,theIsValidScript,aRefSObj,theStr,theName2EntryMap,theEntry2NameMap,theArgumentName,aPrefix);
+       }
+
+       theStr<<aPrefix<<"pass"<<endl<<endl;
+      }
+    }
+  }
+
+
+  //===========================================================================
+  Engines::TMPFile* 
+  VISU_Gen_i::
+  DumpPython(CORBA::Object_ptr theStudy,
+            CORBA::Boolean theIsPublished,
+            CORBA::Boolean& theIsValidScript)
+  {
+    SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
+    if(CORBA::is_nil(aStudy)) 
+      return new Engines::TMPFile(0);
+
+    TName2EntryMap aName2EntryMap;
+    TEntry2NameMap aEntry2NameMap;
+
+#ifndef COUT
+    ostringstream aStr;
+#else
+#define aStr cout    
+#endif
+
+    std::string aPrefix(PREFIX);
+    aStr<<"def RebuildData(theStudy):"<<endl;
+    aStr<<aPrefix<<"from batchmode_salome import orb, naming_service, lcc, myStudyManager"<<endl;
+    aStr<<aPrefix<<"import SALOME_MED"<<endl;
+    aStr<<aPrefix<<"import SALOMEDS"<<endl;
+    aStr<<aPrefix<<"import VISU"<<endl;
+    aStr<<aPrefix<<"import visu"<<endl;
+    aStr<<endl;
+    aStr<<aPrefix<<"aVisu = visu.Initialize(orb,naming_service,lcc,myStudyManager,theStudy,0)"<<endl;
+    aStr<<aPrefix<<"aMed = lcc.FindOrLoadComponent('FactoryServer','MED')"<<endl;
+    aStr<<aPrefix<<"aSComponent = theStudy.FindComponent('VISU')"<<endl;
+    aStr<<aPrefix<<"aBuilder = theStudy.NewBuilder()"<<endl;
+    aStr<<aPrefix<<"aName2ObjectMap = {}"<<endl;
+    aStr<<endl;
+
+    SALOMEDS::SComponent_var aComponent = FindOrCreateVisuComponent(aStudy);
+    VISU::DumpChildrenToPython(aStudy,theIsPublished,theIsValidScript,aComponent.in(),aStr,aName2EntryMap,aEntry2NameMap,"",aPrefix);
+    VISU::DumpContainersToPython(aStudy,theIsPublished,theIsValidScript,aComponent.in(),aStr,aName2EntryMap,aEntry2NameMap,"",aPrefix);
+
+    aStr<<aPrefix<<"pass"<<endl;
+
+#ifndef COUT
+    std::string aResult = aStr.str();
+    ofstream anFStream("/tmp/dump.py");
+    anFStream<<aResult<<endl;
+    return new Engines::TMPFile(aResult.size(),aResult.size(),(CORBA::Octet*)&aResult[0]);
+#else
+#undef aStr
+    return new Engines::TMPFile(0);
+#endif
+  }
+
+}
index 5db5aed55b5d09867b69460f7d969c6eabe1563f..35830b25487f0b340323324cac367e2158a353c3 100644 (file)
@@ -206,6 +206,7 @@ namespace VISU{
     }
     return aString._retn();
   }
+
   //===========================================================================
   SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
                                      const char* theURL,
@@ -218,31 +219,36 @@ namespace VISU{
     int aCounter = 0;
     TColStd_SequenceOfAsciiString aFileNames;
     SALOMEDS::Study_var aStudy = theComponent->GetStudy(); 
+
+    //CORBA::Boolean anIsValidScript;
+    //Engines::TMPFile_var aDump = DumpPython(aStudy,false,anIsValidScript);
+
     SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
     for (; itBig->More(); itBig->Next()) {
       SALOMEDS::SObject_var gotBranch = itBig->Value();
       CORBA::Object_var anObj = SObjectToObject(gotBranch);
       if(CORBA::is_nil(anObj)) continue;
       if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
-       const Result_i::TSourceId& aSourceId = pResult->GetSourceId();
-       if(aSourceId == Result_i::eFile || aSourceId == Result_i::eRestoredFile){
+       switch(pResult->GetCreationId()){
+       case Result_i::eImportFile:
+       case Result_i::eCopyAndImportFile: {
          const QFileInfo& aFileInfo = pResult->GetFileInfo();
          QString aPrefix("");
          if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()).c_str();
          QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
          static QString aCommand;
          aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
-
+         
          int aRes = system(aCommand);
          if(aRes){
            if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"<<aCommand);
            continue;
          }else
            if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aCommand = "<<aCommand);
-
+         
          TCollection_AsciiString aString(strdup(aFileName.latin1()));
          aFileNames.Append(aString);
-       }
+       }}
       }
     }
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
@@ -276,8 +282,9 @@ namespace VISU{
       CORBA::Object_var anObj = SObjectToObject(gotBranch);
       if(CORBA::is_nil(anObj)) continue;
       if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
-       const Result_i::TSourceId& aSourceId = pResult->GetSourceId();
-       if(aSourceId == Result_i::eFile || aSourceId == Result_i::eRestoredFile){
+       switch(pResult->GetCreationId()){
+       case Result_i::eImportFile:
+       case Result_i::eCopyAndImportFile: {
          const QFileInfo& aFileInfo = pResult->GetFileInfo();
          QString aPrefix("");
          if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()).c_str();
@@ -297,7 +304,7 @@ namespace VISU{
          HDFascii::ConvertFromHDFToASCII(strdup((aTmpDir + aString).ToCString()), true);
          
          aFileNames.Append(aString);
-       }
+       }}
       }
     }
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
@@ -377,7 +384,9 @@ namespace VISU{
       return Result::_nil();
     Mutex mt(myMutex);
     aFileInfo.setFile(theFileName);
-    Result_i* pResult = new Result_i(myStudyDocument);
+    Result_i* pResult = new Result_i(myStudyDocument,
+                                    Result_i::eFile,
+                                    Result_i::eImportFile);
     if(pResult->Create(theFileName) != NULL)   
       return pResult->_this();
     else{
@@ -392,7 +401,9 @@ namespace VISU{
     Mutex mt(myMutex);
     VISU::Result_var aResult;
     aFileInfo.setFile(theFileName);
-    Result_i* pResult = new Result_i(myStudyDocument,Result_i::eRestoredFile);
+    Result_i* pResult = new Result_i(myStudyDocument,
+                                    Result_i::eRestoredFile,
+                                    Result_i::eCopyAndImportFile);
     if(pResult->Create(theFileName) != NULL) 
       aResult = pResult->_this();
     return aResult._retn();
@@ -402,7 +413,9 @@ namespace VISU{
     if(myStudyDocument->GetProperties()->IsLocked()) 
       return Result::_nil();
     Mutex mt(myMutex);
-    Result_i* pResult = new Result_i(myStudyDocument);
+    Result_i* pResult = new Result_i(myStudyDocument,
+                                    Result_i::eComponent,
+                                    Result_i::eImportMed);
     if(pResult->Create(theMedSObject) != NULL)
       return pResult->_this();
     else{
@@ -415,7 +428,9 @@ namespace VISU{
     if(myStudyDocument->GetProperties()->IsLocked()) 
       return Result::_nil();
     Mutex mt(myMutex);
-    Result_i* pResult = new Result_i(myStudyDocument);
+    Result_i* pResult = new Result_i(myStudyDocument,
+                                    Result_i::eComponent,
+                                    Result_i::eImportMedField);
     if(pResult->Create(theField) != NULL)
       return pResult->_this();
     else{
@@ -639,11 +654,11 @@ namespace VISU{
          Result_var aResultObj = Result::_narrow(anObj);
          if(!aResultObj->_is_nil()){
            if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(aResultObj).in())){
-             const Result_i::TSourceId& aSourceId = pResult->GetSourceId();
-             if(aSourceId == Result_i::eComponent || aSourceId == Result_i::eRestoredComponent)
-               if((pResult->GetFileInfo()).filePath() == "MED") 
-                 return false;
-             return true;
+             switch(pResult->GetCreationId()){
+             case Result_i::eImportFile:
+             case Result_i::eCopyAndImportFile: 
+               return true;
+             }
            }
          }
        }
index 7869cd6c55e89b4d0a9639689f7c39d4102304d0..d5f71d528ac3462c7ba5a971941087111ed61355 100644 (file)
@@ -98,13 +98,20 @@ namespace VISU{
     virtual void DeleteResult(Result_ptr theResult);
     virtual void DeletePrs3d(Prs3d_ptr thePrs3d);
 
-    // inherited methods from SALOMEDS::Driver
+    // inherited methods from Engines::Component
+    virtual 
+    Engines::TMPFile* 
+    DumpPython(CORBA::Object_ptr theStudy,
+              CORBA::Boolean theIsPublished,
+              CORBA::Boolean& theIsValidScript);
+
     virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
                                    const char* theURL,
                                    bool isMultiFile);
     virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
                                         const char* theURL,
                                         bool isMultiFile);
+
     virtual bool Load(SALOMEDS::SComponent_ptr,
                      const SALOMEDS::TMPFile &,
                      const char* theURL,
index 5ae8a364d1d07966112cac4ce5e1cec2f92c6b8b..d299ac66733f9994f5df1f0688fd8ef144ecdb45 100644 (file)
@@ -81,6 +81,10 @@ namespace VISU{
     static int IsPossible(Result_i* theResult, const char* theMeshName, const char* theGroupName);
     virtual Storable* Create(const char* theMeshName, const char* theGroupName);
 
+    const std::string& GetMeshName() const { return myMeshName;}
+    VISU::Entity GetEntity() const { return VISU::Entity(myEntity);}
+    const string& GetSubMeshName() const { return mySubMeshName;}
+    
     virtual void ToStream(std::ostringstream& theStr);
 
     virtual const char* GetComment() const;
index d4e1ee61553726f19241a932ee11cc96c2b91ee4..6aea4e454c181a524f92cfb236012d935d91fbe6 100644 (file)
@@ -126,14 +126,15 @@ string GetComponentDataType(SALOMEDS::SObject_ptr theSObject){
 const string VISU::Result_i::myComment = "RESULT";
 const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
 
-VISU::Result_i::Result_i(SALOMEDS::Study_ptr theStudy, const TSourceId& aSourceId) {
-  myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
-  mySourceId = aSourceId;
-  myInput = NULL;
-  myIsDone = 0;
-  CORBA::String_var aName = theStudy->Name();
-  MESSAGE("Result_i::Result_i - this = "<<this<<"; StudyId = "<<
-       theStudy->StudyId()<<"; Name = '"<<aName.in()<<"'");
+VISU::Result_i::Result_i(SALOMEDS::Study_ptr theStudy, 
+                        const ESourceId& theSourceId,
+                        const ECreationId& theCreationId):
+  myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
+  myCreationId(theCreationId),
+  mySourceId(theSourceId),
+  myInput(NULL),
+  myIsDone(0)
+{
 }
 
 
@@ -142,7 +143,10 @@ void VISU::Result_i::RemoveFromStudy(){
 }
 
 
-int VISU::Result_i::IsPossible(){
+int 
+VISU::Result_i::
+IsPossible()
+{
   try{
     float aSize = myInput->GetSize();
     bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
@@ -157,7 +161,10 @@ int VISU::Result_i::IsPossible(){
 }
 
 
-CORBA::Boolean VISU::Result_i::BuildAll(){
+CORBA::Boolean 
+VISU::Result_i::
+BuildAll()
+{
   if(MYDEBUG) MESSAGE("Result_i::Build - myIsDone = "<<myIsDone);
   if(myIsDone) return 1;
   if(!IsPossible()) return 0;
@@ -237,7 +244,10 @@ CORBA::Boolean VISU::Result_i::BuildAll(){
   return myIsDone;
 }
 
-VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject) 
+
+VISU::Storable* 
+VISU::Result_i::
+Build(SALOMEDS::SObject_ptr theSObject) 
 {
   SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
   aStudyBuilder->NewCommand();  // There is a transaction
@@ -425,21 +435,25 @@ VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject)
   return this;
 }
 
-VISU::Storable* VISU::Result_i::Create(const char* theFileName){
+
+VISU::Storable* 
+VISU::Result_i::
+Create(const char* theFileName)
+{
   try{
     myFileInfo.setFile(theFileName);
     myInitFileName = myFileInfo.filePath().latin1();
     myName = ::GenerateName(myFileInfo.fileName()).latin1();
-    if(GetSourceId() == eRestoredFile){
-      auto_ptr<char> aTmpDir((char*)SALOMEDS_Tool::GetTmpDir().c_str());
+    if(mySourceId == eRestoredFile){
+      std::string aTmpDir(SALOMEDS_Tool::GetTmpDir());
       static QString aCommand;
-      aCommand.sprintf("cp %s %s",myFileInfo.absFilePath().latin1(),aTmpDir.get());
+      aCommand.sprintf("cp %s %s",myFileInfo.absFilePath().latin1(),aTmpDir.c_str());
       if(system(aCommand) == -1){
        MESSAGE("Create - Can't execute the command :"<<aCommand);
        return NULL;
       }
       if(MYDEBUG) MESSAGE("Result_i::Create - aCommand = "<<aCommand);
-      myFileInfo.setFile(QString(aTmpDir.get()) + myFileInfo.fileName());
+      myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName());
     }
     myInput = CreateConvertor(myFileInfo.absFilePath().latin1());
     if(!myInput) 
@@ -452,15 +466,23 @@ VISU::Storable* VISU::Result_i::Create(const char* theFileName){
   return NULL;
 }
 
-VISU::Storable* VISU::Result_i::Create(SALOMEDS::SObject_ptr theMedSObject){
+
+VISU::Storable* 
+VISU::Result_i::
+Create(SALOMEDS::SObject_ptr theMedSObject)
+{
   if(MYDEBUG)  MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
   try{
     myInput = CreateMEDConvertor(theMedSObject);
-    if(myInput == NULL) return NULL;
-    mySourceId = eComponent;
+    if(myInput == NULL) 
+      return NULL;
+
     string aCompDataType = GetComponentDataType(theMedSObject);
     myFileInfo.setFile(aCompDataType.c_str());
+    myInitFileName = aCompDataType;
+
     myName = ::GenerateName("aResult").latin1();
+
     VISU::Storable* aStorable = Build(theMedSObject);
     return aStorable;
   }catch(std::exception& exc){
@@ -471,18 +493,25 @@ VISU::Storable* VISU::Result_i::Create(SALOMEDS::SObject_ptr theMedSObject){
   return NULL;
 }
 
-VISU::Storable* VISU::Result_i::Create(SALOME_MED::FIELD_ptr theField){
+VISU::Storable* 
+VISU::Result_i::
+Create(SALOME_MED::FIELD_ptr theField)
+{
   if(MYDEBUG)  MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
   try{
     myInput = CreateMEDFieldConvertor(theField);
-    if(myInput == NULL) return NULL;
-    mySourceId = eComponent;
+    if(myInput == NULL) 
+      return NULL;
+
     string aCompDataType = "MED";
     myFileInfo.setFile(aCompDataType.c_str());
     myInitFileName = aCompDataType;
+
     myName = ::GenerateName("aResult").latin1();
+
     CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
     SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
+
     VISU::Storable* aStorable = Build(aFieldSObject);
     return aStorable;
   }catch(std::exception& exc){
@@ -493,8 +522,12 @@ VISU::Storable* VISU::Result_i::Create(SALOME_MED::FIELD_ptr theField){
   return NULL;
 }
 
-VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, 
-                                       const Storable::TRestoringMap& theMap, const string& thePrefix)
+
+VISU::Storable* 
+VISU::Result_i::
+Restore(SALOMEDS::SObject_ptr theSObject, 
+       const Storable::TRestoringMap& theMap, 
+       const string& thePrefix)
 {
   if(MYDEBUG)  MESSAGE("Result_i::Restore - "<<thePrefix);
   try{
@@ -505,7 +538,6 @@ VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject,
     myInitFileName = VISU::Storable::FindValue(theMap,"myInitFileName").latin1();
     SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
     if(mySObject->FindSubObject(1,aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)){
-      mySourceId = eRestoredComponent;
       if(MYDEBUG)  MESSAGE("Result_i::GetInput - There is some reference.");
       SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
       CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
@@ -595,14 +627,25 @@ void VISU::Result_i::ToStream(std::ostringstream& theStr){
   if(MYDEBUG) MESSAGE(GetComment());
   Storable::DataToStream(theStr,"myName",myName.c_str());
   Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str());
+  Storable::DataToStream(theStr,"myCreationId",myCreationId);
 }
 
-VISU::Storable* VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, 
-                                       const string& thePrefix, const Storable::TRestoringMap& theMap)
+VISU::Storable* 
+VISU::Result_i::Restore(SALOMEDS::SObject_ptr theSObject, 
+                       const string& thePrefix, 
+                       const Storable::TRestoringMap& theMap)
 {
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
-  VISU::Result_i* pResult = new VISU::Result_i(aStudy);
-  if(pResult == NULL) return NULL;
+
+  ECreationId aCreationId = ECreationId(Storable::FindValue(theMap,"myCreationId").toInt());
+  ESourceId aSourceId = eRestoredFile;
+  if(aCreationId == eImportMed || aCreationId == eImportMedField)
+    aSourceId = eRestoredComponent;
+
+  VISU::Result_i* pResult = new VISU::Result_i(aStudy,aSourceId,aCreationId);
+  if(pResult == NULL) 
+    return NULL;
+
   return pResult->Restore(theSObject,theMap,thePrefix);
 }
      
@@ -626,7 +669,7 @@ std::string VISU::Result_i::GetEntry(const std::string& theComment)
 
 VISU::Result_i::~Result_i() {
   MESSAGE("Result_i::~Result_i() - this = "<<this);
-  if(GetSourceId() == eRestoredFile){ 
+  if(mySourceId == eRestoredFile){ 
     static QString aCommand;
     aCommand.sprintf("rm %s",myFileInfo.filePath().latin1());
     MESSAGE("Result_i::~Result_i - system("<<aCommand<<") = "<<system(aCommand));
index d172f3f94ec1442b9c41b865635cd200b93b8d31..94f03b7430e79565515b421e07ff576c720fea45 100644 (file)
@@ -41,8 +41,13 @@ namespace VISU{
     Result_i(const Result_i &);
 
   public:
-    enum TSourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2};
-    Result_i(SALOMEDS::Study_ptr theStudy, const TSourceId& aSourceId = eFile);
+    enum ESourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2};
+    enum ECreationId {eImportFile, eCopyAndImportFile, eImportMed, eImportMedField};
+
+    Result_i(SALOMEDS::Study_ptr theStudy, 
+            const ESourceId& theSourceId,
+            const ECreationId& theCreationId);
+
     virtual ~Result_i();
     virtual void RemoveFromStudy();
 
@@ -52,7 +57,9 @@ namespace VISU{
     typedef VISU_Convertor TInput;
 
   private:
-    TSourceId mySourceId;
+    ESourceId mySourceId;
+    ECreationId myCreationId;
+
     TInput *myInput;
     CORBA::Boolean myIsDone;
     std::string myName, myInitFileName;
@@ -67,19 +74,24 @@ namespace VISU{
     virtual Storable* Create(const char* theFileName);
     virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject);
     virtual Storable* Create(SALOME_MED::FIELD_ptr theField);
+
     virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject, 
-                             const Storable::TRestoringMap& theMap, const std::string& thePrefix);
+                             const Storable::TRestoringMap& theMap, 
+                             const std::string& thePrefix);
 
     static Storable* Restore(SALOMEDS::SObject_ptr theSObject, 
-                            const std::string& thePrefix, const Storable::TRestoringMap& theMap);
+                            const std::string& thePrefix, 
+                            const Storable::TRestoringMap& theMap);
 
     virtual void ToStream(std::ostringstream& theStr);
     virtual const char* GetComment() const;
     static const std::string myComment;
     TInput* GetInput();
+
     const std::string& GetName() const { return myName;}
     const QFileInfo& GetFileInfo() const { return myFileInfo;}
-    const Result_i::TSourceId& GetSourceId() const { return mySourceId;}
+    const std::string& GetFileName() const { return myInitFileName;}
+    const ECreationId& GetCreationId() const { return myCreationId;}
 
   private:
     SALOMEDS::SObject_var mySObject;
@@ -99,4 +111,6 @@ namespace VISU{
   Result_var FindResult(SALOMEDS::SObject_ptr theSObject);
   void RemoveFromStudy(SALOMEDS::SObject_ptr theSObject, int theIsAttrOnly = true);
 }
+
+
 #endif
index 510ff794b827a8df12a9099959fb00f42b6393e1..bb4206dcadfdc18801a0bfa0a254df43855d8ac8 100644 (file)
@@ -158,6 +158,11 @@ namespace VISU{
     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
                             const char* theFieldName, int theIteration);
 
+    const std::string& GetMeshName() const { return myMeshName;}
+    VISU::Entity GetEntity() const { return VISU::Entity(myEntity);}
+    const string& GetFieldName() const { return myFieldName;}
+    int GetIteration() const { return myIteration;}
+    
     virtual void ToStream(std::ostringstream& theStr);
 
     static const string myComment;
@@ -173,7 +178,6 @@ namespace VISU{
     virtual void SetMapScale(double theMapScale = 1.0);
 
     const VISU::PField GetField() const { return myField;}
-    const string& GetFieldName() const { return myFieldName;}
 
     virtual bool IsRangeFixed() { return myIsFixedRange; }
     virtual void SetSourceRange();
index d588e45c279085e0ab0ec3e629e6c18b58fc14f9..a907cabf6dc1088465efa989abee014ed9e4474e 100644 (file)
@@ -172,9 +172,30 @@ VISU::Storable* VISU::Table_i::Build( int theRestoring )
     // look for component
     if ( !theRestoring ) {
        SALOMEDS::SComponent_var SComponent = VISU::FindOrCreateVisuComponent( myStudy );
-       // create SObject and set attributes
+
        QString aComment;
-       aComment.sprintf("myComment=%s;myType=%d",GetComment(),VISU::TTABLE);
+       if(pCutLines)
+         aComment.sprintf("myComment=%s;myType=%d;mySourceId=CutLines",GetComment(),VISU::TTABLE);
+       else{
+         aComment.sprintf("myComment=%s;myType=%d;mySourceId=TableAttr",GetComment(),VISU::TTABLE);
+         SALOMEDS::SObject_var aFatherSObject = SO->GetFather();
+         if(aFatherSObject->FindAttribute(anAttr,"AttributeComment")){
+           SALOMEDS::AttributeComment_var aCommentAttr = 
+             SALOMEDS::AttributeComment::_narrow(anAttr);
+           CORBA::String_var aValue = aCommentAttr->Value();
+           Storable::TRestoringMap aMap;         
+           Storable::StrToMap(aValue.in(),aMap);
+           bool anIsExist;
+           QString aMethodName = VISU::Storable::FindValue(aMap,"myComment",&anIsExist);
+           if(anIsExist){
+             if(strcmp(aMethodName.latin1(),"ImportTables") == 0){
+               aComment.sprintf("myComment=%s;myType=%d;mySourceId=TableFile",GetComment(),VISU::TTABLE);
+             }
+           }
+         }
+       }
+
+       // create SObject and set attributes
        string anEntry = CreateAttributes( myStudy, 
                                          SO->GetID(),//SComponent->GetID(),
                                          "",
@@ -1120,11 +1141,20 @@ SALOMEDS::SObject_var VISU::ImportTables(const char* theFileName, SALOMEDS::Stud
   SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
   SALOMEDS::SComponent_var theSComponent = VISU::FindOrCreateVisuComponent(theStudy);
   SALOMEDS::SObject_var aFileObject = aStudyBuilder->NewObject(theSComponent);
+
   SALOMEDS::GenericAttribute_var anAttr = 
     aStudyBuilder->FindOrCreateAttribute(aFileObject, "AttributeName");
   SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
   QFileInfo aFileInfo(theFileName);
   aName->SetValue(aFileInfo.fileName().latin1());
+
+  anAttr = aStudyBuilder->FindOrCreateAttribute(aFileObject, "AttributeComment");
+  SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
+  QString aString;
+  aString.sprintf("myComment=ImportTables;myFileName=%s",
+                 aFileInfo.absFilePath().latin1());
+  aComment->SetValue(aString.latin1());
+
   for(int i = 0, iEnd = aTableCont.size(); i < iEnd; i++){
     const TTable2D& aTable2D = aTableCont[i];
     SALOMEDS::SObject_var aRealObject = aStudyBuilder->NewObject(aFileObject);
index 1d00478b70c746a097fe0ec7d422b5aed68bb6b8..720672320ca7ba45ae5c856ee55a1e8dcbec002d 100644 (file)
@@ -66,6 +66,9 @@ namespace VISU{
 
   public:
     virtual Storable* Create();
+
+    SALOMEDS::SObject_var GetSObject() const { return mySObj;}
+
     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO);
     static Storable* Restore(SALOMEDS::SObject_ptr theSObject, 
                             const string& thePrefix, const Storable::TRestoringMap& theMap);
@@ -124,6 +127,10 @@ namespace VISU{
 
   public:
     virtual Storable* Create();
+
+    int GetHRow() const { return myHRow;}
+    int GetVRow() const { return myVRow;}
+
     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO);
 
     static Storable* Restore(SALOMEDS::SObject_ptr theSObject,