insilmaril@650: #include "geometry.h" insilmaril@650: insilmaril@650: insilmaril@650: QRectF addBBox(QRectF r1, QRectF r2) insilmaril@650: { insilmaril@650: // Find smallest QRectF containing given rectangles insilmaril@650: insilmaril@650: QRectF n; insilmaril@650: // Set left border insilmaril@650: if (r1.left() <= r2.left() ) insilmaril@650: n.setLeft(r1.left() ); insilmaril@650: else insilmaril@650: n.setLeft(r2.left() ); insilmaril@650: insilmaril@650: // Set top border insilmaril@650: if (r1.top() <= r2.top() ) insilmaril@650: n.setTop(r1.top() ); insilmaril@650: else insilmaril@650: n.setTop(r2.top() ); insilmaril@650: insilmaril@650: // Set right border insilmaril@650: if (r1.right() <= r2.right() ) insilmaril@650: n.setRight(r2.right() ); insilmaril@650: else insilmaril@650: n.setRight(r1.right() ); insilmaril@650: insilmaril@650: // Set bottom insilmaril@650: if (r1.bottom() <= r2.bottom() ) insilmaril@650: n.setBottom(r2.bottom() ); insilmaril@650: else insilmaril@650: n.setBottom(r1.bottom() ); insilmaril@650: return n; insilmaril@650: } insilmaril@650: insilmaril@650: bool inBox(const QPointF &p, const QRectF &box) insilmaril@650: { insilmaril@650: if (p.x() >= box.left() && p.x() <= box.right() insilmaril@650: && p.y() <= box.bottom() && p.y() >= box.top() ) insilmaril@650: return true; insilmaril@650: return false; insilmaril@650: }