comparison layer/TimeValueLayer.cpp @ 665:ab9fefdaa103

Make scale drawing in log scale a bit less dumb
author Chris Cannam
date Tue, 16 Jul 2013 13:38:53 +0100
parents 62330d542e1d
children d52751e2728b
comparison
equal deleted inserted replaced
664:62330d542e1d 665:ab9fefdaa103
1261 int prec = trunc(log10f(inc)); 1261 int prec = trunc(log10f(inc));
1262 prec -= 1; 1262 prec -= 1;
1263 if (prec < 0) dp = -prec; 1263 if (prec < 0) dp = -prec;
1264 round = powf(10.f, prec); 1264 round = powf(10.f, prec);
1265 #ifdef DEBUG_TIME_VALUE_LAYER 1265 #ifdef DEBUG_TIME_VALUE_LAYER
1266 std::cerr << "inc = " << inc << ", round = " << round << std::endl; 1266 std::cerr << "inc = " << inc << ", round = " << round << ", dp = " << dp << std::endl;
1267 #endif 1267 #endif
1268 } 1268 }
1269 1269
1270 int prevy = -1; 1270 int prevy = -1;
1271 1271
1301 continue; 1301 continue;
1302 } 1302 }
1303 } 1303 }
1304 1304
1305 if (logarithmic) { 1305 if (logarithmic) {
1306 sprintf(buffer, "%.*g", dp < 2 ? 2 : dp, LogRange::unmap(dispval)); 1306 double dv = LogRange::unmap(dispval);
1307 int digits = trunc(log10f(dv));
1308 int sf = dp + (digits > 0 ? digits : 0);
1309 if (sf < 2) sf = 2;
1310 sprintf(buffer, "%.*g", sf, dv);
1307 } else { 1311 } else {
1308 sprintf(buffer, "%.*f", dp, dispval); 1312 sprintf(buffer, "%.*f", dp, dispval);
1309 } 1313 }
1310 QString label = QString(buffer); 1314 QString label = QString(buffer);
1311 1315