QCAD
Open Source 2D CAD
RPolylineData.h
Go to the documentation of this file.
1 
20 #ifndef RPOLYLINEDATA_H
21 #define RPOLYLINEDATA_H
22 
23 #include "entity_global.h"
24 
25 #include "RBox.h"
26 #include "RDocument.h"
27 #include "REntity.h"
28 #include "RPolyline.h"
29 #include "RVector.h"
30 
31 #ifndef RDEFAULT_MIN1
32 #define RDEFAULT_MIN1 -1
33 #endif
34 
44 
45  friend class RPolylineEntity;
46 
47 protected:
49 
50 public:
51  RPolylineData();
52  RPolylineData(const RPolyline& polyline);
53 
54  virtual QList<RBox> getBoundingBoxes(bool ignoreEmpty=false) const;
55 
56  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
57 
58  virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint);
59 
60  virtual RShape* castToShape() {
61  return this;
62  }
63 
64  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const {
65  Q_UNUSED(draft)
66 
67  double ret = RPolyline::getDistanceTo(point, limited, strictRange);
68  if (ret>range) {
69  return RNANDOUBLE;
70  }
71  return ret;
72  }
73 
75  return *this;
76  }
77 
78  void clear() {
80  }
81 
82  void normalize(double tolerance = RS::PointTolerance) {
83  RPolyline::normalize(tolerance);
84  }
85 
86  QList<RVector> getVertices() const {
87  return RPolyline::getVertices();
88  }
89 
90  RVector getVertexAt(int i) const {
91  return RPolyline::getVertexAt(i);
92  }
93 
94  void appendVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
95  RPolyline::appendVertex(vertex, bulge, w1, w2);
96  }
97 
98  void prependVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
99  RPolyline::prependVertex(vertex, bulge, w1, w2);
100  }
101 
102  void insertVertex(int index, const RVector& vertex) {
103  RPolyline::insertVertex(index, vertex);
104  }
105 
108  }
109 
110  void removeVertex(int index) {
112  }
113 
114  int countSegments() const {
115  return RPolyline::countSegments();
116  }
117 
118  QSharedPointer<RShape> getSegmentAt(int i) const {
119  return RPolyline::getSegmentAt(i);
120  }
121 
122  double getBulgeAt(int i) const {
123  return RPolyline::getBulgeAt(i);
124  }
125 
126  void setBulgeAt(int i, double b) {
127  RPolyline::setBulgeAt(i, b);
128  }
129 
130  double getDirection1() const {
131  return RPolyline::getDirection1();
132  }
133 
134  double getDirection2() const {
135  return RPolyline::getDirection2();
136  }
137 
138  bool reverse() {
139  return RPolyline::reverse();
140  }
141 
143  return RPolyline::getEndPoint();
144  }
145 
147  return RPolyline::getStartPoint();
148  }
149 
150  void setClosed(bool on) {
152  }
153 
154  bool isClosed() const {
155  return RPolyline::isClosed();
156  }
157 
158  bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const {
159  return RPolyline::isGeometricallyClosed(tolerance);
160  }
161 
162  void autoClose() {
164  }
165 
166  QList<QSharedPointer<RShape> > getExploded(int segments = RDEFAULT_MIN1) const {
167  return RPolyline::getExploded(segments);
168  }
169 
171  return RPolyline::toPainterPath();
172  }
173 
174  void simplify(double angleTolerance) {
175  RPolyline::simplify(angleTolerance);
176  }
177 
178  QList<RVector> verifyTangency(double toleranceMin = RS::AngleTolerance, double toleranceMax = M_PI_4) {
179  return RPolyline::verifyTangency(toleranceMin, toleranceMax);
180  }
181 
182  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false) const;
183 
184  virtual QList<RVector> getIntersectionPoints(
185  const REntityData& other, bool limited = true, bool same = false,
186  const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = true) const;
187 
188  void setPolylineGen(bool on) {
189  polylineGen = on;
190  }
191  bool getPolylineGen() const {
192  return polylineGen;
193  }
194 
195 protected:
197 };
198 
202 Q_DECLARE_METATYPE(QSharedPointer<RPolylineData>)
203 
204 #endif
RVector getVertexAt(int i) const
Definition: RPolyline.cpp:369
double getDirection1() const
Definition: RPolylineData.h:130
static const double AngleTolerance
Definition: RS.h:552
bool getPolylineGen() const
Definition: RPolylineData.h:191
Represents a box e.g.
Definition: RBox.h:43
Base class for all entity data classes.
Definition: REntityData.h:65
void normalize(double tolerance=RS::PointTolerance)
Definition: RPolylineData.h:82
Stores and manages all data that defines the geometry and appearance of a polyline entity...
Definition: RPolylineData.h:43
#define M_PI_4
Definition: RMath.h:43
void removeVertex(int index)
Definition: RPolyline.cpp:333
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define RDEFAULT_RBOX
Definition: RBox.h:32
RPainterPath toPainterPath() const
Definition: RPolyline.cpp:669
void appendVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolylineData.h:94
void setBulgeAt(int i, double b)
Definition: RPolylineData.h:126
QList< RVector > getVertices() const
Definition: RPolyline.cpp:365
virtual double getDistanceTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const
Definition: RPolyline.cpp:1403
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
QList< RVector > getVertices() const
Definition: RPolylineData.h:86
QList< RVector > verifyTangency(double toleranceMin=RS::AngleTolerance, double toleranceMax=M_PI_4)
Verifies the tangency of this polyline.
Definition: RPolyline.cpp:1659
virtual QList< RVector > getIntersectionPoints(const REntityData &other, bool limited=true, bool same=false, const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=true) const
Override to disable intersection point.
Definition: REntityData.cpp:437
virtual QList< RBox > getBoundingBoxes(bool ignoreEmpty=false) const
Definition: REntityData.h:122
bool autoClose()
Definition: RPolyline.cpp:576
double getBulgeAt(int i) const
Definition: RPolyline.cpp:421
RVector getStartPoint() const
Definition: RPolylineData.h:146
void insertVertex(int index, const RVector &vertex)
Definition: RPolylineData.h:102
#define RNANDOUBLE
Definition: RMath.h:71
int countSegments() const
Definition: RPolyline.cpp:845
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:129
Polyline entity.
Definition: RPolylineEntity.h:44
QSharedPointer< RShape > getSegmentAt(int i) const
Definition: RPolylineData.h:118
RVector getEndPoint() const
Definition: RPolylineData.h:142
QList< RVector > verifyTangency(double toleranceMin=RS::AngleTolerance, double toleranceMax=M_PI_4)
Definition: RPolylineData.h:178
void clear()
Definition: RPolyline.cpp:84
void prependVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolyline.cpp:249
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition: RPolyline.cpp:572
bool simplify(double angleTolerance=RS::AngleTolerance)
TODO: use douglas peuker.
Definition: RPolyline.cpp:1594
void setBulgeAt(int i, double b)
Definition: RPolyline.cpp:429
static const double PointTolerance
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RS.h:551
virtual RVector getStartPoint() const
Definition: RPolyline.cpp:1008
RVector getVertexAt(int i) const
Definition: RPolylineData.h:90
QList< QSharedPointer< RShape > > getExploded(int segments=RDEFAULT_MIN1) const
Definition: RPolylineData.h:166
QSharedPointer< RShape > getSegmentAt(int i) const
Definition: RPolyline.cpp:859
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
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...
Q_DECLARE_METATYPE(RMath *)
virtual RVector getEndPoint() const
Definition: RPolyline.cpp:1016
virtual bool reverse()
Definition: RPolyline.cpp:1517
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:46
RPolyline getPolylineShape() const
Definition: RPolylineData.h:74
#define RMAXDOUBLE
Definition: RMath.h:63
void clear()
Definition: RPolylineData.h:78
bool polylineGen
Definition: RPolylineData.h:196
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false) const
Definition: REntityData.h:89
void setClosed(bool on)
Definition: RPolyline.cpp:564
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
RPolylineData data
Definition: RPolylineEntity.h:283
virtual double getDirection1() const
Definition: RPolyline.cpp:1050
Definition: RS.h:130
#define RDEFAULT_MIN1
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPolylineData.h:32
double getBulgeAt(int i) const
Definition: RPolylineData.h:122
bool isClosed() const
Definition: RPolyline.cpp:568
int countSegments() const
Definition: RPolylineData.h:114
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition: RPolylineData.h:158
void simplify(double angleTolerance)
Definition: RPolylineData.h:174
void insertVertex(int index, const RVector &vertex)
Definition: RPolyline.cpp:256
void removeLastVertex()
Definition: RPolyline.cpp:323
virtual QList< QSharedPointer< RShape > > getExploded(int segments=RDEFAULT_MIN1) const
Definition: RPolyline.cpp:806
double getDirection2() const
Definition: RPolylineData.h:134
RPainterPath toPainterPath() const
Definition: RPolylineData.h:170
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:50
void setPolylineGen(bool on)
Definition: RPolylineData.h:188
void autoClose()
Definition: RPolylineData.h:162
virtual double getDirection2() const
Definition: RPolyline.cpp:1064
void removeVertex(int index)
Definition: RPolylineData.h:110
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual double getDistanceTo(const RVector &point, bool limited=true, double range=0.0, bool draft=false, double strictRange=RMAXDOUBLE) const
Definition: RPolylineData.h:64
void normalize(double tolerance=RS::PointTolerance)
Removes duplicate vertices.
Definition: RPolyline.cpp:94
void setClosed(bool on)
Definition: RPolylineData.h:150
bool reverse()
Definition: RPolylineData.h:138
void prependVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolylineData.h:98
void appendVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolyline.cpp:242
void removeLastVertex()
Definition: RPolylineData.h:106
bool isClosed() const
Definition: RPolylineData.h:154
virtual RShape * castToShape()
Definition: RPolylineData.h:60
RDocument * document
Definition: RObject.h:267