Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Private Attributes | Friends
FRect Class Reference

The FRect class defines a rectangle in the plane. More...

#include <frect.h>

List of all members.

Public Member Functions

 FRect ()
 
Constructs an invalid rectangle.

 FRect (FPoint &topleft, FPoint &bottomright)
 Constructs a rectangle with topLeft as the top-left corner and bottomRight as the bottom-right corner.
 FRect (FPoint &topleft, FSize &size)
 Constructs a rectangle with topLeft as the top-left corner and size as the rectangle size.
 FRect (double left, double top, double width, double height)
 
Constructs a rectangle with the \a top, \a left corner and \a
width and \a height.

bool isNull () const
 
Returns TRUE if the rectangle is a null rectangle; otherwise
returns FALSE.

bool isEmpty () const
 
Returns TRUE if the rectangle is empty; otherwise returns FALSE.

bool isValid () const
 
Returns TRUE if the rectangle is valid; otherwise returns FALSE.

FRect normalize () const
 Returns a normalized rectangle, i.e.
double left () const
 
Returns the left coordinate of the rectangle.

double top () const
 
Returns the top coordinate of the rectangle.

double right () const
 
Returns the right coordinate of the rectangle.

double bottom () const
 
Returns the bottom coordinate of the rectangle.

double & rLeft ()
 
Returns a reference to the left coordinate of the rectangle.

double & rTop ()
 
Returns a reference to the top coordinate of the rectangle.

double & rRight ()
 
Returns a reference to the right coordinate of the rectangle.

double & rBottom ()
 
Returns a reference to the bottom coordinate of the rectangle.

double x () const
 
Returns the left coordinate of the rectangle.

double y () const
 
Returns the top coordinate of the rectangle.

void setLeft (double pos)
 
Sets the left edge of the rectangle to \a pos.

void setTop (double pos)
 
Sets the top edge of the rectangle to \a pos.

void setRight (double pos)
 
Sets the right edge of the rectangle to \a pos.

void setBottom (double pos)
 
Sets the bottom edge of the rectangle to \a pos.

void setX (double x)
 
Sets the x position of the rectangle (its left end) to \a x.

void setY (double y)
 
Sets the y position of the rectangle (its top) to \a y.

void setTopLeft (FPoint &p)
 Set the top-left corner of the rectangle to p.
void setBottomRight (FPoint &p)
 Set the bottom-right corner of the rectangle to p.
void setTopRight (FPoint &p)
 Set the top-right corner of the rectangle to p.
void setBottomLeft (FPoint &p)
 Set the bottom-left corner of the rectangle to p.
FPoint topLeft () const
 
Returns the top-left position of the rectangle.

FPoint bottomRight () const
 
Returns the bottom-right position of the rectangle.

FPoint topRight () const
 
Returns the top-right position of the rectangle.

FPoint bottomLeft () const
 
Returns the bottom-left position of the rectangle.

FPoint center () const
 
Returns the center point of the rectangle.

void rect (double *x, double *y, double *w, double *h) const
 Extracts the rectangle parameters as the position *x, *y and width *w and height *h.
void coords (double *x1, double *y1, double *x2, double *y2) const
 Extracts the rectangle parameters as the top-left point *xp1, *yp1 and the bottom-right point *xp2, *yp2.
void moveLeft (double pos)
 Sets the left position of the rectangle to pos, leaving the size unchanged.
void moveTop (double pos)
 Sets the top position of the rectangle to pos, leaving the size unchanged.
void moveRight (double pos)
 Sets the right position of the rectangle to pos, leaving the size unchanged.
void moveBottom (double pos)
 Sets the bottom position of the rectangle to pos, leaving the size unchanged.
void moveTopLeft (FPoint &p)
 Sets the top-left position of the rectangle to p, leaving the size unchanged.
void moveBottomRight (FPoint &p)
 Sets the bottom-right position of the rectangle to p, leaving the size unchanged.
