Guiliani  Version 2.5 revision 7293 (documentation build 13)
CGUIRect Class Reference

Helper class to supply a platform independent rectangle implementation. More...

#include <GUIRect.h>

Public Types

enum  ExpandDirection_t { EXPAND_HORIZONTAL , EXPAND_VERTICAL , EXPAND_ALL }
 enum of expansion types More...
 

Public Member Functions

 CGUIRect ()
 
 CGUIRect (const CGUIPoint &kLeftUpperPt, const CGUIPoint &kRightLowerPt)
 
 CGUIRect (const CGUIPoint &kOriginPt, const eC_Value &vWidth, const eC_Value &vHeight)
 
 CGUIRect (const CGUIRect &srcRect)
 
 CGUIRect (const eC_Value &vX1, const eC_Value &vY1, const eC_Value &vX2, const eC_Value &vY2)
 
CGUIRectAssign (const CGUIPoint &kOriginPt, const eC_Value &vWidth, const eC_Value &vHeight)
 
CGUIRectAssign (const eC_Value &vX1, const eC_Value &vY1, const eC_Value &vX2, const eC_Value &vY2)
 
CGUIRectExpand (const eC_Value vDif, const ExpandDirection_t enDirection=EXPAND_ALL)
 
CGUIPoint GetBottomRight () const
 
CGUIPoint GetCenter () const
 
eC_Value GetHeight () const
 
CGUIRect GetOriginRect () const
 
CGUIPoint GetTopLeft () const
 
eC_Value GetWidth () const
 
eC_Value GetX1 () const
 
eC_Value GetX2 () const
 
eC_Value GetY1 () const
 
eC_Value GetY2 () const
 
CGUIRectInterpolate (const CGUIRect &kTargetRect, const eC_Value vInterpolationFactor)
 
CGUIRectInterSect (const CGUIRect &Rect)
 
eC_Bool IsBottomOf (const CGUIRect &Rect) const
 
eC_Bool IsComprehensive () const
 
eC_Bool IsInside (const CGUIPoint &kPt) const
 
eC_Bool IsInside (const CGUIRect &kRect) const
 
eC_Bool IsInside (const eC_Value &vX, const eC_Value &vY) const
 
eC_Bool IsLeftOf (const CGUIRect &Rect) const
 
eC_Bool IsRightOf (const CGUIRect &Rect) const
 
eC_Bool IsTopOf (const CGUIRect &Rect) const
 
CGUIRectMove (const CGUIPoint &kOffsetPt)
 
CGUIRectMove (const eC_Value vDeltaX, const eC_Value vDeltaY)
 
CGUIRectMoveTo (const eC_Value vAbsX, const eC_Value vAbsY)
 
void Normalise ()
 
eC_Bool operator!= (const CGUIRect &rkRect) const
 
CGUIRectoperator= (const CGUIRect &srcRect)
 
eC_Bool operator== (const CGUIRect &rkRect) const
 
eC_Bool Overlaps (const CGUIRect &Rect) const
 
void ReadFromStream ()
 Helper method to stream CGUIRect attributes.
 
void SetComprehensive (const eC_Bool &bComprehensive)
 
void SetHeight (const eC_Value vHeight)
 
void SetWidth (const eC_Value vWidth)
 
void SetX1 (const eC_Value &vX1)
 
void SetX2 (const eC_Value &vX2)
 
void SetY1 (const eC_Value &vY1)
 
void SetY2 (const eC_Value &vY2)
 
CGUIRectUnion (const CGUIRect &Rect)
 
void WriteToStream ()
 Helper method to write CGUIRect attributes.
 

Detailed Description

Helper class to supply a platform independent rectangle implementation.

The CGUIRect class implements basic geometry-handling for rectangles, including functionalities such as intersection or checks for overlaps. Please note that the lower right corner of a rectangle is not considered to be "inside" of the rectangle itself. In other words, a rectangle reaching from positions (0,0) to (10,0) will have a height of zero and therefore be considered "not normalized".

If a rectangle is incomprehensive this means that it has no valid coordinates. When a rectangle is copied the comprehensive flag is always copied too. After a rectangle is created it will always be comprehensive until it is explicitly changed by m_bComprehensive = false; No function that accepts separate coordinate values will automatically normalise them internally in this class.

Speaking of normalised coordinates here means, that the X-coordinate of the top left corner is smaller than the X-coordinate of the bottom right corner AND the Y-coordinate of the top left corner is smaller than the Y-coordinate of the bottom right corner.

