Salome HOME
Implementation of the "0021239: EDF 1829 OCC: Bring to front selected objects" issue.
authorrnv <rnv@opencascade.com>
Tue, 13 Mar 2012 08:41:21 +0000 (08:41 +0000)
committerrnv <rnv@opencascade.com>
Tue, 13 Mar 2012 08:41:21 +0000 (08:41 +0000)
19 files changed:
doc/salome/gui/GEOM/images/bring_example.png [new file with mode: 0755]
doc/salome/gui/GEOM/images/dialog.png
doc/salome/gui/GEOM/input/bring_to_front.doc [new file with mode: 0644]
doc/salome/gui/GEOM/input/viewing_geom_obj.doc
resources/SalomeApp.xml.in
src/GEOMGUI/GEOMGUI_Selection.cxx
src/GEOMGUI/GEOMGUI_Selection.h
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GeometryGUI.cxx
src/GEOMGUI/GeometryGUI.h
src/GEOMGUI/GeometryGUI_Operations.h
src/GEOMToolsGUI/GEOMToolsGUI.cxx
src/GEOMToolsGUI/GEOMToolsGUI.h
src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
src/OBJECT/GEOM_AISShape.cxx
src/OBJECT/GEOM_AISShape.hxx
src/OBJECT/GEOM_Actor.cxx
src/OBJECT/GEOM_Constants.h

diff --git a/doc/salome/gui/GEOM/images/bring_example.png b/doc/salome/gui/GEOM/images/bring_example.png
new file mode 100755 (executable)
index 0000000..62be78d
Binary files /dev/null and b/doc/salome/gui/GEOM/images/bring_example.png differ
index 19f374314eeb776b51856e877f6484c18123bdbc..09459032fef0d6c24d132e22cf060817ae2dc0e0 100755 (executable)
Binary files a/doc/salome/gui/GEOM/images/dialog.png and b/doc/salome/gui/GEOM/images/dialog.png differ
diff --git a/doc/salome/gui/GEOM/input/bring_to_front.doc b/doc/salome/gui/GEOM/input/bring_to_front.doc
new file mode 100644 (file)
index 0000000..efb29e1
--- /dev/null
@@ -0,0 +1,10 @@
+/*!
+
+\page bring_to_front_page Bring To Front
+
+\n This option is relevant for better viewing of the complex 3D models. 
+This item allow to bring to front of viewer selected geometrical object.
+
+\image html bring_example.png
+
+*/
index b269619a94c0d938fb499d97c0cce4835bc5cad3..fdb4e7798cfc1d0c573bcbfa2d0462037f9115be 100644 (file)
@@ -21,6 +21,10 @@ object.</li>
 viewer and from the Object Browser.</li> 
 <li>\subpage display_mode_page "Display Mode" - allows to select between
 Wireframe and Shading presentation.</li>
+<li>\subpage bring_to_front_page "Bring To Front" - allows to bring to 
+front of the viewer selected geometrical object.</li>
+<li><b>Clear Top Level State</b> - allows to remove from foregroung of the viewer 
+geometrical objects which were added there via <b>Bring To Front</b> command.</li>
 <li>\subpage color_page "Color" - allows to change the filling color in
 the standard <b>Select Color</b> menu.</li>
 <li>\subpage transparency_page "Transparency" - allows to change the
index f910e65699456ddd4313ed89bacf37b8807c0279..ae902aa02f7ac551709abb44a1a6fb8b12c5fadb 100644 (file)
@@ -49,6 +49,7 @@
     <parameter name="line_color"          value="255, 0, 0" />
     <parameter name="point_color"         value="255, 255, 0" />
     <parameter name="isos_color"          value="200, 200, 200" />
+    <parameter name="toplevel_color"      value="170, 85, 0" />
     <parameter name="type_of_marker"      value="1"  />
     <parameter name="deflection_coeff"    value="0.001"  />
     <parameter name="auto_create_base_objects" value="false"  />
index ca089eb234200b03ee4dc9069f68e09ab8c2b0c5..d7977004b83faaff7ab2e8806fc752856843b98a 100644 (file)
@@ -149,6 +149,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
     v = isAutoColor( idx );
   else if ( p == "isVectorsMode" )
     v = isVectorsMode( idx );