void moveTopRight (FPoint &p)
 Sets the top-right position of the rectangle to p, leaving the size unchanged.
void moveBottomLeft (FPoint &p)
 Sets the bottom-left position of the rectangle to p, leaving the size unchanged.
void moveCenter (FPoint &p)
 Sets the center point of the rectangle to p, leaving the size unchanged.
void moveBy (double dx, double dy)
 Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
void setRect (double x, double y, double w, double h)
 Sets the coordinates of the rectangle's top-left corner to (x, y), and its size to (w, h).
void setCoords (double x1, double y1, double x2, double y2)
 Sets the coordinates of the rectangle's top-left corner to (xp1, yp1), and the coordinates of its bottom-right corner to (xp2, yp2).
void addCoords (double x1, double y1, double x2, double y2)
 Adds xp1, yp1, xp2 and yp2 respectively to the existing coordinates of the rectangle.
FSize size () const
 
Returns the size of the rectangle.

double width () const
 
Returns the width of the rectangle.

double height () const
 
Returns the height of the rectangle.

void setWidth (double w)
 Sets the width of the rectangle to w.
void setHeight (double h)
 Sets the height of the rectangle to h.
void setSize (const FSize &s)
 Sets the size of the rectangle to s.
FRect operator| (const FRect &r) const
 Returns the bounding rectangle of this rectangle and rectangle r.
FRect operator& (const FRect &r) const
 Returns the intersection of this rectangle and rectangle r.
FRectoperator|= (const FRect &r)
 Unites this rectangle with rectangle r.
FRectoperator&= (const FRect &r)
 Intersects this rectangle with rectangle r.
bool contains (FPoint &p, bool proper=FALSE) const
 Returns TRUE if the point p is inside or on the edge of the rectangle; otherwise returns FALSE.
bool contains (double x, double y) const
bool contains (double x, double y, bool proper) const
bool contains (const FRect &r, bool proper=FALSE) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns TRUE if the rectangle r is inside this rectangle; otherwise returns FALSE.
FRect unite (const FRect &r) const
 Returns the bounding rectangle of this rectangle and rectangle r.
FRect intersect (const FRect &r) const
 Returns the intersection of this rectangle and rectangle r.
bool intersects (const FRect &r) const
 Returns TRUE if this rectangle intersects with rectangle r (there is at least one pixel that is within both rectangles); otherwise returns FALSE.

Private Attributes

double x1
double y1
double x2
double y2

Friends

bool operator== (const FRect &, const FRect &)
bool operator!= (const FRect &, const FRect &)

Detailed Description

The FRect class defines a rectangle in the plane.

A rectangle is internally represented as an upper-left corner and a bottom-right corner, but it is normally expressed as an upper-left corner and a size.

The coordinate type is double (defined in qwindowdefs.h as int). The minimum value of double is double_MIN (-2147483648) and the maximum value is double_MAX (2147483647).

Note that the size (width and height) of a rectangle might be different from what you are used to. If the top-left corner and the bottom-right corner are the same, the height and the width of the rectangle will both be 1.

Generally, {width = right - left + 1} and {height = bottom - top + 1}. We designed it this way to make it correspond to rectangular spaces used by drawing functions in which the width and height denote a number of pixels. For example, drawing a rectangle with width and height 1 draws a single pixel.

The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.

A FRect can be constructed with a set of left, top, width and height integers, from two FPoints or from a FPoint and a FSize. After creation the dimensions can be changed, e.g. with setLeft(), setRight(), setTop() and setBottom(), or by setting sizes, e.g. setWidth(), setHeight() and setSize(). The dimensions can also be changed with the move functions, e.g. moveBy(), moveCenter(), moveBottomRight(), etc. You can also add coordinates to a rectangle with addCoords().

You can test to see if a FRect contains a specific point with contains(). You can also test to see if two FRects intersect with intersects() (see also intersect()). To get the bounding rectangle of two FRects use unite().

