Rectangle Class. More...
#include <frect.h>
Public Member Functions | |
| Rect () | |
| create empty rectangle with coordinates set to zero | |
| Rect (UCoord left, UCoord top, UCoord right, UCoord bottom) | |
| create rectangle with four individual coordinates | |
| Rect (UCoord w, UCoord h) | |
| create rectangle with zero left/top coordinates and right/bottom coordinates according to the given width and height | |
| Rect (const Point &topLeft, const Point &bottomRight) | |
| create rectangle defined by a top/left Point and a bottom/right Point | |
| Rect (const Point &topLeft, UCoord width, UCoord height) | |
| create rectangle defined by a top/left Point and the given width and height | |
| Rect (const ViewRect &vr) | |
| create rectangle defined by a ViewRect | |
| UCoord | getWidth () const |
| return width of rectangle (right coordinate - left coordinate) | |
| UCoord | getHeight () const |
| return height of rectangle (bottom coordinate - top coordinate) | |
| Rect & | setWidth (const UCoord w) |
| set width by setting the right coordinate with respect to the left | |
| Rect & | setHeight (const UCoord h) |
| set height by setting the bottom coordinate with respect to the top | |
| void | setEmpty () |
| resets coordinates to all zero - now isEmpty returns true | |
| Point | getTopLeft () const |
| get top/left as Point | |
| Point & | getTopLeft (Point &) const |
| get top/left as Point | |
| Point | getBottomRight () const |
| get bottom/right as Point | |
| Point & | getBottomRight (Point &) const |
| get bottom/right as Point | |
| Point | getTopRight () const |
| get top/right as Point | |
| Point & | getTopRight (Point &) const |
| get top/right as Point | |
| Point | getBottomLeft () const |
| get bottom/left as Point | |
| Point & | getBottomLeft (Point &) const |
| get bottom/left as Point | |
| Point & | toPoint (Direction dir, Point &p) const |
| convert rectangle to a point | |
| Point | toPoint (Direction dir) const |
| convert rectangle to a point | |
| Rect & | setTopLeft (const UCoord left, const UCoord top) |
| set top/left from coordinates | |
| Rect & | setBottomRight (const UCoord right, const UCoord bottom) |
| set bottom/right from coordinates | |
| Rect & | setSize (const UCoord w, const UCoord h) |
| set size by setting bottom/right with respect to left/top | |
| Rect & | operator() (UCoord left, UCoord top, UCoord right, UCoord bottom) |
| set left/top/right/bottom from four individual coordinates | |
| Rect & | operator() (const Point &topLeft, const Point &bottomRight) |
| set left/top/right/bottom from top/left Point and bottom/right Point | |
| void | set (UCoord left, UCoord top, UCoord right, UCoord bottom) |
| return height of rectangle (bottom coordinate - top coordinate) | |
| Rect & | moveTo (const Point &where) |
| move rectangle to a new top/left point while maintaining width and height | |
| Rect & | offset (UCoord x, UCoord y=0) |
| offset rectangle by x/y coordinates maintaining width and height | |
| Rect & | offset (const Point &where) |
| offset rectangle by a x/y Point maintaining width and height | |
| Rect & | inset (UCoord delta) |
| inset top/left and bottom/right by equal amounts to change rectangle size | |
| Rect & | inset (UCoord deltaH, UCoord deltaV) |
| inset left/right by an equal amount similarly, inset top/bottom by an equal amount, to change rectangle size | |
| Rect & | inset (UCoord deltaL, UCoord deltaT, UCoord deltaR, UCoord deltaB) |
| inset left/top/right/bottom each by a separate amount to change the rectangle size | |
| Rect & | originize () |
| move rectangle so the left/top coordinate are zero while maintaining the width and height | |
| Rect & | normalize () |
| flips left/right and top/bottom values if value pairs are such that right<left or bottom<top coordinates | |
| Rect & | center (const Rect &rect) |
| centers this with respect to rect | |
| Rect & | centerH (const Rect &rect) |
| centers this with respect to rect | |
| Rect & | centerV (const Rect &rect) |
| centers this with respect to rect | |
| bool | bound (const Rect &rect) |
| set this to the intersection of this and rect; returns false if intersection is empty | |
| bool | slideInside (const Rect &rect) |
| fit this inside the larger rect. if not possible return false. | |
| bool | join (const Rect &rect) |
| set this to the union of this and rect | |
| bool | subtract (const Rect &rect) |
| trim this by the rect given | |
| bool | isEmpty () const |
| bool | rectInside (const Rect &rect) const |
| checks if rect is enclosed by this | |
| bool | rectIntersect (const Rect &rect) const |
| checks if rect touches this | |
| bool | rectIntersect (const Rect &rect, Rect &result) const |
| checks if rect touches this: if true intersection is in result | |
| Point | getCenter () const |
| get point in the middle of the rect (might not be precise for even sized rects) | |
| Point | getLeftCenter () const |
| Point | getRightCenter () const |
| Point | getTopCenter () const |
| Point | getBottomCenter () const |
| bool | overlapHorizontal (const Rect &rect) const |
| checks if the horizontal coord ranges overlap | |
| bool | overlapVertical (const Rect &rect) const |
| checks if the vertical coord ranges overlap | |
| UCoord | getOverlapHorizontal (const Rect &rect) const |
| get horizontal overlapping area, returns 0 if not overlapping | |
| UCoord | getOverlapVertical (const Rect &rect) const |
| get vertical overlapping area, returns 0 if not overlapping | |
| bool | pointInside (const Point &where) const |
| checks if point is inside this rect | |
| Point & | constrain (Point &p) const |
| constrains the point such that is lies within this rect | |
| bool | lineInside (const Point &p1, const Point &p2) const |
| is line inside rect ? | |
| bool | lineIntersect (const Point &p1, const Point &p2) const |
| is line intersecting rect? | |
| bool | boundLine (Point &p1, Point &p2) const |
| bound line to rect, returns false if line does not intersect rect | |
| Rect & | operator+= (const Point &p) |
| performs a 'offset' operation on this | |
| Rect & | operator+= (const Rect &rect) |
| performs a 'join' operation on this | |
| bool | operator== (const Rect &rect) const |
| tests for equality of coordinates of this and the rect | |
| bool | operator!= (const Rect &rect) const |
| ViewRect & | toViewRect (ViewRect &vr) const |
| sets the ViewRect coordinates to the current coordinates of this | |
| void | fromViewRect (const ViewRect &vr) |
| sets the current coordinates of this to the ViewRect coordinates | |
| Rect & | operator= (const ViewRect &vr) |
| performs a 'fromViewRect' operation | |
| operator ViewRect () const | |
| conversion operator to ViewRect | |
Data Fields | |
| UCoord | left |
| UCoord | top |
| UCoord | right |
| UCoord | bottom |
Rectangle Class.
| Rect | ( | ) | [inline] |
create empty rectangle with coordinates set to zero
Create empty rectangle with coordinates set to zero.
| Rect | ( | UCoord | left, | |
| UCoord | top, | |||
| UCoord | right, | |||
| UCoord | bottom | |||
| ) | [inline] |
create rectangle with four individual coordinates
Create rectangle with four individual coordinates.
| Rect | ( | UCoord | w, | |
| UCoord | h | |||
| ) | [inline] |
create rectangle with zero left/top coordinates and right/bottom coordinates according to the given width and height
Create rectangle with zero left/top coordinates and right/bottom coordinates according to the given width and height.
| Rect | ( | const ViewRect & | vr | ) |
create rectangle defined by a ViewRect
| UCoord getWidth | ( | ) | const [inline] |
return width of rectangle (right coordinate - left coordinate)
Return width of rectangle (right coordinate - left coordinate).
| UCoord getHeight | ( | ) | const [inline] |
return height of rectangle (bottom coordinate - top coordinate)
Return height of rectangle (bottom coordinate - top coordinate).
| Rect & setWidth | ( | const UCoord | w | ) | [inline] |
set width by setting the right coordinate with respect to the left
Set width by setting the right coordinate with respect to the left.
| Rect & setHeight | ( | const UCoord | h | ) | [inline] |
set height by setting the bottom coordinate with respect to the top
Set height by setting the bottom coordinate with respect to the top.
| void setEmpty | ( | ) | [inline] |
resets coordinates to all zero - now isEmpty returns true
Resets coordinates to all zero - now isEmpty returns true.
| Rect & setTopLeft | ( | const UCoord | left, | |
| const UCoord | top | |||
| ) | [inline] |
set top/left from coordinates
Set top/left from coordinates.
| Rect & setBottomRight | ( | const UCoord | right, | |
| const UCoord | bottom | |||
| ) | [inline] |
set bottom/right from coordinates
Set bottom/right from coordinates.
| Rect & setSize | ( | const UCoord | w, | |
| const UCoord | h | |||
| ) | [inline] |
set size by setting bottom/right with respect to left/top
Set size by setting bottom/right with respect to left/top.
| Rect & operator() | ( | UCoord | left, | |
| UCoord | top, | |||
| UCoord | right, | |||
| UCoord | bottom | |||
| ) | [inline] |
set left/top/right/bottom from four individual coordinates
Set left/top/right/bottom from four individual coordinates.
| void set | ( | UCoord | left, | |
| UCoord | top, | |||
| UCoord | right, | |||
| UCoord | bottom | |||
| ) | [inline] |
return height of rectangle (bottom coordinate - top coordinate)
Return height of rectangle (bottom coordinate - top coordinate).
move rectangle to a new top/left point while maintaining width and height
| Rect & offset | ( | UCoord | x, | |
| UCoord | y = 0 | |||
| ) | [inline] |
offset rectangle by x/y coordinates maintaining width and height
offset rectangle by a x/y Point maintaining width and height
| Rect & inset | ( | UCoord | delta | ) |
inset top/left and bottom/right by equal amounts to change rectangle size
| Rect & inset | ( | UCoord | deltaH, | |
| UCoord | deltaV | |||
| ) |
inset left/right by an equal amount similarly, inset top/bottom by an equal amount, to change rectangle size
| Rect & inset | ( | UCoord | deltaL, | |
| UCoord | deltaT, | |||
| UCoord | deltaR, | |||
| UCoord | deltaB | |||
| ) |
inset left/top/right/bottom each by a separate amount to change the rectangle size
| Rect & originize | ( | ) | [inline] |
move rectangle so the left/top coordinate are zero while maintaining the width and height
| Rect & normalize | ( | ) | [inline] |
flips left/right and top/bottom values if value pairs are such that right<left or bottom<top coordinates
| bool bound | ( | const Rect & | rect | ) | [inline] |
set this to the intersection of this and rect; returns false if intersection is empty
Set this to the intersection of this and rect; returns false if intersection is empty.
| bool slideInside | ( | const Rect & | rect | ) |
fit this inside the larger rect. if not possible return false.
| bool join | ( | const Rect & | rect | ) |
set this to the union of this and rect
| bool subtract | ( | const Rect & | rect | ) |
trim this by the rect given
| bool isEmpty | ( | ) | const |
| bool rectInside | ( | const Rect & | rect | ) | const |
checks if rect is enclosed by this
| bool rectIntersect | ( | const Rect & | rect | ) | const |
checks if rect touches this
checks if rect touches this: if true intersection is in result
| Point getCenter | ( | ) | const [inline] |
get point in the middle of the rect (might not be precise for even sized rects)
| Point getLeftCenter | ( | ) | const [inline] |
| Point getRightCenter | ( | ) | const [inline] |
| Point getTopCenter | ( | ) | const [inline] |
| Point getBottomCenter | ( | ) | const [inline] |
| bool overlapHorizontal | ( | const Rect & | rect | ) | const |
checks if the horizontal coord ranges overlap
| bool overlapVertical | ( | const Rect & | rect | ) | const |
checks if the vertical coord ranges overlap
| UCoord getOverlapHorizontal | ( | const Rect & | rect | ) | const |
get horizontal overlapping area, returns 0 if not overlapping
| UCoord getOverlapVertical | ( | const Rect & | rect | ) | const |
get vertical overlapping area, returns 0 if not overlapping
| bool pointInside | ( | const Point & | where | ) | const |
checks if point is inside this rect
bound line to rect, returns false if line does not intersect rect
performs a 'offset' operation on this
Performs a 'offset' operation on this.
performs a 'join' operation on this
Performs a 'join' operation on this.
| bool operator== | ( | const Rect & | rect | ) | const |
tests for equality of coordinates of this and the rect
| bool operator!= | ( | const Rect & | rect | ) | const |
| ViewRect & toViewRect | ( | ViewRect & | vr | ) | const |
sets the ViewRect coordinates to the current coordinates of this
| void fromViewRect | ( | const ViewRect & | vr | ) |
sets the current coordinates of this to the ViewRect coordinates
| Rect & operator= | ( | const ViewRect & | vr | ) |
performs a 'fromViewRect' operation
| operator ViewRect | ( | ) | const |
conversion operator to ViewRect
| UCoord left |
| UCoord top |
| UCoord right |
| UCoord bottom |