Geometric class. More...
#include <ilviews/base/geometry/IlvBaseGeometry.h>
Public Member Functions | |
IlvRect (IlvPos x=0, IlvPos y=0, IlvDim w=0, IlvDim h=0) | |
Constructor. More... | |
IlvRect & | add (const IlvPoint &point) |
Adds a point. More... | |
IlvRect & | add (const IlvRect &rect) |
Adds a rectangle. 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... | |
IlBoolean | extends (const IlvRect &rect) const |
Checks if a given rectangle is a direct extension of this 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... | |
IlvRect & | intersection (const IlvRect &other) |
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... | |
IlvRect & | operator= (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 IlvPoint & | upperLeft () const |
Retrieves to location of the upper-left corner. More... | |
IlvPoint | upperRight () const |
Retrieves to location of the upper-right corner. More... | |
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.
IlvFloatRect
, IlvPoint
.Name | Type | Equivalent methods |
---|---|---|
x | Int | getX() , setX(IlvPos) |
y | Int | getY() , setY(IlvPos) |
w | UInt | getW() , setW(IlvDim) |
h | UInt | getH() , setH(IlvDim) |
right | Int | right() |
bottom | Int | bottom() |
Name | Return type | Equivalent methods |
---|---|---|
IlvRect(Int x, Int y, UInt w, UInt h) | IlvRect | See [Constructor note] below. |
[Constructor note]: using this accessor allows to create an instance of IlvRect
from a script. For example :
This is equivalent to the following C++ code :
Constructor.
This constructor initializes a new rectangle with defined location and sizes.
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. |
Adds a point.
The following diagram illustrates how this first method add()
operates:
- The method IlvRect::add(const IlvPoint&)
-
The method add()
:
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. this
. As a result of the execution of the member function add()
, the object this
is modified. In the above diagram, the modified object this
is still located at the point (x, y)
, but is changed in size. This would not be the case if the provided point was located to the left or above the rectangle top-left corner.
point | The point to be added. |
this
. Adds a rectangle.
The following diagram illustrates the way in which this second method add()
operates:
- The IlvRect::add(const IlvRect&)
method -
The method add()
:
this
with another given rectangle, referred to as other
. this
. As a result of the execution of the method add()
, the object this
is modified. Note that in the above diagram, the modified object this
is still located at the point (x, y)
, but it has changed in size. That would not be the case if the provided rectangle was located to the left or above the original rectangle top-left corner. this
. rect | The rectangle to add. |
this
. IlvPos IlvRect::bottom | ( | ) | const |
IlvPoint IlvRect::center | ( | ) | const |
Retrieves to location of the center.
IlvPos IlvRect::centerx | ( | ) | const |
IlvPos IlvRect::centery | ( | ) | const |
Retrieves the y coordinate of the center.
Checks if a point is located in this rectangle.
IlBoolean
value indicating whether or not the current rectangle contains a certain point. Checks if a rectangle is located in this rectangle.
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:
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.
delta | The growth to be applied to the rectangle, in all directions. |
Expands the rectangle.
This member function is equivalent to:
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
.
dx | The horizontal growth to be applied to the rectangle. |
dy | The vertical growth to be applied to the rectangle. |
Checks if a given rectangle is a direct extension of this rectangle.
IlBoolean
value indicating whether or not the current rectangle is a direct extension of the given rectangle IlvDim IlvRect::getH | ( | ) | const |
Retrieves the height.
IlvDim IlvRect::getW | ( | ) | const |
Retrieves the width.
IlvPos IlvRect::getX | ( | ) | const |
Retrieves the x coordinate of the origin.
IlvPos IlvRect::getY | ( | ) | const |
Retrieves the y coordinate of the origin.
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.
Checks if a rectangle is located in this rectangle.
This is similar to contains(const IlvRect&)
.
IlBoolean
value indicating whether or not the current rectangle is inside or contained in the rectangle rect. Computes an intersection.
The diagram below illustrates how the intersection()
method operates:
- The IlvRect::intersection()
method -
The intersection
method:
this
with another given rectangle, designated by the parameter other
. this
. As a result of the execution of the method intersection
, the object this
is modified. In the above diagram, the modified object this
has changed in both position and size. It is now located at the same point as the rectangle other
: that is at (x, y)
.
this
. If the rectangles this
and other
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.
Checks if a rectangle intersects with this rectangle.
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()
.
IlvPoint IlvRect::lowerLeft | ( | ) | const |
Retrieves to location of the lower-left corner.
IlvPoint IlvRect::lowerRight | ( | ) | const |
Retrieves to location of the lower-right corner.
void IlvRect::move | ( | const IlvPoint & | orig | ) |
Moves the rectangle.
orig | The new origin of this rectangle. |
Moves the rectangle.
x | The new x coordinate of the top-left corner. |
y | The new y coordinate of the top-left corner. |
Moves and resizes the rectangles.
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. |
Assignment operator.
r | The rectangle that is copied to the current object. |
int IlvRect::operator== | ( | const IlvRect & | r | ) | const |
Equality operator.
r | The rectangle to compare to. |
0
if r is different than the current object. Resizes the rectangle.
w | The new width of this rectangle. |
h | The new height of this rectangle. |
IlvPos IlvRect::right | ( | ) | const |
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.
Moves and resizes the rectangles.
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.
newH | The new height of this rectangle. |
void IlvRect::setW | ( | IlvDim | newW | ) |
Sets the width.
newW | The new width of this rectangle. |
void IlvRect::setX | ( | IlvPos | newX | ) |
Sets the x coordinate of the origin.
newX | The new x coordinate of the origin. |
void IlvRect::setY | ( | IlvPos | newY | ) |
Sets the y coordinate of the origin.
newY | The new y coordinate of the origin. |
Retrieves the dimensions.
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()
.
void IlvRect::translate | ( | const IlvPoint & | dp | ) |
Translates the rectangle.
dp | The translation applied to the rectangle. |
Translates the rectangle.
dx | The x translation applied to the rectangle. |
dy | The 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()
.
IlvPoint IlvRect::upperRight | ( | ) | const |
Retrieves to location of the upper-right corner.