+  else if ( p == "topLevel" )
+    v = topLevel( idx );
   else if ( p == "hasHiddenChildren" )
     v = hasHiddenChildren( idx );
   else if ( p == "hasShownChildren" )
@@ -512,3 +514,40 @@ QString GEOMGUI_Selection::selectionMode() const
   }
   return "";
 }
+
+bool GEOMGUI_Selection::topLevel( const int index ) const {
+  bool res = false;
+  
+#ifdef USE_VISUAL_PROP_MAP
+  bool found = false;
+  QVariant v = visibleProperty( entry( index ), TOP_LEVEL_PROP );
+  if ( v.canConvert<bool>() ) {
+    res = v.toBool();
+    found = true;
+  }
+
+  if ( !found ) {
+#endif
+    SALOME_View* view = GEOM_Displayer::GetActiveView();
+    QString viewType = activeViewType();
+    if ( view && viewType == OCCViewer_Viewer::Type() ) {
+      SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
+      if ( prs ) {
+       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
+         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
+         AIS_ListOfInteractive lst;
+         occPrs->GetObjects( lst );
+         if ( lst.Extent() ) {
+           Handle(AIS_InteractiveObject) io = lst.First();
+           if ( !io.IsNull() ) {
+             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
+             if ( !aSh.IsNull() )
+               res = (bool)aSh->isTopLevel();
+           }
+         }
+       }
+      }
+    }
+  }
+  return res;
+}
index edcdcfada44bbc6cbad62e2658d3a87006ebfa4b..ed9ed7182a4d0411f86c06187c37f8a51258637f 100644 (file)
@@ -69,6 +69,7 @@ private:
   bool                  hasHiddenChildren( const int ) const;
   bool                  hasShownChildren( const int ) const;
   bool                  compoundOfVertices( const int ) const;
+  bool                  topLevel( const int ) const;
 
   bool                  isComponent( const int ) const;
   GEOM::GEOM_Object_ptr getObject( const int ) const;
index 8d7bb760361c25c80ab02f5b41a011dcb7b61cab..ea0fbcade5092797f0a7eee8352b3e447d006986 100644 (file)
@@ -666,15 +666,18 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
           AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() );
           AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt());
 
-          //Color property
-          if(aPropMap.contains(COLOR_PROP)) {
+         if(aPropMap.contains(TOP_LEVEL_PROP)) {
+           AISShape->setTopLevel( aPropMap.value(TOP_LEVEL_PROP).value<Standard_Boolean>() );
+         } 
+         
+         if(aPropMap.contains(COLOR_PROP)) {
             Quantity_Color  quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
             AISShape->SetShadingColor( quant_col );
           } else
             useObjColor = true;
         }else {
           MESSAGE("myDisplayMode = "<< myDisplayMode)
-          AISShape->SetDisplayMode( myDisplayMode );
+           AISShape->SetDisplayMode( myDisplayMode );
           AISShape->SetShadingColor( myShadingColor );
         }
 
@@ -848,7 +851,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
             AISShape->SetOwnDeviationCoefficient(aDC);
           }
         }
-
+               
         if ( HasTexture() )
         {
           AISShape->SetTextureFileName(TCollection_AsciiString(myTexture.c_str()));
@@ -856,7 +859,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
           AISShape->DisableTextureModulate();
           AISShape->SetDisplayMode(3);
         }
-        
+         
         if ( HasWidth() )
           AISShape->SetWidth( GetWidth() );
 
@@ -899,7 +902,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
                   anAspect->SetTypeOfMarker( myTypeOfMarker );
                   AISShape->Attributes()->SetPointAspect( anAspect );
                 }
-              } else if(!hasColor) {
+              } else if( !hasColor ) {
                 //In case if color wasn't defined in the property map of the object
                 //and GEOM_Object color also wasn't defined get default color from Resource Mgr.
                 QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
@@ -2025,6 +2028,10 @@ PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
   //11. Width of iso-lines
   aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1));
 
+  if(viewer_type == SOCC_Viewer::Type()) {
+
+    aDefaultMap.insert(TOP_LEVEL_PROP, Standard_False);
+  }
 
   return aDefaultMap;
 }
