All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GfRect2i Class Reference

A 2D rectangle with integer coordinates for windowing operations. More...

Public Member Functions

 GfRect2i ()
 Constructs an empty rectangle. More...
 
 GfRect2i (const GfVec2i &topLeft, const GfVec2i &bottomRight)
 Constructs a rectangle with topLeft as the top left corner and bottomRight as the bottom right corner. More...
 
 GfRect2i (const GfVec2i &topLeft, int width, int height)
 Constructs a rectangle with topLeft as the top left corner and with the indicated width and height. More...
 
bool IsNull () const
 Returns true if the rectangle is a null rectangle. More...
 
bool IsEmpty () const
 Returns true if the rectangle is empty. More...
 
bool IsValid () const
 Return true if the rectangle is valid (equivalently, not empty). More...
 
GF_API GfRect2i GetNormalized () const
 Returns a normalized rectangle, i.e. More...
 
const GfVec2iGetLower () const
 Returns the lower corner of the rectangle. More...
 
const GfVec2iGetHigher () const
 Returns the upper corner of the rectangle. More...
 
int GetLeft () const
 Return the X value of the left edge. More...
 
void SetLeft (int x)
 Set the X value of the left edge. More...
 
int GetRight () const
 Return the X value of the right edge. More...
 
void SetRight (int x)
 Set the X value of the right edge. More...
 
int GetTop () const
 Return the Y value of the top edge. More...
 
void SetTop (int y)
 Set the Y value of the top edge. More...
 
int GetBottom () const
 Return the Y value of the bottom edge. More...
 
void SetBottom (int y)
 Set the Y value of the bottom edge. More...
 
void SetLower (const GfVec2i &lower)
 Sets the lower corner of the rectangle. More...
 
void SetHigher (const GfVec2i &higher)
 Sets the upper corner of the rectangle. More...
 
GfVec2i GetCenter () const
 Returns the center point of the rectangle. More...
 
void Translate (const GfVec2i &displacement)
 Move the rectangle by displ. More...
 
unsigned long GetArea () const
 Return the area of the rectangle. More...
 
GfVec2i GetSize () const
 Returns the size of the rectangle as a vector (width,height). More...
 
int GetWidth () const
 Returns the width of the rectangle. More...
 
int GetHeight () const
 Returns the height of the rectangle. More...
 
GfRect2i GetIntersection (const GfRect2i &that) const
 Computes the intersection of two rectangles. More...
 
GfRect2i Intersect (const GfRect2i &that) const
 Computes the intersection of two rectangles. More...
 
GfRect2i GetUnion (const GfRect2i &that) const
 Computes the union of two rectangles. More...
 
GfRect2i Union (const GfRect2i &that) const
 Computes the union of two rectangles. More...
 
bool Contains (const GfVec2i &p) const
 Returns true if the specified point in the rectangle. More...
 
GfRect2i operator+= (const GfRect2i &that)
 Computes the union of two rectangles. More...
 

Friends

size_t hash_value (const GfRect2i &r)
 
bool operator== (const GfRect2i &r1, const GfRect2i &r2)
 Returns true if r1 and r2 are equal. More...
 
bool operator!= (const GfRect2i &r1, const GfRect2i &r2)
 Returns true if r1 and r2 are different. More...
 
GfRect2i operator+ (const GfRect2i r1, const GfRect2i &r2)
 

Detailed Description

A 2D rectangle with integer coordinates for windowing operations.

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.

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, then the height and the width of the rectangle will both be one.

Specifically, width = right - left + 1 and height = bottom - top + 1. The design corresponds to rectangular spaces used by drawing functions, where the width and height denote a number of pixels. For example, drawing a rectangle with width and height one 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 downward and the positive x axis is to the right.

Definition at line 65 of file rect2i.h.

Constructor & Destructor Documentation

GfRect2i ( )
inline

Constructs an empty rectangle.

Definition at line 68 of file rect2i.h.

GfRect2i ( const GfVec2i topLeft,
const GfVec2i bottomRight 
)
inline

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

Definition at line 74 of file rect2i.h.

GfRect2i ( const GfVec2i topLeft,
int  width,
int  height 
)
inline

Constructs a rectangle with topLeft as the top left corner and with the indicated width and height.

Definition at line 81 of file rect2i.h.

Member Function Documentation

bool Contains ( const GfVec2i p) const
inline

Returns true if the specified point in the rectangle.

Definition at line 261 of file rect2i.h.

unsigned long GetArea ( ) const
inline

Return the area of the rectangle.

