From 04075816a4d1b23729409d57503889e5f131f448 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 17 Dec 2008 11:16:00 +0000 Subject: [PATCH] Bug 0020075: EDF VISU 905: Impossible to create a deformed shape. --- src/VISUGUI/VisuGUI_CutPlanesDlg.cxx | 23 +++++++++---------- .../VisuGUI_DeformedShapeAndScalarMapDlg.cxx | 19 ++++++++------- src/VISUGUI/VisuGUI_VectorsDlg.cxx | 19 +++++++-------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index d0228a1b..3287e477 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -290,24 +290,23 @@ double VisuGUI_CutPlanesPane::getScaleFactor(){ return myScaleSpn->value(); } -void VisuGUI_CutPlanesPane::setScaleFactor(double theFactor){ - double i=0.1; - if(theFactor!=0){ - while (1) { // Calculate Step & Precission - if ( int (theFactor/i) > 0) - break; - else { - i = i*0.1; - } +void VisuGUI_CutPlanesPane::setScaleFactor(double theFactor) +{ + double step = 0.1; + if (fabs(theFactor) > numeric_limits::epsilon()) { + int degree = int(log10(fabs(theFactor))) - 1; + if (fabs(theFactor) < 1) { + // as logarithm value is negative in this case + // and it is truncated to the bigger integer + degree -= 1; } + step = pow(10., double(degree)); } - myScaleSpn->setLineStep(i); + myScaleSpn->setLineStep(step); myScaleSpn->setValue(theFactor); - } - void VisuGUI_CutPlanesPane::createPlanes() { if (VISU::GetActiveViewWindow() == NULL) return; diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx index 585c65b1..5990ea31 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx @@ -278,19 +278,18 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::initFromPrsObject( VISU::ColoredPrs3d void VisuGUI_DeformedShapeAndScalarMapDlg::setFactor(double theFactor) { - double i=0.1; - if(theFactor != 0) { - while (1) { // Calculate Step & Precission - if ( int (theFactor/i) > 0) - break; - else { - i = i*0.1; - } + double step = 0.1; + if (fabs(theFactor) > numeric_limits::epsilon()) { + int degree = int(log10(fabs(theFactor))) - 1; + if (fabs(theFactor) < 1) { + // as logarithm value is negative in this case + // and it is truncated to the bigger integer + degree -= 1; } + step = pow(10., double(degree)); } - ScalFact->setLineStep(i); - + ScalFact->setLineStep(step); ScalFact->setValue(theFactor); } diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 09173d05..a3b40a38 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -299,18 +299,19 @@ void VisuGUI_VectorsDlg::setVColor() */ void VisuGUI_VectorsDlg::setScaleFactor( double theFactor ) { - double i=0.1; - while (1) { // Calculate Step & Precission - if ( int (theFactor/i) > 0) - break; - else { - i = i*0.1; + double step = 0.1; + if (fabs(theFactor) > numeric_limits::epsilon()) { + int degree = int(log10(fabs(theFactor))) - 1; + if (fabs(theFactor) < 1) { + // as logarithm value is negative in this case + // and it is truncated to the bigger integer + degree -= 1; } + step = pow(10., double(degree)); } - - ScalFact->setLineStep(i); - ScalFact->setValue( theFactor ); + ScalFact->setLineStep(step); + ScalFact->setValue(theFactor); } /*! -- 2.39.2