|
KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
|
|
A 2D rectangle extending QRectF with edge, corner, and geometric query helpers. More...
#include <rectangle.h>
Inheritance diagram for Rectangle:
Collaboration diagram for Rectangle:Classes | |
| class | List |
| A simple list type for Rectangle objects. More... | |
Public Member Functions | |
| Rectangle () | |
| Default constructor — creates a null rectangle. | |
| Rectangle (const QRectF &other) | |
| Construct from a QRectF. | |
| Rectangle (const QRect &other) | |
| Construct from a QRect (integer coordinates). | |
| Rectangle (const QPointF &topLeft, const QSizeF &size) | |
| Construct from a top-left point and size. | |
| Rectangle (double x, double y, int w, int h) | |
| Construct from explicit position and dimensions. | |
| Point | closestCorner (const Point &origin) const |
| Return the corner of this rectangle closest to an origin point. | |
| Point::List | corners () const |
| Return all four corners of the rectangle. | |
| Line::List | edges () const |
| Return all four edges of the rectangle as lines. | |
| QMap< Geo::Side, Line > | edgeMap () const |
| Return a map from Side to edge Line for all four edges. | |
| Line::List | verticalLines () const |
| Return the two vertical edges. | |
| Line::List | horizontalLines () const |
| Return the two horizontal edges. | |
| Line | topEdge () const |
| Return the top edge as a Line. | |
| Line | bottomEdge () const |
| Return the bottom edge as a Line. | |
| Line | leftEdge () const |
| Return the left edge as a Line. | |
| Line | rightEdge () const |
| Return the right edge as a Line. | |
| Line | closestEdge (const Point &point) |
| Return the edge closest to a given point. | |
| bool | isPointOnEdge (const Point &point, Line &foundEdge) const |
| Test whether a point lies on any edge, outputting the edge. | |
| bool | isPointOnEdge (const Point &point) const |
| Test whether a point lies on any edge. | |
| bool | containsAnyPoint (const Line &line) const |
| Test whether a line's endpoints include any point within this rectangle. | |
| Point | centerPoint () const |
| Return the geometric centre point of the rectangle. | |
| Geo::Side | closestSideToPoint (const Point &point) const |
| Return which side of the rectangle is closest to a point. | |
| Rectangle & | scale (double scale) |
| Scale the rectangle dimensions by a factor, keeping the top-left corner fixed. | |
| Rectangle | scaled (double scale) const |
| Return a scaled copy of this rectangle. | |
| Rectangle & | grow (double amount) |
| Grow the rectangle by expanding all edges outward. | |
| Rectangle | grown (double amount) const |
| Return a grown copy of this rectangle. | |
| Rectangle & | shrink (double amount) |
| Shrink the rectangle by contracting all edges inward. | |
| Rectangle | shrunk (double amount) const |
| Return a shrunk copy of this rectangle. | |
| QString | toString () const |
| Format this rectangle as a human-readable string. | |
Static Public Member Functions | |
| static Rectangle | fromPoints (const Point::List &points) |
| Build the bounding rectangle of a list of points. | |
| static Rectangle | fromPoints (const Point &p1, const Point &p2) |
| Build the bounding rectangle of two points. | |
| static Rectangle | fromCenterLine (const Line ¢erLine, double expand) |
| Create a rectangle centred on a line with a given width. | |
| static Rectangle | fromCenterPoint (const Point ¢erPoint, double expand) |
| Create a rectangle centred on a point with a given half-size. | |
| static Rectangle | fromString (const QString &value) |
| Parse a Rectangle from a string produced by toString(). | |
A 2D rectangle extending QRectF with edge, corner, and geometric query helpers.
Extends QRectF with edge and corner accessors, containment tests, and scale/grow/shrink operations.
Definition at line 15 of file rectangle.h.
|
inline |
Default constructor — creates a null rectangle.
Definition at line 19 of file rectangle.h.
|
inline |
|
inline |
Construct from a QRect (integer coordinates).
| other | Source QRect |
Definition at line 25 of file rectangle.h.
|
inline |
Construct from a top-left point and size.
| topLeft | Top-left corner |
| size | Dimensions of the rectangle |
Definition at line 31 of file rectangle.h.
|
inline |
Construct from explicit position and dimensions.
| x | Left edge X coordinate |
| y | Top edge Y coordinate |
| w | Width |
| h | Height |
Definition at line 39 of file rectangle.h.
| Point Rectangle::centerPoint | ( | ) | const |
Return the geometric centre point of the rectangle.
Return the corner of this rectangle closest to an origin point.
| origin | Reference point |
Return which side of the rectangle is closest to a point.
| point | Reference point |
| bool Rectangle::containsAnyPoint | ( | const Line & | line | ) | const |
Test whether a line's endpoints include any point within this rectangle.
| line | Line to test |
| Point::List Rectangle::corners | ( | ) | const |
Return all four corners of the rectangle.
| Line::List Rectangle::edges | ( | ) | const |
Return all four edges of the rectangle as lines.
Create a rectangle centred on a line with a given width.
| centerLine | Centre line of the rectangle |
| expand | Half-width of the rectangle (perpendicular to the line) |
Create a rectangle centred on a point with a given half-size.
| centerPoint | Centre of the rectangle |
| expand | Half-dimension in each direction |
Build the bounding rectangle of two points.
| p1 | First corner point |
| p2 | Opposite corner point |
|
static |
|
static |
Parse a Rectangle from a string produced by toString().
| value | String representation |
| Rectangle & Rectangle::grow | ( | double | amount | ) |
Grow the rectangle by expanding all edges outward.
| amount | Amount to expand each edge |
| Rectangle Rectangle::grown | ( | double | amount | ) | const |
Return a grown copy of this rectangle.
| amount | Amount to expand each edge |
| Line::List Rectangle::horizontalLines | ( | ) | const |
Return the two horizontal edges.
| bool Rectangle::isPointOnEdge | ( | const Point & | point | ) | const |
Test whether a point lies on any edge.
| point | Point to test |
Test whether a point lies on any edge, outputting the edge.
| point | Point to test |
| foundEdge | Output set to the edge containing the point |
| Rectangle & Rectangle::scale | ( | double | scale | ) |
Scale the rectangle dimensions by a factor, keeping the top-left corner fixed.
| scale | Scale factor |
| Rectangle Rectangle::scaled | ( | double | scale | ) | const |
|
inline |
Shrink the rectangle by contracting all edges inward.
| amount | Amount to contract each edge |
Definition at line 197 of file rectangle.h.
|
inline |
Return a shrunk copy of this rectangle.
| amount | Amount to contract each edge |
Definition at line 204 of file rectangle.h.
| QString Rectangle::toString | ( | ) | const |
Format this rectangle as a human-readable string.
| Line::List Rectangle::verticalLines | ( | ) | const |
Return the two vertical edges.