rwlogo

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
List of all members | Public Member Functions
IlvRect Class Reference

Geometric class. More...

#include <ilviews/base/geometry.h>

Inheritance diagram for IlvRect:
IlvWindowsRect

Public Member Functions

 IlvRect (IlvPos x=0, IlvPos y=0, IlvDim w=0, IlvDim h=0)
 Constructor. More...
 
IlvRectadd (const IlvRect &rect)
 Adds a rectangle. More...
 
IlvRectadd (const IlvPoint &point)
 Adds a point. More...
 
IlvPos bottom () const
 Retrieves the location of the bottom border. More...
 
IlvPoint center () const
 Retrieves to location of the center. More...
 
IlvPos centerx () const
 Retrieves the x coordinate of the center. More...
 
IlvPos centery () const
 Retrieves the y coordinate of the center. More...
 
IlBoolean contains (const IlvPoint &p) const
 Checks if a point is located in this rectangle. More...
 
IlBoolean contains (const IlvRect &rect) const
 Checks if a rectangle is located in this rectangle. More...
 
void expand (IlvPos delta)
 Uniformly expands the rectangle. More...
 
void expand (IlvPos dx, IlvPos dy)
 Expands the rectangle. More...
 
IlvDim getH () const
 Retrieves the height. More...
 
IlvDim getW () const
 Retrieves the width. More...
 
IlvPos getX () const
 Retrieves the x coordinate of the origin. More...
 
IlvPos getY () const
 Retrieves the y coordinate of the origin. More...
 
void grow (IlvPos dw, IlvPos dh)
 Resizes the rectangle. More...
 
IlBoolean inside (const IlvRect &rect) const
 Checks if a rectangle is located in this rectangle. More...
 
IlvRectintersection (const IlvRect &)
 Computes an intersection. More...
 
IlBoolean intersects (const IlvRect &rect) const
 Checks if a rectangle intersects with this rectangle. More...
 
IlvPos left () const
 Retrieves the location of the left border. More...
 
IlvPoint lowerLeft () const
 Retrieves to location of the lower-left corner. More...
 
IlvPoint lowerRight () const
 Retrieves to location of the lower-right corner. More...
 
void move (const IlvPoint &orig)
 Moves the rectangle. More...
 
void move (IlvPos x, IlvPos y)
 Moves the rectangle. More...
 
void moveResize (IlvPos x, IlvPos y, IlvDim w, IlvDim h)
 Moves and resizes the rectangles. More...
 
IlvRectoperator= (const IlvRect &r)
 Assignment operator. More...
 
int operator== (const IlvRect &r) const
 Equality operator. More...
 
void resize (IlvDim w, IlvDim h)
 Resizes the rectangle. More...
 
IlvPos right () const
 Retrieves the location of the right border. More...
 
void scale (IlFloat sw, IlFloat sh)
 Resizes the rectangle. More...
 
void set (IlvPos x, IlvPos y, IlvDim w, IlvDim h)
 Moves and resizes the rectangles. More...
 
void setH (IlvDim newH)
 Sets the height. More...
 
void setW (IlvDim newW)
 Sets the width. More...
 
void setX (IlvPos newX)
 Sets the x coordinate of the origin. More...
 
void setY (IlvPos newY)
 Sets the y coordinate of the origin. More...
 
void size (IlvDim &w, IlvDim &h) const
 Retrieves the dimensions. More...
 
IlvPos top () const
 Retrieves the location of the top border. More...
 
void translate (const IlvPoint &dp)
 Translates the rectangle. More...
 
void translate (IlvPos dx, IlvPos dy)
 Translates the rectangle. More...
 
const IlvPointupperLeft () const
 Retrieves to location of the upper-left corner. More...
 
IlvPoint upperRight () const
 Retrieves to location of the upper-right corner. More...
 

Detailed Description

Geometric class.

Library: xviews or winviews or mviews (mutually exclusive)

