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; }
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; }