QCAD
Open Source 2D CAD
RBox.h
Go to the documentation of this file.
1 
20 #ifndef RBOX_H
21 #define RBOX_H
22 
23 #include "../core_global.h"
24 
25 #include <QRectF>
26 
27 #include "RVector.h"
28 #include "RTriangle.h"
29 
30 class RPolyline;
31 
32 #define RDEFAULT_RBOX RBox()
33 
44 public:
45  RBox();
46  explicit RBox(const QRectF& rect);
47  RBox(const RVector& c1, const RVector& c2);
48  RBox(const RVector& center, double range);
49  RBox(const RVector& center, double width, double height);
50 
51  bool isValid() const;
52 
53  double getWidth() const;
54  double getHeight() const;
55  RVector getSize() const;
56  RVector getCenter() const;
57  RVector getMinimum() const;
58  RVector getMaximum() const;
59  bool isOutside(const RBox& other) const;
60  bool isOutsideXY(const RBox& other) const;
61  bool contains(const RBox& other) const;
65  bool contains(const RVector& v) const;
66  bool containsBox(const RBox& other) const {
67  return contains(other);
68  }
69  bool containsPoint(const RVector& v) const {
70  return contains(v);
71  }
72  bool intersects(const RBox& other) const;
73  bool intersectsWith(const RShape& shape, bool limited = true) const;
74 
75  void growToInclude(const RBox& other);
76  void growToIncludeBoxes(const QList<RBox>& others);
77  void growToIncludeBox(const RBox& other) {
78  growToInclude(other);
79  }
83  void growToInclude(const RVector& v);
84  void growToIncludePoint(const RVector& v) {
85  growToInclude(v);
86  }
87 
88  RVector getCorner1() const;
89  void setCorner1(const RVector& v);
90  RVector getCorner2() const;
91  void setCorner2(const RVector& v);
92 
93  QList<RVector> getCorners() const;
94  QList<RVector> getCorners2d() const;
95  QList<RLine> getLines2d() const;
96  RPolyline getPolyline2d() const;
97  QList<RTriangle> getTriangles() const;
98 
99  RBox& grow(double offset);
100  RBox& growXY(double offset);
101 
102  QRectF toQRectF() const;
103 
104  bool operator ==(const RBox& other) const;
105  bool operator !=(const RBox& other) const {
106  return !operator==(other);
107  }
108 
109 public:
120 };
121 
122 QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RBox& b);
123 
126 Q_DECLARE_METATYPE(QSharedPointer<RBox>)
127 Q_DECLARE_METATYPE(QSharedPointer<RBox>*)
128 Q_DECLARE_METATYPE(QList<RBox>)
129 
130 #endif
Represents a box e.g.
Definition: RBox.h:43
RVector c1
Getter function for this property: getCorner1.
Definition: RBox.h:114
void growToIncludePoint(const RVector &v)
Definition: RBox.h:84
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
void growToIncludeBox(const RBox &other)
Definition: RBox.h:77
#define QCADCORE_EXPORT
Definition: core_global.h:10
RVector c2
Getter function for this property: getCorner2.
Definition: RBox.h:119
bool containsBox(const RBox &other) const
Definition: RBox.h:66
QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RBox &b)
Stream operator for QDebug.
Definition: RBox.cpp:393
Q_DECLARE_METATYPE(RMath *)
bool containsPoint(const RVector &v) const
Definition: RBox.h:69
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
Interface for geometrical shape classes.
Definition: RShape.h:52