diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-02-06 12:26:54 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-02-06 10:05:41 -0800 |
commit | 5b6f4685475be7f7b68375fcab465c1626950296 (patch) | |
tree | 5321de5a6baff8d6e41e6919a52bae724c300518 /stats/pieseries.cpp | |
parent | f1203d365a4a890410038943cdd4aaaaf6ab558c (diff) | |
download | subsurface-5b6f4685475be7f7b68375fcab465c1626950296.tar.gz |
statistics: don't place labels at half-integer values
Placing labels at half-integer values gives horrible
rendering artifacts. Therefore, always round to integer
values. The easiest way to do this is right before setting
the position. Introduce a helper function to round QPointF
in such scenarios.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'stats/pieseries.cpp')
-rw-r--r-- | stats/pieseries.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/stats/pieseries.cpp b/stats/pieseries.cpp index 8db3bdbe3..d837abe5a 100644 --- a/stats/pieseries.cpp +++ b/stats/pieseries.cpp @@ -44,8 +44,9 @@ void PieSeries::Item::updatePositions(const QPointF ¢er, double radius) // because half-integer values gives horrible aliasing artifacts. if (innerLabel) { QRectF labelRect = innerLabel->getRect(); - innerLabel->setPos(QPointF(round(center.x() + innerLabelPos.x() * radius - labelRect.width() / 2.0), - round(center.y() + innerLabelPos.y() * radius - labelRect.height() / 2.0))); + QPointF pos(center.x() + innerLabelPos.x() * radius - labelRect.width() / 2.0, + center.y() + innerLabelPos.y() * radius - labelRect.height() / 2.0); + innerLabel->setPos(roundPos(pos)); } if (outerLabel) { QRectF labelRect = outerLabel->getRect(); @@ -59,7 +60,7 @@ void PieSeries::Item::updatePositions(const QPointF ¢er, double radius) pos.ry() -= labelRect.height(); } - outerLabel->setPos(QPointF(round(pos.x()), round(pos.y()))); + outerLabel->setPos(roundPos(pos)); } } |