]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Bug 0020075: EDF VISU 905: Impossible to create a deformed shape. V5_1_0
authorjfa <jfa@opencascade.com>
Fri, 19 Dec 2008 07:52:22 +0000 (07:52 +0000)
committerjfa <jfa@opencascade.com>
Fri, 19 Dec 2008 07:52:22 +0000 (07:52 +0000)
src/VISUGUI/VisuGUI_CutPlanesDlg.cxx
src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx
src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx
src/VISUGUI/VisuGUI_VectorsDlg.cxx

index 3c8021d88d1eab49a81fb9eb8424b493c889e0e9..d5828be4c578eb17e5067f56394746cc560706cb 100644 (file)
@@ -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<double>::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);
 }
 
index 274f9d94b60a611f78d4414eef19fd955873a612..ff349777d55368ab3cd5bfc150baef08e33ac076 100644 (file)
@@ -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<double>::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);
 }
 
index 9e83bb432a2a94c534067fccd0ce3e4ee6852b50..3cf630b1bd3640110464a6dda8254ea4a742069a 100644 (file)
@@ -52,6 +52,8 @@
 #include <QTabWidget>
 #include <QKeyEvent>
 
+#include <math.h>
+
 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<double>::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);
 }
 
index 8ede44c776ac0e14ef83d5157e203a29370f2231..894305dcfe1f9871bdea73d76cbe5a814a7f4159 100644 (file)
@@ -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<double>::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);
 }
 
 /*!