Whenever the coordinates of a rectangle get non-normalised then the rectangle will in turn get incomprehensive, that is, no comprehensive rectangle may be non-normalised. Incomprehensive rectangles on the other hand may have normalised or non-normalised coordinates as the coordinates are invalid anyway. No function will make an incomprehensive rectangle to be comprehensive, except when forcing this via SetComprehensive(true) or assignment or construction. Thus, no function of this class that does not alter the coordinates, needs to check whether the coordinates are normalised; for these functions it is sufficient to check for comprehensiveness.

Example:

// Create a rect.
CGUIRect *pRect = new CGUIRect(eC_FromInt(0),eC_FromInt(0),eC_FromInt(100),eC_FromInt(20));
// Sets the width of the rectangle.
pRect->SetWidth(eC_FromInt(50));
// Assign
pRect->Assign(eC_FromInt(10),eC_FromInt(20),eC_FromInt(100),eC_FromInt(20));
Helper class to supply a platform independent rectangle implementation.
Definition: GUIRect.h:63
void SetWidth(const eC_Value vWidth)
Definition: GUIRect.h:183
CGUIRect & Assign(const CGUIPoint &kOriginPt, const eC_Value &vWidth, const eC_Value &vHeight)

Member Enumeration Documentation

◆ ExpandDirection_t

enum of expansion types

Enumerator
EXPAND_HORIZONTAL 

horizontal only

EXPAND_VERTICAL 

vertical only

EXPAND_ALL 

both horizontal and vertical (default)

Constructor & Destructor Documentation

◆ CGUIRect() [1/5]

CGUIRect::CGUIRect ( )

Standard constructor. Initializes all coordinates with 0. The rectangle will be incomprehensive as the rectangle that covers zero space is invalid.

◆ CGUIRect() [2/5]

CGUIRect::CGUIRect ( const CGUIPoint kLeftUpperPt,
const CGUIPoint kRightLowerPt 
)

Constructor

Parameters
kLeftUpperPtleft upper point
kRightLowerPtright lower point

◆ CGUIRect() [3/5]

CGUIRect::CGUIRect ( const CGUIPoint kOriginPt,
const eC_Value &  vWidth,
const eC_Value &  vHeight 
)

Constructor

Parameters
kOriginPtorigin point
vWidthwidth
vHeightheight

◆ CGUIRect() [4/5]

CGUIRect::CGUIRect ( const eC_Value &  vX1,
const eC_Value &  vY1,
const eC_Value &  vX2,
const eC_Value &  vY2 
)

Constructs a rectangle from four coordinates. The rectangle will be comprehensive if the covered space is not zero.

Parameters
vX1X-coordinate of the top left corner
vY1Y-coordinate of the top left corner
vX2X-coordinate of the bottom right corner
vY2Y-coordinate of the bottom right corner

◆ CGUIRect() [5/5]

CGUIRect::CGUIRect ( const CGUIRect srcRect)

Constructs a rectangle from another rectangle / copy constructor.

Parameters
srcRectRectangle from which a duplicate will be created.

Member Function Documentation

◆ Assign() [1/2]

CGUIRect & CGUIRect::Assign ( const CGUIPoint kOriginPt,
const eC_Value &  vWidth,
const eC_Value &  vHeight 
)

Assigns new coordinates to an existing rectangle. The rectangle will be comprehensive if the covered area of the new rectangle is not negative.

Parameters
kOriginPtX- and Y-coordinate of the left upper corner.
vWidthThe width of the rectangle.
vHeightThe height of the rectangle.
Returns
This rectangle after assignment

◆ Assign() [2/2]

CGUIRect & CGUIRect::Assign ( const eC_Value &  vX1,
const eC_Value &  vY1,
const eC_Value &  vX2,
const eC_Value &  vY2 
)

Assigns new coordinates to an existing rectangle. The rectangle will be comprehensive if the covered area greater than zero.

Parameters
vX1X-coordinate of the top left corner
vY1Y-coordinate of the top left corner
vX2X-coordinate of the bottom right corner
vY2Y-coordinate of the bottom right corner
Returns
This rectangle after assignment

◆ Expand()

CGUIRect & CGUIRect::Expand ( const eC_Value  vDif,
const ExpandDirection_t  enDirection = EXPAND_ALL 
)
inline

Expand the rectangle. Depending on sign this results in expanding or shrinking the rect

Parameters
vDifvalue to add on all sides
enDirection
Returns
This rectangle after operation

◆ GetBottomRight()

CGUIPoint CGUIRect::GetBottomRight ( ) const
inline
Returns
The lower right vertex of the rectangle.

◆ GetCenter()

CGUIPoint CGUIRect::GetCenter ( ) const
inline
Returns
The center point (middle) of the rectangle.

◆ GetHeight()

