29 return paint.fontMetrics().width(
"-000.00") + 15;
45 float inc = (max - val) / n;
49 int boxx = 5, boxy = 5;
51 boxy += paint.fontMetrics().height();
53 int boxw = 10, boxh = h - boxy - 5;
55 int tx = 5 + boxx + boxw;
56 paint.drawRect(boxx, boxy, boxw, boxh);
59 for (
int y = 0; y < boxh; ++y) {
60 float val = ((boxh - y) * (max - min)) / boxh + min;
62 paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1);
69 int prec = trunc(log10f(inc));
71 if (prec < 0) dp = -prec;
78 for (
int i = 0; i < n; ++i) {
82 y = boxy + int(boxh - ((val - min) * boxh) / (max - min));
84 ty = y - paint.fontMetrics().height() +
85 paint.fontMetrics().ascent() + 2;
87 sprintf(buffer,
"%.*f", dp, val);
88 QString label = QString(buffer);
90 paint.drawLine(boxx + boxw - boxw/3, y, boxx + boxw, y);
91 paint.drawText(tx, ty, label);
void paintVertical(View *v, const ColourScaleLayer *layer, QPainter &paint, int x0, float minf, float maxf)
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...
int getWidth(View *v, QPainter &paint)
virtual QString getScaleUnits() const =0