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

qreal QPainterPath::length (  )  const

Returns the length of the current path.

Definition at line 2563 of file qpainterpath.cpp.

References isEmpty(), and QPainterPath::Element::type.

Referenced by angleAtPercent(), percentAtLength(), pointAtPercent(), and slopeAtPercent().

{
    Q_D(QPainterPath);
    if (isEmpty())
        return 0;

    qreal len = 0;
    for (int i=1; i<d->elements.size(); ++i) {
        const Element &e = d->elements.at(i);

        switch (e.type) {
        case MoveToElement:
            break;
        case LineToElement:
        {
            len += QLineF(d->elements.at(i-1), e).length();
            break;
        }
        case CurveToElement:
        {
            QBezier b = QBezier::fromPoints(d->elements.at(i-1),
                                            e,
                                            d->elements.at(i+1),
                                            d->elements.at(i+2));
            len += b.length();
            i += 2;
            break;
        }
        default:
            break;
        }
    }
    return len;
}


Generated by  Doxygen 1.6.0   Back to index