index 0854f89bfadf316cf22de9b129a2c4858c53195e..802b4439457609a07cbb29355949ba8de4404298 100644 (file)
@@ -2363,6 +2363,30 @@ Please, select face, shell or solid and try again</translation>
         <source>MEN_DISPLAY_ONLY</source>
         <translation>Show Only</translation>
     </message>
+    <message>
+        <source>MEN_BRING_TO_FRONT</source>
+        <translation>Bring To Front</translation>
+    </message>
+    <message>
+       <source>TOP_BRING_TO_FRONT</source>
+        <translation>Bring To Front</translation>
+    </message>
+    <message>
+        <source>STB_BRING_TO_FRONT</source>
+        <translation>Bring To Front</translation>
+    </message>
+    <message>
+        <source>MEN_CLS_BRING_TO_FRONT</source>
+        <translation>Clear Top Level State</translation>
+    </message>
+    <message>
+        <source>TOP_CLS_BRING_TO_FRONT</source>
+        <translation>Clear Top Level State</translation>
+    </message>
+    <message>
+        <source>STB_CLS_BRING_TO_FRONT</source>
+        <translation>Clear Top Level State</translation>
+    </message>
     <message>
         <source>MEN_EDGE</source>
         <translation>Edge</translation>
@@ -2935,6 +2959,10 @@ Please, select face, shell or solid and try again</translation>
         <source>PREF_ISOS_COLOR</source>
         <translation>Color of isolines</translation>
     </message>
+    <message>
+        <source>PREF_TOPLEVEL_COLOR</source>
+        <translation>Top level color</translation>
+    </message>
     <message>
         <source>PREF_LINE_COLOR</source>
         <translation>Color of edges, vectors, wires</translation>
index 09aa1abf1c776624b53af80092835db8c370a201..4eebd7280e9e8de2d6240a89399daa1fef6b7a1b 100644 (file)
@@ -426,6 +426,8 @@ void GeometryGUI::OnGUIEvent( int id )
   case GEOMOp::OpMaterialProperties: // POPUP MENU - MATERIAL PROPERTIES
   case GEOMOp::OpEdgeWidth:          // POPUP MENU - LINE WIDTH - EDGE WIDTH
   case GEOMOp::OpIsosWidth:          // POPUP MENU - LINE WIDTH - ISOS WIDTH
+  case GEOMOp::OpBringToFront:       // POPUP MENU - BRING TO FRONT
+  case GEOMOp::OpClsBringToFront:    //
     libName = "GEOMToolsGUI";
     break;
   case GEOMOp::OpDisplayMode:        // MENU VIEW - WIREFRAME/SHADING
@@ -844,6 +846,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( GEOMOp::OpSelectCompound,   "COMPOUND_SEL_ONLY", "",  0, true );
   createGeomAction( GEOMOp::OpSelectAll,        "ALL_SEL_ONLY", "",  0, true );
   createGeomAction( GEOMOp::OpShowOnly,         "DISPLAY_ONLY" );
+  createGeomAction( GEOMOp::OpBringToFront,     "BRING_TO_FRONT", "", 0, true );
+  createGeomAction( GEOMOp::OpClsBringToFront,  "CLS_BRING_TO_FRONT" );
   createGeomAction( GEOMOp::OpHide,             "ERASE" );
 
   createGeomAction( GEOMOp::OpWireframe,        "POP_WIREFRAME", "", 0, true );
@@ -1216,6 +1220,17 @@ void GeometryGUI::initialize( CAM_Application* app )
   mgr->insert( action(  GEOMOp::OpGroupEdit ), -1, -1 );  // edit group
   mgr->setRule( action( GEOMOp::OpGroupEdit ),  QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule );
   mgr->insert( separator(), -1, -1 );     // -----------