See also:
FPoint, FSize

Definition at line 50 of file frect.h.


Constructor & Destructor Documentation

FRect::FRect ( ) [inline]

Constructs an invalid rectangle.

Definition at line 53 of file frect.h.

{ x1 = y1 = 0; x2 = y2 = -1; }
FRect::FRect ( FPoint &  topleft,
FPoint &  bottomright 
)

Constructs a rectangle with topLeft as the top-left corner and bottomRight as the bottom-right corner.

Definition at line 106 of file frect.cpp.

{
    x1 = (double)topLeft.x();
    y1 = (double)topLeft.y();
    x2 = (double)bottomRight.x();
    y2 = (double)bottomRight.y();
}
FRect::FRect ( FPoint &  topleft,
FSize size 
)

Constructs a rectangle with topLeft as the top-left corner and size as the rectangle size.

Definition at line 119 of file frect.cpp.

{
    x1 = (double)topLeft.x();
    y1 = (double)topLeft.y();
    x2 = (double)(x1+size.width());
    y2 = (double)(y1+size.height());
}

Here is the call graph for this function:

FRect::FRect ( double  left,
double  top,
double  width,
double  height 
) [inline]

Constructs a rectangle with the \a top, \a left corner and \a
width and \a height.

Example (creates three identical rectangles):

       FRect r1( FPoint(100,200), FPoint(110,215) );
       FRect r2( FPoint(100,200), FSize(11,16) );
       FRect r3( 100, 200, 11, 16 );

Definition at line 162 of file frect.h.

{
    x1 = (double)left;
    y1 = (double)top;
    x2 = (double)(left+width-1);
    y2 = (double)(top+height-1);
}

Member Function Documentation

void FRect::addCoords ( double  x1,
double  y1,
double  x2,
double  y2 
)

Adds xp1, yp1, xp2 and yp2 respectively to the existing coordinates of the rectangle.

Definition at line 662 of file frect.cpp.

{
    x1 += (double)xp1;
    y1 += (double)yp1;
    x2 += (double)xp2;
    y2 += (double)yp2;
}
double FRect::bottom ( ) const [inline]

Returns the bottom coordinate of the rectangle.

See also:
setBottom(), top(), bottomLeft(), bottomRight()

Definition at line 188 of file frect.h.

{ return y2; }
FPoint FRect::bottomLeft ( ) const [inline]

Returns the bottom-left position of the rectangle.

See also:
setBottomLeft(), moveBottomLeft(), topRight(), bottom(), left()

Definition at line 236 of file frect.h.

{ return FPoint(x1, y2); }
FPoint FRect::bottomRight ( ) const [inline]

Returns the bottom-right position of the rectangle.

See also:
setBottomRight(), moveBottomRight(), topLeft(), right(), bottom()

Definition at line 230 of file frect.h.

{ return FPoint(x2, y2); }
FPoint FRect::center ( ) const [inline]

Returns the center point of the rectangle.

See also:
moveCenter(), topLeft(), bottomRight(), topRight(), bottomLeft()

Definition at line 239 of file frect.h.

{ return FPoint((x1+x2)/2, (y1+y2)/2); }
bool FRect::contains ( FPoint &  p,
bool  proper = FALSE 
) const

Returns TRUE if the point p is inside or on the edge of the rectangle; otherwise returns FALSE.

If proper is TRUE, this function returns TRUE only if p is inside (not on the edge).

Definition at line 741 of file frect.cpp.

