TwiceAsNice  2019-02-18
Public Member Functions | Friends | Related Functions | List of all members
Nice::Rect Class Reference

The Nice::Rect class defines a rectangle in the plane using floating point precision. More...

#include <Rect.h>

Inheritance diagram for Nice::Rect:
Inheritance graph
Collaboration diagram for Nice::Rect:
Collaboration graph

Public Member Functions

 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
 
Rectoperator|= (const Rect &r)
 
Rectoperator &= (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
 
Rectoperator|= (const Rect &r)
 
Rectoperator &= (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
 
- Public Member Functions inherited from Nice::RectVar
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
 

Friends

bool operator== (const Rect &, const Rect &)
 
bool operator!= (const Rect &, const Rect &)
 
bool operator== (const Rect &, const Rect &)
 
bool operator!= (const Rect &, const Rect &)
 

Related Functions

(Note that these are not member functions.)

bool operator== (const Nice::Rect &r1, const Nice::Rect &r2)
 
bool operator!= (const Nice::Rect &r1, const Nice::Rect &r2)
 
std::ostream & operator<< (std::ostream &stream, const Nice::Rect &rectangle)
 
std::istream & operator>> (std::istream &stream, Nice::Rect &rectangle)
 

Additional Inherited Members

- Public Attributes inherited from Nice::RectVar
::Ice::Double xp
 
::Ice::Double yp
 
::Ice::Double wd
 
::Ice::Double ht
 

Detailed Description

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.

Nice::Rect r1(100, 200, 11, 16);
Nice::Rect r2(Nice::Point(100, 200), Nice::Size(11, 16));

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.

Constructor & Destructor Documentation

◆ Rect() [1/8]

Nice::Rect::Rect ( )
inline

◆ Rect() [2/8]

Nice::Rect::Rect ( const Nice::Point topleft,
const Nice::Size size 
)
inline

◆ Rect() [3/8]

Nice::Rect::Rect ( double  left,
double  top,
double  widtht,
double  height 
)
inline

◆ Rect() [4/8]

Nice::Rect::Rect ( const Nice::RectVar rect)
inline

◆ Rect() [5/8]

Nice::Rect::Rect ( )
inline

◆ Rect() [6/8]

Nice::Rect::Rect ( const Nice::Point topleft,
const Nice::Size size 
)

◆ Rect() [7/8]

Nice::Rect::Rect ( double  left,
double  top,
double  widtht,
double  height 
)

◆ Rect() [8/8]

Nice::Rect::Rect ( const Nice::RectVar rect)

Member Function Documentation

◆ adjust() [1/2]

void Nice::Rect::adjust ( double  dx1,
double  dy1,
double  dx2,
double  dy2 
)
inline

Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.

See also
adjusted(), setRectVar()

◆ adjust() [2/2]

void Nice::Rect::adjust ( double  x1,
double  y1,
double  x2,
double  y2 
)
inline

◆ adjusted() [1/2]

Rect Nice::Rect::adjusted ( double  dx1,
double  dy1,
double  dx2,
double  dy2 
) const
inline

Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.

See also
adjust()

◆ adjusted() [2/2]

Rect Nice::Rect::adjusted ( double  x1,
double  y1,
double  x2,
double  y2 
) const
inline

◆ bottom() [1/2]

double Nice::Rect::bottom ( ) const
inline

◆ bottom() [2/2]

double Nice::Rect::bottom ( ) const
inline

Returns the y-coordinate of the rectangle's bottom edge.

See also
setBottom(), bottomLeft(), bottomRight()

◆ bottomLeft() [1/2]

Nice::Point Nice::Rect::bottomLeft ( ) const
inline

◆ bottomLeft() [2/2]

Nice::Point Nice::Rect::bottomLeft ( ) const
inline

Returns the position of the rectangle's bottom-left corner.

See also
setBottomLeft(), bottom(), left()

◆ bottomRight() [1/2]

Nice::Point Nice::Rect::bottomRight ( ) const
inline

◆ bottomRight() [2/2]

Nice::Point Nice::Rect::bottomRight ( ) const
inline

Returns the position of the rectangle's bottom-right corner.

See also
setBottomRight(), bottom(), right()

◆ center() [1/2]

Nice::Point Nice::Rect::center ( ) const
inline

◆ center() [2/2]

Nice::Point Nice::Rect::center ( ) const
inline

Returns the center point of the rectangle.

See also
moveCenter()

◆ contains() [1/6]

bool Nice::Rect::contains ( const Nice::Point point) const

Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false.

See also
intersects()

◆ contains() [2/6]

bool Nice::Rect::contains ( const Nice::Point p) const

◆ contains() [3/6]

bool Nice::Rect::contains ( double  x,
double  y 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns true if the point (x, y) is inside or on the edge of the rectangle; otherwise returns false.

◆ contains() [4/6]

bool Nice::Rect::contains ( double  x,
double  y 
) const

◆ contains() [5/6]

bool Nice::Rect::contains ( const Rect r) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns true if the given rectangle is inside this rectangle; otherwise returns false.

◆ contains() [6/6]

bool Nice::Rect::contains ( const Rect r) const

◆ getCoords() [1/2]

void Nice::Rect::getCoords ( double *  x1,
double *  y1,
double *  x2,
double *  y2 
) const
inline

Extracts the position of the rectangle's top-left corner to *x1 and *y1, and the position of the bottom-right corner to *x2 and y2.

See also
setCoords(), getRectVar()

◆ getCoords() [2/2]

void Nice::Rect::getCoords ( double *  x1,
double *  y1,
double *  x2,
double *  y2 
) const

◆ getRectVar() [1/2]

void Nice::Rect::getRectVar ( double *  x,
double *  y,
double *  width,
double *  height 
) const
inline

Extracts the position of the rectangle's top-left corner to *x and y, and its dimensions to *width and *height.

See also
setRectVar(), getCoords()

◆ getRectVar() [2/2]

void Nice::Rect::getRectVar ( double *  x,
double *  y,
double *  wd,
double *  ht 
) const

◆ height() [1/2]

double Nice::Rect::height ( ) const
inline

Returns the height of the rectangle.

See also
setHeight(), width(), size()

◆ height() [2/2]

double Nice::Rect::height ( ) const

◆ intersect() [1/2]

Rect Nice::Rect::intersect ( const Rect r) const

◆ intersect() [2/2]

Rect Nice::Rect::intersect ( const Rect r) const
inline

Use intersected(rectangle) instead.

◆ intersected() [1/2]

Rect Nice::Rect::intersected ( const Rect other) const

◆ intersected() [2/2]

Rect Nice::Rect::intersected ( const Rect other) const
inline
Since
4.2

Returns the intersection of this rectangle and the given rectangle. Note that {r.intersected(s)} is equivalent to {r & s}.

See also
intersects(), united(), operator&=()

◆ intersects() [1/2]

bool Nice::Rect::intersects ( const Rect r) const

Returns true if this rectangle intersects with the given rectangle (i.e. there is at least one pixel that is within both rectangles), otherwise returns false.

The intersection rectangle can be retrieved using the intersected() function.

See also
contains()

◆ intersects() [2/2]

bool Nice::Rect::intersects ( const Rect r) const

◆ isEmpty() [1/2]

bool Nice::Rect::isEmpty ( ) const
inline

Returns true if the rectangle is empty, otherwise returns false.

An empty rectangle has width() <= 0 or height() <= 0. An empty rectangle is not valid (i.e isEmpty() == !isValid()).

Use the normalized() function to retrieve a rectangle where the corners are swapped.

See also
isNull(), isValid(), normalized()

◆ isEmpty() [2/2]

bool Nice::Rect::isEmpty ( ) const

◆ isNull() [1/2]

bool Nice::Rect::isNull ( ) const

◆ isNull() [2/2]

bool Nice::Rect::isNull ( ) const
inline

Returns true if the rectangle is a null rectangle, otherwise returns false.

A null rectangle has both the width and the height set to 0. A null rectangle is also empty, and hence not valid.

See also
isEmpty(), isValid()

◆ isValid() [1/2]

bool Nice::Rect::isValid ( ) const

◆ isValid() [2/2]

bool Nice::Rect::isValid ( ) const
inline

Returns true if the rectangle is valid, otherwise returns false.

A valid rectangle has a width() > 0 and height() > 0. Note that non-trivial operations like intersections are not defined for invalid rectangles. A valid rectangle is not empty (i.e. isValid() == !isEmpty()).

See also
isNull(), isEmpty(), normalized()

◆ left() [1/2]

double Nice::Rect::left ( ) const
inline

◆ left() [2/2]

double Nice::Rect::left ( ) const
inline

Returns the x-coordinate of the rectangle's left edge. Equivalent to x().

See also
setLeft(), topLeft(), bottomLeft()

◆ moveBottom() [1/2]

void Nice::Rect::moveBottom ( double  pos)

◆ moveBottom() [2/2]

void Nice::Rect::moveBottom ( double  y)
inline

Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate. The rectangle's size is unchanged.

See also
bottom(), setBottom(), moveTop()

◆ moveBottomLeft() [1/2]

void Nice::Rect::moveBottomLeft ( const Nice::Point position)
inline

Moves the rectangle, leaving the bottom-left corner at the given position. The rectangle's size is unchanged.

See also
setBottomLeft(), moveBottom(), moveLeft()

◆ moveBottomLeft() [2/2]

void Nice::Rect::moveBottomLeft ( const Nice::Point p)

◆ moveBottomRight() [1/2]

void Nice::Rect::moveBottomRight ( const Nice::Point position)
inline

Moves the rectangle, leaving the bottom-right corner at the given position. The rectangle's size is unchanged.

See also
setBottomRight(), moveBottom(), moveRight()

◆ moveBottomRight() [2/2]

void Nice::Rect::moveBottomRight ( const Nice::Point p)

◆ moveCenter() [1/2]

void Nice::Rect::moveCenter ( const Nice::Point position)
inline

Moves the rectangle, leaving the center point at the given position. The rectangle's size is unchanged.

See also
center()

◆ moveCenter() [2/2]

void Nice::Rect::moveCenter ( const Nice::Point p)

◆ moveLeft() [1/2]

void Nice::Rect::moveLeft ( double  pos)

◆ moveLeft() [2/2]

void Nice::Rect::moveLeft ( double  x)
inline

Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate. The rectangle's size is unchanged.

See also
left(), setLeft(), moveRight()

◆ moveRight() [1/2]

void Nice::Rect::moveRight ( double  pos)

◆ moveRight() [2/2]

void Nice::Rect::moveRight ( double  x)
inline

Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate. The rectangle's size is unchanged.

See also
right(), setRight(), moveLeft()

◆ moveTo() [1/4]

void Nice::Rect::moveTo ( double  x,
double  y 
)
inline

Moves the rectangle, leaving the top-left corner at the given position (x, y). The rectangle's size is unchanged.

See also
translate(), moveTopLeft()

◆ moveTo() [2/4]

void Nice::Rect::moveTo ( double  x,
double  t 
)

◆ moveTo() [3/4]

void Nice::Rect::moveTo ( const Nice::Point position)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Moves the rectangle, leaving the top-left corner at the given position.

◆ moveTo() [4/4]

void Nice::Rect::moveTo ( const Nice::Point p)

◆ moveTop() [1/2]

void Nice::Rect::moveTop ( double  pos)

◆ moveTop() [2/2]

void Nice::Rect::moveTop ( double  y)
inline

Moves the rectangle vertically, leaving the rectangle's top line at the given y coordinate. The rectangle's size is unchanged.

See also
top(), setTop(), moveBottom()

◆ moveTopLeft() [1/2]

void Nice::Rect::moveTopLeft ( const Nice::Point p)

◆ moveTopLeft() [2/2]

void Nice::Rect::moveTopLeft ( const Nice::Point position)
inline

Moves the rectangle, leaving the top-left corner at the given position. The rectangle's size is unchanged.

See also
setTopLeft(), moveTop(), moveLeft()

◆ moveTopRight() [1/2]

void Nice::Rect::moveTopRight ( const Nice::Point position)
inline

Moves the rectangle, leaving the top-right corner at the given position. The rectangle's size is unchanged.

See also
setTopRight(), moveTop(), moveRight()

◆ moveTopRight() [2/2]

void Nice::Rect::moveTopRight ( const Nice::Point p)

◆ normalize() [1/2]

void Nice::Rect::normalize ( )

◆ normalize() [2/2]

void Nice::Rect::normalize ( )

Returns a normalized rectangle; i.e. a rectangle that has a non-negative width and height.

If width() < 0 the function swaps the left and right corners, and it swaps the top and bottom corners if height() < 0.

See also
isValid(), isEmpty()

◆ normalized() [1/2]

Rect Nice::Rect::normalized ( ) const

◆ normalized() [2/2]

Nice::Rect Nice::Rect::normalized ( ) const

◆ operator &() [1/2]

Nice::Rect Nice::Rect::operator& ( const Rect r) const

Returns the intersection of this rectangle and the given rectangle. Returns an empty rectangle if there is no intersection.

See also
operator&=(), intersected()

◆ operator &() [2/2]

Rect Nice::Rect::operator& ( const Rect r) const

◆ operator &=() [1/2]

Rect& Nice::Rect::operator&= ( const Rect r)

◆ operator &=() [2/2]

Rect& Nice::Rect::operator&= ( const Rect r)

◆ operator|() [1/2]

Nice::Rect Nice::Rect::operator| ( const Rect r) const

Returns the bounding rectangle of this rectangle and the given rectangle.

See also
united(), operator|=()

◆ operator|() [2/2]

Rect Nice::Rect::operator| ( const Rect r) const

◆ operator|=() [1/2]

Rect& Nice::Rect::operator|= ( const Rect r)

◆ operator|=() [2/2]

Rect & Nice::Rect::operator|= ( const Rect r)
inline

Unites this rectangle with the given rectangle.

See also
united(), operator|()

◆ right() [1/2]

double Nice::Rect::right ( ) const
inline

Returns the x-coordinate of the rectangle's right edge.

See also
setRight(), topRight(), bottomRight()

◆ right() [2/2]

double Nice::Rect::right ( ) const
inline

◆ setBottom() [1/2]

void Nice::Rect::setBottom ( double  pos)
inline

◆ setBottom() [2/2]

void Nice::Rect::setBottom ( double  y)
inline

Sets the bottom edge of the rectangle to the given y coordinate. May change the height, but will never change the top edge of the rectangle.

See also
bottom(), moveBottom()

◆ setBottomLeft() [1/2]

void Nice::Rect::setBottomLeft ( const Nice::Point p)

◆ setBottomLeft() [2/2]

void Nice::Rect::setBottomLeft ( const Nice::Point position)
inline

Set the bottom-left corner of the rectangle to the given position. May change the size, but will the never change the top-right corner of the rectangle.

See also
bottomLeft(), moveBottomLeft()

◆ setBottomRight() [1/2]

void Nice::Rect::setBottomRight ( const Nice::Point p)

◆ setBottomRight() [2/2]

void Nice::Rect::setBottomRight ( const Nice::Point position)
inline

Set the top-right corner of the rectangle to the given position. May change the size, but will the never change the top-left corner of the rectangle.

See also
bottomRight(), moveBottomRight()

◆ setCoords() [1/2]

void Nice::Rect::setCoords ( double  x1,
double  y1,
double  x2,
double  y2 
)
inline

Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2).

See also
getCoords() setRectVar()

◆ setCoords() [2/2]

void Nice::Rect::setCoords ( double  x1,
double  y1,
double  x2,
double  y2 
)

◆ setHeight() [1/2]

void Nice::Rect::setHeight ( double  height)
inline

Sets the height of the rectangle to the given height. The bottom edge is changed, but not the top one.

See also
height(), setSize()

◆ setHeight() [2/2]

void Nice::Rect::setHeight ( double  ht)

◆ setLeft() [1/2]

void Nice::Rect::setLeft ( double  x)
inline

Sets the left edge of the rectangle to the given x coordinate. May change the width, but will never change the right edge of the rectangle.

Equivalent to setX().

See also
left(), moveLeft()

◆ setLeft() [2/2]

void Nice::Rect::setLeft ( double  pos)
inline

◆ setRectVar() [1/2]

void Nice::Rect::setRectVar ( double  x,
double  y,
double  wd,
double  ht 
)

◆ setRectVar() [2/2]

void Nice::Rect::setRectVar ( double  x,
double  y,
double  width,
double  height 
)
inline

Sets the coordinates of the rectangle's top-left corner to (x, y), and its size to the given width and height.

See also
getRectVar(), setCoords()

◆ setRight() [1/2]

void Nice::Rect::setRight ( double  pos)
inline

◆ setRight() [2/2]

void Nice::Rect::setRight ( double  x)
inline

Sets the right edge of the rectangle to the given x coordinate. May change the width, but will never change the left edge of the rectangle.

See also
right(), moveRight()

◆ setSize() [1/2]

void Nice::Rect::setSize ( const Nice::Size s)
inline

◆ setSize() [2/2]

void Nice::Rect::setSize ( const Nice::Size s)

◆ setTop() [1/2]

void Nice::Rect::setTop ( double  y)
inline

Sets the top edge of the rectangle to the given y coordinate. May change the height, but will never change the bottom edge of the rectangle.

Equivalent to setY().

See also
top(), moveTop()

◆ setTop() [2/2]

void Nice::Rect::setTop ( double  pos)
inline

◆ setTopLeft() [1/2]

void Nice::Rect::setTopLeft ( const Nice::Point p)

◆ setTopLeft() [2/2]

void Nice::Rect::setTopLeft ( const Nice::Point position)
inline

Set the top-left corner of the rectangle to the given position. May change the size, but will the never change the bottom-right corner of the rectangle.

See also
topLeft(), moveTopLeft()

◆ setTopRight() [1/2]

void Nice::Rect::setTopRight ( const Nice::Point position)
inline

Set the top-right corner of the rectangle to the given position. May change the size, but will the never change the bottom-left corner of the rectangle.

See also
topRight(), moveTopRight()

◆ setTopRight() [2/2]

void Nice::Rect::setTopRight ( const Nice::Point p)

◆ setWidth() [1/2]

void Nice::Rect::setWidth ( double  width)
inline

Sets the width of the rectangle to the given width. The right edge is changed, but not the left one.

See also
width(), setSize()

◆ setWidth() [2/2]

void Nice::Rect::setWidth ( double  wd)

◆ setX() [1/2]

void Nice::Rect::setX ( double  x)
inline

Sets the left edge of the rectangle to the given x coordinate. May change the width, but will never change the right edge of the rectangle.

Equivalent to setLeft().

See also
x(), setY(), setTopLeft()

◆ setX() [2/2]

void Nice::Rect::setX ( double  pos)
inline

◆ setY() [1/2]

void Nice::Rect::setY ( double  y)
inline

Sets the top edge of the rectangle to the given y coordinate. May change the height, but will never change the bottom edge of the rectangle.

Equivalent to setTop().

See also
y(), setX(), setTopLeft()

◆ setY() [2/2]

void Nice::Rect::setY ( double  pos)
inline

◆ size() [1/2]

Nice::Size Nice::Rect::size ( ) const

◆ size() [2/2]

Nice::Size Nice::Rect::size ( ) const
inline

Returns the size of the rectangle.

See also
setSize(), width(), height()

◆ top() [1/2]

double Nice::Rect::top ( ) const
inline

◆ top() [2/2]

double Nice::Rect::top ( ) const
inline

Returns the y-coordinate of the rectangle's top edge. Equivalent to y().

See also
setTop(), topLeft(), topRight()

◆ topLeft() [1/2]

Nice::Point Nice::Rect::topLeft ( ) const
inline

Returns the position of the rectangle's top-left corner.

See also
setTopLeft(), top(), left()

◆ topLeft() [2/2]

Nice::Point Nice::Rect::topLeft ( ) const
inline

◆ topRight() [1/2]

Nice::Point Nice::Rect::topRight ( ) const
inline

◆ topRight() [2/2]

Nice::Point Nice::Rect::topRight ( ) const
inline

Returns the position of the rectangle's top-right corner.

See also
setTopRight(), top(), right()

◆ translate() [1/4]

void Nice::Rect::translate ( double  dx,
double  dy 
)
inline

Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position. Positive values move the rectangle to the right and downwards.

See also
moveTopLeft(), moveTo(), translated()

◆ translate() [2/4]

void Nice::Rect::translate ( double  dx,
double  dy 
)

◆ translate() [3/4]

void Nice::Rect::translate ( const Nice::Point p)

◆ translate() [4/4]

void Nice::Rect::translate ( const Nice::Point offset)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Moves the rectangle {offset}.{Nice::Point::x()}{x()} along the x axis and {offset}.{Nice::Point::y()}{y()} along the y axis, relative to the current position.

◆ translated() [1/4]

Rect Nice::Rect::translated ( double  dx,
double  dy 
) const

◆ translated() [2/4]

Rect Nice::Rect::translated ( double  dx,
double  dy 
) const
inline

Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis, relative to the current position. Positive values move the rectangle to the right and down.

See also
translate()

◆ translated() [3/4]

Rect Nice::Rect::translated ( const Nice::Point offset) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns a copy of the rectangle that is translated {offset}.{Nice::Point::x()}{x()} along the x axis and {offset}.{Nice::Point::y()}{y()} along the y axis, relative to the current position.

◆ translated() [4/4]

Rect Nice::Rect::translated ( const Nice::Point p) const

◆ unite() [1/2]

Rect Nice::Rect::unite ( const Rect r) const
inline

Use united(rectangle) instead.

◆ unite() [2/2]

Rect Nice::Rect::unite ( const Rect r) const

◆ united() [1/2]

Rect Nice::Rect::united ( const Rect other) const
inline
Since
4.2

Returns the bounding rectangle of this rectangle and the given rectangle.

See also
intersected()

◆ united() [2/2]

Rect Nice::Rect::united ( const Rect other) const

◆ width() [1/2]

double Nice::Rect::width ( ) const

◆ width() [2/2]

double Nice::Rect::width ( ) const
inline

Returns the width of the rectangle.

See also
setWidth(), height(), size()

◆ x() [1/2]

double Nice::Rect::x ( ) const
inline

Returns the x-coordinate of the rectangle's left edge. Equivalent to left().

See also
setX(), y(), topLeft()

◆ x() [2/2]

double Nice::Rect::x ( ) const
inline

◆ y() [1/2]

double Nice::Rect::y ( ) const
inline

◆ y() [2/2]

double Nice::Rect::y ( ) const
inline

Returns the y-coordinate of the rectangle's top edge. Equivalent to top().

See also
setY(), x(), topLeft()

Friends And Related Function Documentation

◆ operator!= [1/3]

bool operator!= ( const Rect r1,
const Rect r2 
)
friend

◆ operator!= [2/3]

bool operator!= ( const Rect r1,
const Rect r2 
)
friend

◆ operator!=() [3/3]

bool operator!= ( const Nice::Rect r1,
const Nice::Rect r2 
)
related

Returns true if the rectangles r1 and r2 are different, otherwise returns false.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  stream,
const Nice::Rect rectangle 
)
related

Writes the rectangle to the stream, and returns a reference to the stream.

See also
Format of the QDataStream operators

◆ operator== [1/3]

bool operator== ( const Rect r1,
const Rect r2 
)
friend

◆ operator== [2/3]

bool operator== ( const Rect r1,
const Rect r2 
)
friend

◆ operator==() [3/3]

bool operator== ( const Nice::Rect r1,
const Nice::Rect r2 
)
related

Returns true if the rectangles r1 and r2 are equal, otherwise returns false.

◆ operator>>()

std::istream & operator>> ( std::istream &  stream,
Nice::Rect rectangle 
)
related

Reads a rectangle from the stream, and returns a reference to the stream.

See also
Format of the QDataStream operators

The documentation for this class was generated from the following files: