Converts the path into a list of polygons using the QTransform matrix, and returns the list. This function creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles). To make sure that such overlapping subpaths are filled correctly, use the toFillPolygons() function instead.
Definition at line 1463 of file qpainterpath.cpp. References QList< T >::at(), QVector< T >::clear(), elementCount(), isEmpty(), QVector< T >::reserve(), QVector< T >::size(), QPainterPath::Element::type, QPainterPath::Element::x, and QPainterPath::Element::y. { Q_D(const QPainterPath); QList<QPolygonF> flatCurves; if (isEmpty()) return flatCurves; QPolygonF current; for (int i=0; i<elementCount(); ++i) { const QPainterPath::Element &e = d->elements.at(i); switch (e.type) { case QPainterPath::MoveToElement: if (current.size() > 1) flatCurves += current; current.clear(); current.reserve(16); current += QPointF(e.x, e.y) * matrix; break; case QPainterPath::LineToElement: current += QPointF(e.x, e.y) * matrix; break; case QPainterPath::CurveToElement: { Q_ASSERT(d->elements.at(i+1).type == QPainterPath::CurveToDataElement); Q_ASSERT(d->elements.at(i+2).type == QPainterPath::CurveToDataElement); QBezier bezier = QBezier::fromPoints(QPointF(d->elements.at(i-1).x, d->elements.at(i-1).y) * matrix, QPointF(e.x, e.y) * matrix, QPointF(d->elements.at(i+1).x, d->elements.at(i+1).y) * matrix, QPointF(d->elements.at(i+2).x, d->elements.at(i+2).y) * matrix); bezier.addToPolygon(¤t); i+=2; break; } case QPainterPath::CurveToDataElement: Q_ASSERT(!"QPainterPath::toSubpathPolygons(), bad element type"); break; } } if (current.size()>1) flatCurves += current; return flatCurves; }
|