Mercurial > hg > svgui
comparison layer/LogNumericalScale.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 |
|---|---|
| 26 | 26 |
| 27 #include "base/ScaleTickIntervals.h" | 27 #include "base/ScaleTickIntervals.h" |
| 28 | 28 |
| 29 int | 29 int |
| 30 LogNumericalScale::getWidth(LayerGeometryProvider *, | 30 LogNumericalScale::getWidth(LayerGeometryProvider *, |
| 31 QPainter &paint) | 31 QPainter &paint) |
| 32 { | 32 { |
| 33 return paint.fontMetrics().width("-000.00") + 10; | 33 return paint.fontMetrics().width("-000.00") + 10; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void | 36 void |
| 37 LogNumericalScale::paintVertical(LayerGeometryProvider *v, | 37 LogNumericalScale::paintVertical(LayerGeometryProvider *v, |
| 38 const VerticalScaleLayer *layer, | 38 const VerticalScaleLayer *layer, |
| 39 QPainter &paint, | 39 QPainter &paint, |
| 40 int x0, | 40 int x0, |
| 41 double minlog, | 41 double minlog, |
| 42 double maxlog) | 42 double maxlog) |
| 43 { | 43 { |
| 44 int n = 10; | 44 int n = 10; |
| 45 auto ticks = ScaleTickIntervals::logarithmicAlready({ minlog, maxlog, n }); | 45 auto ticks = ScaleTickIntervals::logarithmicAlready({ minlog, maxlog, n }); |
| 46 n = int(ticks.size()); | 46 n = int(ticks.size()); |
| 47 | 47 |
| 49 | 49 |
| 50 int prevy = -1; | 50 int prevy = -1; |
| 51 | 51 |
| 52 for (int i = 0; i < n; ++i) { | 52 for (int i = 0; i < n; ++i) { |
| 53 | 53 |
| 54 int y, ty; | 54 int y, ty; |
| 55 bool drawText = true; | 55 bool drawText = true; |
| 56 | 56 |
| 57 if (i == n-1 && | 57 if (i == n-1 && |
| 58 v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { | 58 v->getPaintHeight() < paint.fontMetrics().height() * (n*2)) { |
| 59 if (layer->getScaleUnits() != "") drawText = false; | 59 if (layer->getScaleUnits() != "") drawText = false; |
| 60 } | 60 } |
| 61 | 61 |
| 62 double val = ticks[i].value; | 62 double val = ticks[i].value; |
| 63 QString label = QString::fromStdString(ticks[i].label); | 63 QString label = QString::fromStdString(ticks[i].label); |
| 64 | 64 |
| 65 y = layer->getYForValue(v, val); | 65 y = layer->getYForValue(v, val); |
| 66 | 66 |
| 67 ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; | 67 ty = y - paint.fontMetrics().height() + paint.fontMetrics().ascent() + 2; |
| 68 | 68 |
| 69 if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { | 69 if (prevy >= 0 && (prevy - y) < paint.fontMetrics().height()) { |
| 70 continue; | 70 continue; |
| 71 } | 71 } |
| 72 | 72 |
| 73 paint.drawLine(w - 5, y, w, y); | 73 paint.drawLine(w - 5, y, w, y); |
| 74 | 74 |
| 75 if (drawText) { | 75 if (drawText) { |
| 76 paint.drawText(w - paint.fontMetrics().width(label) - 6, | 76 paint.drawText(w - paint.fontMetrics().width(label) - 6, |
| 77 ty, label); | 77 ty, label); |
| 78 } | 78 } |
| 79 | 79 |
| 80 prevy = y; | 80 prevy = y; |
| 81 } | 81 } |
| 82 } | 82 } |
