Mercurial > hg > svgui
comparison layer/LinearNumericalScale.cpp @ 1266:a34a2a25907c
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:22 +0000 |
parents | cdaeff1858af |
children | b4cb11ca8233 |
comparison
equal
deleted
inserted
replaced
1265:6e724c81f18f | 1266:a34a2a25907c |
---|---|
24 | 24 |
25 #include "base/ScaleTickIntervals.h" | 25 #include "base/ScaleTickIntervals.h" |
26 | 26 |
27 int | 27 int |
28 LinearNumericalScale::getWidth(LayerGeometryProvider *, | 28 LinearNumericalScale::getWidth(LayerGeometryProvider *, |
29 QPainter &paint) | 29 QPainter &paint) |
30 { | 30 { |
31 return paint.fontMetrics().width("-000.00") + 10; | 31 return paint.fontMetrics().width("-000.00") + 10; |
32 } | 32 } |
33 | 33 |
34 void | 34 void |
35 LinearNumericalScale::paintVertical(LayerGeometryProvider *v, | 35 LinearNumericalScale::paintVertical(LayerGeometryProvider *v, |
36 const VerticalScaleLayer *layer, | 36 const VerticalScaleLayer *layer, |
37 QPainter &paint, | 37 QPainter &paint, |
38 int x0, | 38 int x0, |
39 double minf, | 39 double minf, |
40 double maxf) | 40 double maxf) |
41 { | 41 { |
42 int n = 10; | 42 int n = 10; |
43 auto ticks = ScaleTickIntervals::linear({ minf, maxf, n }); | 43 auto ticks = ScaleTickIntervals::linear({ minf, maxf, n }); |
44 n = int(ticks.size()); | 44 n = int(ticks.size()); |
45 | 45 |
47 | 47 |
48 int prevy = -1; | 48 int prevy = -1; |
49 | 49 |
50 for (int i = 0; i < n; ++i) { | 50 for (int i = 0; i < n; ++i) { |
51 | 51 |
52 int y, ty; | 52 int y, ty; |
53 bool drawText = true; | 53 bool drawText = true; |
54 | 54 |
55 if (i == n-1 && | 55 if (i == n-1 && |
56 v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { | 56 v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { |
57 if (layer->getScaleUnits() != "") drawText = false; | 57 if (layer->getScaleUnits() != "") drawText = false; |
58 } | 58 } |
59 | 59 |
60 double val = ticks[i].value; | 60 double val = ticks[i].value; |
61 QString label = QString::fromStdString(ticks[i].label); | 61 QString label = QString::fromStdString(ticks[i].label); |
62 | 62 |
63 y = layer->getYForValue(v, val); | 63 y = layer->getYForValue(v, val); |
64 | 64 |
65 ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; | 65 ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; |
66 | 66 |
67 if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { | 67 if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { |
68 continue; | 68 continue; |
69 } | 69 } |
70 | 70 |
71 paint.drawLine(w - 5, y, w, y); | 71 paint.drawLine(w - 5, y, w, y); |
72 | 72 |
73 if (drawText) { | 73 if (drawText) { |
74 paint.drawText(w - paint.fontMetrics().width(label) - 6, | 74 paint.drawText(w - paint.fontMetrics().width(label) - 6, |
75 ty, label); | 75 ty, label); |
76 } | 76 } |
77 | 77 |
78 prevy = y; | 78 prevy = y; |
79 } | 79 } |
80 } | 80 } |