QCAD
Open Source 2D CAD
RPolylineEntity.h
Go to the documentation of this file.
1 
20 #ifndef RPOLYLINEENTITY_H
21 #define RPOLYLINEENTITY_H
22 
23 #include "entity_global.h"
24 
25 #include "REntity.h"
26 #include "RPolylineData.h"
27 
28 class RDocument;
29 class RExporter;
30 class RArc;
31 class RLine;
32 
33 #ifndef RDEFAULT_MIN1
34 #define RDEFAULT_MIN1 -1
35 #endif
36 
45 
46 public:
59 
70 
75 
76 public:
77  RPolylineEntity(RDocument* document, const RPolylineData& data);
78  RPolylineEntity(const RPolylineEntity& other);
79  virtual ~RPolylineEntity();
80 
81  static void init();
82 
83  static QSet<RPropertyTypeId> getStaticPropertyTypeIds() {
85  }
86 
87  virtual RPolylineEntity* clone() const {
88  return new RPolylineEntity(*this);
89  }
90 
91  virtual RS::EntityType getType() const {
92  return RS::EntityPolyline;
93  }
94 
95  void setShape(const RPolyline& l);
96 
97  bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
98  RTransaction* transaction=NULL);
99  QPair<QVariant, RPropertyAttributes> getProperty(
100  RPropertyTypeId& propertyTypeId,
101  bool humanReadable = false, bool noAttributes = false);
102 
103  virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
104 
105  virtual RPolylineData& getData() {
106  return data;
107  }
108 
109  virtual const RPolylineData& getData() const {
110  return data;
111  }
112 
114  return data.getPolylineShape();
115  }
116 
117  void clear() {
118  data.clear();
119  }
120 
121  void normalize(double tolerance = RS::PointTolerance) {
122  data.normalize(tolerance);
123  }
124 
125  int countVertices() const {
126  return data.countVertices();
127  }
128 
129  void appendVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
130  data.appendVertex(vertex, bulge, w1, w2);
131  }
132 
133  void prependVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
134  data.prependVertex(vertex, bulge, w1, w2);
135  }
136 
137  void insertVertex(int index, const RVector& vertex) {
138  data.insertVertex(index, vertex);
139  }
140 
141  void insertVertexAt(const RVector& vertex) {
142  data.insertVertexAt(vertex);
143  }
144 
145  RVector getVertexAt(int i) const {
146  return data.getVertexAt(i);
147  }
148 
150  data.removeLastVertex();
151  }
152 
153  void removeVertex(int index) {
154  data.removeVertex(index);
155  }
156 
157  int countSegments() const {
158  return data.countSegments();
159  }
160 
161  QSharedPointer<RShape> getSegmentAt(int i) const {
162  return data.getSegmentAt(i);
163  }
164 
165  bool isArcSegmentAt(int i) const {
166  return data.isArcSegmentAt(i);
167  }
168 
169  int getClosestSegment(const RVector& point) const {
170  return data.getClosestSegment(point);
171  }
172 
173  int getClosestVertex(const RVector& point) const {
174  return data.getClosestVertex(point);
175  }
176 
177  double getBulgeAt(int i) const {
178  return data.getBulgeAt(i);
179  }
180 
181  void setBulgeAt(int i, double b) {
182  data.setBulgeAt(i, b);
183  }
184 
185  double getStartWidthAt(int i) const {
186  return data.getStartWidthAt(i);
187  }
188 
189  double getEndWidthAt(int i) const {
190  return data.getEndWidthAt(i);
191  }
192 
193  double getDirection1() const {
194  return data.getDirection1();
195  }
196 
197  double getDirection2() const {
198  return data.getDirection2();
199  }
200 
201  bool reverse() {
202  return data.reverse();
203  }
204 
205  RS::Side getSideOfPoint(const RVector& point) const {
206  return data.getSideOfPoint(point);
207  }
208 
210  return data.getEndPoint();
211  }
212 
214  return data.getStartPoint();
215  }
216 
217  void setClosed(bool on) {
218  data.setClosed(on);
219  }
220 
221  bool isClosed() const {
222  return data.isClosed();
223  }
224 
225  bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const {
226  return data.isGeometricallyClosed(tolerance);
227  }
228 
229  void autoClose() {
230  data.autoClose();
231  }
232 
233  QList<RVector> getSelfIntersectionPoints() const {
234  return data.getSelfIntersectionPoints();
235  }
236 
237  RS::Orientation getOrientation(bool implicitelyClosed = false) const {
238  return data.getOrientation(implicitelyClosed);
239  }
240 
241  double getLength() const {
242  return data.getLength();
243  }
244 
245  double getLengthTo(const RVector& p, bool limited = true) const {
246  return data.getLengthTo(p, limited);
247  }
248 
249  QList<QSharedPointer<RShape> > getExploded() const {
250  return data.getExploded();
251  }
252 
253  virtual int getComplexity() const {
254  return countSegments();
255  }
256 
258  return data.toPainterPath();
259  }
260 
261  void simplify(double angleTolerance) {
262  data.simplify(angleTolerance);
263  }
264 
265  QList<RVector> verifyTangency(double toleranceMin = RS::AngleTolerance, double toleranceMax = M_PI_4) {
266  return data.verifyTangency(toleranceMin, toleranceMax);
267  }
268 
269  void setPolylineGen(bool on) {
270  data.setPolylineGen(on);
271  }
272  bool getPolylineGen() const {
273  return data.getPolylineGen();
274  }
275 
276  RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
277  return data.getTrimEnd(trimPoint, clickPoint);
278  }
279 
280  bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
281  return data.trimStartPoint(trimPoint, clickPoint, extend);
282  }
283  bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
284  return data.trimEndPoint(trimPoint, clickPoint, extend);
285  }
286 
287 protected:
288  virtual void print(QDebug dbg) const;
289 
290 protected:
292 };
293 
295 Q_DECLARE_METATYPE(QSharedPointer<RPolylineEntity>)
296 Q_DECLARE_METATYPE(QSharedPointer<RPolylineEntity>*)
297 
298 #endif
static const double AngleTolerance
Definition: RS.h:554
RS::Side getSideOfPoint(const RVector &point) const
Definition: RPolylineEntity.h:205
Ending
Entity ending.
Definition: RS.h:152
void removeLastVertex()
Definition: RPolylineEntity.h:149
int getClosestVertex(const RVector &point) const
Definition: RPolylineEntity.h:173
Stores and manages all data that defines the geometry and appearance of a polyline entity...
Definition: RPolylineData.h:43
static RPropertyTypeId PropertyDisplayedColor
Definition: RPolylineEntity.h:57
static RPropertyTypeId PropertyGlobalWidth
Definition: RPolylineEntity.h:69
#define M_PI_4
Definition: RMath.h:43
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
double getLengthTo(const RVector &p, bool limited=true) const
Definition: RPolylineEntity.h:245
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition: RPolylineEntity.h:225
RS::Orientation getOrientation(bool implicitelyClosed=false) const
Definition: RPolylineEntity.h:237
bool reverse()
Definition: RPolylineEntity.h:201
static RPropertyTypeId PropertyColor
Definition: RPolylineEntity.h:56
static RPropertyTypeId PropertyEndWidthN
Definition: RPolylineEntity.h:68
QList< QSharedPointer< RShape > > getExploded() const
Definition: RPolylineEntity.h:249
void clear()
Definition: RPolylineEntity.h:117
virtual const RPolylineData & getData() const
Definition: RPolylineEntity.h:109
RVector getVertexAt(int i) const
Definition: RPolylineEntity.h:145
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
RPainterPath toPainterPath() const
Definition: RPolylineEntity.h:257
static RPropertyTypeId PropertyBlock
Definition: RPolylineEntity.h:51
static RPropertyTypeId PropertyType
Definition: RPolylineEntity.h:50
bool getPolylineGen() const
Definition: RPolylineEntity.h:272
Low-level mathematical representation of an arc.
Definition: RArc.h:40
static RPropertyTypeId PropertyDrawOrder
Definition: RPolylineEntity.h:58
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
double getLength() const
Definition: RPolylineEntity.h:241
QList< RVector > getSelfIntersectionPoints() const
Definition: RPolylineEntity.h:233
virtual RPolylineEntity * clone() const
Definition: RPolylineEntity.h:87
static RPropertyTypeId PropertyVertexNZ
Definition: RPolylineEntity.h:64
int getClosestSegment(const RVector &point) const
Definition: RPolylineEntity.h:169
Transaction implementation.
Definition: RTransaction.h:74
double getEndWidthAt(int i) const
Definition: RPolylineEntity.h:189
static RPropertyTypeId PropertyLayer
Definition: RPolylineEntity.h:52
void setBulgeAt(int i, double b)
Definition: RPolylineEntity.h:181
void setClosed(bool on)
Definition: RPolylineEntity.h:217
bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RPolylineEntity.h:283
RVector getEndPoint() const
Definition: RPolylineEntity.h:209
RVector getStartPoint() const
Definition: RPolylineEntity.h:213
static RPropertyTypeId PropertyClosed
Definition: RPolylineEntity.h:60
virtual RPolylineData & getData()
Definition: RPolylineEntity.h:105
Polyline entity.
Definition: RPolylineEntity.h:44
double getDirection2() const
Definition: RPolylineEntity.h:197
Side
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:142
void removeVertex(int index)
Definition: RPolylineEntity.h:153
static RPropertyTypeId PropertyAngleN
Definition: RPolylineEntity.h:66
void autoClose()
Definition: RPolylineEntity.h:229
static const double PointTolerance
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RS.h:553
void normalize(double tolerance=RS::PointTolerance)
Definition: RPolylineEntity.h:121
void setPolylineGen(bool on)
Definition: RPolylineEntity.h:269
static QSet< RPropertyTypeId > getPropertyTypeIds(const std::type_info &classInfo)
Gets all property type IDs that where registered for the given class.
Definition: RPropertyTypeId.cpp:229
Base class for all entity classes.
Definition: REntity.h:64
void prependVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolylineEntity.h:133
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
Q_DECLARE_METATYPE(RMath *)
double getBulgeAt(int i) const
Definition: RPolylineEntity.h:177
void insertVertex(int index, const RVector &vertex)
Definition: RPolylineEntity.h:137
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:46
QSharedPointer< RShape > getSegmentAt(int i) const
Definition: RPolylineEntity.h:161
bool isClosed() const
Definition: RPolylineEntity.h:221
void simplify(double angleTolerance)
Definition: RPolylineEntity.h:261
Polyline.
Definition: RS.h:98
static RPropertyTypeId PropertyProtected
Definition: RPolylineEntity.h:49
static RPropertyTypeId PropertyLineweight
Definition: RPolylineEntity.h:55
double getStartWidthAt(int i) const
Definition: RPolylineEntity.h:185
static RPropertyTypeId PropertyArea
Definition: RPolylineEntity.h:73
void insertVertexAt(const RVector &vertex)
Definition: RPolylineEntity.h:141
static RPropertyTypeId PropertyLinetype
Definition: RPolylineEntity.h:53
static QSet< RPropertyTypeId > getStaticPropertyTypeIds()
Definition: RPolylineEntity.h:83
RPolylineData data
Definition: RPolylineEntity.h:291
Low-level mathematical representation of a line.
Definition: RLine.h:41
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false)
Definition: REntity.cpp:228
static RPropertyTypeId PropertyTotalLength
Definition: RPolylineEntity.h:72
static RPropertyTypeId PropertyBulgeN
Definition: RPolylineEntity.h:65
static void init()
Definition: REntity.cpp:82
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPolylineEntity.h:47
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition: REntity.cpp:321
virtual RS::EntityType getType() const
Definition: RPolylineEntity.h:91
bool isArcSegmentAt(int i) const
Definition: RPolylineEntity.h:165
Abstract base class for exporters.
Definition: RExporter.h:71
static RPropertyTypeId PropertyVertexNY
Definition: RPolylineEntity.h:63
RPolyline getPolylineShape() const
Definition: RPolylineEntity.h:113
Orientation
Definition: RS.h:495
int countSegments() const
Definition: RPolylineEntity.h:157
bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RPolylineEntity.h:280
static RPropertyTypeId PropertyPolylineGen
Definition: RPolylineEntity.h:61
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
int countVertices() const
Definition: RPolylineEntity.h:125
RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RPolylineEntity.h:276
void appendVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolylineEntity.h:129
static RPropertyTypeId PropertyLength
Definition: RPolylineEntity.h:71
static RPropertyTypeId PropertyStartWidthN
Definition: RPolylineEntity.h:67
virtual int getComplexity() const
Definition: RPolylineEntity.h:253
static RPropertyTypeId PropertyTotalArea
Definition: RPolylineEntity.h:74
static RPropertyTypeId PropertyHandle
Definition: RPolylineEntity.h:48
static RPropertyTypeId PropertyVertexNX
Definition: RPolylineEntity.h:62
static const RVector invalid
invalid vector
Definition: RVector.h:313
double getDirection1() const
Definition: RPolylineEntity.h:193
virtual void exportEntity(RExporter &e, bool preview=false, bool forceSelected=false) const =0
Exports the entity to the given exporter.
static RPropertyTypeId PropertyLinetypeScale
Definition: RPolylineEntity.h:54
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: REntity.cpp:428
QList< RVector > verifyTangency(double toleranceMin=RS::AngleTolerance, double toleranceMax=M_PI_4)
Definition: RPolylineEntity.h:265