QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RHatchData.h
Go to the documentation of this file.
1 
20 #ifndef RHATCHDATA_H
21 #define RHATCHDATA_H
22 
23 #include "entity_global.h"
24 
25 #include "RBox.h"
26 #include "RDocument.h"
27 #include "REntity.h"
28 #include "RLine.h"
29 #include "RPainterPath.h"
30 #include "RPainterPathSource.h"
31 #include "RPoint.h"
32 #include "RVector.h"
33 
42 
43  friend class RHatchEntity;
44 
45 protected:
47 
48 public:
49  RHatchData();
50  RHatchData(const RHatchData& other);
51  RHatchData(bool solid, double scaleFactor, double angle, const QString& patternName);
52 
53  RHatchData& operator=(const RHatchData& other);
54 
55  virtual RBox getBoundingBox() const;
56 
57  virtual RVector getPointOnEntity() const;
58  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false) const;
59  virtual bool intersectsWith(const RShape& shape) const;
60 
61  virtual QList<RVector> getReferencePoints(
63 
64  virtual bool moveReferencePoint(const RVector& referencePoint,
65  const RVector& targetPoint);
66 
67  virtual bool move(const RVector& offset);
68  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
69  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
70  virtual bool mirror(const RLine& axis);
71  virtual bool stretch(const RPolyline& area, const RVector& offset);
72 
73  virtual RShape* castToShape() {
74  return NULL;
75  }
76 
77  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX) const;
78  virtual QList<QSharedPointer<RShape> > getExploded() const;
79 
80  bool isSolid() const {
81  return solid;
82  }
83 
84  void setSolid(bool on) {
85  solid = on;
86  update();
87  }
88 
89  double getScale() const {
90  return scaleFactor;
91  }
92 
93  void setScale(double s) {
94  scaleFactor = s;
95  update();
96  }
97 
98  double getAngle() const {
99  return angle;
100  }
101 
102  void setAngle(double a) {
103  angle = a;
104  update();
105  }
106 
108  return originPoint;
109  }
110 
111  void setOriginPoint(const RVector& op) {
112  originPoint = op;
113  update();
114  }
115 
116  QString getPatternName() const {
117  return patternName;
118  }
119 
120  void setPatternName(const QString& n) {
121  patternName = n;
122  update();
123  }
124 
125  void newLoop();
126  void addBoundary(QSharedPointer<RShape> shape);
127  RPainterPath getBoundaryPath() const;
128  virtual QList<RPainterPath> getPainterPaths(bool draft = false) const;
129 
130 
131  QList<QList<QSharedPointer<RShape> > > getBoundary() const {
132  return boundary;
133  }
134 
138  QPair<QSharedPointer<RShape>, QSharedPointer<RShape> > getBoundaryElementsAt(int index, int& internalIndex) const;
139 
140  virtual void update() const;
141  bool order();
142 
143  int getLoopCount() const {
144  return boundary.count();
145  }
146 
147  QList<QSharedPointer<RShape> > getLoopBoundary(int index) const;
148 
149  int getComplexity() const;
150 
151 protected:
152  QList<RLine> getSegments(const RLine& line) const;
153 
154 private:
155  bool solid;
156  double scaleFactor;
157  double angle;
158  QString patternName;
160 
164  QList<QList<QSharedPointer<RShape> > > boundary;
165 
167  mutable QList<RPainterPath> painterPaths;
168  mutable bool dirty;
169  mutable bool gotDraft;
170 };
171 
175 Q_DECLARE_METATYPE(QSharedPointer<RHatchData>)
176 
177 #endif