comparison layer/LinearColourScale.cpp @ 944:78c152e4db95

Merge from branch tonioni
author Chris Cannam
date Mon, 20 Apr 2015 09:12:17 +0100
parents b66fb15de477
children 4fe7a09be0fe
comparison
equal deleted inserted replaced
896:78e041e45ff0 944:78c152e4db95
32 void 32 void
33 LinearColourScale::paintVertical(View *v, 33 LinearColourScale::paintVertical(View *v,
34 const ColourScaleLayer *layer, 34 const ColourScaleLayer *layer,
35 QPainter &paint, 35 QPainter &paint,
36 int /* x0 */, 36 int /* x0 */,
37 float min, 37 double min,
38 float max) 38 double max)
39 { 39 {
40 int h = v->height(); 40 int h = v->height();
41 41
42 int n = 10; 42 int n = 10;
43 43
44 float val = min; 44 double val = min;
45 float inc = (max - val) / n; 45 double inc = (max - val) / n;
46 46
47 const int buflen = 40; 47 const int buflen = 40;
48 char buffer[buflen]; 48 char buffer[buflen];
49 49
50 int boxx = 5, boxy = 5; 50 int boxx = 5, boxy = 5;
56 int tx = 5 + boxx + boxw; 56 int tx = 5 + boxx + boxw;
57 paint.drawRect(boxx, boxy, boxw, boxh); 57 paint.drawRect(boxx, boxy, boxw, boxh);
58 58
59 paint.save(); 59 paint.save();
60 for (int y = 0; y < boxh; ++y) { 60 for (int y = 0; y < boxh; ++y) {
61 float val = ((boxh - y) * (max - min)) / boxh + min; 61 double val = ((boxh - y) * (max - min)) / boxh + min;
62 paint.setPen(layer->getColourForValue(v, val)); 62 paint.setPen(layer->getColourForValue(v, val));
63 paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); 63 paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1);
64 } 64 }
65 paint.restore(); 65 paint.restore();
66 66
67 // float round = 1.f; 67 // double round = 1.f;
68 int dp = 0; 68 int dp = 0;
69 if (inc > 0) { 69 if (inc > 0) {
70 int prec = trunc(log10f(inc)); 70 int prec = int(trunc(log10(inc)));
71 prec -= 1; 71 prec -= 1;
72 if (prec < 0) dp = -prec; 72 if (prec < 0) dp = -prec;
73 // round = powf(10.f, prec); 73 // round = powf(10.f, prec);
74 //#ifdef DEBUG_TIME_VALUE_LAYER 74 //#ifdef DEBUG_TIME_VALUE_LAYER
75 // cerr << "inc = " << inc << ", round = " << round << ", dp = " << dp << endl; 75 // cerr << "inc = " << inc << ", round = " << round << ", dp = " << dp << endl;