X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSalomeApp%2FSalomeApp_Study.cxx;h=70bd944cbdf7458bfc2b35f49957c6cbf107c4e3;hb=02904c3728214667f919cfe06072a91e1687b12f;hp=ef989b5a4540d54ee55c16483fe715988a6a61e7;hpb=bb8609caf7881d966fbb88dec0a7822736da93f5;p=modules%2Fgui.git diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index ef989b5a4..70bd944cb 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 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 @@ -6,7 +6,7 @@ // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -41,6 +41,9 @@ #include #include #include +#include +#include +#include #include @@ -183,6 +186,22 @@ public: //aFatherDO->insertChild(suit_obj, pos); aFatherDO->updateItem(); + /* Define visibility state */ + bool isComponent = dynamic_cast( suit_obj ) != 0; + if ( suit_obj && !isComponent && myStudy->visibilityState( theID.c_str() ) == Qtx::UnpresentableState ) { + QString moduleTitle = ((CAM_Application*)myStudy->application())->moduleTitle(suit_obj->componentDataType()); + if (!moduleTitle.isEmpty()) { + LightApp_Displayer* aDisplayer = LightApp_Displayer::FindDisplayer(moduleTitle,false); + if (aDisplayer) { + if(aDisplayer->canBeDisplayed(theID.c_str())) { + myStudy->setVisibilityState( theID.c_str(), Qtx::HiddenState ); //hide the just added object + //MESSAGE("Object with entry : "<< theID <<" CAN be displayed !!!"); + } + else + MESSAGE("Object with entry : "<< theID <<" CAN'T be displayed !!!"); + } + } + } } // END: work with tree nodes structure else { // BEGIN: work with study structure EntryMapIter it = entry2SuitObject.find( theID ); @@ -318,11 +337,13 @@ public: } break; } +#ifndef DISABLE_PYCONSOLE case 6: //NoteBook variables were modified { myStudy->onNoteBookVarUpdate( QString( theID.c_str() ) ); break; } +#endif default:MESSAGE("Unknown event: " << event);break; } //switch } //notifyObserverID_real @@ -386,10 +407,12 @@ SalomeApp_Study::~SalomeApp_Study() } } +#ifndef DISABLE_PYCONSOLE void SalomeApp_Study::onNoteBookVarUpdate( QString theVarName) { emit notebookVarUpdated( theVarName ); } +#endif /*! Gets study id. @@ -411,7 +434,7 @@ QString SalomeApp_Study::studyName() const // it can be changed outside of GUI // TEMPORARILY SOLUTION: better to be implemented with help of SALOMEDS observers if ( studyDS() ) { - QString newName = studyDS()->Name().c_str(); + QString newName = QString::fromUtf8(studyDS()->Name().c_str()); if ( LightApp_Study::studyName() != newName ) { SalomeApp_Study* that = const_cast( this ); that->setStudyName( newName ); @@ -438,7 +461,22 @@ bool SalomeApp_Study::createDocument( const QString& theStr ) // initialize myStudyDS, read HDF file QString aName = newStudyName(); - _PTR(Study) study ( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) ); + + _PTR(Study) study; + try { + study = _PTR(Study)( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) ); + } + catch(const SALOME_Exception& ex) { + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr("ERR_ERROR"), tr(ex.what())); + return false; + } + catch(...) { + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr("ERR_ERROR"), tr("CREATE_DOCUMENT_PROBLEM")); + return false; + } + if ( !study ) return false; @@ -474,7 +512,21 @@ bool SalomeApp_Study::openDocument( const QString& theFileName ) MESSAGE( "openDocument" ); // initialize myStudyDS, read HDF file - _PTR(Study) study ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) ); + _PTR(Study) study; + try { + study = _PTR(Study) ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) ); + } + catch(const SALOME_Exception& ex) { + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr("ERR_ERROR"), tr(ex.what())); + return false; + } + catch(...) { + SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), + tr("ERR_ERROR"), tr("OPEN_DOCUMENT_PROBLEM")); + return false; + } + if ( !study ) return false; @@ -674,7 +726,9 @@ void SalomeApp_Study::closeDocument(bool permanently) _PTR(Study) studyPtr = studyDS(); if ( studyPtr ) { - if(permanently) { + if ( myObserver ) + myStudyDS->detach( myObserver->_this() ); + if ( permanently ) { SalomeApp_Application::studyMgr()->Close( studyPtr ); } SALOMEDSClient_Study* aStudy = 0; @@ -1134,6 +1188,7 @@ void SalomeApp_Study::RemoveTemporaryFiles ( const char* theModuleName, const bo } } +#ifndef DISABLE_PYCONSOLE /*! Mark the study as saved in the file \param theFileName - the name of file @@ -1144,10 +1199,17 @@ void SalomeApp_Study::updateFromNotebook( const QString& theFileName, bool isSav studyDS()->Name(theFileName.toStdString()); setIsSaved( isSaved ); } +#endif LightApp_DataObject* SalomeApp_Study::findObjectByEntry( const QString& theEntry ) { - LightApp_DataObject* o = dynamic_cast( myObserver ? myObserver->findObject( theEntry.toLatin1().constData() ) : 0 ); + LightApp_DataObject* o = 0; + if ( myObserver ) { + o = dynamic_cast( myObserver->findObject( theEntry.toLatin1().constData() ) ); + } + if ( !o ) { + o = LightApp_Study::findObjectByEntry( theEntry ); + } return o; }