19 #include "base/LogRange.h" 31 return paint.fontMetrics().width(
"-000.00") + 15;
47 float inc = (maxlog - val) / n;
51 int boxx = 5, boxy = 5;
53 boxy += paint.fontMetrics().height();
55 int boxw = 10, boxh = h - boxy - 5;
57 int tx = 5 + boxx + boxw;
58 paint.drawRect(boxx, boxy, boxw, boxh);
61 for (
int y = 0; y < boxh; ++y) {
62 float val = ((boxh - y) * (maxlog - minlog)) / boxh + minlog;
64 paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1);
70 int prec = trunc(log10f(inc));
72 if (prec < 0) dp = -prec;
75 for (
int i = 0; i < n; ++i) {
79 y = boxy + int(boxh - ((val - minlog) * boxh) / (maxlog - minlog));
81 ty = y - paint.fontMetrics().height() +
82 paint.fontMetrics().ascent() + 2;
84 double dv = LogRange::unmap(val);
85 int digits = trunc(log10f(dv));
86 int sf = dp + (digits > 0 ? digits : 0);
88 sprintf(buffer,
"%.*g", sf, dv);
90 QString label = QString(buffer);
92 paint.drawLine(boxx + boxw - boxw/3, y, boxx + boxw, y);
93 paint.drawText(tx, ty, label);
int getWidth(View *v, QPainter &paint)
virtual QColor getColourForValue(View *v, float value) const =0
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
void paintVertical(View *v, const ColourScaleLayer *layer, QPainter &paint, int x0, float minf, float maxf)
virtual QString getScaleUnits() const =0