Salome HOME
Implementation of 0021757: EDF 1829 : Activate bring to front action on simple select...
authormpa <mpa@opencascade.com>
Tue, 6 Aug 2013 14:37:17 +0000 (14:37 +0000)
committermpa <mpa@opencascade.com>
Tue, 6 Aug 2013 14:37:17 +0000 (14:37 +0000)
doc/salome/gui/GEOM/images/pref15.png
doc/salome/gui/GEOM/input/geometry_preferences.doc
src/GEOMGUI/GEOMGUI_Selection.cxx
src/GEOMGUI/GEOMGUI_Selection.h
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GEOM_msg_fr.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI.h

index f58d7309121558b538a94d5292b5d65b4a6186bc..b3b4df0f2a084feca2a1dbadc2f0abd01100726d 100755 (executable)
Binary files a/doc/salome/gui/GEOM/images/pref15.png and b/doc/salome/gui/GEOM/images/pref15.png differ
index d9301d5bbd0108443baa1333976931f1caa6f0a8..ab98a8281cf7733296d0b56e4a213c35d4df97ef 100644 (file)
@@ -44,6 +44,8 @@ predefined materials.</li>
 <li><b>Isolines width</b> - allows to define default width of the isolines.</li>
 <li><b>Preview edges width</b> - allows to define width of the edges for preview.</li>
 <li><b>Measures line width</b> - allows to define lines width of measurements tools.</li>
+<li><b>Automatic bring to front</b> - when option is ON: the objects selected by the user will be automatically 
+made "top-level".</li>
 
 </ul>
 </ul>
index c090dbbd9061aa782d9cd733aa54af35c4d9ea81..9ae0a597fa5bfa30ff58e5d83c11749f6bab13d0 100644 (file)
@@ -41,6 +41,7 @@
 #include <SUIT_Desktop.h>
 #include <SUIT_ViewWindow.h>
 #include <SUIT_ViewManager.h>
+#include <SUIT_ResourceMgr.h>
 
 #include <SALOME_Prs.h>
 #include <SALOME_InteractiveObject.hxx>
@@ -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
index fddb4df4ce797a495e8a227ed8de13bdbd740e91..1d470c9639f8fab3dc41f68ad58b06485ecacf2b 100644 (file)
@@ -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;
index 718477015517e317c7d9840c94f77d7b803b87cf..8ca73f4664b445b0ce228f59b95a4fa311d27009 100644 (file)
@@ -3236,6 +3236,10 @@ Please, select face, shell or solid and try again</translation>
         <source>PREF_MEASURES_LINE_WIDTH</source>
         <translation>Measures lines width</translation>
     </message>
+    <message>
+        <source>PREF_AUTO_BRING_TO_FRONT</source>
+        <translation>Automatic bring to front</translation>
+    </message>
     <message>
         <source>PREF_ISOS</source>
         <translation>Number of isolines</translation>
index 0d165390f657bff31278bd29d22325d239ed8daf..fa0c70000ef9f4fc9bc0f9fd3c130bae48f81b62 100644 (file)
@@ -3242,6 +3242,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>PREF_MEASURES_LINE_WIDTH</source>
         <translation>Epaisseur des traits de mesure</translation>
     </message>
+    <message>
+        <source>PREF_AUTO_BRING_TO_FRONT</source>
+        <translation>Afficher au premier plan automatiquement</translation>
+    </message>
     <message>
         <source>PREF_ISOS</source>
         <translation>Nombre d&apos;isolignes</translation>
index e63309a01b696ee5daf4041227d559261ef3f490..10ce0ffee2c90c434defc649d41d73dfb28e1355 100644 (file)
@@ -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 );
index d7b820851f801629408a3f311a0678b992f345c0..cbef549b61a2bf6808083f4024b9b5f267a83e3a 100644 (file)
@@ -168,6 +168,7 @@ private slots:
   void                        OnSetMaterial( const QString& );
   void                        updateMaterials();
   void                        updateCreationInfo();
+  void                        onAutoBringToFront();
 
 signals :
   void                        SignalDeactivateActiveDialog();