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  bool isSane() const;
53 
54  double getWidth() const;
55  double getHeight() const;
56  RVector getSize() const;
57  RVector getCenter() const;
58  RVector getMinimum() const;
59  RVector getMaximum() const;
60  bool isOutside(const RBox& other) const;
61  bool isOutsideXY(const RBox& other) const;
62  bool contains(const RBox& other) const;
66  bool contains(const RVector& v) const;
67  bool containsBox(const RBox& other) const {
68  return contains(other);
69  }
70  bool containsPoint(const RVector& v) const {
71  return contains(v);
72  }
73  bool intersects(const RBox& other) const;
74  bool intersectsWith(const RShape& shape, bool limited = true) const;
75 
76  void growToInclude(const RBox& other);
77  void growToIncludeBoxes(const QList<RBox>& others);
78  void growToIncludeBox(const RBox& other) {
79  growToInclude(other);
80  }
84  void growToInclude(const RVector& v);
85  void growToIncludePoint(const RVector& v) {
86  growToInclude(v);
87  }
88 
89  RVector getCorner1() const;
90  void setCorner1(const RVector& v);
91  RVector getCorner2() const;
92  void setCorner2(const RVector& v);
93 
94  QList<RVector> getCorners() const;
95  QList<RVector> getCorners2d() const;
96  QList<RLine> getLines2d() const;
97  RPolyline getPolyline2d() const;
98  QList<RTriangle> getTriangles() const;
99 
100  RBox& grow(double offset);
101  RBox& growXY(double offset);
102 
103  void move(const RVector& offset);
104 
105  QRectF toQRectF() const;
106 
107  bool operator ==(const RBox& other) const;
108  bool operator !=(const RBox& other) const {
109  return !operator==(other);
110  }
111 
112 public:
123 };
124 
125 QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RBox& b);
126 
129 Q_DECLARE_METATYPE(QSharedPointer<RBox>)
130 Q_DECLARE_METATYPE(QSharedPointer<RBox>*)
131 Q_DECLARE_METATYPE(QList<RBox>)
132 
133 #endif
Represents a box e.g.
Definition: RBox.h:43
RVector c1
Getter function for this property: getCorner1.
Definition: RBox.h:117
void growToIncludePoint(const RVector &v)
Definition: RBox.h:85
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
void growToIncludeBox(const RBox &other)
Definition: RBox.h:78
#define QCADCORE_EXPORT
Definition: core_global.h:10
RVector c2
Getter function for this property: getCorner2.
Definition: RBox.h:122
bool containsBox(const RBox &other) const
Definition: RBox.h:67
QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RBox &b)
Stream operator for QDebug.
Definition: RBox.cpp:402
Q_DECLARE_METATYPE(RMath *)
bool containsPoint(const RVector &v) const
Definition: RBox.h:70
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:50
Interface for geometrical shape classes.
Definition: RShape.h:52