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 RS::EntityType getType() const {
55  return RS::EntityPolyline;
56  }
57  virtual QList<RBox> getBoundingBoxes(bool ignoreEmpty=false) const;
58 
59  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
60 
61  virtual bool moveReferencePoint(const RVector& referencePoint, const RVector& targetPoint);
62 
63  virtual RShape* castToShape() {
64  return this;
65  }
66 
67  virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false, double strictRange = RMAXDOUBLE) const {
68  Q_UNUSED(draft)
69 
70  double ret = RPolyline::getDistanceTo(point, limited, strictRange);
71  if (ret>range) {
72  return RNANDOUBLE;
73  }
74  return ret;
75  }
76 
78  return *this;
79  }
80 
81  void clear() {
83  }
84 
85  void normalize(double tolerance = RS::PointTolerance) {
86  RPolyline::normalize(tolerance);
87  }
88 
89  QList<RVector> getVertices() const {
90  return RPolyline::getVertices();
91  }
92 
93  RVector getVertexAt(int i) const {
94  return RPolyline::getVertexAt(i);
95  }
96 
97  void appendVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
98  RPolyline::appendVertex(vertex, bulge, w1, w2);
99  }
100 
101  void prependVertex(const RVector& vertex, double bulge = 0.0, double w1 = 0.0, double w2 = 0.0) {
102  RPolyline::prependVertex(vertex, bulge, w1, w2);
103  }
104 
105  void insertVertex(int index, const RVector& vertex) {
106  RPolyline::insertVertex(index, vertex);
107  }
108 
111  }
112 
113  void removeVertex(int index) {
115  }
116 
117  int countSegments() const {
118  return RPolyline::countSegments();
119  }
120 
121  QSharedPointer<RShape> getSegmentAt(int i) const {
122  return RPolyline::getSegmentAt(i);
123  }
124 
125  double getBulgeAt(int i) const {
126  return RPolyline::getBulgeAt(i);
127  }
128 
129  void setBulgeAt(int i, double b) {
130  RPolyline::setBulgeAt(i, b);
131  }
132 
133  double getDirection1() const {
134  return RPolyline::getDirection1();
135  }
136 
137  double getDirection2() const {
138  return RPolyline::getDirection2();
139  }
140 
141  bool reverse() {
142  return RPolyline::reverse();
143  }
144 
146  return RPolyline::getEndPoint();
147  }
148 
150  return RPolyline::getStartPoint();
151  }
152 
153  void setClosed(bool on) {
155  }
156 
157  bool isClosed() const {
158  return RPolyline::isClosed();
159  }
160 
161  bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const {
162  return RPolyline::isGeometricallyClosed(tolerance);
163  }
164 
165  bool autoClose() {
167  }
168 
169  bool toLogicallyClosed(double tolerance=RS::PointTolerance) {
170  return RPolyline::toLogicallyClosed(tolerance);
171  }
172 
175  }
176 
177  RS::Orientation getOrientation(bool implicitelyClosed = false) const {
178  return RPolyline::getOrientation(implicitelyClosed);
179  }
180 
181  QList<QSharedPointer<RShape> > getExploded(int segments = RDEFAULT_MIN1) const {
182  return RPolyline::getExploded(segments);
183  }
184 
186  return RPolyline::toPainterPath();
187  }
188 
189  void simplify(double angleTolerance) {
190  RPolyline::simplify(angleTolerance);
191  }
192 
193  QList<RVector> verifyTangency(double toleranceMin = RS::AngleTolerance, double toleranceMax = M_PI_4) {
194  return RPolyline::verifyTangency(toleranceMin, toleranceMax);
195  }
196 
197  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false, bool segment = false) const;
198 
199  virtual QList<RVector> getIntersectionPoints(
200  const REntityData& other, bool limited = true, bool same = false,
201  const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = true) const;
202 
203  void setPolylineGen(bool on) {
204  polylineGen = on;
205  }
206  bool getPolylineGen() const {
207  return polylineGen;
208  }
209 
210 protected:
212 };
213 
217 Q_DECLARE_METATYPE(QSharedPointer<RPolylineData>)
218 
219 #endif
RVector getVertexAt(int i) const
Definition: RPolyline.cpp:380
double getDirection1() const
Definition: RPolylineData.h:133
static const double AngleTolerance
Definition: RS.h:577
bool getPolylineGen() const
Definition: RPolylineData.h:206
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:85
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:344
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define RDEFAULT_RBOX
Definition: RBox.h:32
RPainterPath toPainterPath() const
Definition: RPolyline.cpp:726
void appendVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolylineData.h:97
void setBulgeAt(int i, double b)
Definition: RPolylineData.h:129
QList< RVector > getVertices() const
Definition: RPolyline.cpp:376
virtual double getDistanceTo(const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const
Definition: RPolyline.cpp:1455
bool toLogicallyClosed(double tolerance=RS::PointTolerance)
Definition: RPolylineData.h:169
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false) const
Definition: REntityData.h:104
QList< RVector > getVertices() const
Definition: RPolylineData.h:89
QList< RVector > verifyTangency(double toleranceMin=RS::AngleTolerance, double toleranceMax=M_PI_4)
Verifies the tangency of this polyline.
Definition: RPolyline.cpp:1734
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:458
virtual QList< RBox > getBoundingBoxes(bool ignoreEmpty=false) const
Definition: REntityData.h:140
double getBulgeAt(int i) const
Definition: RPolyline.cpp:432
bool toLogicallyOpen()
Definition: RPolyline.cpp:596
RVector getStartPoint() const
Definition: RPolylineData.h:149
void insertVertex(int index, const RVector &vertex)
Definition: RPolylineData.h:105
#define RNANDOUBLE
Definition: RMath.h:71
int countSegments() const
Definition: RPolyline.cpp:881
RS::Orientation getOrientation(bool implicitelyClosed=false) const
Definition: RPolylineData.h:177
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:131
Polyline entity.
Definition: RPolylineEntity.h:44
QSharedPointer< RShape > getSegmentAt(int i) const
Definition: RPolylineData.h:121
RVector getEndPoint() const
Definition: RPolylineData.h:145
QList< RVector > verifyTangency(double toleranceMin=RS::AngleTolerance, double toleranceMax=M_PI_4)
Definition: RPolylineData.h:193
void clear()
Definition: RPolyline.cpp:97
void prependVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolyline.cpp:263
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition: RPolyline.cpp:578
bool simplify(double angleTolerance=RS::AngleTolerance)
TODO: use douglas peuker.
Definition: RPolyline.cpp:1659
void setBulgeAt(int i, double b)
Definition: RPolyline.cpp:440
static const double PointTolerance
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RS.h:576
virtual RVector getStartPoint() const
Definition: RPolyline.cpp:1043
RVector getVertexAt(int i) const
Definition: RPolylineData.h:93
QList< QSharedPointer< RShape > > getExploded(int segments=RDEFAULT_MIN1) const
Definition: RPolylineData.h:181
QSharedPointer< RShape > getSegmentAt(int i) const
Definition: RPolyline.cpp:895
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...
virtual RS::EntityType getType() const
Definition: RPolylineData.h:54
Q_DECLARE_METATYPE(RMath *)
virtual RVector getEndPoint() const
Definition: RPolyline.cpp:1051
virtual bool reverse()
Definition: RPolyline.cpp:1569
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:46
Polyline.
Definition: RS.h:98
RPolyline getPolylineShape() const
Definition: RPolylineData.h:77
#define RMAXDOUBLE
Definition: RMath.h:63
void clear()
Definition: RPolylineData.h:81
RS::Orientation getOrientation(bool implicitelyClosed=false) const
Definition: RPolyline.cpp:640
bool polylineGen
Definition: RPolylineData.h:211
void setClosed(bool on)
Definition: RPolyline.cpp:570
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
RPolylineData data
Definition: RPolylineEntity.h:303
bool toLogicallyOpen()
Definition: RPolylineData.h:173
virtual double getDirection1() const
Definition: RPolyline.cpp:1085
Definition: RS.h:132
#define RDEFAULT_MIN1
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RPolylineData.h:32
double getBulgeAt(int i) const
Definition: RPolylineData.h:125
bool isClosed() const
Definition: RPolyline.cpp:574
int countSegments() const
Definition: RPolylineData.h:117
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition: RPolylineData.h:161
void simplify(double angleTolerance)
Definition: RPolylineData.h:189
void insertVertex(int index, const RVector &vertex)
Definition: RPolyline.cpp:270
void removeLastVertex()
Definition: RPolyline.cpp:334
Orientation
Definition: RS.h:518
virtual QList< QSharedPointer< RShape > > getExploded(int segments=RDEFAULT_MIN1) const
Definition: RPolyline.cpp:842
double getDirection2() const
Definition: RPolylineData.h:137
RPainterPath toPainterPath() const
Definition: RPolylineData.h:185
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
void setPolylineGen(bool on)
Definition: RPolylineData.h:203
virtual double getDirection2() const
Definition: RPolyline.cpp:1094
void removeVertex(int index)
Definition: RPolylineData.h:113
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:67
void normalize(double tolerance=RS::PointTolerance)
Removes duplicate vertices.
Definition: RPolyline.cpp:107
void setClosed(bool on)
Definition: RPolylineData.h:153
bool reverse()
Definition: RPolylineData.h:141
void prependVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolylineData.h:101
void appendVertex(const RVector &vertex, double bulge=0.0, double w1=0.0, double w2=0.0)
Definition: RPolyline.cpp:256
void removeLastVertex()
Definition: RPolylineData.h:109
bool toLogicallyClosed(double tolerance=RS::PointTolerance)
Definition: RPolyline.cpp:582
bool autoClose()
Definition: RPolylineData.h:165
bool isClosed() const
Definition: RPolylineData.h:157
virtual RShape * castToShape()
Definition: RPolylineData.h:63
RDocument * document
Definition: RObject.h:271