From 96313c9c5d4c9ffea4ffb4f0502fec58f3a74e0e Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 29 Sep 2009 16:52:15 +0000 Subject: [PATCH] FixedPoints hypothesis: fix problem with values close to 0.0 and 1.0 --- .../StdMeshersGUI_FixedPointsParamWdg.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/StdMeshersGUI/StdMeshersGUI_FixedPointsParamWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_FixedPointsParamWdg.cxx index 0069a7b4e..c5c228bc7 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_FixedPointsParamWdg.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_FixedPointsParamWdg.cxx @@ -48,6 +48,8 @@ #define TOLERANCE 1e-7 #define EQUAL_DBL(a,b) (fabs(a-b)b)&&!EQUAL_DBL(a,b)) /* * class : Tree Widget Item Delegate @@ -255,13 +257,13 @@ QString StdMeshersGUI_FixedPointsParamWdg::treeItemText( double v1, double v2 ) //================================================================================= void StdMeshersGUI_FixedPointsParamWdg::addPoint( double v) { - if ( v > 0 && v < 1) { + if ( GT_DBL(v, 0.0) && LT_DBL(v, 1.0)) { bool toInsert = true; int idx = myTreeWidget->topLevelItemCount()-1; for ( int i = 0 ; i < myListWidget->count(); i++ ) { double lv = point( i ); - if ( EQUAL_DBL(lv,v) ) { toInsert = false; break; } - else if ( lv > v ) { + if ( EQUAL_DBL(lv, v) ) { toInsert = false; break; } + else if ( GT_DBL(lv, v) ) { idx = i; break; } } @@ -333,7 +335,8 @@ void StdMeshersGUI_FixedPointsParamWdg::onCheckBoxChanged() //================================================================================= void StdMeshersGUI_FixedPointsParamWdg::updateState() { - myAddButton->setEnabled( mySpinBox->value() > 0 && mySpinBox->value() < 1 ); + double v = mySpinBox->value(); + myAddButton->setEnabled( GT_DBL(v, 0.0) && LT_DBL(v, 1.0) ); myRemoveButton->setEnabled( myListWidget->selectedItems().count() > 0 ); } -- 2.39.2