void Ruler::paintEvent(QPaintEvent *event)
{
QPainter p(this);
+ p.setRenderHint(QPainter::Antialiasing);
const double MinSpacing = 80;
const int order = (int)floorf(log10f(min_period));
const double order_decimal = pow(10, order);
- int unit = 0;
+ unsigned int unit = 0;
double tick_period = 0.0f;
do
tick_period = order_decimal * ScaleUnits[unit++];
} while(tick_period < min_period && unit < countof(ScaleUnits));
- const int prefix = (order - FirstSIPrefixPower) / 3;
+ const unsigned int prefix = (order - FirstSIPrefixPower) / 3;
assert(prefix >= 0);
assert(prefix < countof(SIPrefixes));
- const double multiplier = pow(0.1, prefix * 3 + FirstSIPrefixPower);
+ const double multiplier = pow(10.0, - prefix * 3 - FirstSIPrefixPower);
const int text_height = p.boundingRect(0, 0, INT_MAX, INT_MAX,
Qt::AlignLeft | Qt::AlignTop, "8").height();
ts << (t * multiplier) << SIPrefixes[prefix] << "s";
p.drawText(x, 0, 0, text_height, Qt::AlignCenter |
Qt::AlignTop | Qt::TextDontClip, s);
- p.drawLine(x, text_height, x, height());
+ p.drawLine(QPointF(x, text_height),
+ QPointF(x, height()));
}
else
{
// Draw a minor tick
- p.drawLine(x, (text_height + height()) / 2,
- x, height());
+ p.drawLine(QPointF(x, (text_height + height()) / 2),
+ QPointF(x, height()));
}
division++;