+
+#if OCC_VERSION_LARGE > 0x06050200
+  //QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
+  QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) 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), "topLevel=true", QtxPopupMgr::ToggleRule );
+  mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
+  mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule );  
+#endif
+  mgr->insert( separator(), -1, -1 );     // -----------
   dispmodeId = mgr->insert(  tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
   mgr->insert( action(  GEOMOp::OpWireframe ), dispmodeId, -1 ); // wireframe
   mgr->setRule( action( GEOMOp::OpWireframe ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
@@ -1308,7 +1323,6 @@ void GeometryGUI::initialize( CAM_Application* app )
   mgr->setRule(action(GEOMOp::OpSelectAll),      selectOnly + " and selectionmode='ALL'", QtxPopupMgr::ToggleRule);
   mgr->insert( action(GEOMOp::OpShowOnly ), -1, -1 ); // display only
   mgr->setRule(action(GEOMOp::OpShowOnly ), rule.arg( types ).arg( "true" ), QtxPopupMgr::VisibleRule );
-  mgr->insert( separator(), -1, -1 );
 
   mgr->insert( separator(), -1, -1 );     // -----------
   mgr->insert( action(  GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
@@ -1693,6 +1707,12 @@ void GeometryGUI::createPreferences()
   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
                  LightApp_Preferences::Color, "Geometry", "isos_color" );
 
+  addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
+                 LightApp_Preferences::Color, "Geometry", "toplevel_color" );
+
+  addPreference( "", genGroup, LightApp_Preferences::Space );
+
+
   int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup,
                             LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" );
 
@@ -1964,6 +1984,13 @@ void GeometryGUI::storeVisualParameters (int savePoint)
             param = occParam + TRANSPARENCY_PROP;
             ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
           }
+
+          if(aProps.contains(TOP_LEVEL_PROP)) {
+            param = occParam + TOP_LEVEL_PROP;
+           Standard_Boolean val = aProps.value(TOP_LEVEL_PROP).value<Standard_Boolean>();
+           if (val == Standard_True) 
+             ip->setParameter(entry, param, "1");
+          }      
         }
 
         if(aProps.contains(ISOS_PROP)) {
@@ -2092,9 +2119,12 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
       } else if(paramNameStr == OPACITY_PROP) {
         aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
 
-      }        else if(paramNameStr == TRANSPARENCY_PROP) {
-        aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble());
+      } else if(paramNameStr == TRANSPARENCY_PROP) {
+        aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val.toDouble() );
 
+      }        else if(paramNameStr == TOP_LEVEL_PROP) {
+         aListOfMap[viewIndex].insert( TRANSPARENCY_PROP, val == "1" ? Standard_True : Standard_False );
+         
       } else if(paramNameStr == DISPLAY_MODE_PROP) {
         aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
 
@@ -2179,6 +2209,15 @@ void GeometryGUI::onViewAboutToShow()
   }
 }
 
