Fill curve with different brushes, while two curves' cross. Like the picture
选区_001.png
My code like this.
void FillAreaCurve::fillCurve(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, QPolygonF &polygon) const
{
.........
// calculate crossing points
for ( int i = 0; i < corssingNum; i++ ) {
......
// according to different terms, get the clipRect and assign different brush to painter.
painter->save();
painter->setClipRect( clipRect, Qt::IntersectClip );
closePolyline( painter, xMap, yMap, polygon );
polygon = QwtClipper::clipPolygonF( canvasRect, polygon, true );
painter->setPen( Qt::NoPen );
painter->setBrush( brush );
QwtPainter::drawPolygon( painter, polygon );
painter->restore();
}
}
Apparently, how much time it would consume is determined by the crossing points' number, which is out of my control.
Is there another way to fill my curves quicker ?
Bookmarks