IGRect2D
- IGRect2D provides axis-aligned rectangles. Each side of a rectangle is parallel to the x-axis or the y-axis.
A rectangle is defined by the coordinate points for the top left corner and the bottom right
corner. The top left corner consists of the minimum x and y coordinates. The bottom right corner
consists of the maximum x and y coordinates.
An IGRect2D defines area-enclosing geometry that may be filled or filled and framed. The geometry is defined over a
half open interval, so a point is considered to be contained in the rectangle if it falls within
left <= x < right and top <= y < bottom.
Do not derive your own classes from this class.
IGRect2D - Member Functions and Data by Group
Constructors & Destructor
Use the functions in this group to construct or destroy rectangle objects of class IGRect2D.
- ~IGRect2D
public:
~IGRect2D()
- Destroys the IGRect2D object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- IGRect2D
- Constructs a 2D rectangle object of class IGRect2D.
Overload 1
public:
IGRect2D( GCoordinate left,
GCoordinate top,
GCoordinate right,
GCoordinate bottom )
- Use this constructor to create a rectangle using the four given corner values.
- left
- The x-coordinate of the rectangle's left side.
- top
- The y-coordinate of the rectangle's top side.
- right
- The x-coordinate of the rectangle's right side.
- bottom
- The y-coordinate of the rectangle's bottom side.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 2
- Creates a rectangle with the specified top left and bottom right corners.
public:
IGRect2D(const IGPoint2D& p0, const IGPoint2D& p1)
- Use this constructor to create a rectangle with the specified top left and bottom right corners.
Points are not sorted so p0 > p1, call orderPoints if you need this done.
- p0
- The top left corner.
- p1
- The bottom right corner.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 3
public:
IGRect2D(const IGRect2D&)
- Use this constructor to create a rectangle object that is copied from the given one.
- IGRect2D
- A constant reference to the new rectangle to be copied.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 4
public:
IGRect2D(const IRectangle& rect)
- Use this constructor to create a rectangle that is copied from the given IRectangle object.
- rect
- The new IRectangle to be copied.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 5
- Default constructor.
public:
IGRect2D()
- Use this constructor to create a rectangle object with default
values of fLeft=0.0 and fRight=0.0 and fTop=0.0 and fBottom=0.0
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Assignment Operators
Use the operator in this group to replace the current 2D rectangle with the given one.
- operator =
public:
IGRect2D& operator =(const IGRect2D& Src)
- Assignment operator.
- Src
- The rectangle to be copied.
- Return
- A non-const reference to the left-hand side object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Creating Rectangles
Use the functions in this group to create an infinite rectangle or a zero rectangle.
- infiniteRect
public:
static const IGRect2D& infiniteRect()
- Returns a rectangle whose coordinates are (-1e10, -1e10, 1e10, 1e10).
- Return
- A infinite rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- zeroRect
public:
static const IGRect2D& zeroRect()
- Returns a rectangle whose coordinates are (0.0, 0.0, 0.0, 0.0).
- Return
- A zero rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Data Types
These data types are define for coordinate values.
- fBottom
public:
GCoordinate fBottom
- The coordinate value of the bottom of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- fLeft
public:
GCoordinate fLeft
- The coordinate value of the left side of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- fRight
public:
GCoordinate fRight
- The coordinate value of the right side of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- fTop
public:
GCoordinate fTop
- The coordinate value of the top side of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Getting Rectangle Values
Use the functions in this group to obtain information about the rectangle, such as its height and width, the size
of its sides, its midpoint, its top right point, and its top left point.
- center
public:
IGPoint2D center() const
- Retrieves the midpoint of the current rectangle.
- Return
- The point at the horizontal and vertical center of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- height
public:
GCoordinate height() const
- Retrieves the rectangle's height.
- Return
- The rectangle's height. The value is negative if the bottom side has been set to be above the top side.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- leftLine
public:
IGLine2D leftLine() const
- Retrieves the left side of the rectangle.
- Return
- The line segment from the top left corner to bottom left corner of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- rightLine
public:
IGLine2D rightLine() const
- Retrieves the right side of the rectangle.
- Return
- The line segment from the top-right to bottom-right corner of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- size
public:
IGPoint2D size() const
- Retrieves the height and width of the rectangle.
- Return
- A point whose fX member variable equals the rectangle's width and whose fY equals the rectangle's height.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- topLeft
public:
IGPoint2D topLeft() const
- Returns the top left point of the rectangle.
- Return
- The top-left point of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- topLine
public:
IGLine2D topLine() const
- Retrieves the top side of the rectangle.
- Return
- The line segment from the top-left to top-right corner of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- topRight
public:
IGPoint2D topRight() const
- Returns the top right point of the rectangle.
- Return
- The top-right point of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- width
public:
GCoordinate width() const
- Retrieves the width of the rectangle.
- Return
- The rectangle's width. The value is negative if the left side has been set to the right of the right side.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Modifying Points in Relation to the Rectangle
Use the functions in this group to create or move the given point.
- interpolate
public:
IGPoint2D interpolate(GParametric u, GParametric v) const
- Bilinearly creates the point within the rectangle or outside it that corresponds to (u,v).
- u
- The horizontal parameter. 0 is the left edge, 1 is the right edge.
- v
- The vertical parameter. 0 is the top edge, 1 is the bottom edge.
- Return
- The interpolated or extrapolated point.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- pin
- Moves a point to within the rectangle by forcing it to the nearest edge.
public:
void pin(IGPoint2D& Point) const
If the point is outside the rectangle, its values are modified to lie on the nearest
border of the rectangle. If only one of the point's coordinates is outside the range
of the rectangle's corresponding coordinate, the point is moved perpendicularly to the
nearest border. If both its coordinates are outside the rectangle's range, it is moved
to the nearest corner. If two sides of the rectangle are not in the normal order--for
example, if fLeft >fRight--the point is always considered to be outside the rectangle,
and it is moved to midway between these two sides.
- Point
- The point to be moved.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Modifying the Rectangle
Use the functions in this group to modify the rectangle, such as expanding or contracting it, moving it,
converting a rectangle of class IGRect2D to one of class IRectangle, or swaping its coordinates.
- extendTo
- Expands the rectangle until it just encompasses the specified point.
If the specified point already lies within this rectangle, nothing changes.
The rectangle is only stretched in the required direction(s), so it does not
necessarily retain its original shape or center.
Overload 1
public:
void extendTo(const IGPoint2D& pt)
- g
- The point to enclose within this one.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 2
- Expands the rectangle until it just encompasses the specified rectangle.
public:
void extendTo(const IGRect2D& g)
- g
- The rectangle to enclose within this one.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- inset
- Moves opposite sides of the rectangle inward toward its center or outward from its center.
public:
void inset(const IGPoint2D& inset)
- Use the functions in this group to modify the rectangle, such as expanding or contracting it,
- inset
- The point whose x and y coordinates determine the amount that each side moves.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- offset
public:
void offset(const IGPoint2D& dg)
- Moves the rectangle by the specified vector dg.
- dg
- The offset.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator IRectangle
public:
operator IRectangle() const
- Converts from IGRect2D to IRectangle.
- Return
- The new IRectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- orderPoints
public:
void orderPoints()
- Swaps the rectangle's coordinates if necessary, so that the top left corner is
now below or to the right of the bottom right corner.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Obtaining Information About the Rectangles
Use the functions in this group to obtain information about the rectangle, such as whether the current
rectangle encloses the given one rectangle, whether the current rectangle intersects the given one, and the
coordinates where two rectangles intersect.
- bottomLeft
public:
IGPoint2D bottomLeft() const
- Returns the bottom-left point of the rectangle.
- Return
- The bottom-left point of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- bottomLine
public:
IGLine2D bottomLine() const
- Retrieves the bottom side of the rectangle.
- Return
- The line segment from the bottom-left to bottom-right corner of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- bottomRight
public:
IGPoint2D bottomRight() const
- Returns the bottom-right point of the rectangle.
- Return
- The bottom-right point of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- contains
- Specifies whether the rectangle encloses the specified rectangle.
Any or all sides of the enclosed rectangle can lie on the corresponding sides of
the outer rectangle.
Overload 1
- Determines whether the current rectangle encloses the specified rectangle.
public:
bool contains(const IGRect2D& g) const
- g
- The rectangle that is tested to see whether it is contained by *this.
- Return
- True if the specified rectangle is contained in this rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Overload 2
- Determines whether the current rectangle encloses the specified point.
public:
bool contains(const IGPoint2D& p) const
- p
- The point to test.
- Return
- True if the specified point is contained in this rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- equalSize
public:
bool equalSize(const IGRect2D& g) const
- Determines whether two rectangles have the same height and width.
- g
- The rectangle to compare with this rectangle.
- Return
- True if the rectangles have matching heights and widths.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- intersects
public:
bool intersects(const IGRect2D& g) const
- Determines whether the current rectangle intersects the specified rectangle.
- g
- The rectangle to test.
- Return
- True if neither rectangle is empty and they intersect.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- intersectWith
public:
void intersectWith(const IGRect2D& g)
- Finds the intersection of this rectangle with the specified rectangle g.
It modifies *this by replacing its coordinates with those of the rectangular
intersection.
- g
- The rectangle that intersects with this rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- isEmpty
public:
bool isEmpty() const
- Determines if the rectangle encloses no space.
- Return
- TRUE if the calling rectangle encloses no space (fTop>=fBottom || fLeft>=fRight).
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- mapRect
- Takes the size and position of a given rectangle relative to this, the current rectangle.
public:
void mapRect(IGRect2D& r, const IGRect2D& dr) const
- Takes the size and position of a rectangle r relative to this rectangle (in other words, *this)
and maps it to the same proportional size and position relative to the destination
rectangle dr.
- r
- The rectangle to be scaled and moved.
- dr
- The destination rectangle, to which rectangle r bears the relationship it previously bore to *this.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Setting Rectangle Values
Use the functions in this group to set rectangle values, such as its height and width, its corners,
and its center.
- set
public:
void set(const IGPoint2D& a, const IGPoint2D& b)
- Moves the rectangle's top left and bottom right corners to the specified points.
- a
- The new top-left corner.
- b
- The new bottom-right corner.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setBottomLeft
public:
void setBottomLeft(const IGPoint2D& pt)
- Sets the bottom left corner of the rectangle to the specified point.
- point
- The new location of the bottom-left corner.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setBottomRight
public:
void setBottomRight(const IGPoint2D& point)
- Sets the bottom right corner of the rectangle to the specified point.
- point
- The new location of the bottom-right corner.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setCenter
public:
void setCenter(const IGPoint2D& center)
- Moves the rectangle so that it is centered on the specified point.
- center
- The new center point of the rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setSize
public:
void setSize(const IGPoint2D& size)
- Sets the rectangle's height and width, without changing its center point.
- size
- The point whose x-coordinate specifies the new width, and whose y-coordinate specifies the new height.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setTopLeft
public:
void setTopLeft(const IGPoint2D& point)
- Sets the top left corner of the rectangle to the specified point.
- point
- The new location of the top-left corner.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setToPoint
public:
void setToPoint(const IGPoint2D&)
- Makes the rectangle infinitesimal and places it at the specified point.
- const IGPoint2D&
- The new location of the zero-sized rectangle.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- setTopRight
public:
void setTopRight(const IGPoint2D& pt)
- Sets the top right corner of the rectangle to the specified point.
- point
- The new location of the top-right corner.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Streaming the Object In and Out
Use the functions and operators in this group to stream a 2D rectangle object in and out.
- operator <<=
public:
IDataStream& operator <<=(IDataStream&)
- Operator that streams the object in using the given polymorphic stream.
- IDataStream
- The stream used to stream in the rectangle object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator >>=
public:
IDataStream& operator >>=(IDataStream&) const
- Operator that streams the object out using the given polymorphic stream.
- IDataStream
- The stream used to stream out the rectangle object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- readFromStream
public:
void readFromStream(IDataStream& toWhere)
- Streams in the rectangle using the polymorphic stream specified by fromWhere.
- fromWhere
- The stream used to stream in the rectangle object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- writeToStream
public:
void writeToStream(IDataStream& toWhere) const
- Streams out the rectangle using the polymorphic streaming streaming specified by toWhere.
- toWhere
- The stream used to stream out the rectangle object.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
Testing for Equality and Inequaltiy
Use the functions in this group to test two rectangles for equality or inequality.
- operator !=
public:
bool operator !=(const IGRect2D& Src) const
- Tests whether this rectangle's coordinates differ from those of the given rectangle.
- Src
- The object whose coordinates are compared to this object's coordinates.
- Return
- True if the rectangles have different coordinates.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
- operator ==
public:
bool operator ==(const IGRect2D& Src) const
- Tests whether this rectangle's coordinates equal those of the given one.
- Src
- The object whose coordinates are compared to this object's coordinates.
- Return
- True if the coordinates of the two rectangles are equal.
- Supported Platforms
Windows |
OS/2 |
AIX |
Yes |
Yes |
Yes |
IGRect2D - Inherited Member Functions and Data
Inherited Public Functions
Inherited Public Data
Inherited Protected Functions
Inherited Protected Data