diff -r 000000000000 -r d4b49c6c6069 geometry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/geometry.cpp Wed Jan 16 15:45:19 2008 +0000 @@ -0,0 +1,41 @@ +#include "geometry.h" + + +QRectF addBBox(QRectF r1, QRectF r2) +{ + // Find smallest QRectF containing given rectangles + + QRectF n; + // Set left border + if (r1.left() <= r2.left() ) + n.setLeft(r1.left() ); + else + n.setLeft(r2.left() ); + + // Set top border + if (r1.top() <= r2.top() ) + n.setTop(r1.top() ); + else + n.setTop(r2.top() ); + + // Set right border + if (r1.right() <= r2.right() ) + n.setRight(r2.right() ); + else + n.setRight(r1.right() ); + + // Set bottom + if (r1.bottom() <= r2.bottom() ) + n.setBottom(r2.bottom() ); + else + n.setBottom(r1.bottom() ); + return n; +} + +bool inBox(const QPointF &p, const QRectF &box) +{ + if (p.x() >= box.left() && p.x() <= box.right() + && p.y() <= box.bottom() && p.y() >= box.top() ) + return true; + return false; +}