Definition at line 199 of file rect2i.h.

int GetBottom ( ) const
inline

Return the Y value of the bottom edge.

Definition at line 168 of file rect2i.h.

GfVec2i GetCenter ( ) const
inline

Returns the center point of the rectangle.

Definition at line 188 of file rect2i.h.

int GetHeight ( ) const
inline

Returns the height of the rectangle.

Note
If the top and bottom sides are coincident, the height is one.

Definition at line 218 of file rect2i.h.

const GfVec2i& GetHigher ( ) const
inline

Returns the upper corner of the rectangle.

Definition at line 133 of file rect2i.h.

GfRect2i GetIntersection ( const GfRect2i that) const
inline

Computes the intersection of two rectangles.

Definition at line 223 of file rect2i.h.

int GetLeft ( ) const
inline

Return the X value of the left edge.

Definition at line 138 of file rect2i.h.

const GfVec2i& GetLower ( ) const
inline

Returns the lower corner of the rectangle.

Definition at line 128 of file rect2i.h.

GF_API GfRect2i GetNormalized ( ) const

Returns a normalized rectangle, i.e.

one that has a non-negative width and height.

GetNormalized() swaps left and right to ensure a non-negative width, and similarly for top and bottom.

int GetRight ( ) const
inline

Return the X value of the right edge.

Definition at line 148 of file rect2i.h.

GfVec2i GetSize ( ) const
inline

Returns the size of the rectangle as a vector (width,height).

Definition at line 204 of file rect2i.h.

int GetTop ( ) const
inline

Return the Y value of the top edge.

Definition at line 158 of file rect2i.h.

GfRect2i GetUnion ( const GfRect2i that) const
inline

Computes the union of two rectangles.

Definition at line 242 of file rect2i.h.

int GetWidth ( ) const
inline

Returns the width of the rectangle.

Note
If the left and right sides are coincident, the width is one.

Definition at line 211 of file rect2i.h.

GfRect2i Intersect ( const GfRect2i that) const
inline

Computes the intersection of two rectangles.

Deprecated:
Use GetIntersection() instead

Definition at line 237 of file rect2i.h.

bool IsEmpty ( ) const
inline

Returns true if the rectangle is empty.

An empty rectangle has its left side strictly greater than its right side or its top strictly greater than its bottom.

An empty rectangle is not valid.

Definition at line 110 of file rect2i.h.

bool IsNull ( ) const
inline

Returns true if the rectangle is a null rectangle.

A null rectangle has both the width and the height set to 0, that is

* GetRight() == GetLeft() - 1
*

and

* GetBottom() == GetTop() - 1
*

Remember that if GetRight() and GetLeft() return the same value then the rectangle has width 1, and similarly for the height.

A null rectangle is both empty, and not valid.

Definition at line 100 of file rect2i.h.

bool IsValid ( ) const
inline

Return true if the rectangle is valid (equivalently, not empty).

Definition at line 115 of file rect2i.h.

GfRect2i operator+= ( const GfRect2i that)
inline

Computes the union of two rectangles.

See Also
GetUnion()

Definition at line 285 of file rect2i.h.

void SetBottom ( int  y)
inline

Set the Y value of the bottom edge.

Definition at line 173 of file rect2i.h.

void SetHigher ( const GfVec2i higher)
inline

Sets the upper corner of the rectangle.

Definition at line 183 of file rect2i.h.

void SetLeft ( int  x)
inline

Set the X value of the left edge.

Definition at line 143 of file rect2i.h.

void SetLower ( const GfVec2i lower)
inline

Sets the lower corner of the rectangle.

Definition at line 178 of file rect2i.h.

void SetRight ( int  x)
inline

Set the X value of the right edge.

Definition at line 153 of file rect2i.h.

void SetTop ( int  y)
inline

Set the Y value of the top edge.

Definition at line 163 of file rect2i.h.

void Translate ( const GfVec2i displacement)
inline

Move the rectangle by displ.

Definition at line 193 of file rect2i.h.

GfRect2i Union ( const GfRect2i that) const
inline

Computes the union of two rectangles.

Deprecated:
Use GetUnion() instead.

Definition at line 256 of file rect2i.h.

Friends And Related Function Documentation

bool operator!= ( const GfRect2i r1,
const GfRect2i r2 
)
friend

Returns true if r1 and r2 are different.

Definition at line 279 of file rect2i.h.

bool operator== ( const GfRect2i r1,
const GfRect2i r2 
)
friend

Returns true if r1 and r2 are equal.

Definition at line 274 of file rect2i.h.


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