]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
debug of load and dump to python of notebook
authorasl <asl@opencascade.com>
Tue, 24 Nov 2009 10:15:41 +0000 (10:15 +0000)
committerasl <asl@opencascade.com>
Tue, 24 Nov 2009 10:15:41 +0000 (10:15 +0000)
src/SALOMEDS/SALOMEDS_Driver_i.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx

index 0aec6fc2dc59b0653726b1f29bbd368a162f6553..b92264ce2f2e4ad1cad165dfb58c8b9bc4d12d6d 100644 (file)
@@ -219,7 +219,7 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::DumpPython(SALOMEDSImpl_Study* theStudy
                                                    bool& isValidScript,
                                                    long& theStreamLength)
 {
-  SALOMEDS_Study_i *  st_servant = new SALOMEDS_Study_i (theStudy, _orb);
+  SALOMEDS_Study_i *  st_servant = SALOMEDS_Study_i::GetStudyServant (theStudy, _orb);
   SALOMEDS::Study_var st  = SALOMEDS::Study::_narrow(st_servant->_this());
   Engines::Component_ptr aComponent = Engines::Component::_narrow(_driver);
 
index d3e97bee64e437edc4e9550736d44f28a08a420e..ce1259c5b6a67ff3780425fd2258e3b97de995b8 100644 (file)
@@ -36,6 +36,8 @@
 #include "SALOMEDSImpl_SComponent.hxx"
 #include "SALOMEDSImpl_AttributeIOR.hxx"
 
+#include "SALOME_NotebookDriver.hxx"
+
 #include "Utils_CorbaException.hxx"
 #include "Utils_ExceptHandlers.hxx"
 #include "Basics_Utils.hxx"
@@ -181,7 +183,9 @@ SALOMEDS::Study_ptr  SALOMEDS_StudyManager_i::Open(const char* aUrl)
   if(!_name_service->Change_Directory("/Study")) MESSAGE( "Unable to access the study directory" )
   else _name_service->Register(Study, CORBA::string_dup(aStudyImpl->Name().c_str()));
 
-  Study->GetNotebook();
+  SALOMEDS::SComponent_ptr aNotebookComponent = Study->FindComponent( "NOTEBOOK" );
+  SALOMEDS::StudyBuilder_var aBuilder = Study->NewBuilder();
+  aBuilder->LoadWith( aNotebookComponent, SALOME_NotebookDriver::getInstance() );
 
   return Study._retn();
 }
index 62e1b842872b1569a43865e8405d73b212a8f31b..2f21c45e2b750918cec377c2d7a97e3ad8e2598c 100644 (file)
@@ -960,24 +960,26 @@ SALOME::Notebook_ptr SALOMEDS_Study_i::GetNotebook()
     SALOME_Notebook* aNb = new SALOME_Notebook( _default_POA(), _this() );
     myNotebook = aNb->_this();
 
-    //Creation of default component for the Notebook
-    SALOMEDS::GenericAttribute_var anAttr;
     SALOMEDS::StudyBuilder_var aStudyBuilder = NewBuilder();
-    SALOMEDS::SComponent_var aNotebookComponent = aStudyBuilder->NewComponent( "NOTEBOOK" );
+    SALOMEDS::SComponent_var aNotebookComponent = FindComponent( "NOTEBOOK" );
+    if( CORBA::is_nil( aNotebookComponent ) )
+    {
+      //Creation of default component for the Notebook
+      SALOMEDS::GenericAttribute_var anAttr;
+      aNotebookComponent = aStudyBuilder->NewComponent( "NOTEBOOK" );
 
-    anAttr = aStudyBuilder->FindOrCreateAttribute( aNotebookComponent, "AttributeName" );
-    SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow( anAttr );
-    aName->SetValue( "Notebook" );
-    aName->Destroy();
+      anAttr = aStudyBuilder->FindOrCreateAttribute( aNotebookComponent, "AttributeName" );
+      SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow( anAttr );
+      aName->SetValue( "Notebook" );
+      aName->Destroy();
 
-    anAttr = aStudyBuilder->FindOrCreateAttribute( aNotebookComponent, "AttributePixMap" );
-    SALOMEDS::AttributePixMap_var aPixMap = SALOMEDS::AttributePixMap::_narrow( anAttr );
-    aPixMap->SetPixMap( "ICON_OBJBROWSER_Notebook" );
-    aPixMap->Destroy();
+      anAttr = aStudyBuilder->FindOrCreateAttribute( aNotebookComponent, "AttributePixMap" );
+      SALOMEDS::AttributePixMap_var aPixMap = SALOMEDS::AttributePixMap::_narrow( anAttr );
+      aPixMap->SetPixMap( "ICON_OBJBROWSER_Notebook" );
+      aPixMap->Destroy();
 
-    SALOME_NotebookDriver* aDriver = new SALOME_NotebookDriver();
-    SALOMEDS::Driver_var aDriverVar = aDriver->_this();
-    aStudyBuilder->DefineComponentInstance( aNotebookComponent, aDriverVar._retn() );
+      aStudyBuilder->DefineComponentInstance( aNotebookComponent, SALOME_NotebookDriver::getInstance() );
+    }
   }
 
   return SALOME::Notebook::_duplicate( myNotebook );
index 5c266e1dd72a853c242563049b34ad28e944253c..4420d17329d66aac841d454b46fff36a2763773f 100644 (file)
@@ -1137,6 +1137,10 @@ bool SALOMEDSImpl_Study::DumpStudy(const string& thePath,
     else
       aSeq.push_back(aCompType);
   }
+  
+  //The notebook should be first in the list
+  aSeq.erase( find( aSeq.begin(), aSeq.end(), "NOTEBOOK" ) );
+  aSeq.insert( aSeq.begin(), "NOTEBOOK" );
 
 #ifdef WIN32
   string aFileName =