Fix off-by-one/one positioning by GeoPainter::drawEllipse/Rectangle
ClosedPublic

Authored by kossebau on Jul 12 2016, 3:37 AM.

Details

Summary

GeoPainter::drawEllipse() & GeoPainter::drawRect() both take the
parameters width & height as qreal type, but if !isGeoProjected they do the
actual rendering calls using int based coordinates & sizes.

The old calculation would not compensate qreal->int rounding changes and often result
in a wrong 1 pixel offset in direction of topleft corner.

The respective GeoPainter::regionFromEllipse() and GeoPainter::regionFromRect()
also are adapted, with the first also being fixed to take also strokeWidth
into account for the topleft corner calculation, like done with the rect.

Test Plan

Extended geopainter example app renders rectangles and ellipses as expected.

Diff Detail

Repository
R34 Marble
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau updated this revision to Diff 5090.Jul 12 2016, 3:37 AM
kossebau retitled this revision from to Fix off-by-one/one positioning by GeoPainter::drawEllipse/Rectangle.
kossebau updated this object.
kossebau edited the test plan for this revision. (Show Details)
kossebau added reviewers: Marble, rahn, nienhueser.
rahn accepted this revision.Jul 12 2016, 5:47 AM
rahn edited edge metadata.

Looks good

This revision is now accepted and ready to land.Jul 12 2016, 5:47 AM
This revision was automatically updated to reflect the committed changes.