From a7e7892e048c92757f41654347af6e5dbb35b794 Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 24 Nov 2009 10:15:41 +0000 Subject: [PATCH] debug of load and dump to python of notebook --- src/SALOMEDS/SALOMEDS_Driver_i.cxx | 2 +- src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 6 ++++- src/SALOMEDS/SALOMEDS_Study_i.cxx | 30 +++++++++++++----------- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 4 ++++ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.cxx b/src/SALOMEDS/SALOMEDS_Driver_i.cxx index 0aec6fc2d..b92264ce2 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.cxx @@ -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); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index d3e97bee6..ce1259c5b 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -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(); } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 62e1b8428..2f21c45e2 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -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 ); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 5c266e1dd..4420d1732 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -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 = -- 2.39.2