Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QList< QPolygonF > QPainterPath::toSubpathPolygons ( const QTransform matrix  )  const

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.

See also:
toFillPolygons(), toFillPolygon(), {QPainterPath::QPainterPath Conversion}{QPainterPath Conversion}

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 += QPointF(e.x, e.y) * matrix;
        case QPainterPath::LineToElement:
            current += QPointF(e.x, e.y) * matrix;
        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);
        case QPainterPath::CurveToDataElement:
            Q_ASSERT(!"QPainterPath::toSubpathPolygons(), bad element type");

    if (current.size()>1)
        flatCurves += current;

    return flatCurves;

Generated by  Doxygen 1.6.0   Back to index