From: mpa Date: Tue, 6 Aug 2013 14:37:17 +0000 (+0000) Subject: Implementation of 0021757: EDF 1829 : Activate bring to front action on simple select... X-Git-Tag: BR_hydro_v_0_3_1~147 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e688f2b77fb43e644dbf580365e16394ec2b8461;p=modules%2Fgeom.git Implementation of 0021757: EDF 1829 : Activate bring to front action on simple selection of an object --- diff --git a/doc/salome/gui/GEOM/images/pref15.png b/doc/salome/gui/GEOM/images/pref15.png index f58d73091..b3b4df0f2 100755 Binary files a/doc/salome/gui/GEOM/images/pref15.png and b/doc/salome/gui/GEOM/images/pref15.png differ diff --git a/doc/salome/gui/GEOM/input/geometry_preferences.doc b/doc/salome/gui/GEOM/input/geometry_preferences.doc index d9301d5bb..ab98a8281 100644 --- a/doc/salome/gui/GEOM/input/geometry_preferences.doc +++ b/doc/salome/gui/GEOM/input/geometry_preferences.doc @@ -44,6 +44,8 @@ predefined materials.
  • Isolines width - allows to define default width of the isolines.
  • Preview edges width - allows to define width of the edges for preview.
  • Measures line width - allows to define lines width of measurements tools.
  • +
  • Automatic bring to front - when option is ON: the objects selected by the user will be automatically +made "top-level".
  • diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index c090dbbd9..9ae0a597f 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -159,6 +160,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const v = isVectorsMode( idx ); else if ( p == "topLevel" ) v = topLevel( idx ); + else if ( p == "autoBringToFront" ) + v = autoBringToFront( idx ); else if ( p == "hasChildren" ) v = hasChildren( idx ); else if ( p == "nbChildren" ) @@ -352,6 +355,11 @@ QString GEOMGUI_Selection::displayMode( const int index ) const return res; } +bool GEOMGUI_Selection::autoBringToFront( const int /*index*/ ) const +{ + return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" ); +} + bool GEOMGUI_Selection::isVectorsMode( const int index ) const { #ifdef USE_VISUAL_PROP_MAP diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index fddb4df4c..1d470c963 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -73,6 +73,7 @@ private: bool hasDisclosedChildren( const int ) const; bool compoundOfVertices( const int ) const; bool topLevel( const int ) const; + bool autoBringToFront( const int ) const; bool isPhysicalMaterial( const int ) const; bool isComponent( const int ) const; diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 718477015..8ca73f466 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -3236,6 +3236,10 @@ Please, select face, shell or solid and try again PREF_MEASURES_LINE_WIDTH Measures lines width + + PREF_AUTO_BRING_TO_FRONT + Automatic bring to front + PREF_ISOS Number of isolines diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index 0d165390f..fa0c70000 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -3242,6 +3242,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau PREF_MEASURES_LINE_WIDTH Epaisseur des traits de mesure + + PREF_AUTO_BRING_TO_FRONT + Afficher au premier plan automatiquement + PREF_ISOS Nombre d'isolignes diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index e63309a01..10ce0ffee 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1292,10 +1292,10 @@ void GeometryGUI::initialize( CAM_Application* app ) //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false"; QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true"; mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front - mgr->setRule(action(GEOMOp::OpBringToFront), bringRule, QtxPopupMgr::VisibleRule ); + mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule ); mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule ); mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front - mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule ); + mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule ); #endif mgr->insert( separator(), -1, -1 ); // ----------- dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu @@ -1474,6 +1474,8 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) LightApp_SelectionMgr* sm = getApp()->selectionMgr(); connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() )); + connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() )); + if ( !myCreationInfoWdg ) myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() ); getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg ); @@ -1755,6 +1757,54 @@ void GeometryGUI::updateCreationInfo() } } +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; + + SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() ); + 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 ); + } + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + QString GeometryGUI::engineIOR() const { if ( !CORBA::is_nil( GetGeomGen() ) ) @@ -1960,6 +2010,9 @@ void GeometryGUI::createPreferences() setPreferenceProperty( wd[i], "min", 1 ); setPreferenceProperty( wd[i], "max", 5 ); } + + addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup, + LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" ); int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId ); setPreferenceProperty( isoGroup, "columns", 2 ); diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index d7b820851..cbef549b6 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -168,6 +168,7 @@ private slots: void OnSetMaterial( const QString& ); void updateMaterials(); void updateCreationInfo(); + void onAutoBringToFront(); signals : void SignalDeactivateActiveDialog();