From 2fee37828a65e600b0a84c8eddda9db0e04d7261 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 9 Feb 2011 15:25:51 +0000 Subject: [PATCH] 0021180: EDF 1772 SMESH: Set of hypothesis in 1D --- src/SMESHGUI/SMESHGUI_MeshDlg.cxx | 15 ++++++++++++--- src/SMESHGUI/SMESHGUI_MeshOp.cxx | 27 ++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx index 9a4eab9d1..dee5e025f 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx @@ -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 ); - if ( !enable ) + if ( !enable ) { myTabs[ dim ]->reset(); - myTabWg->setTabEnabled( myTabWg->indexOf( myTabs[ dim ] ), enable ); + disableTab( dim ); + } + else { + enableTab( dim ); + } } // 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 ] ); } - 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 ); + 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 ); + if ( theTabId == Dim3D ) { + QMenu* aHypoSetPopup = myHypoSetButton->menu(); + myHypoSetButton->setEnabled( aHypoSetPopup && !aHypoSetPopup->actions().isEmpty() ); + } } //================================================================================ diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index e0d17b734..48806273d 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -474,7 +474,7 @@ void SMESHGUI_MeshOp::selectionDone() { // Enable tabs according to shape dimension - int shapeDim = 3; + int shapeDim = -1; QStringList aGEOMs; myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs); @@ -504,7 +504,7 @@ void SMESHGUI_MeshOp::selectionDone() } 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() ) { @@ -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 - shapeDim = (shapeDim < 2) ? 2 : shapeDim; 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; - case GEOM::FACE: shapeDim = (shapeDim < 2) ? 2 : shapeDim; break; + case GEOM::FACE: shapeDim = qMax(2, shapeDim); break; 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; @@ -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 - 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() ) - shapeDim = (shapeDim < 2) ? 2 : shapeDim; + shapeDim = qMax(2, shapeDim); 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); } } } -- 2.39.2