1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/geometry.cpp Wed Jan 16 15:45:19 2008 +0000
1.3 @@ -0,0 +1,41 @@
1.4 +#include "geometry.h"
1.5 +
1.6 +
1.7 +QRectF addBBox(QRectF r1, QRectF r2)
1.8 +{
1.9 + // Find smallest QRectF containing given rectangles
1.10 +
1.11 + QRectF n;
1.12 + // Set left border
1.13 + if (r1.left() <= r2.left() )
1.14 + n.setLeft(r1.left() );
1.15 + else
1.16 + n.setLeft(r2.left() );
1.17 +
1.18 + // Set top border
1.19 + if (r1.top() <= r2.top() )
1.20 + n.setTop(r1.top() );
1.21 + else
1.22 + n.setTop(r2.top() );
1.23 +
1.24 + // Set right border
1.25 + if (r1.right() <= r2.right() )
1.26 + n.setRight(r2.right() );
1.27 + else
1.28 + n.setRight(r1.right() );
1.29 +
1.30 + // Set bottom
1.31 + if (r1.bottom() <= r2.bottom() )
1.32 + n.setBottom(r2.bottom() );
1.33 + else
1.34 + n.setBottom(r1.bottom() );
1.35 + return n;
1.36 +}
1.37 +
1.38 +bool inBox(const QPointF &p, const QRectF &box)
1.39 +{
1.40 + if (p.x() >= box.left() && p.x() <= box.right()
1.41 + && p.y() <= box.bottom() && p.y() >= box.top() )
1.42 + return true;
1.43 + return false;
1.44 +}