eC_Value CGUIRect::GetHeight ( ) const
inline

Returns the height of the rectangle. This function only returns the expected value if it is used on a comprehensive (and normalized) rectangle, so please check this. This function also only works correctly if the coordinates are not more far away from each other than eC_MAXVALUE so please be careful that your rectangles don't get too big.

Returns
The height

◆ GetOriginRect()

CGUIRect CGUIRect::GetOriginRect ( ) const
inline
Returns
the rectangle as if it would be placed at the origin (0, 0).

◆ GetTopLeft()

CGUIPoint CGUIRect::GetTopLeft ( ) const
inline
Returns
The upper left vertex of the rectangle.

◆ GetWidth()

eC_Value CGUIRect::GetWidth ( ) const
inline

Returns the width of the rectangle. This function only returns the expected value if it is used on a comprehensive (and normalized) rectangle, so please check this. This function also only works correctly if the coordinates are not more far away from each other than eC_MAXVALUE so please be careful that your rectangles don't get too big.

Returns
The width

◆ GetX1()

eC_Value CGUIRect::GetX1 ( ) const
inline
Returns
X of vertex 1

◆ GetX2()

eC_Value CGUIRect::GetX2 ( ) const
inline
Returns
X of vertex 2

◆ GetY1()

eC_Value CGUIRect::GetY1 ( ) const
inline
Returns
Y of vertex 1

◆ GetY2()

eC_Value CGUIRect::GetY2 ( ) const
inline
Returns
Y of vertex 2

◆ Interpolate()

CGUIRect & CGUIRect::Interpolate ( const CGUIRect kTargetRect,
const eC_Value  vInterpolationFactor 
)
inline

Interpolate between two rectangles.

Parameters
kTargetRectTarget of interpolation
vInterpolationFactorValue between 0 (this rectangle stays unchanged) and 1 (identical to target rectangle)
Returns
This rectangle after operation

◆ InterSect()

CGUIRect & CGUIRect::InterSect ( const CGUIRect Rect)

Calculates the area where two rectangles overlap. The resulting rectangle is stored within this object. If the rectangles do not overlap then "this" rectangle will be incomprehensive. Doing this function on an incomprehensive "this" rectangle doesn't change any rectangle. Calling this function on a comprehensive "this" rectangle and an incomprehensive argument rectangle will make "this" rectangle incomprehensive.

Exceptions
CGUIExceptionif one of the rectangles is not normalised (only in _DEBUG build)
Parameters
RectThe rectangle to check
Returns
This rectangle after operation

◆ IsBottomOf()

eC_Bool CGUIRect::IsBottomOf ( const CGUIRect Rect) const
inline

Checks if this rectangle is fully at the bottom of 'Rect' or the relevant edges touch each other.

Parameters
RectThe rectangle to check
Returns
True if fully to the bottom

◆ IsComprehensive()

eC_Bool CGUIRect::IsComprehensive ( ) const
inline

If true then it is guaranteed that the rectangle is also normalised.

Returns
True if comprehensive

◆ IsInside() [1/3]

eC_Bool CGUIRect::IsInside ( const CGUIPoint kPt) const
inline

Checks whether a point at a given coordinate is inside a rectangle or not. Only comprehensive rectangles contain points.

Parameters
kPtThe point to check
Returns
True if it is inside, False otherwise.

◆ IsInside() [2/3]

eC_Bool CGUIRect::IsInside ( const CGUIRect kRect) const
inline

Check if the given rectangle is completely within this rectangle. True is also returned for exactly same positions and sizes.

Parameters
kRectThe rectangle to check
Returns
True if inside, False otherwise

◆ IsInside() [3/3]

eC_Bool CGUIRect::IsInside ( const eC_Value &  vX,
const eC_Value &  vY 
) const
inline

Checks whether a point at a given coordinate is inside a rectangle or not. Only comprehensive rectangles contain points.

Parameters
vXX-coordinate
vYY-coordinate
Returns
True if it is inside, False otherwise.

◆ IsLeftOf()

eC_Bool CGUIRect::IsLeftOf ( const CGUIRect Rect) const
inline

Checks if this rectangle is fully to the left of 'Rect' or the relevant edges touch each other.

Parameters
RectThe rectangle to check
Returns
True if fully to the left

◆ IsRightOf()

eC_Bool CGUIRect::IsRightOf ( const CGUIRect Rect) const
inline

Checks if this rectangle is fully to the right of 'Rect' or the relevant edges touch each other.

Parameters
RectThe rectangle to check
Returns
True if fully to the right

◆ IsTopOf()

eC_Bool CGUIRect::IsTopOf ( const CGUIRect Rect) const
inline

