QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RBox.h
Go to the documentation of this file.
1 #ifndef RBOX_H
2 #define RBOX_H
3 
4 #include <QRectF>
5 
6 #include "RVector.h"
7 #include "RTriangle.h"
8 
9 class RPolyline;
10 
11 #define RDEFAULT_RBOX RBox()
12 
22 class RBox {
23 public:
24  RBox();
25  explicit RBox(const QRectF& rect);
26  RBox(const RVector& c1, const RVector& c2);
27  RBox(const RVector& center, double range);
28 
29  bool isValid() const;
30 
31  double getWidth() const;
32  double getHeight() const;
33  RVector getSize() const;
34  RVector getCenter() const;
35  RVector getMinimum() const;
36  RVector getMaximum() const;
37  bool isOutside(const RBox& other) const;
38  bool contains(const RBox& other) const;
39  bool contains(const RVector& v) const;
40  bool intersects(const RBox& other) const;
41 
42  void growToInclude(const RBox& other);
43  void growToInclude(const RVector& v);
44 
46  void setCorner1(const RVector& v);
48  void setCorner2(const RVector& v);
49 
50  QList<RVector> getCorners() const;
51  QList<RVector> getCorners2d() const;
52  QList<RLine> getLines2d() const;
53  RPolyline getPolyline2d() const;
54  QList<RTriangle> getTriangles() const;
55 
56  RBox& grow(double offset);
57  RBox& growXY(double offset);
58 
59  QRectF toQRectF() const;
60 
61  bool operator ==(const RBox& other) const;
62  bool operator !=(const RBox& other) const {
63  return !operator==(other);
64  }
65 
66 public:
77 };
78 
79 QDebug operator<<(QDebug dbg, const RBox& b);
80 
83 Q_DECLARE_METATYPE(QSharedPointer<RBox>)
84 Q_DECLARE_METATYPE(QSharedPointer<RBox>*)
86 
87 #endif