comparison layer/LogNumericalScale.cpp @ 704:b81f21f2c4c3

Not quite so many digits
author Chris Cannam
date Wed, 04 Dec 2013 14:00:27 +0000
parents 1a1448f7beb2
children 3ca3b8fbbcee
comparison
equal deleted inserted replaced
701:084f65094203 704:b81f21f2c4c3
62 62
63 if (minDispInc > 0) { 63 if (minDispInc > 0) {
64 int prec = trunc(log10f(minDispInc)); 64 int prec = trunc(log10f(minDispInc));
65 if (prec < 0) dp = -prec; 65 if (prec < 0) dp = -prec;
66 round = powf(10.f, prec); 66 round = powf(10.f, prec);
67 if (dp > 4) dp = 4;
67 #ifdef DEBUG_TIME_VALUE_LAYER 68 #ifdef DEBUG_TIME_VALUE_LAYER
68 cerr << "round = " << round << ", prec = " << prec << ", dp = " << dp << endl; 69 cerr << "round = " << round << ", prec = " << prec << ", dp = " << dp << endl;
69 #endif 70 #endif
70 } 71 }
71 72
95 if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { 96 if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) {
96 val += inc; 97 val += inc;
97 continue; 98 continue;
98 } 99 }
99 100
100 double dv = dispval; 101 int digits = trunc(log10f(dispval));
101 int digits = trunc(log10f(dv));
102 int sf = dp + (digits > 0 ? digits : 0); 102 int sf = dp + (digits > 0 ? digits : 0);
103 if (sf < 4) sf = 4; 103 if (sf < 4) sf = 4;
104 sprintf(buffer, "%.*g", sf, dv); 104 #ifdef DEBUG_TIME_VALUE_LAYER
105 cerr << "sf = " << sf << endl;
106 #endif
107 sprintf(buffer, "%.*g", sf, dispval);
105 108
106 QString label = QString(buffer); 109 QString label = QString(buffer);
107 110
108 paint.drawLine(w - 5, y, w, y); 111 paint.drawLine(w - 5, y, w, y);
109 112