QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
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
28class RDocument;
29class RExporter;
30class RArc;
31class RLine;
32
33#ifndef RDEFAULT_MIN1
34#define RDEFAULT_MIN1 -1
35#endif
36
45
46public:
60
71
77
81
83
84// static QString TrClockwise;
85// static QString TrCounterclockwise;
86
87public:
88 RPolylineEntity(RDocument* document, const RPolylineData& data);
89 RPolylineEntity(const RPolylineEntity& other);
90 virtual ~RPolylineEntity();
91
92 static void init();
93
95 return RS::EntityPolyline;
96 }
97
101
102 virtual QSharedPointer<RObject> clone() const {
103 return QSharedPointer<RObject>(new RPolylineEntity(*this));
104 }
105
106 QSharedPointer<RPolylineEntity> cloneToPolylineEntity() const {
107 return QSharedPointer<RPolylineEntity>(new RPolylineEntity(*this));
108 }
109
110 void setShape(const RPolyline& l);
111
112 virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
113 RTransaction* transaction=NULL);
114 virtual QPair<QVariant, RPropertyAttributes> getProperty(
115 RPropertyTypeId& propertyTypeId,
116 bool humanReadable = false, bool noAttributes = false, bool showOnRequest = false);
117
118 virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
119
121 return data;
122 }
123
124 virtual const RPolylineData& getData() const {
125 return data;
126 }
127
129 return data.getPolylineShape();
130 }
131
132 void clear() {
133 data.clear();
134 }
135
136 void normalize(double tolerance = RS::PointTolerance) {
137 data.normalize(tolerance);
138 }
139
140 int countVertices() const {
141 return data.countVertices();
142 }
143
144 void appendVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
145 data.appendVertex(vertex, bulge, w1, w2);
146 }
147
148 void prependVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
149 data.prependVertex(vertex, bulge, w1, w2);
150 }
151
152 void insertVertex(int index, const RVector& vertex) {
153 data.insertVertex(index, vertex);
154 }
155
156 void insertVertexAt(const RVector& vertex) {
157 data.insertVertexAt(vertex);
158 }
159
161 return data.insertVerticesAtSelfIntersections();
162 }
163
164 RVector getVertexAt(int i) const {
165 return data.getVertexAt(i);
166 }
167
168 void setVertexAt(int i, const RVector& v) {
169 data.setVertexAt(i, v);
170 }
171
173 data.removeLastVertex();
174 }
175
176 void removeVertex(int index) {
177 data.removeVertex(index);
178 }
179
180 int countSegments() const {
181 return data.countSegments();
182 }
183
184 QSharedPointer<RShape> getSegmentAt(int i) const {
185 return data.getSegmentAt(i);
186 }
187
188 bool isArcSegmentAt(int i) const {
189 return data.isArcSegmentAt(i);
190 }
191
192 bool hasArcSegments() const {
193 return data.hasArcSegments();
194 }
195
196 int getClosestSegment(const RVector& point) const {
197 return data.getClosestSegment(point);
198 }
199
200 int getClosestVertex(const RVector& point) const {
201 return data.getClosestVertex(point);
202 }
203
204 double getBulgeAt(int i) const {
205 return data.getBulgeAt(i);
206 }
207
208 void setBulgeAt(int i, double b) {
209 data.setBulgeAt(i, b);
210 }
211
212 double getVertexAngle(int i, RS::Orientation orientation = RS::UnknownOrientation) const {
213 return data.getVertexAngle(i, orientation);
214 }
215
216 void stripWidths() {
217 data.stripWidths();
218 }
219
220 void setMinimumWidth(double w) {
221 data.setMinimumWidth(w);
222 }
223
224 void setGlobalWidth(double w) {
225 data.setGlobalWidth(w);
226 }
227
228 void setStartWidthAt(int i, double w) {
229 data.setStartWidthAt(i, w);
230 }
231
232 double getStartWidthAt(int i) const {
233 return data.getStartWidthAt(i);
234 }
235
236 void setEndWidthAt(int i, double w) {
237 data.setEndWidthAt(i, w);
238 }
239
240 double getEndWidthAt(int i) const {
241 return data.getEndWidthAt(i);
242 }
243
244 bool hasWidths() const {
245 return data.hasWidths();
246 }
247
248 void setStartWidths(const QList<double>& sw) {
249 data.setStartWidths(sw);
250 }
251
252 QList<double> getStartWidths() const {
253 return data.getStartWidths();
254 }
255
256 void setEndWidths(const QList<double>& ew) {
257 data.setEndWidths(ew);
258 }
259
260 QList<double> getEndWidths() const {
261 return data.getEndWidths();
262 }
263
264 double getDirection1() const {
265 return data.getDirection1();
266 }
267
268 double getDirection2() const {
269 return data.getDirection2();
270 }
271
272 bool reverse() {
273 return data.reverse();
274 }
275
276 RS::Side getSideOfPoint(const RVector& point) const {
277 return data.getSideOfPoint(point);
278 }
279
281 return data.getEndPoint();
282 }
283
285 return data.getStartPoint();
286 }
287
289 data.relocateStartPoint(p);
290 }
291
292 void setClosed(bool on) {
293 data.setClosed(on);
294 }
295
296 bool isClosed() const {
297 return data.isClosed();
298 }
299
300 bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const {
301 return data.isGeometricallyClosed(tolerance);
302 }
303
304 bool autoClose(double tolerance=RS::PointTolerance) {
305 return data.toLogicallyClosed(tolerance);
306 }
307
308 bool toLogicallyClosed(double tolerance=RS::PointTolerance) {
309 return data.toLogicallyClosed(tolerance);
310 }
311
313 return data.toLogicallyOpen();
314 }
315
316 QList<RVector> getSelfIntersectionPoints(double tolerance=RS::PointTolerance) const {
317 return data.getSelfIntersectionPoints(tolerance);
318 }
319
320 RS::Orientation getOrientation(bool implicitelyClosed = false) const {
321 return data.getOrientation(implicitelyClosed);
322 }
323
324 double getArea() const {
325 return data.getArea();
326 }
327
328 double getLength() const {
329 return data.getLength();
330 }
331
332 double getLengthTo(const RVector& p, bool limited = true) const {
333 return data.getLengthTo(p, limited);
334 }
335
336 QList<QSharedPointer<RShape> > getExploded() const {
337 return data.getExploded();
338 }
339
340 virtual int getComplexity() const {
341 return countSegments();
342 }
343
345 return data.toPainterPath();
346 }
347
348 void simplify(double angleTolerance) {
349 data.simplify(angleTolerance);
350 }
351
352 QList<RVector> verifyTangency(double toleranceMin = RS::AngleTolerance, double toleranceMax = M_PI_4) {
353 return data.verifyTangency(toleranceMin, toleranceMax);
354 }
355
356 void setPolylineGen(bool on) {
357 data.setPolylineGen(on);
358 }
359 bool getPolylineGen() const {
360 return data.getPolylineGen();
361 }
362
363 void setElevation(double v) {
364 data.setElevation(v);
365 }
366 double getElevation() const {
367 return data.getElevation();
368 }
369
370 bool isFlat() const {
371 return data.isFlat();
372 }
373
374 RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
375 return data.getTrimEnd(trimPoint, clickPoint);
376 }
377
378 bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
379 return data.trimStartPoint(trimPoint, clickPoint, extend);
380 }
381 bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
382 return data.trimEndPoint(trimPoint, clickPoint, extend);
383 }
384
385 bool trimStartPoint(double trimDist) {
386 return data.trimStartPoint(trimDist);
387 }
388 bool trimEndPoint(double trimDist) {
389 return data.trimEndPoint(trimDist);
390 }
391
392 QList<RPolyline> morph(const RPolyline& target, int steps) const {
393 return data.morph(target, steps);
394 }
395
396 bool contains(const RVector& point, bool borderIsInside=false, double tolerance=RS::PointTolerance) const {
397 return data.contains(point, borderIsInside, tolerance);
398 }
399 bool containsShape(const RShape& shape) const {
400 return data.containsShape(shape);
401 }
402
403 virtual bool validate();
404
405protected:
406 virtual void print(QDebug dbg) const;
407
408protected:
410};
411
413Q_DECLARE_METATYPE(QSharedPointer<RPolylineEntity>)
414Q_DECLARE_METATYPE(QSharedPointer<RPolylineEntity>*)
415
416#endif
Q_DECLARE_METATYPE(RMath *)
#define M_PI_4
Definition RMath.h:46
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Low-level mathematical representation of an arc.
Definition RArc.h:42
A graphics document contains and owns entities, layers, user coordinate systems, variables,...
Definition RDocument.h:78
Base class for all entity classes.
Definition REntity.h:63
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false, bool showOnRequest=false)
Definition REntity.cpp:236
static void init()
Definition REntity.cpp:89
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition REntity.cpp:338
virtual void exportEntity(RExporter &e, bool preview=false, bool forceSelected=false) const =0
Exports the entity to the given exporter.
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition REntity.cpp:487
Abstract base class for exporters.
Definition RExporter.h:78
Low-level mathematical representation of a line.
Definition RLine.h:41
virtual bool validate()
Definition RObject.h:291
Extended painter path with a z-level and a pen.
Definition RPainterPath.h:48
Stores and manages all data that defines the geometry and appearance of a polyline entity.
Definition RPolylineData.h:46
Polyline entity.
Definition RPolylineEntity.h:44
RS::Side getSideOfPoint(const RVector &point) const
Definition RPolylineEntity.h:276
void setBulgeAt(int i, double b)
Definition RPolylineEntity.h:208
double getLength() const
Definition RPolylineEntity.h:328
QList< double > getStartWidths() const
Definition RPolylineEntity.h:252
static RPropertyTypeId PropertyBulgeN
Definition RPolylineEntity.h:66
static RPropertyTypeId PropertyElevation
Definition RPolylineEntity.h:82
static RPropertyTypeId PropertyLinetypeScale
Definition RPolylineEntity.h:55
static RPropertyTypeId PropertyVertexNY
Definition RPolylineEntity.h:64
static RS::EntityType getRtti()
Definition RPolylineEntity.h:94
QSharedPointer< RShape > getSegmentAt(int i) const
Definition RPolylineEntity.h:184
void relocateStartPoint(const RVector &p)
Definition RPolylineEntity.h:288
bool autoClose(double tolerance=RS::PointTolerance)
Definition RPolylineEntity.h:304
bool contains(const RVector &point, bool borderIsInside=false, double tolerance=RS::PointTolerance) const
Definition RPolylineEntity.h:396
bool insertVerticesAtSelfIntersections()
Definition RPolylineEntity.h:160
void normalize(double tolerance=RS::PointTolerance)
Definition RPolylineEntity.h:136
static RPropertyTypeId PropertyBlock
Definition RPolylineEntity.h:52
double getEndWidthAt(int i) const
Definition RPolylineEntity.h:240
RVector getEndPoint() const
Definition RPolylineEntity.h:280
void prependVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition RPolylineEntity.h:148
int getClosestVertex(const RVector &point) const
Definition RPolylineEntity.h:200
void setMinimumWidth(double w)
Definition RPolylineEntity.h:220
static RPropertyTypeId PropertyVertexNZ
Definition RPolylineEntity.h:65
void setGlobalWidth(double w)
Definition RPolylineEntity.h:224
bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition RPolylineEntity.h:381
RPolyline getPolylineShape() const
Definition RPolylineEntity.h:128
virtual int getComplexity() const
Definition RPolylineEntity.h:340
bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition RPolylineEntity.h:378
void insertVertexAt(const RVector &vertex)
Definition RPolylineEntity.h:156
static RPropertyTypeId PropertyArea
Definition RPolylineEntity.h:75
bool toLogicallyOpen()
Definition RPolylineEntity.h:312
static RPropertyTypeId PropertyColor
Definition RPolylineEntity.h:57
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RPolylineEntity.h:47
void setStartWidthAt(int i, double w)
Definition RPolylineEntity.h:228
static RPropertyTypeId PropertyOrientation
Definition RPolylineEntity.h:72
double getElevation() const
Definition RPolylineEntity.h:366
bool trimEndPoint(double trimDist)
Definition RPolylineEntity.h:388
bool isArcSegmentAt(int i) const
Definition RPolylineEntity.h:188
static RPropertyTypeId PropertyLinetype
Definition RPolylineEntity.h:54
RS::Orientation getOrientation(bool implicitelyClosed=false) const
Definition RPolylineEntity.h:320
QList< RVector > verifyTangency(double toleranceMin=RS::AngleTolerance, double toleranceMax=M_PI_4)
Definition RPolylineEntity.h:352
static RPropertyTypeId PropertyBaseAngle
Definition RPolylineEntity.h:78
static RPropertyTypeId PropertyLayer
Definition RPolylineEntity.h:53
void stripWidths()
Definition RPolylineEntity.h:216
double getStartWidthAt(int i) const
Definition RPolylineEntity.h:232
bool isFlat() const
Definition RPolylineEntity.h:370
int countSegments() const
Definition RPolylineEntity.h:180
double getVertexAngle(int i, RS::Orientation orientation=RS::UnknownOrientation) const
Definition RPolylineEntity.h:212
virtual const RPolylineData & getData() const
Definition RPolylineEntity.h:124
static RPropertyTypeId PropertyGlobalWidth
Definition RPolylineEntity.h:70
static RPropertyTypeId PropertyType
Definition RPolylineEntity.h:51
QList< double > getEndWidths() const
Definition RPolylineEntity.h:260
double getBulgeAt(int i) const
Definition RPolylineEntity.h:204
int getClosestSegment(const RVector &point) const
Definition RPolylineEntity.h:196
RPolylineData data
Definition RPolylineEntity.h:409
void clear()
Definition RPolylineEntity.h:132
void setPolylineGen(bool on)
Definition RPolylineEntity.h:356
static RPropertyTypeId PropertyVertexNX
Definition RPolylineEntity.h:63
void removeLastVertex()
Definition RPolylineEntity.h:172
bool reverse()
Definition RPolylineEntity.h:272
QList< QSharedPointer< RShape > > getExploded() const
Definition RPolylineEntity.h:336
static RPropertyTypeId PropertyDrawOrder
Definition RPolylineEntity.h:59
bool containsShape(const RShape &shape) const
Definition RPolylineEntity.h:399
double getArea() const
Definition RPolylineEntity.h:324
static RPropertyTypeId PropertyDisplayedColor
Definition RPolylineEntity.h:58
static RPropertyTypeId PropertyClosed
Definition RPolylineEntity.h:61
static QSet< RPropertyTypeId > getStaticPropertyTypeIds()
Definition RPolylineEntity.h:98
RVector getVertexAt(int i) const
Definition RPolylineEntity.h:164
static RPropertyTypeId PropertyLineweight
Definition RPolylineEntity.h:56
void appendVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition RPolylineEntity.h:144
QList< RVector > getSelfIntersectionPoints(double tolerance=RS::PointTolerance) const
Definition RPolylineEntity.h:316
void simplify(double angleTolerance)
Definition RPolylineEntity.h:348
double getDirection2() const
Definition RPolylineEntity.h:268
static RPropertyTypeId PropertyLength
Definition RPolylineEntity.h:73
static RPropertyTypeId PropertyHandle
Definition RPolylineEntity.h:48
static RPropertyTypeId PropertyProtected
Definition RPolylineEntity.h:49
RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition RPolylineEntity.h:374
bool getPolylineGen() const
Definition RPolylineEntity.h:359
static RPropertyTypeId PropertyStartWidthN
Definition RPolylineEntity.h:68
double getLengthTo(const RVector &p, bool limited=true) const
Definition RPolylineEntity.h:332
void setEndWidths(const QList< double > &ew)
Definition RPolylineEntity.h:256
static RPropertyTypeId PropertyWorkingSet
Definition RPolylineEntity.h:50
static RPropertyTypeId PropertyAngleN
Definition RPolylineEntity.h:67
bool hasWidths() const
Definition RPolylineEntity.h:244
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition RPolylineEntity.h:300
void setStartWidths(const QList< double > &sw)
Definition RPolylineEntity.h:248
QSharedPointer< RPolylineEntity > cloneToPolylineEntity() const
Definition RPolylineEntity.h:106
void setElevation(double v)
Definition RPolylineEntity.h:363
bool toLogicallyClosed(double tolerance=RS::PointTolerance)
Definition RPolylineEntity.h:308
void insertVertex(int index, const RVector &vertex)
Definition RPolylineEntity.h:152
void setEndWidthAt(int i, double w)
Definition RPolylineEntity.h:236
void setClosed(bool on)
Definition RPolylineEntity.h:292
bool trimStartPoint(double trimDist)
Definition RPolylineEntity.h:385
bool isClosed() const
Definition RPolylineEntity.h:296
void setVertexAt(int i, const RVector &v)
Definition RPolylineEntity.h:168
bool hasArcSegments() const
Definition RPolylineEntity.h:192
static RPropertyTypeId PropertyPolylineGen
Definition RPolylineEntity.h:62
virtual QSharedPointer< RObject > clone() const
Definition RPolylineEntity.h:102
double getDirection1() const
Definition RPolylineEntity.h:264
virtual RPolylineData & getData()
Definition RPolylineEntity.h:120
RPainterPath toPainterPath() const
Definition RPolylineEntity.h:344
void removeVertex(int index)
Definition RPolylineEntity.h:176
static RPropertyTypeId PropertyEndWidthN
Definition RPolylineEntity.h:69
static RPropertyTypeId PropertySize1
Definition RPolylineEntity.h:79
static RPropertyTypeId PropertyTotalArea
Definition RPolylineEntity.h:76
RVector getStartPoint() const
Definition RPolylineEntity.h:284
static RPropertyTypeId PropertyTotalLength
Definition RPolylineEntity.h:74
int countVertices() const
Definition RPolylineEntity.h:140
static RPropertyTypeId PropertySize2
Definition RPolylineEntity.h:80
QList< RPolyline > morph(const RPolyline &target, int steps) const
Definition RPolylineEntity.h:392
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition RPolyline.h:50
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RPropertyTypeId.h:54
static QSet< RPropertyTypeId > getPropertyTypeIds(RS::EntityType type, RPropertyAttributes::Option=RPropertyAttributes::NoOptions)
Gets all property type IDs that where registered for the given class.
Definition RPropertyTypeId.cpp:283
Orientation
Definition RS.h:700
@ UnknownOrientation
Definition RS.h:701
EntityType
Entity types used for property handling / filtering.
Definition RS.h:227
@ EntityPolyline
Polyline.
Definition RS.h:252
static const double PointTolerance
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RS.h:920
static const double AngleTolerance
Definition RS.h:921
Side
Side used for side of a point relative to an entity (right hand or left hand side)
Definition RS.h:313
Ending
Entity ending.
Definition RS.h:323
Interface for geometrical shape classes.
Definition RShape.h:72
Transaction implementation.
Definition RTransaction.h:73
Represents a 3d vector (x/y/z).
Definition RVector.h:47
static const RVector invalid
invalid vector
Definition RVector.h:335
#define QCADENTITY_EXPORT
Definition entity_global.h:10
#define NULL
Definition opennurbs_system.h:256