QCAD
Open Source 2D CAD
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 
43 
44  friend class RHatchEntity;
45 
46 protected:
48 
49 public:
50  RHatchData();
51  RHatchData(const RHatchData& other);
52  RHatchData(bool solid, double scaleFactor, double angle, const QString& patternName);
53 
54  RHatchData& operator=(const RHatchData& other);
55 
56  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
57 
58  virtual RVector getPointOnEntity() const;
59  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const;
60  virtual bool intersectsWith(const RShape& shape) const;
61 
62  virtual QList<RVector> getReferencePoints(
64 
65  virtual bool moveReferencePoint(const RVector& referencePoint,
66  const RVector& targetPoint);
67 
68  virtual bool move(const RVector& offset);
69  virtual bool rotate(double rotation, const RVector& center = RDEFAULT_RVECTOR);
70  virtual bool scale(const RVector& scaleFactors, const RVector& center = RDEFAULT_RVECTOR);
71  virtual bool mirror(const RLine& axis);
72  virtual bool stretch(const RPolyline& area, const RVector& offset);
73 
74  virtual RShape* castToShape() {
75  return NULL;
76  }
77 
78  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false) const;
79  virtual QList<QSharedPointer<RShape> > getExploded() const;
80 
81  bool isSolid() const {
82  return solid;
83  }
84 
85  void setSolid(bool on) {
86  solid = on;
87  update();
88  }
89 
90  double getScale() const {
91  return scaleFactor;
92  }
93 
94  void setScale(double s) {
95  scaleFactor = s;
96  update();
97  }
98 
99  double getAngle() const {
100  return angle;
101  }
102 
103  void setAngle(double a) {
104  angle = a;
105  update();
106  }
107 
109  return originPoint;
110  }
111 
112  void setOriginPoint(const RVector& op) {
113  originPoint = op;
114  update();
115  }
116 
117  QString getPatternName() const {
118  return patternName;
119  }
120 
121  void setPatternName(const QString& n) {
122  patternName = n;
123  update();
124  }
125 
126  void newLoop();
127  void addBoundary(QSharedPointer<RShape> shape);
128  RPainterPath getBoundaryPath() const;
129  virtual QList<RPainterPath> getPainterPaths(bool draft = false) const;
130 
131 
132  QList<QList<QSharedPointer<RShape> > > getBoundary() const {
133  return boundary;
134  }
135 
139  QPair<QSharedPointer<RShape>, QSharedPointer<RShape> > getBoundaryElementsAt(int index, int& internalIndex) const;
140 
141  virtual void update() const;
142  bool order();
143 
144  int getLoopCount() const {
145  return boundary.count();
146  }
147 
148  QList<QSharedPointer<RShape> > getLoopBoundary(int index) const;
149 
150  int getComplexity() const;
151 
152 protected:
153  QList<RLine> getSegments(const RLine& line) const;
154 
155 private:
156  bool solid;
157  double scaleFactor;
158  double angle;
159  QString patternName;
161 
165  QList<QList<QSharedPointer<RShape> > > boundary;
166 
168  mutable QList<RPainterPath> painterPaths;
169  mutable bool dirty;
170  mutable bool gotDraft;
171 };
172 
176 Q_DECLARE_METATYPE(QSharedPointer<RHatchData>)
177 
178 #endif
Represents a box e.g.
Definition: RBox.h:43
Base class for all entity data classes.
Definition: REntityData.h:64
virtual RShape * castToShape()
Definition: RHatchData.h:74
virtual RVector getPointOnEntity() const
Definition: REntityData.cpp:260
double scaleFactor
Definition: RHatchData.h:157
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define RDEFAULT_RBOX
Definition: RBox.h:32
RHatchData data
Definition: RHatchEntity.h:178
virtual bool mirror(const RLine &axis)
Definition: REntityData.cpp:477
virtual QList< QSharedPointer< RShape > > getExploded() const
Definition: RHatchEntity.h:170
RVector originPoint
Definition: RHatchData.h:160
void setScale(double s)
Definition: RHatchData.h:94
virtual int getComplexity() const
Definition: RHatchEntity.h:106
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
QList< QList< QSharedPointer< RShape > > > boundary
Hatch boundary, ordered by loops, in strictly defined order.
Definition: RHatchData.h:165
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
Definition: REntityData.cpp:443
void newLoop()
Definition: RHatchEntity.h:110
bool solid
Definition: RHatchData.h:156
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: REntityData.cpp:216
double getScale() const
Definition: RHatchData.h:90
QList< QList< QSharedPointer< RShape > > > getBoundary() const
Definition: RHatchData.h:132
QString patternName
Definition: RHatchData.h:159
virtual bool intersectsWith(const RShape &shape) const
Definition: REntityData.cpp:390
void addBoundary(QSharedPointer< RShape > shape)
Definition: RHatchEntity.h:114
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:118
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:463
RVector getOriginPoint() const
Definition: RHatchData.h:108
void setAngle(double a)
Definition: RHatchData.h:103
QList< RPainterPath > getPainterPaths(bool draft=false) const
Definition: RHatchEntity.h:102
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:230
virtual QList< RVector > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:63
virtual bool moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint)=0
Moves the given reference point to the given target point or does nothing if this entity has no refer...
QList< RPainterPath > painterPaths
Definition: RHatchData.h:168
Q_DECLARE_METATYPE(RMath *)
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RHatchData.h:42
QString getPatternName() const
Definition: RHatchData.h:117
void setSolid(bool on)
Definition: RHatchData.h:85
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:45
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)
Definition: REntityData.cpp:453
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPainterPathSource.h:36
#define RMAXDOUBLE
Definition: RMath.h:50
int getLoopCount() const
Definition: RHatchData.h:144
virtual bool stretch(const RPolyline &area, const RVector &offset)
Stretches the end points of this entity that are inside area by offset.
Definition: REntityData.cpp:502
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false) const
Definition: REntityData.h:88
void setPatternName(const QString &n)
Definition: RHatchData.h:121
Low-level mathematical representation of a line.
Definition: RLine.h:42
Definition: RS.h:119
bool isSolid() const
Definition: RHatchData.h:81
RPainterPath boundaryPath
Definition: RHatchData.h:167
Point entity.
Definition: RHatchEntity.h:38
double angle
Definition: RHatchData.h:158
QList< QSharedPointer< RShape > > getLoopBoundary(int index) const
Definition: RHatchEntity.h:162
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
bool gotDraft
Definition: RHatchData.h:170
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: REntityData.h:320
bool dirty
Definition: RHatchData.h:169
void setOriginPoint(const RVector &op)
Definition: RHatchData.h:112
#define RDEFAULT_RVECTOR
Definition: RVector.h:37
double getAngle() const
Definition: RHatchData.h:99
RDocument * document
Definition: RObject.h:251