QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RHatchData.h
Go to the documentation of this file.
1 #ifndef RHATCHDATA_H
2 #define RHATCHDATA_H
3 
4 #include "RBox.h"
5 #include "RDocument.h"
6 #include "REntity.h"
7 #include "RLine.h"
8 #include "RPainterPath.h"
9 #include "RPainterPathSource.h"
10 #include "RPoint.h"
11 #include "RVector.h"
12 
20 class RHatchData: public REntityData, public RPainterPathSource {
21 
22  friend class RHatchEntity;
23 
24 protected:
26 
27 public:
28  RHatchData();
29  RHatchData(const RHatchData& other);
30  RHatchData(bool solid, double scaleFactor, double angle, const QString& patternName);
31 
32  RHatchData& operator=(const RHatchData& other);
33 
34  virtual RBox getBoundingBox() const;
35 
36  virtual RVector getPointOnEntity() const;
37  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false) const;
38  virtual bool intersectsWith(const RShape& shape) const;
39 
40  virtual QList<RVector> getReferencePoints(
42 
43  virtual bool moveReferencePoint(const RVector& referencePoint,
44  const RVector& targetPoint);
45 
46  virtual bool move(const RVector& offset);
47  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
48  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
49  virtual bool mirror(const RLine& axis);
50  virtual bool stretch(const RPolyline& area, const RVector& offset);
51 
52  virtual RShape* castToShape() {
53  return NULL;
54  }
55 
56  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX) const;
57  virtual QList<QSharedPointer<RShape> > getExploded() const;
58 
59  bool isSolid() const {
60  return solid;
61  }
62 
63  void setSolid(bool on) {
64  solid = on;
65  update();
66  }
67 
68  double getScale() const {
69  return scaleFactor;
70  }
71 
72  void setScale(double s) {
73  scaleFactor = s;
74  update();
75  }
76 
77  double getAngle() const {
78  return angle;
79  }
80 
81  void setAngle(double a) {
82  angle = a;
83  update();
84  }
85 
86  QString getPatternName() const {
87  return patternName;
88  }
89 
90  void setPatternName(const QString& n) {
91  patternName = n;
92  update();
93  }
94 
95  void newLoop();
96  void addBoundary(QSharedPointer<RShape> shape);
98  virtual QList<RPainterPath> getPainterPaths(bool draft = false) const;
99  RPainterPath getPainterPath(bool draft) const;
100 
101 
102  QList<QList<QSharedPointer<RShape> > > getBoundary() const {
103  return boundary;
104  }
105 
109  QPair<QSharedPointer<RShape>, QSharedPointer<RShape> > getBoundaryElementsAt(int index, int& internalIndex) const;
110 
111  virtual void update() const;
112  bool order();
113 
114  int getLoopCount() const {
115  return boundary.count();
116  }
117 
118  QList<QSharedPointer<RShape> > getLoopBoundary(int index) const;
119 
120 protected:
121  QList<RLine> getSegments(const RLine& line) const;
122 
123 private:
124  bool solid;
125  double scaleFactor;
126  double angle;
127  QString patternName;
129 
133  QList<QList<QSharedPointer<RShape> > > boundary;
134 
137  mutable bool dirty;
138  mutable bool gotDraft;
139 };
140 
143 Q_DECLARE_METATYPE(QSharedPointer<RHatchData>)
144 
145 #endif