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);
}
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);
}
#include <QTabWidget>
#include <QKeyEvent>
+#include <math.h>
+
using namespace std;
/*!
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);
}
/*!
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);
}
/*!