From: rnv Date: Thu, 21 Nov 2013 10:38:52 +0000 (+0000) Subject: Issue "0021757: EDF 1829 : Activate bring to front action on simple selection of... X-Git-Tag: BR_hydro_v_0_3_1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7cb2566ca61753bad42effb02d972c25c58aea1e;p=modules%2Fgeom.git Issue "0021757: EDF 1829 : Activate bring to front action on simple selection of an object": additional patch from Renaud NEDELEC. --- diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 25b53507c..bdf31b968 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -75,7 +75,7 @@ #include #include -#include +// #include #include #include @@ -200,7 +200,8 @@ void GeometryGUI::Modified (bool theIsUpdateActions) // purpose : Constructor //======================================================================= GeometryGUI::GeometryGUI() : - SalomeApp_Module( "GEOM" ) + SalomeApp_Module( "GEOM" ), + myTopLevelIOList() { if ( CORBA::is_nil( myComponentGeom ) ) { @@ -2084,7 +2085,7 @@ void GeometryGUI::onAutoBringToFront() bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" ); if( !isAutoBringToFront ) return; - + SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow(); if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() ) return; @@ -2093,36 +2094,42 @@ void GeometryGUI::onAutoBringToFront() if (!appStudy) return; GEOM_Displayer displayer( appStudy ); - + SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; - + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); - + SALOME_ListIO selected; getApp()->selectionMgr()->selectedObjects( selected ); - SALOME_ListIO allObjects; - window->GetVisible( allObjects ); - - for ( SALOME_ListIteratorOfListIO It( allObjects ); It.More(); It.Next() ) { - Handle( SALOME_InteractiveObject ) io = It.Value(); - bool isSelected = false; - for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { - Handle( SALOME_InteractiveObject ) ioSelected = It.Value(); - if( io->isSame( ioSelected ) ) - isSelected = true; - } - QVariant v = appStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), QVariant() ); - bool isTopLevel = v.isValid() ? v.toBool() : false; - if( isSelected && !isTopLevel ) { - appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true ); - if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); - } - else if( !isSelected ) { - appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false ); - if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + if (!myTopLevelIOList.IsEmpty()) + { + for( SALOME_ListIteratorOfListIO It( myTopLevelIOList ); It.More(); It.Next() ) + { + Handle( SALOME_InteractiveObject ) io = It.Value(); + bool isSelected = false; + for( SALOME_ListIteratorOfListIO It_sel( selected ); It_sel.More(); It_sel.Next() ) + { + Handle( SALOME_InteractiveObject ) sel_io = It_sel.Value(); + if( io->isSame( sel_io ) ) + isSelected = true; + } + if (!isSelected && appStudy->findObjectByEntry(io->getEntry())) + { + appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } } } + + myTopLevelIOList.Assign(selected); + for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) + { + Handle( SALOME_InteractiveObject ) io = It.Value(); + appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); GeometryGUI::Modified(); } diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 3d4af608b..0ffe7ce93 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -57,6 +57,8 @@ #include "SALOMEconfig.h" #include CORBA_CLIENT_HEADER(SALOMEDS) +#include + class QDialog; class QMenu; class QAction; @@ -231,6 +233,8 @@ private: int myLocalSelectionMode; //Select Only GEOMGUI_CreationInfoWdg* myCreationInfoWdg; + + SALOME_ListIO myTopLevelIOList; friend class DisplayGUI; };