QwtPointMapper rounding overflow
Brought to you by:
rathmann
QwtPointMapper uses qRound() to transform float values to integer coordinates. This may cause an overflow, negative coordinates and incorrect plot lines drawing on deep zoom. For example, when horizontal axis is date/time axis and has large values that become even larger when zoomed. qRound() should probably be replaced by qRound64().
Anonymous
Example:
When using integers ( regardless of 32/64 bit ) you might run into this overflow situation and the best way to avoid it is to stay with doubles.
Fortunately QwtPointMapper already supports this and in combination with QwtPlotCurve::ClipPolygons it is possible to clip away large values before mapping them to paint device coordinates ( integers again for QWidget ).
By QwtPainter::setRoundingAlignment( false ) you can tell QwtPlotCurve to run into the non rounding path ( maybe overload QwtPlotCurve::drawSeries, enabling/disabling this flag ).
There were a couple of reasons, why Qwt is rounding to integers manually - one of them was that in several Qt versions the raster paint engine is significantly slower for doubles, than for integers. But I need to re-evaluate the situation for the relevant Qt versions we have today - that's why I will keep this bug report open for the moment.
Unfortunately nearbyint()/round() are not available on all platforms. Therefore I added a slightly less performant version without having integers involved.
Fixed on all branches >= 6.1