geometry.cpp
author insilmaril
Tue, 15 Jan 2008 10:54:41 +0000
changeset 650 65c5a0c28d20
child 656 53ef954e90b6
permissions -rw-r--r--
added some missing files
     1 #include "geometry.h"
     2 
     3 
     4 QRectF addBBox(QRectF r1, QRectF r2)
     5 {	
     6 	// Find smallest QRectF containing given rectangles
     7 
     8 	QRectF n;
     9 	// Set left border
    10 	if (r1.left() <= r2.left() )
    11 		n.setLeft(r1.left() );
    12 	else
    13 		n.setLeft(r2.left() );
    14 		
    15 	// Set top border		
    16 	if (r1.top() <= r2.top() )
    17 		n.setTop(r1.top() );
    18 	else
    19 		n.setTop(r2.top() );
    20 		
    21 	// Set right border
    22 	if (r1.right() <= r2.right() )
    23 		n.setRight(r2.right() );
    24 	else
    25 		n.setRight(r1.right() );
    26 		
    27 	// Set bottom 
    28 	if (r1.bottom() <= r2.bottom() )
    29 		n.setBottom(r2.bottom() );
    30 	else
    31 		n.setBottom(r1.bottom() );
    32 	return n;
    33 }
    34 
    35 bool inBox(const QPointF &p, const QRectF &box)
    36 {
    37     if (p.x() >= box.left() && p.x() <= box.right()  
    38 	&& p.y() <= box.bottom() && p.y() >= box.top() )
    39 		return true;
    40     return false;	
    41 }