Salome HOME
0021180: EDF 1772 SMESH: Set of hypothesis in 1D
authorvsr <vsr@opencascade.com>
Wed, 9 Feb 2011 15:25:51 +0000 (15:25 +0000)
committervsr <vsr@opencascade.com>
Wed, 9 Feb 2011 15:25:51 +0000 (15:25 +0000)
src/SMESHGUI/SMESHGUI_MeshDlg.cxx
src/SMESHGUI/SMESHGUI_MeshOp.cxx

index 9a4eab9d1ac5601bc3784c139e60c93401d3425e..dee5e025f6d4e074e2bea69ace63166673a64692 100644 (file)
@@ -479,9 +479,13 @@ void SMESHGUI_MeshDlg::setMaxHypoDim( const int maxDim )
   const int DIM = maxDim;
   for ( int dim = Dim0D; dim <= Dim3D; ++dim ) {
     bool enable = ( dim <= DIM );
   const int DIM = maxDim;
   for ( int dim = Dim0D; dim <= Dim3D; ++dim ) {
     bool enable = ( dim <= DIM );
-    if ( !enable )
+    if ( !enable ) {
       myTabs[ dim ]->reset();
       myTabs[ dim ]->reset();
-    myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ dim ] ), enable );
+      disableTab( dim );
+    }
+    else {
+      enableTab( dim );
+    }
   }
   // deselect desabled tab
   if ( !myTabWg->isTabEnabled( myTabWg->currentIndex() ) )
   }
   // deselect desabled tab
   if ( !myTabWg->isTabEnabled( myTabWg->currentIndex() ) )
@@ -507,7 +511,7 @@ void SMESHGUI_MeshDlg::setHypoSets( const QStringList& theSets )
   for ( int i = 0, n = theSets.count(); i < n; i++ ) {
     aHypoSetPopup->addAction( theSets[ i ] );
   }
   for ( int i = 0, n = theSets.count(); i < n; i++ ) {
     aHypoSetPopup->addAction( theSets[ i ] );
   }
-  myHypoSetButton->setEnabled( !aHypoSetPopup->isEmpty() );
+  myHypoSetButton->setEnabled( !aHypoSetPopup->isEmpty() && isTabEnabled( Dim3D ) );
 }
 
 //================================================================================
 }
 
 //================================================================================
@@ -565,6 +569,7 @@ void SMESHGUI_MeshDlg::setGeomPopupEnabled( const bool enable )
 //================================================================================
 void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false );
 //================================================================================
 void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), false );
+  if ( theTabId == Dim3D ) myHypoSetButton->setEnabled( false );
 }
 
 //================================================================================
 }
 
 //================================================================================
@@ -575,6 +580,10 @@ void SMESHGUI_MeshDlg::disableTab(const int theTabId) {
 //================================================================================
 void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true );
 //================================================================================
 void SMESHGUI_MeshDlg::enableTab(const int theTabId) {
   myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ theTabId ] ), true );
+  if ( theTabId == Dim3D ) {
+    QMenu* aHypoSetPopup = myHypoSetButton->menu();
+    myHypoSetButton->setEnabled( aHypoSetPopup && !aHypoSetPopup->actions().isEmpty() );
+  }
 }
 
 //================================================================================
 }
 
 //================================================================================
index e0d17b7343ae8fcf2cd11e84c423ed6d8ee6c2c9..48806273dc28b53edc80c7b25ad8a62c844ea592 100644 (file)
@@ -474,7 +474,7 @@ void SMESHGUI_MeshOp::selectionDone()
     {
       // Enable tabs according to shape dimension
 
     {
       // Enable tabs according to shape dimension
 
-      int shapeDim = 3;
+      int shapeDim = -1;
 
       QStringList aGEOMs;
       myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
 
       QStringList aGEOMs;
       myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
@@ -504,7 +504,7 @@ void SMESHGUI_MeshOp::selectionDone()
       }
 
       if (aSeq->length() > 0) {
       }
 
       if (aSeq->length() > 0) {
-        shapeDim = 0;
+        //shapeDim = 0;
         for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
           GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
           switch ( aGeomVar->GetShapeType() ) {
         for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
           GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
           switch ( aGeomVar->GetShapeType() ) {
@@ -512,18 +512,15 @@ void SMESHGUI_MeshOp::selectionDone()
           case GEOM::SHELL:
             {
               //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
           case GEOM::SHELL:
             {
               //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
-              shapeDim = (shapeDim < 2) ? 2 : shapeDim;
               TopoDS_Shape aShape;
               TopoDS_Shape aShape;
-              if (GEOMBase::GetShape(aGeomVar, aShape)) {
-                if (/*aShape.Closed()*/BRep_Tool::IsClosed(aShape))
-                  shapeDim = 3;
-              }
+             bool isClosed = GEOMBase::GetShape(aGeomVar, aShape) && /*aShape.Closed()*/BRep_Tool::IsClosed(aShape);
+              shapeDim = qMax(isClosed ? 3 : 2, shapeDim);
             }
             break;
             }
             break;
-          case GEOM::FACE:   shapeDim = (shapeDim < 2) ? 2 : shapeDim; break;
+          case GEOM::FACE:   shapeDim = qMax(2, shapeDim); break;
           case GEOM::WIRE:
           case GEOM::WIRE:
-          case GEOM::EDGE:   shapeDim = (shapeDim < 1) ? 1 : shapeDim; break;
-          case GEOM::VERTEX: break;
+          case GEOM::EDGE:   shapeDim = qMax(1, shapeDim); break;
+          case GEOM::VERTEX: shapeDim = qMax(0, shapeDim); break;
           default:
             {
               TopoDS_Shape aShape;
           default:
             {
               TopoDS_Shape aShape;
@@ -531,18 +528,18 @@ void SMESHGUI_MeshOp::selectionDone()
                 TopExp_Explorer exp (aShape, TopAbs_SHELL);
                 if (exp.More()) {
                   //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
                 TopExp_Explorer exp (aShape, TopAbs_SHELL);
                 if (exp.More()) {
                   //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
-                  shapeDim = (shapeDim < 2) ? 2 : shapeDim;
+                  shapeDim = qMax(2, shapeDim);
                   for (; exp.More() && shapeDim == 2; exp.Next()) {
                     if (/*exp.Current().Closed()*/BRep_Tool::IsClosed(exp.Current()))
                       shapeDim = 3;
                   }
                 }
                 else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
                   for (; exp.More() && shapeDim == 2; exp.Next()) {
                     if (/*exp.Current().Closed()*/BRep_Tool::IsClosed(exp.Current()))
                       shapeDim = 3;
                   }
                 }
                 else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
-                  shapeDim = (shapeDim < 2) ? 2 : shapeDim;
+                  shapeDim = qMax(2, shapeDim);
                 else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
                 else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
-                  shapeDim = (shapeDim < 1) ? 1 : shapeDim;
-                else
-                  ;//shapeDim = 0;
+                  shapeDim = qMax(1, shapeDim);
+                else if ( exp.Init( aShape, TopAbs_VERTEX ), exp.More() )
+                  shapeDim = qMax(0, shapeDim);
               }
             }
           }
               }
             }
           }