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  void setShape(const RPolyline& l);
92 
93  bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
94  RTransaction* transaction=NULL);
95  QPair<QVariant, RPropertyAttributes> getProperty(
96  RPropertyTypeId& propertyTypeId,
97  bool humanReadable = false, bool noAttributes = false);
98 
99  virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
100 
101  virtual RPolylineData& getData() {
102  return data;
103  }
104 
105  virtual const RPolylineData& getData() const {
106  return data;
107  }
108 
110  return data.getPolylineShape();
111  }
112 
113  void clear() {
114  data.clear();
115  }
116 
117  void normalize(double tolerance = RS::PointTolerance) {
118  data.normalize(tolerance);
119  }
120 
121  int countVertices() const {
122  return data.countVertices();
123  }
124 
125  void appendVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
126  data.appendVertex(vertex, bulge, w1, w2);
127  }
128 
129  void prependVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
130  data.prependVertex(vertex, bulge, w1, w2);
131  }
132 
133  void insertVertex(int index, const RVector& vertex) {
134  data.insertVertex(index, vertex);
135  }
136 
137  void insertVertexAt(const RVector& vertex) {
138  data.insertVertexAt(vertex);
139  }
140 
141  RVector getVertexAt(int i) const {
142  return data.getVertexAt(i);
143  }
144 
146  data.removeLastVertex();
147  }
148 
149  void removeVertex(int index) {
150  data.removeVertex(index);
151  }
152 
153  int countSegments() const {
154  return data.countSegments();
155  }
156 
157  QSharedPointer<RShape> getSegmentAt(int i) const {
158  return data.getSegmentAt(i);
159  }
160 
161  bool isArcSegmentAt(int i) const {
162  return data.isArcSegmentAt(i);
163  }
164 
165  int getClosestSegment(const RVector& point) const {
166  return data.getClosestSegment(point);
167  }
168 
169  int getClosestVertex(const RVector& point) const {
170  return data.getClosestVertex(point);
171  }
172 
173  double getBulgeAt(int i) const {
174  return data.getBulgeAt(i);
175  }
176 
177  void setBulgeAt(int i, double b) {
178  data.setBulgeAt(i, b);
179  }
180 
181  double getStartWidthAt(int i) const {
182  return data.getStartWidthAt(i);
183  }
184 
185  double getEndWidthAt(int i) const {
186  return data.getEndWidthAt(i);
187  }
188 
189  double getDirection1() const {
190  return data.getDirection1();
191  }
192 
193  double getDirection2() const {
194  return data.getDirection2();
195  }
196 
197  bool reverse() {
198  return data.reverse();
199  }
200 
201  RS::Side getSideOfPoint(const RVector& point) const {
202  return data.getSideOfPoint(point);
203  }
204 
206  return data.getEndPoint();
207  }
208 
210  return data.getStartPoint();
211  }
212 
213  void setClosed(bool on) {
214  data.setClosed(on);
215  }
216 
217  bool isClosed() const {
218  return data.isClosed();
219  }
220 
221  bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const {
222  return data.isGeometricallyClosed(tolerance);
223  }
224 
225  bool autoClose(double tolerance=RS::PointTolerance) {
226  return data.toLogicallyClosed(tolerance);
227  }
228 
229  bool toLogicallyClosed(double tolerance=RS::PointTolerance) {
230  return data.toLogicallyClosed(tolerance);
231  }
232 
234  return data.toLogicallyOpen();
235  }
236 
237  QList<RVector> getSelfIntersectionPoints() const {
238  return data.getSelfIntersectionPoints();
239  }
240 
241  RS::Orientation getOrientation(bool implicitelyClosed = false) const {
242  return data.getOrientation(implicitelyClosed);
243  }
244 
245  double getLength() const {
246  return data.getLength();
247  }
248 
249  double getLengthTo(const RVector& p, bool limited = true) const {
250  return data.getLengthTo(p, limited);
251  }
252 
253  QList<QSharedPointer<RShape> > getExploded() const {
254  return data.getExploded();
255  }
256 
257  virtual int getComplexity() const {
258  return countSegments();
259  }
260 
262  return data.toPainterPath();
263  }
264 
265  void simplify(double angleTolerance) {
266  data.simplify(angleTolerance);
267  }
268 
269  QList<RVector> verifyTangency(double toleranceMin = RS::AngleTolerance, double toleranceMax = M_PI_4) {
270  return data.verifyTangency(toleranceMin, toleranceMax);
271  }
272 
273  void setPolylineGen(bool on) {
274  data.setPolylineGen(on);
275  }
276  bool getPolylineGen() const {
277  return data.getPolylineGen();
278  }
279 
280  RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
281  return data.getTrimEnd(trimPoint, clickPoint);
282  }
283 
284  bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
285  return data.trimStartPoint(trimPoint, clickPoint, extend);
286  }
287  bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
288  return data.trimEndPoint(trimPoint, clickPoint, extend);
289  }
290 
291 protected:
292  virtual void print(QDebug dbg) const;
293 
294 protected:
296 };
297 
299 Q_DECLARE_METATYPE(QSharedPointer<RPolylineEntity>)
300 Q_DECLARE_METATYPE(QSharedPointer<RPolylineEntity>*)
301 
302 #endif
static const double AngleTolerance
Definition: RS.h:575
RS::Side getSideOfPoint(const RVector &point) const
Definition: RPolylineEntity.h:201
bool autoClose(double tolerance=RS::PointTolerance)
Definition: RPolylineEntity.h:225
Ending
Entity ending.
Definition: RS.h:152
void removeLastVertex()
Definition: RPolylineEntity.h:145
int getClosestVertex(const RVector &point) const
Definition: RPolylineEntity.h:169
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:249
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition: RPolylineEntity.h:221
RS::Orientation getOrientation(bool implicitelyClosed=false) const
Definition: RPolylineEntity.h:241
bool reverse()
Definition: RPolylineEntity.h:197
static RPropertyTypeId PropertyColor
Definition: RPolylineEntity.h:56
static RPropertyTypeId PropertyEndWidthN
Definition: RPolylineEntity.h:68
QList< QSharedPointer< RShape > > getExploded() const
Definition: RPolylineEntity.h:253
void clear()
Definition: RPolylineEntity.h:113
virtual const RPolylineData & getData() const
Definition: RPolylineEntity.h:105
RVector getVertexAt(int i) const
Definition: RPolylineEntity.h:141
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
RPainterPath toPainterPath() const
Definition: RPolylineEntity.h:261
static RPropertyTypeId PropertyBlock
Definition: RPolylineEntity.h:51
static RPropertyTypeId PropertyType
Definition: RPolylineEntity.h:50
bool getPolylineGen() const
Definition: RPolylineEntity.h:276
Low-level mathematical representation of an arc.
Definition: RArc.h:40
static RPropertyTypeId PropertyDrawOrder
Definition: RPolylineEntity.h:58
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
double getLength() const
Definition: RPolylineEntity.h:245
QList< RVector > getSelfIntersectionPoints() const
Definition: RPolylineEntity.h:237
virtual RPolylineEntity * clone() const
Definition: RPolylineEntity.h:87
static RPropertyTypeId PropertyVertexNZ
Definition: RPolylineEntity.h:64
int getClosestSegment(const RVector &point) const
Definition: RPolylineEntity.h:165
Transaction implementation.
Definition: RTransaction.h:74
double getEndWidthAt(int i) const
Definition: RPolylineEntity.h:185
static RPropertyTypeId PropertyLayer
Definition: RPolylineEntity.h:52
void setBulgeAt(int i, double b)
Definition: RPolylineEntity.h:177
void setClosed(bool on)
Definition: RPolylineEntity.h:213
bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RPolylineEntity.h:287
RVector getEndPoint() const
Definition: RPolylineEntity.h:205
RVector getStartPoint() const
Definition: RPolylineEntity.h:209
static RPropertyTypeId PropertyClosed
Definition: RPolylineEntity.h:60
virtual RPolylineData & getData()
Definition: RPolylineEntity.h:101
Polyline entity.
Definition: RPolylineEntity.h:44
double getDirection2() const
Definition: RPolylineEntity.h:193
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:149
static RPropertyTypeId PropertyAngleN
Definition: RPolylineEntity.h:66
static const double PointTolerance
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RS.h:574
void normalize(double tolerance=RS::PointTolerance)
Definition: RPolylineEntity.h:117
void setPolylineGen(bool on)
Definition: RPolylineEntity.h:273
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:129
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:173
void insertVertex(int index, const RVector &vertex)
Definition: RPolylineEntity.h:133
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:46
QSharedPointer< RShape > getSegmentAt(int i) const
Definition: RPolylineEntity.h:157
bool isClosed() const
Definition: RPolylineEntity.h:217
void simplify(double angleTolerance)
Definition: RPolylineEntity.h:265
static RPropertyTypeId PropertyProtected
Definition: RPolylineEntity.h:49
static RPropertyTypeId PropertyLineweight
Definition: RPolylineEntity.h:55
double getStartWidthAt(int i) const
Definition: RPolylineEntity.h:181
static RPropertyTypeId PropertyArea
Definition: RPolylineEntity.h:73
void insertVertexAt(const RVector &vertex)
Definition: RPolylineEntity.h:137
static RPropertyTypeId PropertyLinetype
Definition: RPolylineEntity.h:53
static QSet< RPropertyTypeId > getStaticPropertyTypeIds()
Definition: RPolylineEntity.h:83
RPolylineData data
Definition: RPolylineEntity.h:295
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-2017 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
bool isArcSegmentAt(int i) const
Definition: RPolylineEntity.h:161
Abstract base class for exporters.
Definition: RExporter.h:71
static RPropertyTypeId PropertyVertexNY
Definition: RPolylineEntity.h:63
RPolyline getPolylineShape() const
Definition: RPolylineEntity.h:109
Orientation
Definition: RS.h:516
int countSegments() const
Definition: RPolylineEntity.h:153
bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RPolylineEntity.h:284
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:121
RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RPolylineEntity.h:280
void appendVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolylineEntity.h:125
bool toLogicallyClosed(double tolerance=RS::PointTolerance)
Definition: RPolylineEntity.h:229
static RPropertyTypeId PropertyLength
Definition: RPolylineEntity.h:71
static RPropertyTypeId PropertyStartWidthN
Definition: RPolylineEntity.h:67
virtual int getComplexity() const
Definition: RPolylineEntity.h:257
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:317
double getDirection1() const
Definition: RPolylineEntity.h:189
bool toLogicallyOpen()
Definition: RPolylineEntity.h:233
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:468
QList< RVector > verifyTangency(double toleranceMin=RS::AngleTolerance, double toleranceMax=M_PI_4)
Definition: RPolylineEntity.h:269