RBox
Class in Math Module
Header: #include <src/core/math/RBox.h>
Description
Section titled “Description”Represents a box e.g.
a bounding box. The surfaces of the box are orthogonal to the Cartesian coordinate system.
Scriptable: This class is available in script environments.
Shared Pointer Support: Objects can be used in QSharedPointer.
Copyable: Objects are cleaned up automatically by the garbage collector of the script engine.
Public Functions
Section titled “Public Functions”RBox() |
|
RBox(const QRectF &rect)Constructor for a box based on the given QRectF object. |
|
RBox(const RVector &c1, const RVector &c2)Constructor for a box with two given diagonally opposite corners. |
|
RBox(const RVector ¢er, double range)Creates a square box with the given center and the given range (= side length / 2). |
|
RBox(const RVector ¢er, double width, double height)Creates a box with the given center and the given width / height. |
|
RBox(double x1, double y1, double x2, double y2) |
|
| bool | contains(const RBox &other) const |
| bool | contains(const RVector &v) const |
| bool | containsBox(const RBox &other) const |
| bool | containsPoint(const RVector &v) const |
| bool | equalsFuzzy(const RBox &b, double tol=RS::PointTolerance) const |
| bool | equalsFuzzy2D(const RBox &b, double tol=RS::PointTolerance) const |
| RBox | get2D() const |
| double | getArea() const |
| RVector | getCenter() const |
| RVector | getCorner1() const |
| RVector | getCorner2() const |
| QList< RVector > | getCorners() const |
| QList< RVector > | getCorners2d() const |
| double | getHeight() const |
| QList< RLine > | getLines2d() const |
| RVector | getMaximum() const |
| RVector | getMinimum() const |
| RPolyline | getPolyline2d() const |
| RVector | getSize() const |
| QList< RTriangle > | getTriangles() const |
| double | getWidth() const |
| RBox & | grow(double offset)Grows this box by the given offset in X, Y and Z (!). |
| void | growToInclude(const RBox &other)Grows this box to include the given box or sets this box to the given box if this box is invalid. |
| void | growToInclude(const RVector &v)Grows this box to include the given point. |
| void | growToIncludeBox(const RBox &other) |
| void | growToIncludeBoxes(const QList< RBox > &others)Grows this box to include all other given boxes. |
| void | growToIncludePoint(const RVector &v) |
| RBox & | growXY(double offset)Grows this box by the given offset in X and Y only. |
| RBox & | growXY(double offsetX, double offsetY)Grows this box by the given offsets in X and Y only. |
| bool | intersects(const RBox &other) const |
| bool | intersectsWith(const RShape &shape, bool limited=true) const |
| bool | isOutside(const RBox &other) const |
| bool | isOutsideXY(const RBox &other) const |
| bool | isSane() const |
| bool | isValid() const |
| void | move(const RVector &offset)Moves this box by the given offset. |
| bool | operator!=(const RBox &other) const |
| bool | operator==(const RBox &other) const== operator |
| bool | scaleByReference(const RVector &referencePoint, const RVector &targetPoint, bool keepAspectRatio=false, bool fromCenter=false) |
| void | setCorner1(const RVector &v)Set first of two diagonally opposite corners that define the box. |
| void | setCorner2(const RVector &v)Set second of two diagonally opposite corners that define the box. |
| QRectF | toQRectF() const |
| void | transform(QTransform &t) |
Public Attributes
Section titled “Public Attributes”| RVector | c1 Getter function for this property: getCorner1. |
| RVector | c2 Getter function for this property: getCorner2. |
Member Documentation
Section titled “Member Documentation”RBox::RBox()All rights reserved.
This file is part of the QCAD project.
QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with QCAD. Constructor for an invalid box with invalid corner points.
explicit RBox::RBox(const QRectF &rect)explicit
Constructor for a box based on the given QRectF object.
RBox::RBox(const RVector &c1, const RVector &c2)Constructor for a box with two given diagonally opposite corners.
RBox::RBox(const RVector ¢er, double range)Creates a square box with the given center and the given range (= side length / 2).
RBox::RBox(const RVector ¢er, double width, double height)Creates a box with the given center and the given width / height.
RBox::RBox(double x1, double y1, double x2, double y2)contains
Section titled “contains”bool RBox::contains(const RBox &other) constconst
Returns: True if the given box is completely inside this box.
contains
Section titled “contains”bool RBox::contains(const RVector &v) constconst
Non-Scriptable: This function is not available in script environments.
Returns: True if the given vector is inside this box.
containsBox
Section titled “containsBox”bool RBox::containsBox(const RBox &other) constinline const
containsPoint
Section titled “containsPoint”bool RBox::containsPoint(const RVector &v) constinline const
equalsFuzzy
Section titled “equalsFuzzy”bool RBox::equalsFuzzy(const RBox &b, double tol=RS::PointTolerance) constconst
equalsFuzzy2D
Section titled “equalsFuzzy2D”bool RBox::equalsFuzzy2D(const RBox &b, double tol=RS::PointTolerance) constconst
RBox RBox::get2D() constinline const
getArea
Section titled “getArea”double RBox::getArea() constconst
getCenter
Section titled “getCenter”RVector RBox::getCenter() constconst
Returns: Center of this box.
getCorner1
Section titled “getCorner1”RVector RBox::getCorner1() constconst
Returns: First of two diagonally opposite corners that define the box.
getCorner2
Section titled “getCorner2”RVector RBox::getCorner2() constconst
Returns: Second of two diagonally opposite corners that define the box.
getCorners
Section titled “getCorners”QList< RVector > RBox::getCorners() constconst
Returns: 8 vectors for the eight corners of the box.
The first box corner is the first defining corner c1. The next three corners are the corners on the same Z level as c1, counter-clockwise. The next four corners are on the same Z-level as c2 starting with the corner at the same X/Y position as c1, continuing counter-clockwise.
getCorners2d
Section titled “getCorners2d”QList< RVector > RBox::getCorners2d() constconst
Returns: List of all four corners of this box flattened to 2D.
getHeight
Section titled “getHeight”double RBox::getHeight() constconst
Returns: Height of this box.
getLines2d
Section titled “getLines2d”QList< RLine > RBox::getLines2d() constconst
Returns: List of all four sides of this box flattened to 2D.
getMaximum
Section titled “getMaximum”RVector RBox::getMaximum() constconst
Returns: Maximum point of this box (maximum X, Y and Z).
getMinimum
Section titled “getMinimum”RVector RBox::getMinimum() constconst
Returns: Minimum point of this box (minimum X, Y and Z).
getPolyline2d
Section titled “getPolyline2d”RPolyline RBox::getPolyline2d() constconst
Returns: Polyline representing the four sides of this box flattened to 2D.
getSize
Section titled “getSize”RVector RBox::getSize() constconst
Returns: Size of this box (X,Y,Z).
getTriangles
Section titled “getTriangles”QList< RTriangle > RBox::getTriangles() constconst
Returns: 12 triangles, two for each side of the box.
getWidth
Section titled “getWidth”double RBox::getWidth() constconst
Returns: Width of this box.
RBox & RBox::grow(double offset)Grows this box by the given offset in X, Y and Z (!).
Returns: pointer to this box
growToInclude
Section titled “growToInclude”void RBox::growToInclude(const RBox &other)Grows this box to include the given box or sets this box to the given box if this box is invalid.
growToInclude
Section titled “growToInclude”void RBox::growToInclude(const RVector &v)Grows this box to include the given point.
Non-Scriptable: This function is not available in script environments.
growToIncludeBox
Section titled “growToIncludeBox”void RBox::growToIncludeBox(const RBox &other)inline
growToIncludeBoxes
Section titled “growToIncludeBoxes”void RBox::growToIncludeBoxes(const QList< RBox > &others)Grows this box to include all other given boxes.
growToIncludePoint
Section titled “growToIncludePoint”void RBox::growToIncludePoint(const RVector &v)inline
growXY
Section titled “growXY”RBox & RBox::growXY(double offset)Grows this box by the given offset in X and Y only.
Returns: pointer to this box
growXY
Section titled “growXY”RBox & RBox::growXY(double offsetX, double offsetY)Grows this box by the given offsets in X and Y only.
Returns: pointer to this box
intersects
Section titled “intersects”bool RBox::intersects(const RBox &other) constconst
Returns: True if this box intersects the given other box.
intersectsWith
Section titled “intersectsWith”bool RBox::intersectsWith(const RShape &shape, bool limited=true) constconst
Returns: True if this box intersects the given shape.
Parameters:
limited: True to limit the shape to its actual length, false to return true if the extended shape intersects this box.
isOutside
Section titled “isOutside”bool RBox::isOutside(const RBox &other) constconst
Returns: True if the given box is completely outside this box.
isOutsideXY
Section titled “isOutsideXY”bool RBox::isOutsideXY(const RBox &other) constconst
Returns: True if the given box is completely outside this box.
isSane
Section titled “isSane”bool RBox::isSane() constconst
Returns: True if this box is sane (i.e. both diagonally opposite corners are valid and not Infinity or NaN).
isValid
Section titled “isValid”bool RBox::isValid() constconst
Returns: True if this box is valid (i.e. both diagonally opposite corners are valid).
void RBox::move(const RVector &offset)Moves this box by the given offset.
operator!=
Section titled “operator!=”bool RBox::operator!=(const RBox &other) constinline const
operator==
Section titled “operator==”bool RBox::operator==(const RBox &other) constconst
== operator
scaleByReference
Section titled “scaleByReference”bool RBox::scaleByReference(const RVector &referencePoint, const RVector &targetPoint, bool keepAspectRatio=false, bool fromCenter=false)setCorner1
Section titled “setCorner1”void RBox::setCorner1(const RVector &v)Set first of two diagonally opposite corners that define the box.
setCorner2
Section titled “setCorner2”void RBox::setCorner2(const RVector &v)Set second of two diagonally opposite corners that define the box.
toQRectF
Section titled “toQRectF”QRectF RBox::toQRectF() constconst
Returns: This box converted to a QRectF object (2D).
transform
Section titled “transform”void RBox::transform(QTransform &t)RVector RBox::c1Getter function for this property: getCorner1.
Setter function for this property: setCorner1
RVector RBox::c2Getter function for this property: getCorner2.
Setter function for this property: setCorner2