QXRD  0.11.16
qxrdcenterstepspinner.cpp
Go to the documentation of this file.
2 #include <qmath.h>
3 #include <stdio.h>
4 
6  QDoubleSpinBox(parent)
7 {
8  setDecimals(5);
9 }
10 
12 {
13  double newVal = value();
14  double sgn = (newVal < 0 ? -1 : 1);
15  double logVal = log10(fabs(newVal));
16  double frac = logVal - floor(logVal);
17 
18 // printf("frac = %g\n", frac);
19  double mul;
20  if (frac < 0.2) {
21  mul = (steps > 0 ? 2.0 : 2.0);
22  } else if (frac < 0.5) {
23  mul = (steps > 0 ? 2.5 : 2.0);
24  } else {
25  mul = (steps > 0 ? 2.0 : 2.5);
26  }
27 
28 
29  if (steps > 0) {
30  if (newVal == 0) {
31  newVal = 0.00001;
32  } else {
33  newVal *= mul;
34  }
35  } else if (steps < 0) {
36  newVal /= mul;
37  }
38 
39  setValue(newVal*sgn);
40 //
41 // emit valueChanged(newVal);
42 }
QxrdCenterStepSpinner(QWidget *parent=0)
virtual void stepBy(int steps)