rwlogo
Rogue Wave Views 5.5.1

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

IlvRect Class Reference

Geometric class. More...

#include <ilviews/base/geometry.h>

Inheritance diagram for IlvRect:
IlvWindowsRect

List of all members.

Public Member Functions

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

Detailed Description

Geometric class.

Library: display

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:
x The x coordinate of the top-left corner of this rectangle.
y The y coordinate of the top-left corner of this rectangle.
w The width of this rectangle.
h The height of this rectangle. rectangle.

Member Function Documentation

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:

rect2.gif


- 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:
point The point to be added.
Returns:
The modified this object.
IlvRect& IlvRect::add ( const IlvRect rect  ) 

Adds a rectangle.

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

rect3.gif


- 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:
rect The rectangle 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 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.
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.
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:
dx The horizontal growth to be applied to the rectangle.
dy The vertical growth to be applied to the rectangle.
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:
delta The growth to be applied to the rectangle, in all directions.
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:

rect1.gif


- 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 ( IlvPos  x,
IlvPos  y 
)

Moves the rectangle.

Parameters:
x The new x coordinate of the top-left corner.
y The new y coordinate of the top-left corner.
void IlvRect::move ( const IlvPoint orig  ) 

Moves the rectangle.

Parameters:
point The new origin of this rectangle.
void IlvRect::moveResize ( IlvPos  x,
IlvPos  y,
IlvDim  w,
IlvDim  h 
)

Moves and resizes the rectangles.

Parameters:
x The new x coordinate of the top-left corner of this rectangle.
y The new y coordinate of the top-left corner of this rectangle.
w The new width of this rectangle.
h The new height of this rectangle.
IlvRect& IlvRect::operator= ( const IlvRect r  ) 

Assignment operator.

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

Equality operator.

Parameters:
r The 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:
w The new width of this rectangle.
h The 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:
x The new x coordinate of the top-left corner of this rectangle.
y The new y coordinate of the top-left corner of this rectangle.
w The new width of this rectangle.
h The new height of this rectangle.
void IlvRect::setH ( IlvDim  newH  ) 

Sets the height.

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

Sets the width.

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

Sets the x coordinate of the origin.

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

Sets the y coordinate of the origin.

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

Retrieves the dimensions.

Parameters:
w Is assigned the width of this rectangle.
h Is 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 ( IlvPos  dx,
IlvPos  dy 
)

Translates the rectangle.

Parameters:
x The x translation applied to the rectangle.
y The y translation applied to the rectangle.
void IlvRect::translate ( const IlvPoint dp  ) 

Translates the rectangle.

Parameters:
delta The 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 2012, 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.