]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Bug 0020075: EDF VISU 905: Impossible to create a deformed shape.
authorjfa <jfa@opencascade.com>
Wed, 17 Dec 2008 11:16:00 +0000 (11:16 +0000)
committerjfa <jfa@opencascade.com>
Wed, 17 Dec 2008 11:16:00 +0000 (11:16 +0000)
src/VISUGUI/VisuGUI_CutPlanesDlg.cxx
src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx
src/VISUGUI/VisuGUI_VectorsDlg.cxx

index d0228a1bce86aaf1c959e5f16a98b2e82341f092..3287e47787b945877a7badcf0c92a34632526edc 100644 (file)
@@ -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<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->setLineStep(i);
+  myScaleSpn->setLineStep(step);
   myScaleSpn->setValue(theFactor);
-  
 }
 
-
 void VisuGUI_CutPlanesPane::createPlanes()
 {
   if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
index 585c65b1621c60bd9ea8cd6bd648e13bf2b62597..5990ea31ce826df8e75e2ee7a1b9e805903c5f2c 100644 (file)
@@ -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<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->setLineStep(i);
-
+  ScalFact->setLineStep(step);
   ScalFact->setValue(theFactor);
 }
 
index 09173d05df331aaf5b59457f73f61203eeb4290f..a3b40a387cc37998b649b68182412adee4d73fff 100644 (file)
@@ -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<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->setLineStep(i);
 
-  ScalFact->setValue( theFactor );
+  ScalFact->setLineStep(step);
+  ScalFact->setValue(theFactor);
 }
 
 /*!