Beispiel #1
0
bool RPolyline::reverse() {
    RPolyline nPolyline;
    QList<QSharedPointer<RShape> > segments = getExploded();
    for (int i=segments.count()-1; i>=0; i--) {
        QSharedPointer<RShape> seg = segments.at(i);
        QSharedPointer<RDirected> directed = seg.dynamicCast<RDirected>();
        directed->reverse();
        nPolyline.appendShape(*seg);
    }
    nPolyline.setClosed(closed);
    *this = nPolyline;
    return true;
}
Beispiel #2
0
bool RPolyline::reverse() {
    RPolyline nPolyline;
    QList<QSharedPointer<RShape> > segments = getExploded();

    // skip last segment if polyline is closed and add flag instead:
    int iLast = segments.count()-1;
    if (isClosed()) {
        iLast--;
    }

    for (int i=iLast; i>=0; i--) {
        QSharedPointer<RShape> seg = segments.at(i);
        QSharedPointer<RDirected> directed = seg.dynamicCast<RDirected>();
        directed->reverse();
        nPolyline.appendShape(*seg);
    }
    nPolyline.setClosed(closed);
    *this = nPolyline;
    return true;
}