From: ouv Date: Wed, 18 Sep 2013 12:26:00 +0000 (+0000) Subject: Storing/restoring selection during the module update. X-Git-Tag: BR_hydro_v_0_1~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e867556dcc52065557442970feb3b4698cd3cc13;p=modules%2Fhydro.git Storing/restoring selection during the module update. --- diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index b6d25267..509fc2e3 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -47,6 +47,7 @@ #include #include +#include #include #include #include @@ -364,6 +365,9 @@ void HYDROGUI_Module::update( const int flags ) // from one of the methods called below setUpdateEnabled( false ); + // store selected objects + QStringList aSelectedEntries = storeSelection(); + if( ( flags & UF_Viewer ) ) updateGV( flags & UF_GV_Init, flags & UF_GV_Forced ); @@ -387,6 +391,9 @@ void HYDROGUI_Module::update( const int flags ) if( ( flags & UF_Controls ) && getApp() ) getApp()->updateActions(); + // restore selected objects + restoreSelection( aSelectedEntries ); + setUpdateEnabled( true ); QApplication::restoreOverrideCursor(); @@ -704,3 +711,34 @@ bool HYDROGUI_Module::isUpdateEnabled() const { return myIsUpdateEnabled; } + +QStringList HYDROGUI_Module::storeSelection() const +{ + QStringList anEntryList; + if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() ) + { + SUIT_DataOwnerPtrList aList( true ); + aSelectionMgr->selected( aList ); + + SUIT_DataOwnerPtrList::iterator anIter; + for( anIter = aList.begin(); anIter != aList.end(); anIter++ ) + { + const LightApp_DataOwner* anOwner = + dynamic_cast( (*anIter).operator->() ); + if( anOwner ) + anEntryList.append( anOwner->entry() ); + } + } + return anEntryList; +} + +void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList ) +{ + if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() ) + { + SUIT_DataOwnerPtrList aList( true ); + for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ ) + aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) ); + aSelectionMgr->setSelected( aList ); + } +}