Celartem::Rect Struct Reference

#include <cel_geom.h>

List of all members.

Public Member Functions

ssize_t right () const
ssize_t bottom () const
Point leftTop () const
Point leftBottom () const
Point rightTop () const
Point rightBottom () const
 Rect (ssize_t inLeft=0, ssize_t inTop=0, ssize_t inWidth=0, ssize_t inHeight=0)
 Rect (const Rect &inRect)
Rectoperator= (const Rect &inRect)
bool operator== (const Rect &inRect) const
bool operator!= (const Rect &inRect) const
void zeroReset ()
bool isValid () const
bool isInside (const Rect &inRect) const
bool intersectWith (const Rect &inRect) const
void offset (ssize_t inHorzOffset, ssize_t inVertOffset)
void offset (const Point &inOffset)
void inflate (ssize_t size)
void deflate (ssize_t size)

Static Public Member Functions

static void unionRects (Rect &outRect, const Rect &inRect1, const Rect &inRect2)
static void unionRects (Rect &outRect, const Rect *inRects, size_t inCount)
static bool intersection (Rect &outRect, const Rect &inRect1, const Rect &inRect2)

Public Attributes

ssize_t left
 X-coordinate of the upper-left corner.
ssize_t top
 Y-coordinate of the upper-left corner.
ssize_t width
 Width of the rectangle.
ssize_t height
 Height of the rectangle.


Detailed Description

A Rect struct stores the upper-left corner, width, and height of a rectangle.

Definition at line 101 of file cel_geom.h.


Constructor & Destructor Documentation

Celartem::Rect::Rect ( ssize_t  inLeft = 0,
ssize_t  inTop = 0,
ssize_t  inWidth = 0,
ssize_t  inHeight = 0 
) [inline]

This constructor initializes a Rect instance whose x-coordinate, y-coordinate, width, and height are all zero.

Parameters:
inLeft X-coordinate of the upper-left corner of the rectangle.
inTop Y-coordinate of the upper-left corner of the rectangle.
inWidth Width of the rectangle.
inHeight Height of the rectangle.

Definition at line 162 of file cel_geom.h.

Celartem::Rect::Rect ( const Rect inRect  )  [inline]

This constructor copies the specified Rect instance.

Parameters:
inRect A rectangle instance.

Definition at line 174 of file cel_geom.h.


Member Function Documentation

ssize_t Celartem::Rect::right (  )  const [inline]

This function returns the X-coordinate of the right line.

Returns:
X-coordinate of the right line.

Definition at line 113 of file cel_geom.h.

Referenced by intersection(), isInside(), rightBottom(), rightTop(), and unionRects().

ssize_t Celartem::Rect::bottom (  )  const [inline]

This function returns the Y-coordinate of the bottom line.

Returns:
Y-coordinate of the bottom line.

Definition at line 120 of file cel_geom.h.

Referenced by intersection(), isInside(), leftBottom(), rightBottom(), and unionRects().

Point Celartem::Rect::leftTop (  )  const [inline]

This function returns the left-top position.

Returns:
The left-top position in Point structure.

Definition at line 127 of file cel_geom.h.

Point Celartem::Rect::leftBottom (  )  const [inline]

This function returns the left-bottom position.

Returns:
The left-bottom position in Point structure.

Definition at line 134 of file cel_geom.h.

Point Celartem::Rect::rightTop (  )  const [inline]

This function returns the right-top position.

Returns:
The right-top position in Point structure.

Definition at line 141 of file cel_geom.h.

Point Celartem::Rect::rightBottom (  )  const [inline]

This function returns the right-bottom position.

Returns:
The right-bottom position in Point structure.

Definition at line 148 of file cel_geom.h.

Rect& Celartem::Rect::operator= ( const Rect inRect  )  [inline]

This function copies the specified Rect instance.

Parameters:
inRect A rectangle instance.
Returns:
Reference to this instance.

Definition at line 189 of file cel_geom.h.

bool Celartem::Rect::operator== ( const Rect inRect  )  const [inline]

This function compares this instance with another.

Returns:
true if this instance is identical to inRect, otherwise false.

Definition at line 204 of file cel_geom.h.

bool Celartem::Rect::operator!= ( const Rect inRect  )  const [inline]

This function compares this instance with another.

Returns:
true if this instance is not identical to inRect, otherwise false.

Definition at line 217 of file cel_geom.h.

void Celartem::Rect::zeroReset (  )  [inline]

This function initializes the Rect instance to (0,0,0,0).

Definition at line 226 of file cel_geom.h.

bool Celartem::Rect::isValid (  )  const [inline]

This function checks whether this rectangle stands for some valid area or not.

Returns:
true if the rectangle is valid, otherwise false.

Definition at line 238 of file cel_geom.h.

Referenced by intersection().

