QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
50  bool isValid() const;
51 
52  double getWidth() const;
53  double getHeight() const;
54  RVector getSize() const;
55  RVector getCenter() const;
56  RVector getMinimum() const;
57  RVector getMaximum() const;
58  bool isOutside(const RBox& other) const;
59  bool isOutsideXY(const RBox& other) const;
60  bool contains(const RBox& other) const;
64  bool contains(const RVector& v) const;
65  bool containsBox(const RBox& other) const {
66  return contains(other);
67  }
68  bool containsPoint(const RVector& v) const {
69  return contains(v);
70  }
71  bool intersects(const RBox& other) const;
72  bool intersectsWith(const RShape& shape, bool limited = true) const;
73 
74  void growToInclude(const RBox& other);
75  void growToIncludeBox(const RBox& other) {
76  growToInclude(other);
77  }
81  void growToInclude(const RVector& v);
82  void growToIncludePoint(const RVector& v) {
83  growToInclude(v);
84  }
85 
86  RVector getCorner1() const;
87  void setCorner1(const RVector& v);
88  RVector getCorner2() const;
89  void setCorner2(const RVector& v);
90 
91  QList<RVector> getCorners() const;
92  QList<RVector> getCorners2d() const;
93  QList<RLine> getLines2d() const;
94  RPolyline getPolyline2d() const;
95  QList<RTriangle> getTriangles() const;
96 
97  RBox& grow(double offset);
98  RBox& growXY(double offset);
99 
100  QRectF toQRectF() const;
101 
102  bool operator ==(const RBox& other) const;
103  bool operator !=(const RBox& other) const {
104  return !operator==(other);
105  }
106 
107 public:
118 };
119 
120 QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RBox& b);
121 
124 Q_DECLARE_METATYPE(QSharedPointer<RBox>)
125 Q_DECLARE_METATYPE(QSharedPointer<RBox>*)
126 Q_DECLARE_METATYPE(QList<RBox>)
127 
128 #endif