The IlvRect class handle rectangular geometric entities, which are always specified by four numbers: the x and y coordinates of the top-left corner (also called the origin of the rectangle, the width and the height.

See Also
IlvFloatRect, IlvPoint.

Constructor & Destructor Documentation

IlvRect::IlvRect ( IlvPos  x = 0,
IlvPos  y = 0,
IlvDim  w = 0,
IlvDim  h = 0 
)

Constructor.

This constructor initializes a new rectangle with defined location and sizes.

Parameters
xThe x coordinate of the top-left corner of this rectangle.
yThe y coordinate of the top-left corner of this rectangle.
wThe width of this rectangle.
hThe height of this rectangle. rectangle.

Member Function Documentation

IlvRect& IlvRect::add ( const IlvRect rect)

Adds a rectangle.

The following diagram illustrates the way in which this second add function operates:


- The IlvRect::add(const IlvRect&) member function -

The add function:

  • Calculates the rectangular union of the rectangle this with another given rectangle, referred to as other.
  • Assigns this union to the rectangle this. As a result of the execution of the member function add, the this object is physically modified. Note that in the above diagram, the modified this object is still located at the point (x,y), but it has changed its size. That would not be the case if the provided rectangle was located to the left or above the original rectangle top-left corner.
  • Returns the modified this object.
Parameters
rectThe rectangle to be added.
Returns
The modified this object.
IlvRect& IlvRect::add ( const IlvPoint point)

Adds a point.

Acts on the current rectangle (referred to here by the C++ keyword this). The following diagram illustrates how this first add function operates:


- The IlvRect::add(const IlvPoint&) member function -

The add function:

  • Stretches the rectangle this so that it is just big enough to include the point at (p,q) referred to as point. In the special case in which point lies inside the rectangle this, the rectangle is not modified.
  • Assigns (if stretching took place) the stretched rectangle to this.

As a result of the execution of the member function add, the this object is physically modified. In the above diagram, the modified this object is still located at the point (x,y), but it is changed in size. This would not be the case if the provided point was located to the left or above the rectangle's top-left corner.

Parameters
pointThe point to be added.
Returns
The modified this object.
IlvPos IlvRect::bottom ( ) const

Retrieves the location of the bottom border.

This member function is equivalent to getY()+getH().

Returns
The y coordinate of the bottom-right corner of this rectangle.
IlvPoint IlvRect::center ( ) const

Retrieves to location of the center.

Returns
The coordinates of the center of this rectangle.
IlvPos IlvRect::centerx ( ) const

Retrieves the x coordinate of the center.

This member function is equivalent to getX()+(getW()/2).

Returns
The x coordinate of the center of this rectangle.
IlvPos IlvRect::centery ( ) const

Retrieves the y coordinate of the center.

Returns
The y coordinate of the center of this rectangle.
IlBoolean IlvRect::contains ( const IlvPoint p) const

Checks if a point is located in this rectangle.

Returns
an IlBoolean value indicating whether or not the current rectangle contains a certain point.
IlBoolean IlvRect::contains ( const IlvRect rect) const

Checks if a rectangle is located in this rectangle.

Returns
an IlBoolean value indicating whether or not the current rectangle contains the rectangle passed as the rect parameter.
void IlvRect::expand ( IlvPos  delta)

Uniformly expands the rectangle.

This member function is equivalent to:

translate(-delta, -delta);
grow(2*delta, 2*delta);

If delta is negative, and 2*|delta| is bigger than of one of the rectangle's current dimensions, this dimension (width or height) is set to 0.

Parameters
deltaThe growth to be applied to the rectangle, in all directions.
void IlvRect::expand ( IlvPos  dx,
IlvPos  dy 
)

Expands the rectangle.

This member function is equivalent to:

translate(-dx, -dy);
grow(2*dx, 2*dy);

If dx is negative, and |dx| is bigger than the current width, the new width is set to 0. If dy is negative, and |dy| is bigger than the current height, the new height is set to 0.

Parameters
dxThe horizontal growth to be applied to the rectangle.
dyThe vertical growth to be applied to the rectangle.
IlvDim IlvRect::getH ( ) const

Retrieves the height.

Returns
The height of this rectangle.
IlvDim IlvRect::getW ( ) const

Retrieves the width.

Returns
The width of this rectangle.
IlvPos IlvRect::getX ( ) const

Retrieves the x coordinate of the origin.

Returns
The x coordinate of the top-left corner of the rectangle.
IlvPos IlvRect::getY ( ) const

Retrieves the y coordinate of the origin.

Returns
The y coordinate of the top-left corner of the rectangle.
void IlvRect::grow ( IlvPos  dw,
IlvPos  dh 
)

Resizes the rectangle.

Changes the dimensions of this object by means of a variation of the current width and height. The new width is the sum of the old width and dw. Sets the new width of the rectangle to 0 if -dw is larger than the current width. The new height is the sum of the old height and dh.Sets the new height of the rectangle to 0 if -dh is larger than the current height.

IlBoolean IlvRect::inside ( const IlvRect rect) const

Checks if a rectangle is located in this rectangle.

This is similar to contains(const IlvRect&).

Returns
an IlBoolean value indicating whether or not the current rectangle is inside or contained in the rect rectangle.
IlvRect& IlvRect::intersection ( const IlvRect )

Computes an intersection.

Acts on the current rectangle (referred to here by the C++ keyword this). The diagram below illustrates how the intersection function operates:


- The IlvRect::intersection member function -

The intersection function:

  • Calculates the rectangular intersection of the rectangle this with another given rectangle, designated by the parameter other.
  • Assigns this intersection to the rectangle this.

As a result of the execution of the member function intersection, the this object is physically modified. In the above diagram, the modified this object has changed both its position and its size. It is now located at the same point as the other rectangle: that is at (x,y).

  • Returns the modified this object.

If the this and other rectangles do not intersect, then this is given 0 width and height, indicating an invalid rectangle. In this case, both the x and the y coordinates of the rectangle this are left unchanged.

IlBoolean IlvRect::intersects ( const IlvRect rect) const

Checks if a rectangle intersects with this rectangle.

Returns
an IlBoolean value indicating whether or not the current rectangle forms a non-empty intersection with another given rectangle.
IlvPos IlvRect::left ( ) const

Retrieves the location of the left border.

This member function is equivalent to x().

Returns
The x coordinate of the top-left corner of this rectangle.
IlvPoint IlvRect::lowerLeft ( ) const

Retrieves to location of the lower-left corner.

Returns
The coordinates of the lower-left corner of this rectangle.
IlvPoint IlvRect::lowerRight ( ) const

Retrieves to location of the lower-right corner.

Returns
The coordinates of the lower-right corner of this rectangle.
void IlvRect::move ( const IlvPoint orig)

Moves the rectangle.

Parameters
origThe new origin of this rectangle.
void IlvRect::move ( IlvPos  x,
IlvPos  y 
)

Moves the rectangle.

Parameters
xThe new x coordinate of the top-left corner.
yThe new y coordinate of the top-left corner.
void IlvRect::moveResize ( IlvPos  x,
IlvPos  y,
IlvDim  w,
IlvDim  h 
)

Moves and resizes the rectangles.

Parameters
xThe new x coordinate of the top-left corner of this rectangle.
yThe new y coordinate of the top-left corner of this rectangle.
wThe new width of this rectangle.
hThe new height of this rectangle.
IlvRect& IlvRect::operator= ( const IlvRect r)

Assignment operator.

Parameters
rThe rectangle that is copied to the current object.
int IlvRect::operator== ( const IlvRect r) const

Equality operator.

Parameters
rThe rectangle to compare to.
Returns
0 if r is different than the current object.
void IlvRect::resize ( IlvDim  w,
IlvDim  h 
)

Resizes the rectangle.

Parameters
wThe new width of this rectangle.
hThe new height of this rectangle.
IlvPos IlvRect::right ( ) const

Retrieves the location of the right border.

This member function is equivalent to getX()+getW().

Returns
The x coordinate of the bottom-right corner of this rectangle.
void IlvRect::scale ( IlFloat  sw,
IlFloat  sh 
)

Resizes the rectangle.

Changes the dimensions of this object by means of two scaling factors applied to both the width and the height of this rectangle. sw and sh must be positive values.

void IlvRect::set ( IlvPos  x,
IlvPos  y,
IlvDim  w,
IlvDim  h 
)

Moves and resizes the rectangles.

Parameters
xThe new x coordinate of the top-left corner of this rectangle.
yThe new y coordinate of the top-left corner of this rectangle.
wThe new width of this rectangle.
hThe new height of this rectangle.
void IlvRect::setH ( IlvDim  newH)

Sets the height.

Parameters
newHThe new height of this rectangle.
void IlvRect::setW ( IlvDim  newW)

Sets the width.

Parameters
newWThe new width of this rectangle.
void IlvRect::setX ( IlvPos  newX)

Sets the x coordinate of the origin.

Parameters
newXThe new x coordinate of the origin.
void IlvRect::setY ( IlvPos  newY)

Sets the y coordinate of the origin.

Parameters
newYThe new y coordinate of the origin.
void IlvRect::size ( IlvDim w,
IlvDim h 
) const

Retrieves the dimensions.

Parameters
wIs assigned the width of this rectangle.
hIs assigned the height of this rectangle.
IlvPos IlvRect::top ( ) const

Retrieves the location of the top border.

This member function is equivalent to y().

Returns
The y coordinate of the top-left corner of this rectangle.
void IlvRect::translate ( const IlvPoint dp)

Translates the rectangle.

Parameters
dpThe translation applied to the rectangle.
void IlvRect::translate ( IlvPos  dx,
IlvPos  dy 
)

Translates the rectangle.

Parameters
dxThe x translation applied to the rectangle.
dyThe y translation applied to the rectangle.
const IlvPoint& IlvRect::upperLeft ( ) const

Retrieves to location of the upper-left corner.

This member function is equivalent to orig().

Returns
The coordinates of the upper-left corner of this rectangle.
IlvPoint IlvRect::upperRight ( ) const

Retrieves to location of the upper-right corner.

Returns
The coordinates of the upper-right corner of this rectangle.

© Copyright 2015, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.