bool Celartem::Rect::isInside ( const Rect inRect  )  const [inline]

This function checks wether the specified rectangle is in the rectangle or not. In the judgement, the 4 border lines of the inner rectangle can be overwrapped onto the lines of the outer rectangle.

Parameters:
inRect The rectangle to check the containment.
Returns:
true if the rectangle is in this rectangle, otherwise false.

Definition at line 254 of file cel_geom.h.

static void Celartem::Rect::unionRects ( Rect outRect,
const Rect inRect1,
const Rect inRect2 
) [inline, static]

This function calculates the smallest rectangle that can contain both of the two rectangles specified by inRect1 and inRect2.

Parameters:
outRect The result rectangle.
inRect1 
inRect2 The rectangles to be contained.

Definition at line 272 of file cel_geom.h.

static void Celartem::Rect::unionRects ( Rect outRect,
const Rect inRects,
size_t  inCount 
) [inline, static]

This function calculates the smallest rectangle that can contain all the rectangles specified.

Parameters:
outRect The result rectangle.
inRects An array of Rect instances.
inCount The count of Rect instances in the array.

Definition at line 295 of file cel_geom.h.

static bool Celartem::Rect::intersection ( Rect outRect,
const Rect inRect1,
const Rect inRect2 
) [inline, static]

This function calculates the intersection of the two rectangles specified by inRect1 and inRect2.

Parameters:
outRect The result rectangle.
inRect1 
inRect2 The rectangles to calculate the intersection.
Returns:
true if there're a valid intersection between the rectangles, otherwise false.

Definition at line 328 of file cel_geom.h.

Referenced by intersectWith().

bool Celartem::Rect::intersectWith ( const Rect inRect  )  const [inline]

This function determines whether this Rect intersects with the specified Rect instance or not.

Parameters:
inRect The rectangle to calculate the intersection.
Returns:
true if there're a valid intersection between the rectangles, otherwise false.

Definition at line 355 of file cel_geom.h.

void Celartem::Rect::offset ( ssize_t  inHorzOffset,
ssize_t  inVertOffset 
) [inline]

This function moves this rectangle the specified offsets.

Parameters:
inHorzOffset Horizontal offset to move the rectangle.
inVertOffset Vertical offset to move the rectangle.

Definition at line 369 of file cel_geom.h.

Referenced by offset().

void Celartem::Rect::offset ( const Point inOffset  )  [inline]

This function moves this rectangle the specified offsets.

Parameters:
inOffset Offset to move the rectangle.

Definition at line 381 of file cel_geom.h.

void Celartem::Rect::inflate ( ssize_t  size  )  [inline]

This function inflates this rectangle by the specified size.
For example, if the original rectangle is Left=0, Top=0, Width=8, Height=8 and then do infration by 2, the result is Left=-2, Top=-2, Width=12, Height=12.

Parameters:
size Size to inflate.

Definition at line 394 of file cel_geom.h.

Referenced by deflate().

void Celartem::Rect::deflate ( ssize_t  size  )  [inline]

This function inflates this rectangle by the specified size.
For example, if the original rectangle is Left=0, Top=0, Width=8, Height=8 and then do defration by 2, the result is Left=2, Top=2, Width=4, Height=4.
Please note that this function does not check the validity of the resulting rectangle (negative width/height).

Parameters:
size Size to deflate.

Definition at line 412 of file cel_geom.h.


Member Data Documentation

ssize_t Celartem::Rect::left

X-coordinate of the upper-left corner.

Definition at line 103 of file cel_geom.h.

Referenced by Celartem::DjVu::TextZone::create(), inflate(), intersection(), isInside(), leftBottom(), leftTop(), offset(), operator!=(), operator=(), operator==(), Rect(), right(), unionRects(), and zeroReset().

ssize_t Celartem::Rect::top

Y-coordinate of the upper-left corner.

Definition at line 104 of file cel_geom.h.

Referenced by bottom(), Celartem::DjVu::TextZone::create(), inflate(), intersection(), isInside(), leftTop(), offset(), operator!=(), operator=(), operator==(), Rect(), rightTop(), unionRects(), and zeroReset().

ssize_t Celartem::Rect::width

Width of the rectangle.

Definition at line 105 of file cel_geom.h.

Referenced by Celartem::DjVu::TextZone::create(), inflate(), intersection(), isValid(), operator!=(), operator=(), operator==(), Rect(), right(), unionRects(), and zeroReset().

ssize_t Celartem::Rect::height

Height of the rectangle.

Definition at line 106 of file cel_geom.h.

Referenced by bottom(), Celartem::DjVu::TextZone::create(), inflate(), intersection(), isValid(), operator!=(), operator=(), operator==(), Rect(), unionRects(), and zeroReset().


The documentation for this struct was generated from the following file:
This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:23:17 2008.