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