class PRect: public PObject

This class defines a rectangle in the drawing plane.

Inheritance:


Public Methods

[more] PRect ( PORDINATE x = 0, PORDINATE y = 0, PDIMENSION dx = 0, PDIMENSION dy = 0 )
Create a rectangle given the top left corner and width and height.
[more] PRect ( const PDim & dim )
Create a rectangle at 0,0 and the dimensions specified.
[more] PRect ( const PPoint & p1, const PPoint & p2 )
Create a rectangle given the 2 points as opposite corners.
[more] PRect ( const PPoint & topLeft, const PDim & dim )
Create a rectangle given the top left corner and dimensions.
[more]virtual PObject* Clone () const
Create a new copy of the rectangle.
[more]virtual Comparison Compare ( const PObject & obj ) const
Determine if the two rectangles are identical.
[more]PORDINATE Top () const
Get the top side of the rectangle.
[more]PORDINATE Left () const
Get the left side of the rectangle.
[more]PORDINATE Bottom () const
Get the bottom side of the rectangle.
[more]PORDINATE Right () const
Get the right side of the rectangle.
[more]PORDINATE X () const
Get the horizontal position of the origin of the rectangle.
[more]PORDINATE Y () const
Get the vertical position of the origin of the rectangle.
[more]PDIMENSION Width () const
Get the horizontal dimension of the rectagle.
[more]PDIMENSION Height () const
Get the vertical dimension of the rectagle.
[more]void SetTop ( PORDINATE top )
Set the Y value of the top of the rectagle.
[more]void SetLeft ( PORDINATE left )
Set the X value of the left of the rectagle.
[more]void SetBottom ( PORDINATE bottom )
Set the Y value of the bottom of the rectagle.
[more]void SetRight ( PORDINATE right )
Set the X value of the right of the rectagle.
[more]void SetX ( PORDINATE x )
Set the X value of the left of the rectagle.
[more]void SetY ( PORDINATE ny )
Set the Y value of the top of the rectagle.
[more]void SetWidth ( PDIMENSION dx )
Set the width of the rectagle.
[more]void SetHeight ( PDIMENSION dy )
Set the height of the rectagle.
[more]PPoint Origin () const
Get the origin or top left corner of the rectangle.
[more]PPoint Corner () const
Get the bottom right corner of the rectangle.
[more]PPoint Centre () const
Get the coordinates of the centre of the rectangle.
[more]PDim Dimensions () const
Get the width and height of the rectangle.
[more]void SetOrigin ( PORDINATE nx, PORDINATE ny )
Set the top left corner of the rectangle.
[more]void SetCorner ( PORDINATE nx, PORDINATE ny )
Set the top left corner of the rectangle.
[more]void SetDimensions ( PDIMENSION dx, PDIMENSION dy )
Set the width and height of the rectangle.
[more]BOOL IsEmpty () const
Determine if the width and height of the rectangle are zero.
[more]void Inflate ( PORDINATE dx, PORDINATE dy )
Increase the size of the rectangle by expanding in all four directions by the amount specified.
[more]void Offset ( PORDINATE dx, PORDINATE dy )
Move the rectangle the specified delta amount.
[more]BOOL ContainsPoint (const PPoint & pt) const
Determine if the point is contained within the bounds of the rectangle.
[more]PRect Intersection (const PRect & rect) const
Calculate the rectangle that is the intersection of the object and the specified rectangle.
[more]PRect Union (const PRect & rect) const
Calculate the rectangle that is the union of the object and the specified rectangle.

Public

[more] Overrides from class PObject
[more] New functions for class


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions

Miscellaneous functions


Documentation

This class defines a rectangle in the drawing plane. A rectangle is defined by two points on the plane. A rectangle is always "normalised". That is the left is always less then the right and the top is always less than the bottom.
o PRect( PORDINATE x = 0, PORDINATE y = 0, PDIMENSION dx = 0, PDIMENSION dy = 0 )
Create a rectangle given the top left corner and width and height.
Parameters:
x - Horizontal position of the rectangle.
y - Vertical position of the rectangle.
dx - Width of the rectangle.
dy - Height of the rectangle.

o PRect( const PDim & dim )
Create a rectangle at 0,0 and the dimensions specified.
Parameters:
dim - Dimensions of the rectangle.

o PRect( const PPoint & p1, const PPoint & p2 )
Create a rectangle given the 2 points as opposite corners. Note that the top left corner of the rectangle may not be either of these points as it is normalised so that left is less than right and top is less than bottom.
Parameters:
p1 - First corner of rectangle.
p2 - Second, opposite, corner of rectangle.

o PRect( const PPoint & topLeft, const PDim & dim )
Create a rectangle given the top left corner and dimensions.
Parameters:
topLeft - Top left corner ofthe rectangle.
dim - Dimensions of the rectangle.

o Overrides from class PObject

ovirtual PObject* Clone() const
Create a new copy of the rectangle. Note that it is the responsibility of the caller to delete the object.

Returns:
a new rectangle on the heap.

ovirtual Comparison Compare( const PObject & obj ) const
Determine if the two rectangles are identical. A rectangle is identical if the origin and dimensions are the same.

Returns:
EqualTo if the rectangles are the same, otherwise returns GreaterThan.
Parameters:
obj - Another rectangle object to comapre against.

