|
| Rect () |
|
| Rect (const Nice::Point &topleft, const Nice::Size &size) |
|
| Rect (double left, double top, double widtht, double height) |
|
| Rect (const Nice::RectVar &rect) |
|
bool | isNull () const |
|
bool | isEmpty () const |
|
bool | isValid () const |
|
void | normalize () |
|
Rect | normalized () const |
|
double | left () const |
|
double | top () const |
|
double | right () const |
|
double | bottom () const |
|
double | x () const |
|
double | y () const |
|
void | setLeft (double pos) |
|
void | setTop (double pos) |
|
void | setRight (double pos) |
|
void | setBottom (double pos) |
|
void | setX (double pos) |
|
void | setY (double pos) |
|
Nice::Point | topLeft () const |
|
Nice::Point | bottomRight () const |
|
Nice::Point | topRight () const |
|
Nice::Point | bottomLeft () const |
|
Nice::Point | center () const |
|
void | setTopLeft (const Nice::Point &p) |
|
void | setBottomRight (const Nice::Point &p) |
|
void | setTopRight (const Nice::Point &p) |
|
void | setBottomLeft (const Nice::Point &p) |
|
void | moveLeft (double pos) |
|
void | moveTop (double pos) |
|
void | moveRight (double pos) |
|
void | moveBottom (double pos) |
|
void | moveTopLeft (const Nice::Point &p) |
|
void | moveBottomRight (const Nice::Point &p) |
|
void | moveTopRight (const Nice::Point &p) |
|
void | moveBottomLeft (const Nice::Point &p) |
|
void | moveCenter (const Nice::Point &p) |
|
void | translate (double dx, double dy) |
|
void | translate (const Nice::Point &p) |
|
Rect | translated (double dx, double dy) const |
|
Rect | translated (const Nice::Point &p) const |
|
void | moveTo (double x, double t) |
|
void | moveTo (const Nice::Point &p) |
|
void | setRectVar (double x, double y, double wd, double ht) |
|
void | getRectVar (double *x, double *y, double *wd, double *ht) const |
|
void | setCoords (double x1, double y1, double x2, double y2) |
|
void | getCoords (double *x1, double *y1, double *x2, double *y2) const |
|
void | adjust (double x1, double y1, double x2, double y2) |
|
Rect | adjusted (double x1, double y1, double x2, double y2) const |
|
Nice::Size | size () const |
|
double | width () const |
|
double | height () const |
|
void | setWidth (double wd) |
|
void | setHeight (double ht) |
|
void | setSize (const Nice::Size &s) |
|
Rect | operator| (const Rect &r) const |
|
Rect | operator & (const Rect &r) const |
|
Rect & | operator|= (const Rect &r) |
|
Rect & | operator &= (const Rect &r) |
|
bool | contains (const Nice::Point &p) const |
|
bool | contains (double x, double y) const |
|
bool | contains (const Rect &r) const |
|
Rect | unite (const Rect &r) const |
|
Rect | united (const Rect &other) const |
|
Rect | intersect (const Rect &r) const |
|
Rect | intersected (const Rect &other) const |
|
bool | intersects (const Rect &r) const |
|
| Rect () |
|
| Rect (const Nice::Point &topleft, const Nice::Size &size) |
|
| Rect (double left, double top, double widtht, double height) |
|
| Rect (const Nice::RectVar &rect) |
|
bool | isNull () const |
|
bool | isEmpty () const |
|
bool | isValid () const |
|
void | normalize () |
|
Rect | normalized () const |
|
double | left () const |
|
double | top () const |
|
double | right () const |
|
double | bottom () const |
|
double | x () const |
|
double | y () const |
|
void | setLeft (double pos) |
|
void | setTop (double pos) |
|
void | setRight (double pos) |
|
void | setBottom (double pos) |
|
void | setX (double pos) |
|
void | setY (double pos) |
|
Nice::Point | topLeft () const |
|
Nice::Point | bottomRight () const |
|
Nice::Point | topRight () const |
|
Nice::Point | bottomLeft () const |
|
Nice::Point | center () const |
|
void | setTopLeft (const Nice::Point &p) |
|
void | setBottomRight (const Nice::Point &p) |
|
void | setTopRight (const Nice::Point &p) |
|
void | setBottomLeft (const Nice::Point &p) |
|
void | moveLeft (double pos) |
|
void | moveTop (double pos) |
|
void | moveRight (double pos) |
|
void | moveBottom (double pos) |
|
void | moveTopLeft (const Nice::Point &p) |
|
void | moveBottomRight (const Nice::Point &p) |
|
void | moveTopRight (const Nice::Point &p) |
|
void | moveBottomLeft (const Nice::Point &p) |
|
void | moveCenter (const Nice::Point &p) |
|
void | translate (double dx, double dy) |
|
void | translate (const Nice::Point &p) |
|
Rect | translated (double dx, double dy) const |
|
Rect | translated (const Nice::Point &p) const |
|
void | moveTo (double x, double t) |
|
void | moveTo (const Nice::Point &p) |
|
void | setRectVar (double x, double y, double wd, double ht) |
|
void | getRectVar (double *x, double *y, double *wd, double *ht) const |
|
void | setCoords (double x1, double y1, double x2, double y2) |
|
void | getCoords (double *x1, double *y1, double *x2, double *y2) const |
|
void | adjust (double x1, double y1, double x2, double y2) |
|
Rect | adjusted (double x1, double y1, double x2, double y2) const |
|
Nice::Size | size () const |
|
double | width () const |
|
double | height () const |
|
void | setWidth (double wd) |
|
void | setHeight (double ht) |
|
void | setSize (const Nice::Size &s) |
|
Rect | operator| (const Rect &r) const |
|
Rect | operator & (const Rect &r) const |
|
Rect & | operator|= (const Rect &r) |
|
Rect & | operator &= (const Rect &r) |
|
bool | contains (const Nice::Point &p) const |
|
bool | contains (double x, double y) const |
|
bool | contains (const Rect &r) const |
|
Rect | unite (const Rect &r) const |
|
Rect | united (const Rect &other) const |
|
Rect | intersect (const Rect &r) const |
|
Rect | intersected (const Rect &other) const |
|
bool | intersects (const Rect &r) const |
|
bool | operator== (const RectVar &__rhs) const |
|
bool | operator< (const RectVar &__rhs) const |
|
bool | operator!= (const RectVar &__rhs) const |
|
bool | operator<= (const RectVar &__rhs) const |
|
bool | operator> (const RectVar &__rhs) const |
|
bool | operator>= (const RectVar &__rhs) const |
|
bool | operator== (const RectVar &__rhs) const |
|
bool | operator< (const RectVar &__rhs) const |
|
bool | operator!= (const RectVar &__rhs) const |
|
bool | operator<= (const RectVar &__rhs) const |
|
bool | operator> (const RectVar &__rhs) const |
|
bool | operator>= (const RectVar &__rhs) const |
|
The Nice::Rect class defines a rectangle in the plane using floating point precision.
A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a Nice::Rect is always equivalent to the mathematical rectangle that forms the basis for its rendering.
A Nice::Rect can be constructed with a set of left, top, width and height integers, or from a Nice::Point and a Nice::Size. The following code creates two identical rectangles.
There is also a third constructor creating a Nice::Rect from a QRectVar, and a corresponding toRectVar() function that returns a QRectVar object based on the values of this rectangle (note that the coordinates in the returned rectangle are rounded to the nearest integer).
The Nice::Rect class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. Nice::Rect also provide functions to move the rectangle relative to the various coordinates. In addition there is a moveTo() function that moves the rectangle, leaving its top left corner at the given coordinates. Alternatively, the translate() function moves the rectangle the given offset relative to the current position, and the translated() function returns a translated copy of this rectangle.
The size() function returns the rectange's dimensions as a Nice::Size. The dimensions can also be retrieved separately using the width() and height() functions. To manipulate the dimensions use the setSize(), setWidth() or setHeight() functions. Alternatively, the size can be changed by applying either of the functions setting the rectangle coordinates, for example, setBottom() or setRight().
The contains() function tells whether a given point is inside the rectangle or not, and the intersects() function returns true if this rectangle intersects with a given rectangle (otherwise false). The Nice::Rect class also provides the intersected() function which returns the intersection rectangle, and the united() function which returns the rectangle that encloses the given rectangle and this:
qrect-intersect.png qrect-unite.png intersected() united()
The isEmpty() function returns true if the rectangle's width or height is less than, or equal to, 0. Note that an empty rectangle is not valid: The isValid() function returns true if both width and height is larger than 0. A null rectangle (isNull() == true) on the other hand, has both width and height set to 0.
Finally, Nice::Rect objects can be streamed as well as compared.