{
    if ( proper )
       return p.x() > x1 && p.x() < x2 &&
              p.y() > y1 && p.y() < y2;
    else
       return p.x() >= x1 && p.x() <= x2 &&
              p.y() >= y1 && p.y() <= y2;
}
bool FRect::contains ( double  x,
double  y 
) const [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 261 of file frect.h.

{
    return x >= x1 && x <= x2 &&
          y >= y1 && y <= y2;
}
bool FRect::contains ( double  x,
double  y,
bool  proper 
) const [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If proper is TRUE, this function returns TRUE only if the point is entirely inside (not on the edge).

Definition at line 251 of file frect.h.

{
    if ( proper )
        return x > x1 && x < x2 &&
               y > y1 && y < y2;
    else
        return x >= x1 && x <= x2 &&
               y >= y1 && y <= y2;
}
bool FRect::contains ( const FRect r,
bool  proper = FALSE 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns TRUE if the rectangle r is inside this rectangle; otherwise returns FALSE.

If proper is TRUE, this function returns TRUE only if r is entirely inside (not on the edge).

See also:
unite(), intersect(), intersects()

Definition at line 780 of file frect.cpp.

{
    if ( proper )
       return r.x1 > x1 && r.x2 < x2 && r.y1 > y1 && r.y2 < y2;
    else
       return r.x1 >= x1 && r.x2 <= x2 && r.y1 >= y1 && r.y2 <= y2;
}
void FRect::coords ( double *  xp1,
double *  yp1,
double *  xp2,
double *  yp2 
) const

Extracts the rectangle parameters as the top-left point *xp1, *yp1 and the bottom-right point *xp2, *yp2.

See also:
setCoords(), rect()

Definition at line 479 of file frect.cpp.

{
    *xp1 = x1;
    *yp1 = y1;
    *xp2 = x2;
    *yp2 = y2;
}
double FRect::height ( ) const [inline]

Returns the height of the rectangle.

The height includes both the top and bottom edges, i.e. height = bottom - top + 1.

See also:
width(), size(), setHeight()

Definition at line 245 of file frect.h.

{ return  y2 - y1 + 1; }
FRect FRect::intersect ( const FRect r) const

Returns the intersection of this rectangle and rectangle r.

{r.intersect(s)} is equivalent to {r&s}.

Definition at line 867 of file frect.cpp.

{
    return *this & r;
}
bool FRect::intersects ( const FRect r) const

Returns TRUE if this rectangle intersects with rectangle r (there is at least one pixel that is within both rectangles); otherwise returns FALSE.

See also:
intersect(), contains()

Definition at line 880 of file frect.cpp.

{
    return ( QMAX( x1, r.x1 ) <= QMIN( x2, r.x2 ) &&
            QMAX( y1, r.y1 ) <= QMIN( y2, r.y2 ) );
}
bool FRect::isEmpty ( ) const [inline]

Returns TRUE if the rectangle is empty; otherwise returns FALSE.

An empty rectangle has a left() > right() or top() > bottom().

An empty rectangle is not valid. {isEmpty() == !isValid()}

See also:
isNull(), isValid(), normalize()

Definition at line 173 of file frect.h.

{ return x1 > x2 || y1 > y2; }
bool FRect::isNull ( ) const [inline]

Returns TRUE if the rectangle is a null rectangle; otherwise
returns FALSE.

A null rectangle has both the width and the height set to 0, that is right() == left() - 1 and bottom() == top() - 1.

Note that if right() == left() and bottom() == top(), then the rectangle has width 1 and height 1.

A null rectangle is also empty.

A null rectangle is not valid.

See also:
isEmpty(), isValid()

Definition at line 170 of file frect.h.

{ return x2 == x1-1 && y2 == y1-1; }
bool FRect::isValid ( ) const [inline]

Returns TRUE if the rectangle is valid; otherwise returns FALSE.

A valid rectangle has a left() <= right() and top() <= bottom().

Note that non-trivial operations like intersections are not defined for invalid rectangles.

{isValid() == !isEmpty()}

See also:
isNull(), isEmpty(), normalize()

Definition at line 176 of file frect.h.

{ return x1 <= x2 && y1 <= y2; }

Here is the caller graph for this function:

double FRect::left ( ) const [inline]

Returns the left coordinate of the rectangle.

Identical to x().

See also:
setLeft(), right(), topLeft(), bottomLeft()

Definition at line 179 of file frect.h.

{ return x1; }
void FRect::moveBottom ( double  pos)

Sets the bottom position of the rectangle to pos, leaving the size unchanged.

See also:
bottom(), setBottom(), moveLeft(), moveTop(), moveRight()

Definition at line 533 of file frect.cpp.

{
    y1 += (double)(pos - y2);
    y2 = (double)pos;
}

Here is the caller graph for this function:

void FRect::moveBottomLeft ( FPoint &  p)

Sets the bottom-left position of the rectangle to p, leaving the size unchanged.

See also:
bottomLeft(), setBottomLeft(), moveTopLeft(), moveBottomRight(), moveTopRight()

Definition at line 585 of file frect.cpp.

{
    moveLeft( p.x() );
    moveBottom( p.y() );
}

Here is the call graph for this function:

void FRect::moveBottomRight ( FPoint &  p)

Sets the bottom-right position of the rectangle to p, leaving the size unchanged.

See also:
bottomRight(), setBottomRight(), moveTopLeft(), moveTopRight(), moveBottomLeft()

Definition at line 559 of file frect.cpp.

{
    moveRight( p.x() );
    moveBottom( p.y() );
}

Here is the call graph for this function:

void FRect::moveBy ( double  dx,
double  dy 
)

Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.

Positive values move the rectangle to the right and down.

See also:
moveTopLeft()

Definition at line 618 of file frect.cpp.

{
    x1 += (double)dx;
    y1 -= (double)dy;
    x2 += (double)dx;
    y2 -= (double)dy;
}
void FRect::moveCenter ( FPoint &  p)

Sets the center point of the rectangle to p, leaving the size unchanged.

See also:
center(), moveTopLeft(), moveBottomRight(), moveTopRight(), moveBottomLeft()

Definition at line 599 of file frect.cpp.

{
    double w = x2 - x1;
    double h = y2 - y1;
    x1 = (double)(p.x() - w/2);
    y1 = (double)(p.y() - h/2);
    x2 = x1 + w;
    y2 = y1 + h;
}
void FRect::moveLeft ( double  pos)

Sets the left position of the rectangle to pos, leaving the size unchanged.

See also:
left(), setLeft(), moveTop(), moveRight(), moveBottom()

Definition at line 494 of file frect.cpp.

{
    x2 += (double)(pos - x1);
    x1 = (double)pos;
}

Here is the caller graph for this function:

void FRect::moveRight ( double  pos)

Sets the right position of the rectangle to pos, leaving the size unchanged.

See also:
right(), setRight(), moveLeft(), moveTop(), moveBottom()

Definition at line 520 of file frect.cpp.

{
    x1 += (double)(pos - x2);
    x2 = (double)pos;
}

Here is the caller graph for this function:

void FRect::moveTop ( double  pos)

Sets the top position of the rectangle to pos, leaving the size unchanged.

See also:
top(), setTop(), moveLeft(), moveRight(), moveBottom()

Definition at line 507 of file frect.cpp.

{
    y2 += (double)(pos - y1);
    y1 = (double)pos;
}

Here is the caller graph for this function:

void FRect::moveTopLeft ( FPoint &  p)

Sets the top-left position of the rectangle to p, leaving the size unchanged.

See also:
topLeft(), setTopLeft(), moveBottomRight(), moveTopRight(), moveBottomLeft()

Definition at line 546 of file frect.cpp.

{
    moveLeft( p.x() );
    moveTop( p.y() );
}

Here is the call graph for this function:

void FRect::moveTopRight ( FPoint &  p)

Sets the top-right position of the rectangle to p, leaving the size unchanged.

See also:
topRight(), setTopRight(), moveTopLeft(), moveBottomRight(), moveBottomLeft()

Definition at line 572 of file frect.cpp.

{
    moveRight( p.x() );
    moveTop( p.y() );
}

Here is the call graph for this function:

Returns a normalized rectangle, i.e.

a rectangle that has a non-negative width and height.

It swaps left and right if left() > right(), and swaps top and bottom if top() > bottom().

See also:
isValid()

Definition at line 199 of file frect.cpp.

{
    FRect r;
    if ( x2 < x1 ) {                      // swap bad x values
       r.x1 = x2;
       r.x2 = x1;
    } else {
       r.x1 = x1;
       r.x2 = x2;
    }
    if ( y2 < y1 ) {                      // swap bad y values
       r.y1 = y2;
       r.y2 = y1;
    } else {
       r.y1 = y1;
       r.y2 = y2;
    }
    return r;
}
FRect FRect::operator& ( const FRect r) const

Returns the intersection of this rectangle and rectangle r.

Returns an empty rectangle if there is no intersection.

See also:
operator&=(), operator|(), isEmpty(), intersects(), contains()

Definition at line 853 of file frect.cpp.

{
    FRect tmp;
    tmp.x1 = QMAX( x1, r.x1 );
    tmp.x2 = QMIN( x2, r.x2 );
    tmp.y1 = QMAX( y1, r.y1 );
    tmp.y2 = QMIN( y2, r.y2 );
    return tmp;
}
FRect & FRect::operator&= ( const FRect r)

Intersects this rectangle with rectangle r.

Definition at line 800 of file frect.cpp.

{
    *this = *this & r;
    return *this;
}
FRect FRect::operator| ( const FRect r) const

Returns the bounding rectangle of this rectangle and rectangle r.

The bounding rectangle of a nonempty rectangle and an empty or invalid rectangle is defined to be the nonempty rectangle.

See also:
operator|=(), operator&(), intersects(), contains()

Definition at line 817 of file frect.cpp.

{
    if ( isValid() ) {
       if ( r.isValid() ) {
           FRect tmp;
           tmp.setLeft(   QMIN( x1, r.x1 ) );
           tmp.setRight(  QMAX( x2, r.x2 ) );
           tmp.setTop(         QMIN( y1, r.y1 ) );
           tmp.setBottom( QMAX( y2, r.y2 ) );
           return tmp;
       } else {
           return *this;
       }
    } else {
       return r;
    }
}

Here is the call graph for this function:

FRect & FRect::operator|= ( const FRect r)

Unites this rectangle with rectangle r.

Definition at line 791 of file frect.cpp.

{
    *this = *this | r;
    return *this;
}
double & FRect::rBottom ( ) [inline]

Returns a reference to the bottom coordinate of the rectangle.

See also:
rLeft(), rTop(), rRight()

Definition at line 200 of file frect.h.

{ return y2; }
void FRect::rect ( double *  x,
double *  y,
double *  w,
double *  h 
) const

Extracts the rectangle parameters as the position *x, *y and width *w and height *h.

See also:
setRect(), coords()

Definition at line 464 of file frect.cpp.

{
    *x = x1;
    *y = y1;
    *w = x2-x1;
    *h = y2-y1;
}
double FRect::right ( ) const [inline]

Returns the right coordinate of the rectangle.

See also:
setRight(), left(), topRight(), bottomRight()

Definition at line 185 of file frect.h.

{ return x2; }
double & FRect::rLeft ( ) [inline]

Returns a reference to the left coordinate of the rectangle.

See also:
rTop(), rRight(), rBottom()

Definition at line 191 of file frect.h.

{ return x1; }
double & FRect::rRight ( ) [inline]

Returns a reference to the right coordinate of the rectangle.

See also:
rLeft(), rTop(), rBottom()

Definition at line 197 of file frect.h.

{ return x2; }
double & FRect::rTop ( ) [inline]

Returns a reference to the top coordinate of the rectangle.

See also:
rLeft(), rRight(), rBottom()

Definition at line 194 of file frect.h.

{ return y1; }
void FRect::setBottom ( double  pos) [inline]

Sets the bottom edge of the rectangle to \a pos.

May change the height, but will never change the top edge of the rectangle.

See also:
bottom(), setTop(), setHeight()

Definition at line 218 of file frect.h.

{ y2 = (double)pos; }

Here is the caller graph for this function:

void FRect::setBottomLeft ( FPoint &  p)

Set the bottom-left corner of the rectangle to p.

May change the size, but will the never change the top-right corner of the rectangle.

See also:
bottomLeft(), moveBottomLeft(), setTopLeft(), setBottomRight(), setTopRight()

Definition at line 410 of file frect.cpp.

{
    setLeft( p.x() );
    setBottom( p.y() );
}

Here is the call graph for this function:

void FRect::setBottomRight ( FPoint &  p)

Set the bottom-right corner of the rectangle to p.

May change the size, but will the never change the top-left corner of the rectangle.

See also:
bottomRight(), moveBottomRight(), setTopLeft(), setTopRight(), setBottomLeft()

Definition at line 384 of file frect.cpp.

{
    setRight( p.x() );
    setBottom( p.y() );
}

Here is the call graph for this function:

void FRect::setCoords ( double  xp1,
double  yp1,
double  xp2,
double  yp2 
)

Sets the coordinates of the rectangle's top-left corner to (xp1, yp1), and the coordinates of its bottom-right corner to (xp2, yp2).

See also:
coords(), setRect()

Definition at line 649 of file frect.cpp.

{
    x1 = (double)xp1;
    y1 = (double)yp1;
    x2 = (double)xp2;
    y2 = (double)yp2;
}
void FRect::setHeight ( double  h)

Sets the height of the rectangle to h.

The top edge is not moved, but the bottom edge may be moved.

See also:
height(), setTop(), setBottom(), setSize()

Definition at line 715 of file frect.cpp.

{
    y2 = (double)(y1 + h);
}
void FRect::setLeft ( double  pos) [inline]

Sets the left edge of the rectangle to \a pos.

May change the width, but will never change the right edge of the rectangle.

Identical to setX().

See also:
left(), setTop(), setWidth()

Definition at line 209 of file frect.h.

{ x1 = (double)pos; }

Here is the caller graph for this function:

void FRect::setRect ( double  x,
double  y,
double  w,
double  h 
)

Sets the coordinates of the rectangle's top-left corner to (x, y), and its size to (w, h).

See also:
rect(), setCoords()

Definition at line 633 of file frect.cpp.

{
    x1 = (double)x;
    y1 = (double)y;
    x2 = (double)(x+w);
    y2 = (double)(y+h);
}
void FRect::setRight ( double  pos) [inline]

Sets the right edge of the rectangle to \a pos.

May change the width, but will never change the left edge of the rectangle.

See also:
right(), setLeft(), setWidth()

Definition at line 215 of file frect.h.

{ x2 = (double)pos; }

Here is the caller graph for this function:

void FRect::setSize ( const FSize s)

Sets the size of the rectangle to s.

The top-left corner is not moved.

See also:
size(), setWidth(), setHeight()

Definition at line 727 of file frect.cpp.

{
    x2 = (double)(s.width() +x1);
    y2 = (double)(s.height()+y1);
}

Here is the call graph for this function:

void FRect::setTop ( double  pos) [inline]

Sets the top edge of the rectangle to \a pos.

May change the height, but will never change the bottom edge of the rectangle.

Identical to setY().

See also:
top(), setBottom(), setHeight()

Definition at line 212 of file frect.h.

{ y1 = (double)pos; }

Here is the caller graph for this function:

void FRect::setTopLeft ( FPoint &  p)

Set the top-left corner of the rectangle to p.

May change the size, but will the never change the bottom-right corner of the rectangle.

See also:
topLeft(), moveTopLeft(), setBottomRight(), setTopRight(), setBottomLeft()

Definition at line 371 of file frect.cpp.

{
    setLeft( p.x() );
    setTop( p.y() );
}

Here is the call graph for this function:

void FRect::setTopRight ( FPoint &  p)

Set the top-right corner of the rectangle to p.

May change the size, but will the never change the bottom-left corner of the rectangle.

See also:
topRight(), moveTopRight(), setTopLeft(), setBottomRight(), setBottomLeft()

Definition at line 397 of file frect.cpp.

{
    setRight( p.x() );
    setTop( p.y() );
}

Here is the call graph for this function:

void FRect::setWidth ( double  w)

Sets the width of the rectangle to w.

The right edge is changed, but not the left edge.

See also:
width(), setLeft(), setRight(), setSize()

Definition at line 703 of file frect.cpp.

{
    x2 = (double)(x1 + w);
}
void FRect::setX ( double  x) [inline]

Sets the x position of the rectangle (its left end) to \a x.

May change the width, but will never change the right edge of the rectangle.

Identical to setLeft().

See also:
x(), setY()

Definition at line 221 of file frect.h.

{ x1 = (double)x; }
void FRect::setY ( double  y) [inline]

Sets the y position of the rectangle (its top) to \a y.

May change the height, but will never change the bottom edge of the rectangle.

Identical to setTop().

See also:
y(), setX()

Definition at line 224 of file frect.h.

{ y1 = (double)y; }
FSize FRect::size ( ) const [inline]

Returns the size of the rectangle.

See also:
width(), height()

Definition at line 248 of file frect.h.

{ return FSize(x2-x1+1, y2-y1+1); }
double FRect::top ( ) const [inline]

Returns the top coordinate of the rectangle.

Identical to y().

See also:
setTop(), bottom(), topLeft(), topRight()

Definition at line 182 of file frect.h.

{ return y1; }
FPoint FRect::topLeft ( ) const [inline]

Returns the top-left position of the rectangle.

See also:
setTopLeft(), moveTopLeft(), bottomRight(), left(), top()

Definition at line 227 of file frect.h.

{ return FPoint(x1, y1); }
FPoint FRect::topRight ( ) const [inline]

Returns the top-right position of the rectangle.

See also:
setTopRight(), moveTopRight(), bottomLeft(), top(), right()

Definition at line 233 of file frect.h.

{ return FPoint(x2, y1); }
FRect FRect::unite ( const FRect r) const

Returns the bounding rectangle of this rectangle and rectangle r.

{r.unite(s)} is equivalent to {r|s}.

Definition at line 839 of file frect.cpp.

{
    return *this | r;
}
double FRect::width ( ) const [inline]

Returns the width of the rectangle.

The width includes both the left and right edges, i.e. width = right - left + 1.

See also:
height(), size(), setHeight()

Definition at line 242 of file frect.h.

{ return  x2 - x1 + 1; }
double FRect::x ( ) const [inline]

Returns the left coordinate of the rectangle.

Identical to left().

See also:
left(), y(), setX()

Definition at line 203 of file frect.h.

{ return x1; }
double FRect::y ( ) const [inline]

Returns the top coordinate of the rectangle.

Identical to top().

See also:
top(), x(), setY()

Definition at line 206 of file frect.h.

{ return y1; }

Friends And Related Function Documentation

bool operator!= ( const FRect r1,
const FRect r2 
) [friend]

Returns TRUE if r1 and r2 are different; otherwise returns FALSE.

Definition at line 904 of file frect.cpp.

{
    return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2;
}
bool operator== ( const FRect r1,
const FRect r2 
) [friend]

Returns TRUE if r1 and r2 are equal; otherwise returns FALSE.

Definition at line 893 of file frect.cpp.

{
    return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2;
}

Member Data Documentation

double FRect::x1 [private]

Definition at line 139 of file frect.h.

double FRect::x2 [private]

Definition at line 141 of file frect.h.

double FRect::y1 [private]

Definition at line 140 of file frect.h.

double FRect::y2 [private]

Definition at line 142 of file frect.h.


The documentation for this class was generated from the following files: