QCAD
Open Source 2D CAD
RBox Class Reference

Represents a box e.g. More...

#include <RBox.h>

Public Member Functions

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< RVectorgetCorners () const
 
QList< RVectorgetCorners2d () const
 
double getHeight () const
 
QList< RLinegetLines2d () const
 
RVector getMaximum () const
 
RVector getMinimum () const
 
RPolyline getPolyline2d () const
 
RVector getSize () const
 
QList< RTrianglegetTriangles () const
 
double getWidth () const
 
RBoxgrow (double offset)
 Grows this box by the given offset in X, Y and Z (!). More...
 
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. More...
 
void growToInclude (const RVector &v)
 Grows this box to include the given point. More...
 
void growToIncludeBox (const RBox &other)
 
void growToIncludeBoxes (const QList< RBox > &others)
 Grows this box to include all other given boxes. More...
 
void growToIncludePoint (const RVector &v)
 
RBoxgrowXY (double offset)
 Grows this box by the given offset in X and Y only. More...
 
RBoxgrowXY (double offsetX, double offsetY)
 Grows this box by the given offsets in X and Y only. More...
 
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. More...
 
bool operator!= (const RBox &other) const
 
bool operator== (const RBox &other) const
 == operator More...
 
 RBox ()
 Copyright (c) 2011-2018 by Andrew Mustun. More...
 
 RBox (const QRectF &rect)
 Constructor for a box based on the given QRectF object. More...
 
 RBox (const RVector &c1, const RVector &c2)
 Constructor for a box with two given diagonally opposite corners. More...
 
 RBox (const RVector &center, double range)
 Creates a square box with the given center and the given range (= side length / 2). More...
 
 RBox (const RVector &center, double width, double height)
 Creates a box with the given center and the given width / height. More...
 
 RBox (double x1, double y1, double x2, double y2)
 
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. More...
 
void setCorner2 (const RVector &v)
 Set second of two diagonally opposite corners that define the box. More...
 
QRectF toQRectF () const
 
void transform (QTransform &t)
 

Public Attributes

RVector c1
 
Getter function for this property: getCorner1

Setter function for this property: setCorner1
More...
 
RVector c2
 
Getter function for this property: getCorner2

Setter function for this property: setCorner2
More...
 

Detailed Description

Represents a box e.g.

a bounding box. The surfaces of the box are orthogonal to the Cartesian coordinate system.

Scriptable:\nThis class is available in script environments.\n
Shared Pointer Support:\nObjects can be used in QSharedPointer.\n
Copyable:\nObjects are cleaned up automatically by the garbage collector of the script engine.\n

Constructor & Destructor Documentation

◆ RBox() [1/6]

RBox::RBox ( )

Copyright (c) 2011-2018 by Andrew Mustun.

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.

◆ RBox() [2/6]

RBox::RBox ( const QRectF &  rect)
explicit

Constructor for a box based on the given QRectF object.

◆ RBox() [3/6]

RBox::RBox ( double  x1,
double  y1,
double  x2,
double  y2 
)

◆ RBox() [4/6]

RBox::RBox ( const RVector c1,
const RVector c2 
)

Constructor for a box with two given diagonally opposite corners.

◆ RBox() [5/6]

RBox::RBox ( const RVector center,
double  range 
)

Creates a square box with the given center and the given range (= side length / 2).

◆ RBox() [6/6]

RBox::RBox ( const RVector center,
double  width,
double  height 
)

Creates a box with the given center and the given width / height.

Member Function Documentation

◆ contains() [1/2]

bool RBox::contains ( const RBox other) const
Returns
True if the given box is completely inside this box.

◆ contains() [2/2]

bool RBox::contains ( const RVector v) const
Non-Scriptable:\nThis function is not available in script environments.\n
Returns
True if the given vector is inside this box.

◆ containsBox()

bool RBox::containsBox ( const RBox other) const
inline

◆ containsPoint()

bool RBox::containsPoint ( const RVector v) const
inline

◆ equalsFuzzy()

bool RBox::equalsFuzzy ( const RBox b,
double  tol = RS::PointTolerance 
) const

◆ equalsFuzzy2D()

bool RBox::equalsFuzzy2D ( const RBox b,
double  tol = RS::PointTolerance 
) const

◆ get2D()

RBox RBox::get2D ( ) const
inline

◆ getArea()

double RBox::getArea ( ) const

◆ getCenter()

RVector RBox::getCenter ( ) const
Returns
Center of this box.

◆ getCorner1()

RVector RBox::getCorner1 ( ) const
Returns
First of two diagonally opposite corners that define the box.

◆ getCorner2()

RVector RBox::getCorner2 ( ) const
Returns
Second of two diagonally opposite corners that define the box.

◆ getCorners()

QList< RVector > RBox::getCorners ( ) const
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()

QList< RVector > RBox::getCorners2d ( ) const
Returns
List of all four corners of this box flattened to 2D.

◆ getHeight()

double RBox::getHeight ( ) const
Returns
Height of this box.

◆ getLines2d()

QList< RLine > RBox::getLines2d ( ) const
Returns
List of all four sides of this box flattened to 2D.

◆ getMaximum()

RVector RBox::getMaximum ( ) const
Returns
Maximum point of this box (maximum X,Z and Z).

◆ getMinimum()

RVector RBox::getMinimum ( ) const
Returns
Minimum point of this box (minimum X,Z and Z).

◆ getPolyline2d()

RPolyline RBox::getPolyline2d ( ) const
Returns
Polyline representing the four sides of this box flattened to 2D.

◆ getSize()

RVector RBox::getSize ( ) const
Returns
Size of this box (X,Y,Z).

◆ getTriangles()

QList< RTriangle > RBox::getTriangles ( ) const
Returns
12 triangles, two for each side of the box.

◆ getWidth()

double RBox::getWidth ( ) const
Returns
Width of this box.

◆ grow()

RBox & RBox::grow ( double  offset)

Grows this box by the given offset in X, Y and Z (!).

Returns
pointer to this box

◆ growToInclude() [1/2]

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() [2/2]

void RBox::growToInclude ( const RVector v)

Grows this box to include the given point.

Non-Scriptable:\nThis function is not available in script environments.\n

◆ growToIncludeBox()

void RBox::growToIncludeBox ( const RBox other)
inline

◆ growToIncludeBoxes()

void RBox::growToIncludeBoxes ( const QList< RBox > &  others)

Grows this box to include all other given boxes.

◆ growToIncludePoint()

void RBox::growToIncludePoint ( const RVector v)
inline

◆ growXY() [1/2]

RBox & RBox::growXY ( double  offset)

Grows this box by the given offset in X and Y only.

Returns
pointer to this box

◆ growXY() [2/2]

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()

bool RBox::intersects ( const RBox other) const
Returns
True if this box intersects the given other box.

◆ intersectsWith()

bool RBox::intersectsWith ( const RShape shape,
bool  limited = true 
) const
Returns
True if this box intersects the given shape.
Parameters
limitedTrue to limit the shape to its actual length, false to return true if the extended shape intersects this box.

◆ isOutside()

bool RBox::isOutside ( const RBox other) const
Returns
True if the given box is completely outside this box.

◆ isOutsideXY()

bool RBox::isOutsideXY ( const RBox other) const
Returns
True if the given box is completely outside this box.

◆ isSane()

bool RBox::isSane ( ) const
Returns
True if this box is sane (i.e. both diagonally opposite corners are valid and not Infitiy or NaN).

◆ isValid()

bool RBox::isValid ( ) const
Returns
True if this box is valid (i.e. both diagonally opposite corners are valid).

◆ move()

void RBox::move ( const RVector offset)

Moves this box by the given offset.

◆ operator!=()

bool RBox::operator!= ( const RBox other) const
inline

◆ operator==()

bool RBox::operator== ( const RBox other) const

== operator

◆ scaleByReference()

bool RBox::scaleByReference ( const RVector referencePoint,
const RVector targetPoint,
bool  keepAspectRatio = false,
bool  fromCenter = false 
)
Todo:
implement fromCenter

◆ setCorner1()

void RBox::setCorner1 ( const RVector v)

Set first of two diagonally opposite corners that define the box.

◆ setCorner2()

void RBox::setCorner2 ( const RVector v)

Set second of two diagonally opposite corners that define the box.

◆ toQRectF()

QRectF RBox::toQRectF ( ) const
Returns
This box converted to a QRectF object (2D).

◆ transform()

void RBox::transform ( QTransform &  t)

Member Data Documentation

◆ c1

RVector RBox::c1


Getter function for this property: getCorner1

Setter function for this property: setCorner1

◆ c2

RVector RBox::c2


Getter function for this property: getCorner2

Setter function for this property: setCorner2


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