diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-10-04 11:47:33 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-10-06 06:45:41 +0000 |
commit | da071825245a4ec1dc4904a9d3329db5a132c074 (patch) | |
tree | b594384bd75a174f134abcc4bd347c6cb5b72298 | |
parent | a64d954717a4b7fecc8eeea001e4a77483985132 (diff) |
Adjust linechart cliprect to allow drawing on plot area edgesv5.7.1
Line segments along the plot area edges were not drawn on all edges.
The missing edges depended on whether the position of the series
item was a round number or a .5 fraction. Adding half a pixel of
clip area to each direction fixes both cases without causing
line to get out of plot area boundaries.
Task-number: QTBUG-56324
Change-Id: Ide05274bc59b80c8000502cdc3b596336b58d12b
Reviewed-by: Mika Salmela <mika.salmela@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r-- | src/charts/linechart/linechartitem.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/charts/linechart/linechartitem.cpp b/src/charts/linechart/linechartitem.cpp index 03099356..04e00c35 100644 --- a/src/charts/linechart/linechartitem.cpp +++ b/src/charts/linechart/linechartitem.cpp @@ -373,6 +373,14 @@ void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt return; QRectF clipRect = QRectF(QPointF(0, 0), domain()->size()); + // Adjust clip rect half a pixel in required dimensions to make it include lines along the + // plot area edges, but never increase clip so much that any portion of the line is draw beyond + // the plot area. + const qreal x1 = pos().x() - int(pos().x()); + const qreal y1 = pos().y() - int(pos().y()); + const qreal x2 = (clipRect.width() + 0.5) - int(clipRect.width() + 0.5); + const qreal y2 = (clipRect.height() + 0.5) - int(clipRect.height() + 0.5); + clipRect.adjust(-x1, -y1, qMax(x1, x2), qMax(y1, y2)); painter->save(); painter->setPen(m_linePen); |