o New functions for class

oPORDINATE Top() const
Get the top side of the rectangle.

Returns:
Y value of the top of the rectagle.

oPORDINATE Left() const
Get the left side of the rectangle.

Returns:
X value of the left of the rectagle.

oPORDINATE Bottom() const
Get the bottom side of the rectangle.

Returns:
Y value of the bottom of the rectagle.

oPORDINATE Right() const
Get the right side of the rectangle.

Returns:
X value of the right of the rectagle.

oPORDINATE X() const
Get the horizontal position of the origin of the rectangle.

Returns:
X value of the left of the rectagle.

oPORDINATE Y() const
Get the vertical position of the origin of the rectangle.

Returns:
Y value of the top of the rectagle.

oPDIMENSION Width() const
Get the horizontal dimension of the rectagle.

Returns:
width of the rectagle.

oPDIMENSION Height() const
Get the vertical dimension of the rectagle.

Returns:
height of the rectagle.

ovoid SetTop( PORDINATE top )
Set the Y value of the top of the rectagle. Note that this does not change the bottom of the rectangle so the height will change.
Parameters:
top - New top for rectangle.

ovoid SetLeft( PORDINATE left )
Set the X value of the left of the rectagle. Note that this does not change the right of the rectangle so the width will change.
Parameters:
left - New left for rectangle.

ovoid SetBottom( PORDINATE bottom )
Set the Y value of the bottom of the rectagle. Note that this does not change the top of the rectangle so the height will change.
Parameters:
bottom - New bottom of rectangle.

ovoid SetRight( PORDINATE right )
Set the X value of the right of the rectagle. Note that this does not change the left of the rectangle so the width will change.
Parameters:
right - New right of rectangle.

ovoid SetX( PORDINATE x )
Set the X value of the left of the rectagle. Note that this does not change the width of the rectangle so the right position will change.
Parameters:
x - New x position for rectangle.

ovoid SetY( PORDINATE ny )
Set the Y value of the top of the rectagle. Note that this does not change the height of the rectangle so the bottom position will change.
Parameters:
ny - new y position for rectangle.

ovoid SetWidth( PDIMENSION dx )
Set the width of the rectagle. Note that this does not change the x position of the rectangle so the right position will change.
Parameters:
dx - New width for rectangle.

ovoid SetHeight( PDIMENSION dy )
Set the height of the rectagle. Note that this does not change the y position of the rectangle so the bottom position will change.
Parameters:
dy - New height for the rectangle.

oPPoint Origin() const
Get the origin or top left corner of the rectangle.

Returns:
point for top left corner of rectangle.

oPPoint Corner() const
Get the bottom right corner of the rectangle.

Returns:
point for bottom right corner of rectangle.

oPPoint Centre() const
Get the coordinates of the centre of the rectangle.

Returns:
point for the centre of the rectangle.

oPDim Dimensions() const
Get the width and height of the rectangle.

Returns:
dimensions of the rectangle.

ovoid SetOrigin( PORDINATE nx, PORDINATE ny )
Set the top left corner of the rectangle. This is eqivalent to doing a SetX() and a SetY(), ie does not change the width and height of the rectangle.
Parameters:
nx - New x position for the rectangle.
ny - New y position for the rectangle.

ovoid SetCorner( PORDINATE nx, PORDINATE ny )
Set the top left corner of the rectangle. This is eqivalent to doing a SetBottom() and a SetTop(), ie does not change the width and height of the rectangle.
Parameters:
nx - New x position for bottom right corner of the rectangle.
ny - New y position for bottom right corner of the rectangle.

ovoid SetDimensions( PDIMENSION dx, PDIMENSION dy )
Set the width and height of the rectangle. This is equivalent to doing a SetWidth() and SetHeight.
Parameters:
dx - New width for rectangle.
dy - New height for rectangle.

oBOOL IsEmpty() const
Determine if the width and height of the rectangle are zero.

Returns:
TRUE if the rectangle is empty.

ovoid Inflate( PORDINATE dx, PORDINATE dy )
Increase the size of the rectangle by expanding in all four directions by the amount specified. That is the left has dx subtracted from it and the right has it added while the top has dy subtracted from it and the bottom has it added.
Parameters:
dx - Amount to increase the horizontal.
dy - Amount to increase the vertical.

ovoid Offset( PORDINATE dx, PORDINATE dy )
Move the rectangle the specified delta amount. This is eqivalent to doing a SetX() and a SetY(), ie does not change the width and height of the rectangle.
Parameters:
dx - Amount to move the rectangle horizontally.
dy - Amount to move the rectangle vertically.

oBOOL ContainsPoint(const PPoint & pt) const
Determine if the point is contained within the bounds of the rectangle.

Returns:
TRUE if point is within the rectangle.

oPRect Intersection(const PRect & rect) const
Calculate the rectangle that is the intersection of the object and the specified rectangle. That is the part of the two rectangle contained by both rectangles. This can easily be an empty rectangle.

Returns:
intersection rectangle.

oPRect Union(const PRect & rect) const
Calculate the rectangle that is the union of the object and the specified rectangle. That is the amllest rectangle that will contain both the other rectangles.

Returns:
union rectangle.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.