##// END OF EJS Templates
Finetuning shape of line chart item to remove drawing artifacts
Tero Ahola -
r1823:a1c4c93bea9c
parent child
Show More
@@ -81,11 +81,15 void LineChartItem::updateGeometry()
81 }
81 }
82 }
82 }
83
83
84 m_linePath=linePath;
84 m_linePath = linePath;
85
85 QPainterPathStroker stroker;
86 QPainterPathStroker stroker;
86 stroker.setWidth(m_linePen.width()*1.42);
87 // QPainter::drawLine does not respect join styles, for example BevelJoin becomes MiterJoin.
87 stroker.setJoinStyle(m_linePen.joinStyle());
88 // This is why we are prepared for the "worst case" scenario, i.e. use always MiterJoin and
88 stroker.setCapStyle(m_linePen.capStyle());
89 // multiply line width with square root of two when defining shape and bounding rectangle.
90 stroker.setWidth(m_linePen.width() * 1.42);
91 stroker.setJoinStyle(Qt::MiterJoin);
92 stroker.setCapStyle(Qt::SquareCap);
89 stroker.setMiterLimit(m_linePen.miterLimit());
93 stroker.setMiterLimit(m_linePen.miterLimit());
90
94
91 prepareGeometryChange();
95 prepareGeometryChange();
@@ -109,6 +113,7 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
109 Q_UNUSED(widget)
113 Q_UNUSED(widget)
110 Q_UNUSED(option)
114 Q_UNUSED(option)
111
115
116
112 painter->setPen(m_linePen);
117 painter->setPen(m_linePen);
113
118
114 painter->setBrush(m_linePen.color());
119 painter->setBrush(m_linePen.color());
@@ -119,7 +124,7 void LineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
119 }
124 }
120 else {
125 else {
121 for (int i(1); i < m_points.size();i++)
126 for (int i(1); i < m_points.size();i++)
122 painter->drawLine(m_points.at(i-1), m_points.at(i));
127 painter->drawLine(m_points.at(i-1), m_points.at(i));
123 }
128 }
124 }
129 }
125
130
General Comments 0
You need to be logged in to leave comments. Login now