X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSalomeApp%2FSalomeApp_Study.cxx;h=8b6f9019350346dbe664bd054a0abb256f9a80a3;hb=d926caff4b6b96185c3deaa0ec548d0ed84af3d9;hp=de81f209175379d068eb96eb0d4c5767caa5989d;hpb=f8db3b7a8b9b34de34783450120aa15a659a2460;p=modules%2Fgui.git diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index de81f2091..8b6f90193 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -14,12 +14,11 @@ SalomeApp_Study::SalomeApp_Study( SUIT_Application* app ) : CAM_Study( app ) -{} - +{ +} SalomeApp_Study::~SalomeApp_Study() { - closeDocument(); } int SalomeApp_Study::id() const @@ -40,11 +39,13 @@ void SalomeApp_Study::createDocument() MESSAGE( "openDocument" ); // initialize myStudyDS, read HDF file - _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( newStudyName().latin1() ) ); + QString aName = newStudyName(); + _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( aName.latin1() ) ); if ( !study ) return; setStudyDS( study ); + setStudyName( aName ); // create myRoot setRoot( new SalomeApp_RootObject( this ) ); @@ -69,24 +70,20 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) setStudyDS( study ); - // build a SUIT_DataObject-s tree under myRoot member field - // 1. create myRoot - setRoot( new SalomeApp_RootObject( this ) ); - // 2. iterate through all components and create corresponding sub-trees under them - _PTR(SComponentIterator) it ( studyDS()->NewComponentIterator() ); - for ( ; it->More(); it->Next() ) { - // don't use shared_ptr here, for Data Object will take - // ownership of this pointer - _PTR(SComponent) aComponent ( it->Value() ); + setRoot( new SalomeApp_RootObject( this ) ); // create myRoot - if ( aComponent->ComponentDataType() == "Interface Applicative" ) - continue; // skip the magic "Interface Applicative" component - - SalomeApp_DataModel::BuildTree( aComponent, root(), this ); - } + // update loaded data models: call open() and update() on them. + ModelList dm_s; + dataModels( dm_s ); + for ( ModelListIterator it( dm_s ); it.current(); ++it ) + openDataModel( studyName(), it.current() ); - bool res = CAM_Study::openDocument( theFileName ); + // this will build a SUIT_DataObject-s tree under myRoot member field + // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step + // but tree that corresponds to not-loaded data models will be updated any way. + ((SalomeApp_Application*)application())->updateObjectBrowser( false ); + bool res = CAM_Study::openDocument( theFileName ); emit opened( this ); return res; @@ -119,16 +116,17 @@ bool SalomeApp_Study::loadDocument( const QString& theStudyName ) if ( aComponent->ComponentDataType() == "Interface Applicative" ) continue; // skip the magic "Interface Applicative" component - + SalomeApp_DataModel::BuildTree( aComponent, root(), this ); } // TODO: potentially unsafe call, since base study's openDocument() might try to access the file directly - to be improved + //bool res = true; bool res = CAM_Study::openDocument( theStudyName ); - emit opened( this ); + //emit opened( this ); - return res; + return res; } //======================================================================= @@ -143,14 +141,15 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName ) for ( ; aModel; aModel = (SalomeApp_DataModel*)list.next() ) aModel->saveAs( theFileName, this ); - bool res = CAM_Study::saveDocumentAs( theFileName ); - // save SALOMEDS document bool isMultiFile = false, isAscii = false;// TODO: This information should be taken from preferences afterwards! - isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) : - SalomeApp_Application::studyMgr()->SaveAs ( theFileName.latin1(), studyDS(), isMultiFile ); + /* bool res = */isAscii ? SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.latin1(), studyDS(), isMultiFile ) : + SalomeApp_Application::studyMgr()->SaveAs ( theFileName.latin1(), studyDS(), isMultiFile ); - emit saved( this ); + bool res = CAM_Study::saveDocumentAs( theFileName ); //SRN: BugID IPAL9377, removed usage of uninitialized variable + + if ( res ) + emit saved( this ); return res; } @@ -181,18 +180,22 @@ void SalomeApp_Study::saveDocument() // Function : closeDocument // Purpose : //================================================================ -void SalomeApp_Study::closeDocument() +void SalomeApp_Study::closeDocument(bool permanently) { // Inform everybody that this study is going to close when it's most safe to, // i.e. in the very beginning emit closed( this ); // close SALOMEDS document - SalomeApp_Application::studyMgr()->Close( studyDS() ); - SALOMEDSClient_Study* aStudy = NULL; - setStudyDS( _PTR(Study)(aStudy) ); + _PTR(Study) studyPtr = studyDS(); + if ( studyPtr ) + { + if(permanently) SalomeApp_Application::studyMgr()->Close( studyPtr ); + SALOMEDSClient_Study* aStudy = 0; + setStudyDS( _PTR(Study)(aStudy) ); + } - CAM_Study::closeDocument(); + CAM_Study::closeDocument(permanently); } //================================================================ @@ -255,7 +258,7 @@ void SalomeApp_Study::dataModelInserted (const CAM_DataModel* dm) aComp = aBuilder->NewComponent(dm->module()->name()); // Set default engine IOR - aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1() ); + aBuilder->DefineComponentInstance(aComp, SalomeApp_Application::defaultEngineIOR().latin1()); } } }