Checks if this rectangle is fully top of 'Rect' or the relevant edges touch each other.

Parameters
RectThe rectangle to check
Returns
True if fully to the top

◆ Move() [1/2]

CGUIRect & CGUIRect::Move ( const CGUIPoint kOffsetPt)

Moves the rectangle.

Parameters
kOffsetPtPixels to move in x/y direction
Returns
This rectangle after operation

◆ Move() [2/2]

CGUIRect & CGUIRect::Move ( const eC_Value  vDeltaX,
const eC_Value  vDeltaY 
)

Moves the rectangle.

Parameters
vDeltaXPixels to move in x direction
vDeltaYPixels to move in y direction
Returns
This rectangle after operation

◆ MoveTo()

CGUIRect & CGUIRect::MoveTo ( const eC_Value  vAbsX,
const eC_Value  vAbsY 
)

Moves the rectangle to an absolute position

Parameters
vAbsXTarget position in x direction
vAbsYTarget position in y direction
Returns
This rectangle after operation

◆ Normalise()

void CGUIRect::Normalise ( )

This normalises the rectangle so that the functions and operations of this class may operate on it successfully. Only comprehensive rectangles will be made normalised as it makes no sense to normalise invalid coordinates.

◆ operator!=()

eC_Bool CGUIRect::operator!= ( const CGUIRect rkRect) const
inline

Checks whether two rectangles are identical. They are identical if the coordinates of their upper left and lower right corners are identical.

Parameters
rkRectRectangle to compare with.
Returns
True if the rectangles are identical, otherwise False.

◆ operator=()

CGUIRect & CGUIRect::operator= ( const CGUIRect srcRect)

Assigns an existing rectangle from another rectangle.

Parameters
srcRectRectangle from which a duplicate will be created.
Returns
Assignment destination

◆ operator==()

eC_Bool CGUIRect::operator== ( const CGUIRect rkRect) const
inline

Checks whether two rectangles are identical. They are identical if the coordinates of their upper left and lower right corners are identical.

Parameters
rkRectRectangle to compare with.
Returns
True if the rectangles are identical, otherwise False.

◆ Overlaps()

eC_Bool CGUIRect::Overlaps ( const CGUIRect Rect) const

Does an overlap-check between two rectangles.

Parameters
RectThe rectangle to check
Returns
True if the two rectangles overlap, False otherwise. No incomprehensive rectangle overlaps another.
Exceptions
CGUIExceptionif one of the rectangles is not normalised (only in _DEBUG build)

◆ SetComprehensive()

void CGUIRect::SetComprehensive ( const eC_Bool &  bComprehensive)
inline

If a non-normalised rectangle is forced to be comprehensive via this function, then it also gets normalised automatically.

Parameters
bComprehensivetrue if comprehensive

◆ SetHeight()

void CGUIRect::SetHeight ( const eC_Value  vHeight)
inline

Sets the new height of the rectangle. Bottom corner will be extended.

Parameters
vHeightnew height of the rectangle

◆ SetWidth()

void CGUIRect::SetWidth ( const eC_Value  vWidth)
inline

Sets the new width of the rectangle. Right corner will be extended.

Parameters
vWidthnew width of the rectangle

◆ SetX1()

void CGUIRect::SetX1 ( const eC_Value &  vX1)
inline
Parameters
vX1New X of vertex 1

◆ SetX2()

void CGUIRect::SetX2 ( const eC_Value &  vX2)
inline
Parameters
vX2New Y of vertex 2

◆ SetY1()

void CGUIRect::SetY1 ( const eC_Value &  vY1)
inline
Parameters
vY1New X of vertex 1

◆ SetY2()

void CGUIRect::SetY2 ( const eC_Value &  vY2)
inline
Parameters
vY2New Y of vertex 2

◆ Union()

CGUIRect & CGUIRect::Union ( const CGUIRect Rect)

Merges the rectangle with another rectangle. The resulting rectangle is the smallest enclosing rectangle around the two input rectangles and is stored within this object. Doing this function on an incomprehensive rectangle that is passed as an argument doesn't change any rectangle. If this rectangle is incomprehensive and the rectangle that is passed as an argument is comprehensive then the argument will be copied to this rectangle. This is because not just a usual comprehensive rectangle but also an incomprehensive rectangle should be able to get bigger when a union with a comprehensive rectangle is performed. This is especially useful for enlarging the invalidated rectangle in reset (= incomprehensive) state. A rectangle with covers zero space will have no effect for a union operation.

Exceptions
CGUIExceptionif one of the rectangles is not normalised (only in _DEBUG build)
Parameters
RectThe rectangle to check
Returns
This rectangle after operation

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