comparison layer/LinearNumericalScale.cpp @ 904:e0f08e108064 cxx11

Move to using double rather than float for floating-point calculations (float only for storage); more build fixes
author Chris Cannam
date Mon, 09 Mar 2015 12:02:10 +0000
parents 3ca3b8fbbcee
children b66fb15de477
comparison
equal deleted inserted replaced
903:1757933ce5a7 904:e0f08e108064
32 void 32 void
33 LinearNumericalScale::paintVertical(View *v, 33 LinearNumericalScale::paintVertical(View *v,
34 const VerticalScaleLayer *layer, 34 const VerticalScaleLayer *layer,
35 QPainter &paint, 35 QPainter &paint,
36 int x0, 36 int x0,
37 float minf, 37 double minf,
38 float maxf) 38 double maxf)
39 { 39 {
40 int n = 10; 40 int n = 10;
41 41
42 float val = minf; 42 double val = minf;
43 float inc = (maxf - val) / n; 43 double inc = (maxf - val) / n;
44 44
45 const int buflen = 40; 45 const int buflen = 40;
46 char buffer[buflen]; 46 char buffer[buflen];
47 47
48 int w = getWidth(v, paint) + x0; 48 int w = getWidth(v, paint) + x0;
49 49
50 float round = 1.f; 50 double round = 1.f;
51 int dp = 0; 51 int dp = 0;
52 if (inc > 0) { 52 if (inc > 0) {
53 int prec = trunc(log10f(inc)); 53 int prec = trunc(log10f(inc));
54 prec -= 1; 54 prec -= 1;
55 if (prec < 0) dp = -prec; 55 if (prec < 0) dp = -prec;
64 for (int i = 0; i < n; ++i) { 64 for (int i = 0; i < n; ++i) {
65 65
66 int y, ty; 66 int y, ty;
67 bool drawText = true; 67 bool drawText = true;
68 68
69 float dispval = val; 69 double dispval = val;
70 70
71 if (i == n-1 && 71 if (i == n-1 &&
72 v->height() < paint.fontMetrics().height() * (n*2)) { 72 v->height() < paint.fontMetrics().height() * (n*2)) {
73 if (layer->getScaleUnits() != "") drawText = false; 73 if (layer->getScaleUnits() != "") drawText = false;
74 } 74 }