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(double x1, double y1, double x2, double y2);
48  RBox(const RVector& c1, const RVector& c2);
49  RBox(const RVector& center, double range);
50  RBox(const RVector& center, double width, double height);
51 
52  bool isValid() const;
53  bool isSane() const;
54 
55  RBox get2D() const {
56  return RBox(c1.get2D(), c2.get2D());
57  }
58 
59  double getWidth() const;
60  double getHeight() const;
61  RVector getSize() const;
62  RVector getCenter() const;
63  RVector getMinimum() const;
64  RVector getMaximum() const;
65  bool isOutside(const RBox& other) const;
66  bool isOutsideXY(const RBox& other) const;
67  bool contains(const RBox& other) const;
71  bool contains(const RVector& v) const;
72  bool containsBox(const RBox& other) const {
73  return contains(other);
74  }
75  bool containsPoint(const RVector& v) const {
76  return contains(v);
77  }
78  bool intersects(const RBox& other) const;
79  bool intersectsWith(const RShape& shape, bool limited = true) const;
80 
81  void growToInclude(const RBox& other);
82  void growToIncludeBoxes(const QList<RBox>& others);
83  void growToIncludeBox(const RBox& other) {
84  growToInclude(other);
85  }
89  void growToInclude(const RVector& v);
90  void growToIncludePoint(const RVector& v) {
91  growToInclude(v);
92  }
93 
94  RVector getCorner1() const;
95  void setCorner1(const RVector& v);
96  RVector getCorner2() const;
97  void setCorner2(const RVector& v);
98 
99  QList<RVector> getCorners() const;
100  QList<RVector> getCorners2d() const;
101  QList<RLine> getLines2d() const;
102  RPolyline getPolyline2d() const;
103  QList<RTriangle> getTriangles() const;
104 
105  RBox& grow(double offset);
106  RBox& growXY(double offset);
107 
108  void move(const RVector& offset);
109 
110  QRectF toQRectF() const;
111 
112  bool operator ==(const RBox& other) const;
113  bool operator !=(const RBox& other) const {
114  return !operator==(other);
115  }
116 
117 public:
128 };
129 
130 QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RBox& b);
131 
134 Q_DECLARE_METATYPE(QSharedPointer<RBox>)
135 Q_DECLARE_METATYPE(QSharedPointer<RBox>*)
136 Q_DECLARE_METATYPE(QList<RBox>)
137 
138 #endif
Represents a box e.g.
Definition: RBox.h:43
RVector c1
Getter function for this property: getCorner1.
Definition: RBox.h:122
void growToIncludePoint(const RVector &v)
Definition: RBox.h:90
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
void growToIncludeBox(const RBox &other)
Definition: RBox.h:83
#define QCADCORE_EXPORT
Definition: core_global.h:10
RVector c2
Getter function for this property: getCorner2.
Definition: RBox.h:127
void move(void e, void p1, void p2)
Moves the given entity or shape by the given offset.
Definition: simple_modify.js:14
bool containsBox(const RBox &other) const
Definition: RBox.h:72
QCADCORE_EXPORT QDebug operator<<(QDebug dbg, const RBox &b)
Stream operator for QDebug.
Definition: RBox.cpp:447
Q_DECLARE_METATYPE(RMath *)
RVector get2D() const
Definition: RVector.h:81
bool containsPoint(const RVector &v) const
Definition: RBox.h:75
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
RBox get2D() const
Definition: RBox.h:55