From f4bc1f55901adcd25cab6d7a21f86ec1aaaf83fa Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 19 Dec 2008 07:52:22 +0000 Subject: [PATCH] Bug 0020075: EDF VISU 905: Impossible to create a deformed shape. --- src/VISUGUI/VisuGUI_CutPlanesDlg.cxx | 20 ++++++++-------- .../VisuGUI_DeformedShapeAndScalarMapDlg.cxx | 17 +++++++------- src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx | 19 ++++++++------- src/VISUGUI/VisuGUI_VectorsDlg.cxx | 23 ++++++++++--------- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index 3c8021d8..d5828be4 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -309,18 +309,20 @@ 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) > std::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->setSingleStep(i); + myScaleSpn->setSingleStep(step); myScaleSpn->setValue(theFactor); } diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx index 274f9d94..ff349777 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx @@ -293,17 +293,18 @@ double VisuGUI_DeformedShapeAndScalarMapDlg::getFactor() const 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) > std::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->setSingleStep(i); + ScalFact->setSingleStep(step); ScalFact->setValue(theFactor); } diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index 9e83bb43..3cf630b1 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -52,6 +52,8 @@ #include #include +#include + using namespace std; /*! @@ -171,17 +173,18 @@ void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, void VisuGUI_DeformedShapeDlg::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->setSingleStep(i); + ScalFact->setSingleStep(step); ScalFact->setValue(theFactor); } diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 8ede44c7..894305dc 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -324,20 +324,21 @@ void VisuGUI_VectorsDlg::enableSetColor() /*! Sets Scale factor */ -void VisuGUI_VectorsDlg::setScaleFactor( double theFactor ) +void VisuGUI_VectorsDlg::setScaleFactor(double theFactor) { - double i=0.1; - if (theFactor > 0) { // Calculate Step & Precission - while (1) { - if ( int (theFactor/i) > 0) - break; - else - i = i*0.1; + double step = 0.1; + if (fabs(theFactor) > std::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->setSingleStep(i); - ScalFact->setValue( theFactor ); + + ScalFact->setSingleStep(step); + ScalFact->setValue(theFactor); } /*! -- 2.39.2