void plotBoxesToPainter(QPainter& painter, const Numpy1DObj& x1, const Numpy1DObj& y1, const Numpy1DObj& x2, const Numpy1DObj& y2, const QRectF* clip, bool autoexpand) { // if autoexpand, expand rectangle by line width QRectF clipcopy(QPointF(-32767,-32767), QPointF(32767,32767)); if ( clip != 0 && autoexpand ) { const qreal lw = painter.pen().widthF(); qreal x1, y1, x2, y2; clip->getCoords(&x1, &y1, &x2, &y2); clipcopy.setCoords(x1, y1, x2, y2); clipcopy.adjust(-lw, -lw, lw, lw); } const int maxsize = min(x1.dim, x2.dim, y1.dim, y2.dim); QVector<QRectF> rects; for(int i = 0; i < maxsize; ++i) { QPointF pt1(x1(i), y1(i)); QPointF pt2(x2(i), y2(i)); const QRectF rect(pt1, pt2); if( clipcopy.intersects(rect) ) { rects << clipcopy.intersected(rect); } } if( ! rects.isEmpty() ) painter.drawRects(rects); }
void xclipcopy(void) { clipcopy(NULL); }