+/*!
+  \brief Return action by id
+  \param id identifier of the action
+  \return action 
+*/
+QAction* GeometryGUI::getAction(const int id) {
+  return action(id);
+}
+
 /*!
   \brief Check if this object is can't be renamed in place
 
index b584fd7e32e07685154aada5ed31f0019fed5813..ccb81254b5619d93123844c41bc6a4b0d5319f19 100644 (file)
@@ -56,6 +56,7 @@
 
 class QDialog;
 class QMenu;
+class QAction;
 class GEOMGUI_OCCSelector;
 class LightApp_VTKSelector;
 class LightApp_Selection;
@@ -131,6 +132,8 @@ public:
   virtual void storeVisualParameters  (int savePoint);
   virtual void restoreVisualParameters(int savePoint);
 
+  QAction*                    getAction(const int id);
+
 public slots:
   virtual bool                deactivateModule( SUIT_Study* );
   virtual bool                activateModule( SUIT_Study* );
index a4ad5eadfd034fafb60061e032aac68e006f55da..c21e405e2633e9203f2bea28c14698d661a3b7df 100644 (file)
@@ -70,6 +70,8 @@ namespace GEOMOp {
     OpShadingWithEdges    = 2202,   // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES
     OpVectors             = 2203,   // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION
     OpTexture             = 2204,   // POPUP MENU - DISPLAY MODE - TEXTURE
+    OpBringToFront        = 2205,   // POPUP MENU - BRING TO FRONT
+    OpClsBringToFront     = 2206,
     // BasicGUI ------------------//--------------------------------
     OpPoint               = 3000,   // MENU NEW ENTITY - BASIC - POINT
     OpLine                = 3001,   // MENU NEW ENTITY - BASIC - LINE
index 05259bf29461815a486f7667182178168a0ca20f..0234bd4bc9920f681d8d7488f96524093d6251eb 100644 (file)
@@ -373,6 +373,12 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   case GEOMOp::OpIsosWidth:
     OnIsosWidth();
     break;
+  case GEOMOp::OpBringToFront:
+    OnBringToFront();
+    break;
+  case GEOMOp::OpClsBringToFront:
+    OnClsBringToFront();
+     break;
   default:
     SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
     break;
index 2141f0c97cf9cd7c7587fa23606fc4dd2e2baf5e..e6b80f3cc7faa63f30fc20920ee15d23752f0995 100644 (file)
@@ -78,6 +78,8 @@ private:
   void         OnMaterialProperties();
   void         OnEdgeWidth();
   void         OnIsosWidth();
+  void         OnBringToFront();
+  void         OnClsBringToFront();
 
   // Shortcut commands
   void         OnChangeTransparency( bool );
index 31b734b330d6975bc936e9860b8ac784281a12d8..3a002dbfa9bc95c56b47ff477e0518016912a473 100644 (file)
@@ -23,6 +23,8 @@
 //  File   : GEOMToolsGUI_1.cxx
 //  Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
 
+#define protected public
+
 #include <PyConsole_Console.h>
 
 #include "GEOMToolsGUI.h"
@@ -81,6 +83,9 @@
 #include <Prs3d_PointAspect.hxx>
 #include <Graphic3d_AspectMarker3d.hxx>
 #include <Graphic3d_AspectLine3d.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_ListOfInteractive.hxx>
+
 
 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
 #include <TColStd_HArray1OfByte.hxx>
@@ -89,6 +94,7 @@
 #endif
 
 // QT Includes
+#include <QAction>
 #include <QColorDialog>
 #include <QInputDialog>
 #include <QFileDialog>
 // VTK includes
 #include <vtkRenderer.h>
 
-
 void GEOMToolsGUI::OnCheckGeometry()
 {
   SalomeApp_Application* app =
@@ -296,13 +301,17 @@ void GEOMToolsGUI::OnColor()
           }
         } // if ( isVTK )
         else if ( isOCC ) {
-          Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
+         Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
           if ( !io.IsNull() ) {
             Quantity_Color aColor;
-            io->Color( aColor );
-            QColor initcolor ((int)( aColor.Red() * 255.0 ),
-                              (int)( aColor.Green() * 255.0 ),
-                              (int)( aColor.Blue() * 255.0 ));
+            io->Color( aColor ); 
+           QColor ic = QColor((int )( aColor.Red() * 255.0 ),
+                             (int)( aColor.Green() * 255.0 ),
+                             (int)( aColor.Blue() * 255.0 ));      
+
+           QVariant v = appStudy->getObjectProperty(mgrId,selected.First()->getEntry(), COLOR_PROP, ic);
+
+            QColor initcolor = v.value<QColor>();
             QColor c =  QColorDialog::getColor( initcolor, app->desktop() );
             if ( c.isValid() ) {
               SUIT_OverrideCursor();
@@ -343,16 +352,16 @@ void GEOMToolsGUI::OnColor()
                       ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
                     }
                   }
-
+                 
                   io->SetColor( aColor );
                   if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
                     Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
                    aGAISShape->SetShadingColor( aColor );
                    aGAISShape->storeBoundaryColors();
                  }
-
+                 
                   appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
-
+                 
                   io->Redisplay( Standard_True );
 
                   // store color to GEOM_Object
@@ -367,7 +376,7 @@ void GEOMToolsGUI::OnColor()
                   aSColor.G = (double)c.green() / 255.0;
                   aSColor.B = (double)c.blue() / 255.0;
                   anObject->SetColor( aSColor );
-                  anObject->SetAutoColor( false );
+                  anObject->SetAutoColor( false );               
                 }
               } // for
               ic->UpdateCurrentViewer();
@@ -406,8 +415,8 @@ void GEOMToolsGUI::OnTexture()
               io = GEOMBase::GetAIS( It.Value(), true );
               if ( !io.IsNull() ) {
                 if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
-                  Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str()));
-                io->Redisplay( Standard_True );
+                 Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str()));
+               io->Redisplay( Standard_True );
               } // if ( !io.IsNull() )
             } // for
             ic->UpdateCurrentViewer();
@@ -570,7 +579,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType )
         Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
 
        QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP , QVariant() );
-       
+
        int width = v.isValid() ? v.toInt() : 1;
 
         CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width , newNbUIso) );
@@ -1187,3 +1196,112 @@ void GEOMToolsGUI::OnIsosWidth() {
     GeometryGUI::Modified();
   } // end vtkviewer  
 }
+
+void GEOMToolsGUI::OnBringToFront() {
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( !app )
+    return;
+
+  SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
+  if(!mod)
+    return;
+  
+  GEOM_Displayer* disp  = dynamic_cast<GEOM_Displayer*>(mod->displayer());
+  
+  if(!disp)
+    return;
+  
+  LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+  if ( !aSelMgr )
+    return;
+
+  SALOME_ListIO selected;
+  aSelMgr->selectedObjects( selected );
+  if ( selected.IsEmpty() )
+    return;
+
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());  
+  if(!appStudy)
+    return;
+
+  SUIT_ViewWindow* window = app->desktop()->activeWindow();
+
+  OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+  if ( !vm )
+    return;
+  
+  bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+
+  QAction* a = getGeometryGUI()->action( GEOMOp::OpBringToFront );
+  bool checked = a->isChecked();
+  
+  if ( isOCC ) {
+    GEOMBase* gb = new GEOMBase();
+    Handle(GEOM_AISShape) aisShape;
+   
+    Handle(AIS_InteractiveContext) ic = vm->getAISContext();
+    SALOME_ListIO anIOlst;
+    for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+      aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
+      if ( !aisShape.IsNull() ) {
+       aisShape->setTopLevel(checked);
+       int aMgrId = window->getViewManager()->getGlobalId();
+       appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked );
+       anIOlst.Append(aisShape->getIO());
+      }
+    } // for...
+    disp->Redisplay(anIOlst);
+    GeometryGUI::Modified();
+  } // if ( isOCC )
+}
+
+void GEOMToolsGUI::OnClsBringToFront() {
+  SalomeApp_Application* app =
+    dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if(!app)
+    return;
+
+  SalomeApp_Module* mod = dynamic_cast<SalomeApp_Module*>(app->activeModule());
+  if(!mod)
+    return;
+  
+  GEOM_Displayer* disp  = dynamic_cast<GEOM_Displayer*>(mod->displayer());
+  
+  if(!disp)
+    return;
+
+
+  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());  
+  if(!appStudy)
+    return;
+  
+  SUIT_ViewWindow* window = app->desktop()->activeWindow();  
+  
+  bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
+  
+  if(isOCC){ // if is OCCViewer
+    
+    OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
+    Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+    
+    SALOME_ListIO anIOlst;
+    AIS_ListOfInteractive aList;
+    ic->DisplayedObjects( aList );
+    for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) {
+      
+      Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(it.Value());
+      
+      if(CurObject.IsNull())
+       continue;
+      
+      CurObject->setTopLevel(Standard_False);
+      
+      int aMgrId = window->getViewManager()->getGlobalId();
+      appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False );
+      anIOlst.Append(CurObject->getIO());
+    }
+    disp->Redisplay(anIOlst);
+    GeometryGUI::Modified();
+  }
+}
+  
index 9313c6ee7c66e0b4a33cf2e8d5e08daf8854b4df..81a6dbe1c04670f65a3ec63d9c050d9ea4072f72 100644 (file)
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
 
+#include <SalomeApp_Tools.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
 
 static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
                              const Handle(AIS_InteractiveContext)& theIC,
@@ -139,6 +144,8 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
 
   myUIsoNumber = -1;
   myVIsoNumber = -1;
+
+  myTopLevel = Standard_False;
 }
 
 void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
@@ -174,17 +181,30 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
                             const Standard_Integer aMode)
 {  
   if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
+
+  Handle(AIS_InteractiveContext) anIC = GetContext();
   
-//   StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
+  //   StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
   switch (aMode) {
     case 0://StdSelect_DM_Wireframe: 
     {
+
       restoreIsoNumbers();
 
       // Restore wireframe edges colors
       restoreBoundaryColors();
 
+
+      if(isTopLevel()) {
+       SetColor(topLevelColor());
+
+       Handle(Prs3d_LineAspect) anAspect = Attributes()->WireAspect();
+       anAspect->SetColor( topLevelColor() );
+       Attributes()->SetWireAspect( anAspect );
+      }
+
       StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
+      
       break;
     }
     case 1://StdSelect_DM_Shading:
@@ -200,7 +220,10 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
     }
     case 3: //StdSelect_DM_HLR:
     {
-      AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode);
+      if(!isTopLevel())
+       AIS_TexturedShape::Compute(aPresentationManager, aPrs, aMode);
+      else 
+       shadingMode(aPresentationManager, aPrs, AIS_Shaded);
       break;
     }
   }
@@ -373,7 +396,7 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
       //       P->SetPrimitivesAspect(a4bis);
       //        G->SetGroupPrimitivesAspect(a4bis);
       //a4bis->SetInteriorColor(myShadingColor);
-      myDrawer->ShadingAspect()->SetColor(myShadingColor);
+      myDrawer->ShadingAspect()->SetColor(isTopLevel() ? topLevelColor() : myShadingColor);
 
       // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
       //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
@@ -433,3 +456,19 @@ void GEOM_AISShape::restoreBoundaryColors()
   anAspect->SetColor( myUnFreeBoundaryColor );
   myDrawer->SetUnFreeBoundaryAspect( anAspect );
 }
+
+
+Standard_Boolean GEOM_AISShape::isTopLevel() {
+  return myTopLevel;
+}
+
+void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
+  myTopLevel = f;
+}
+
+Quantity_Color GEOM_AISShape::topLevelColor() {
+  SUIT_Session* session = SUIT_Session::session();
+  SUIT_ResourceMgr* resMgr = session->resourceMgr();
+  QColor c = resMgr->colorValue( "Geometry", "toplevel_color", QColor( 170, 85, 0 ) );
+  return SalomeApp_Tools::color(c);
+}
index 387b3ef37c02d38e2950157b122daf96f0c3a168..21e1c5a7e9831efd0e7a9051561c05acd0f53957 100644 (file)
@@ -99,6 +99,8 @@ public:
         void setIO(const Handle(SALOME_InteractiveObject)& name) ;
         void setName(const Standard_CString aName) ;
         Standard_CString getName() ;
+        Standard_Boolean isTopLevel();
+        void setTopLevel(Standard_Boolean);
         Handle_SALOME_InteractiveObject getIO() ;
         void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight );
         ~GEOM_AISShape();
@@ -126,6 +128,8 @@ public:
 
         void storeBoundaryColors();
 
+       static Quantity_Color topLevelColor();
+
 protected: 
   void shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
                   const Handle(Prs3d_Presentation)& aPrs,
@@ -146,6 +150,7 @@ protected:
 private: 
   TCollection_AsciiString myName;
   bool                    myDisplayVectors;
+  Standard_Boolean        myTopLevel;
 };
 
 
index 9b956bf68619c68e24455218a7ee0aeb988ff6d7..bc9c5c9f19dee6f0d1792b8d58a7d30acb3cac60 100644 (file)
@@ -1012,7 +1012,7 @@ void GEOM_Actor::SetIsosWidth(const int width) {
 }
 
 int GEOM_Actor::GetIsosWidth() const {
-  return myWireframeFaceActor->GetProperty()->GetLineWidth();
+  return (int)myWireframeFaceActor->GetProperty()->GetLineWidth();
 }
 
 void GEOM_Actor::SetWidth(const int width) {
@@ -1025,7 +1025,7 @@ void GEOM_Actor::SetWidth(const int width) {
 }
 
 int GEOM_Actor::GetWidth() const {
-  return myIsolatedEdgeActor->GetProperty()->GetLineWidth();
+  return (int)myIsolatedEdgeActor->GetProperty()->GetLineWidth();
 }
     
 void GEOM_Actor::RestoreIsoNumbers()
index 655dfc12589c1f44cbceee50a61c0968f5f7e670..de4adb9c82ade19fd0e5cf8a4985662f7d327779 100644 (file)
@@ -46,6 +46,7 @@
 #define FRONT_MATERIAL_PROP   "FrontMaterial"   //Object front material property
 #define BACK_MATERIAL_PROP    "BackMaterial"    //Object back material property
 #define EDGE_WIDTH_PROP       "EdgeWidth"       //Width of the edge
-#define ISOS_WIDTH_PROP       "IsosWidth"       //Width of the iso-lines 
+#define ISOS_WIDTH_PROP       "IsosWidth"       //Width of the iso-lines
+#define TOP_LEVEL_PROP        "TopLevelFlag"    //Top level flag
 
 #endif //GEOM_CONSTANTS_H