QCAD
Open Source 2D CAD
RSplineEntity.h
Go to the documentation of this file.
1 
20 #ifndef RSPLINEENTITY_H
21 #define RSPLINEENTITY_H
22 
23 #include "entity_global.h"
24 
25 #include "REntity.h"
26 #include "RSplineData.h"
27 
28 class RDocument;
29 class RExporter;
30 
31 #ifndef RDEFAULT_MIN1
32 #define RDEFAULT_MIN1 -1
33 #endif
34 
43 
44 public:
57 
67 // static RPropertyTypeId PropertyUseStartTangent;
68 // static RPropertyTypeId PropertyStartTangentX;
69 // static RPropertyTypeId PropertyStartTangentY;
70 // static RPropertyTypeId PropertyStartTangentZ;
71 // static RPropertyTypeId PropertyUseEndTangent;
72 // static RPropertyTypeId PropertyEndTangentX;
73 // static RPropertyTypeId PropertyEndTangentY;
74 // static RPropertyTypeId PropertyEndTangentZ;
75 
78 
79 public:
80  RSplineEntity(RDocument* document, const RSplineData& data);
81  RSplineEntity(const RSplineEntity& other);
82  virtual ~RSplineEntity();
83 
84  static void init();
85 
86  static QSet<RPropertyTypeId> getStaticPropertyTypeIds() {
88  }
89 
90  virtual RSplineEntity* clone() const {
91  return new RSplineEntity(*this);
92  }
93 
94  bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
95  RTransaction* transaction=NULL);
96  QPair<QVariant, RPropertyAttributes> getProperty(
97  RPropertyTypeId& propertyTypeId,
98  bool humanReadable = false, bool noAttributes = false);
99 
100  virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
101 
102  virtual void setUndone(bool on) {
103  REntity::setUndone(on);
104  data.update();
105  }
106 
107  virtual RSplineData& getData() {
108  return data;
109  }
110 
111  virtual const RSplineData& getData() const {
112  return data;
113  }
114 
115  void setShape(const RSpline& s);
116 
117  bool isValid() const {
118  return data.isValid();
119  }
120 
121  double getTDelta() const {
122  return data.getTDelta();
123  }
124 
125  double getTMin() const {
126  return data.getTMin();
127  }
128 
129  double getTMax() const {
130  return data.getTMax();
131  }
132 
133  double getTAtPoint(const RVector& point) const {
134  return data.getTAtPoint(point);
135  }
136 
137  double getTAtDistance(double distance) const {
138  return data.getTAtDistance(distance);
139  }
140 
141  int getDegree() const {
142  return data.getDegree();
143  }
144 
145  double getDirection1() const {
146  return data.getDirection1();
147  }
148 
149  double getDirection2() const {
150  return data.getDirection2();
151  }
152 
153  RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
154  return data.getTrimEnd(trimPoint, clickPoint);
155  }
156 
157  bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
158  return data.trimStartPoint(trimPoint, clickPoint, extend);
159  }
160  bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
161  return data.trimEndPoint(trimPoint, clickPoint, extend);
162  }
163 
164  QList<RSpline> splitAtPoints(const QList<RVector>& points) const {
165  return data.splitAtPoints(points);
166  }
167  QList<RSpline> splitAtParams(const QList<double>& params) const {
168  return data.splitAtParams(params);
169  }
170 
172  return data.getTangentAtStart();
173  }
174 
176  return data.getTangentAtEnd();
177  }
178 
179  bool isClosed() const {
180  return data.isClosed();
181  }
182 
183  bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const {
184  return data.isGeometricallyClosed(tolerance);
185  }
186 
187  bool isPeriodic() const {
188  return data.isPeriodic();
189  }
190 
191  void appendControlPoint(const RVector& point) {
192  data.appendControlPoint(point);
193  }
194 
195  void appendFitPoint(const RVector& point) {
196  data.appendFitPoint(point);
197  }
198 
199  void prependFitPoint(const RVector& point) {
200  data.prependFitPoint(point);
201  }
202 
203  void insertFitPointAt(const RVector& point) {
204  data.insertFitPointAt(point);
205  }
206 
207  void removeFitPointAt(const RVector& point) {
208  data.removeFitPointAt(point);
209  }
210 
211  void setPeriodic(bool on) {
212  data.setPeriodic(on);
213  }
214 
215  QList<RVector> getControlPoints() const {
216  return data.getControlPoints();
217  }
218 
219  QList<RVector> getControlPointsWrapped() const {
220  return data.getControlPointsWrapped();
221  }
222 
223  int countControlPoints() const {
224  return data.countControlPoints();
225  }
226 
227  QList<RVector> getFitPoints() const {
228  return data.getFitPoints();
229  }
230 
231  bool hasFitPoints() const {
232  return data.hasFitPoints();
233  }
234 
235  int countFitPoints() const {
236  return data.countFitPoints();
237  }
238 
239  QList<double> getKnotVector() const {
240  return data.getKnotVector();
241  }
242 
243  QList<double> getActualKnotVector() const {
244  return data.getActualKnotVector();
245  }
246 
247  QList<double> getWeights() const {
248  return data.getWeights();
249  }
250 
251  //RSpline getSubSpline(double d1, double d2) const {
252  // return data.getSubSpline(d1, d2);
253  //}
254 
255  double getLength() const {
256  return data.getLength();
257  }
258 
259  RVector getPointAt(double t) const {
260  return data.getPointAt(t);
261  }
262 
263  RVector getPointAtDistance(double distance) const {
264  return data.getPointAtDistance(distance);
265  }
266 
267  double getAngleAt(double distance, RS::From from = RS::FromStart) const {
268  return data.getAngleAt(distance, from);
269  }
270 
272  return data.getStartPoint();
273  }
274 
276  return data.getEndPoint();
277  }
278 
279  void setStartPoint(const RVector& sp) {
280  return data.setStartPoint(sp);
281  }
282 
283  void setEndPoint(const RVector& ep) {
284  return data.setEndPoint(ep);
285  }
286 
287  RPolyline toPolyline(int segments) const {
288  return data.toPolyline(segments);
289  }
290 
291  RPolyline approximateWithArcs(double tolerance) const {
292  return data.approximateWithArcs(tolerance);
293  }
294 
295  bool reverse() {
296  return data.reverse();
297  }
298 
299  RS::Side getSideOfPoint(const RVector& point) const {
300  return data.getSideOfPoint(point);
301  }
302 
303  virtual int getComplexity() const;
304 
305  QList<QSharedPointer<RShape> > getExploded(int segments = RDEFAULT_MIN1) const {
306  return data.getExploded(segments);
307  }
308 
309  void simplify(double tolerance) {
310  data.simplify(tolerance);
311  }
312 
313  /*
314  double getAngle() const {
315  return data.getAngle();
316  }
317 
318  double getDirection1() const {
319  return data.getDirection1();
320  }
321 
322  double getDirection2() const {
323  return data.getDirection2();
324  }
325 
326  RS::Side getSideOfPoint(const RVector& point) const {
327  return data.getSideOfPoint(point);
328  }
329  */
330 
331 protected:
332  virtual void print(QDebug dbg) const;
333 
334 protected:
336 };
337 
339 Q_DECLARE_METATYPE(QSharedPointer<RSplineEntity>)
340 Q_DECLARE_METATYPE(QSharedPointer<RSplineEntity>*)
341 
342 #endif
static RPropertyTypeId PropertyDisplayedColor
Definition: RSplineEntity.h:55
QList< QSharedPointer< RShape > > getExploded(int segments=RDEFAULT_MIN1) const
Definition: RSplineEntity.h:305
Ending
Entity ending.
Definition: RS.h:152
double getTAtPoint(const RVector &point) const
Definition: RSplineEntity.h:133
static RPropertyTypeId PropertyLinetype
Definition: RSplineEntity.h:51
static RPropertyTypeId PropertyColor
Definition: RSplineEntity.h:54
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
static RPropertyTypeId PropertyLayer
Definition: RSplineEntity.h:50
void setEndPoint(const RVector &ep)
Definition: RSplineEntity.h:283
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RSpline.h:55
double getDirection1() const
Definition: RSplineEntity.h:145
RVector getStartPoint() const
Definition: RSplineEntity.h:271
QList< RVector > getControlPoints() const
Definition: RSplineEntity.h:215
double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RSplineEntity.h:267
double getTMax() const
Definition: RSplineEntity.h:129
static RPropertyTypeId PropertyDrawOrder
Definition: RSplineEntity.h:56
RVector getTangentAtStart() const
Definition: RSplineEntity.h:171
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
void setUndone(bool on)
Definition: RObject.cpp:68
bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSplineEntity.h:157
QList< RVector > getFitPoints() const
Definition: RSplineEntity.h:227
void removeFitPointAt(const RVector &point)
Definition: RSplineEntity.h:207
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
double getTMin() const
Definition: RSplineEntity.h:125
QList< double > getKnotVector() const
Definition: RSplineEntity.h:239
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition: RSplineEntity.h:183
void prependFitPoint(const RVector &point)
Definition: RSplineEntity.h:199
static RPropertyTypeId PropertyLineweight
Definition: RSplineEntity.h:53
RPolyline approximateWithArcs(double tolerance) const
Definition: RSplineEntity.h:291
Transaction implementation.
Definition: RTransaction.h:74
void appendControlPoint(const RVector &point)
Definition: RSplineEntity.h:191
QList< double > getActualKnotVector() const
Definition: RSplineEntity.h:243
static RPropertyTypeId PropertyFitPointNZ
Definition: RSplineEntity.h:63
#define RDEFAULT_MIN1
Definition: RSplineEntity.h:32
static RPropertyTypeId PropertyLength
Definition: RSplineEntity.h:76
RVector getPointAtDistance(double distance) const
Definition: RSplineEntity.h:263
bool isValid() const
Definition: RSplineEntity.h:117
static RPropertyTypeId PropertyLinetypeScale
Definition: RSplineEntity.h:52
static RPropertyTypeId PropertyBlock
Definition: RSplineEntity.h:49
Side
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:142
QList< RSpline > splitAtPoints(const QList< RVector > &points) const
Definition: RSplineEntity.h:164
static RPropertyTypeId PropertyDegree
Definition: RSplineEntity.h:66
static RPropertyTypeId PropertyPeriodic
Definition: RSplineEntity.h:65
virtual int getComplexity() const
Definition: REntity.h:621
static const double PointTolerance
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RS.h:576
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
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
Q_DECLARE_METATYPE(RMath *)
bool isClosed() const
Definition: RSplineEntity.h:179
double getTDelta() const
Definition: RSplineEntity.h:121
static RPropertyTypeId PropertyHandle
Definition: RSplineEntity.h:46
static RPropertyTypeId PropertyType
Definition: RSplineEntity.h:48
static RPropertyTypeId PropertyFitPointNY
Definition: RSplineEntity.h:62
QList< RSpline > splitAtParams(const QList< double > &params) const
Definition: RSplineEntity.h:167
virtual RSplineEntity * clone() const
Definition: RSplineEntity.h:90
RPolyline toPolyline(int segments) const
Definition: RSplineEntity.h:287
void setPeriodic(bool on)
Definition: RSplineEntity.h:211
static RPropertyTypeId PropertyKnotN
Definition: RSplineEntity.h:64
static RPropertyTypeId PropertyControlPointNZ
Definition: RSplineEntity.h:60
Spline entity.
Definition: RSplineEntity.h:42
double getTAtDistance(double distance) const
Definition: RSplineEntity.h:137
int countFitPoints() const
Definition: RSplineEntity.h:235
double getDirection2() const
Definition: RSplineEntity.h:149
Definition: RS.h:201
void appendFitPoint(const RVector &point)
Definition: RSplineEntity.h:195
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false)
Definition: REntity.cpp:228
static RPropertyTypeId PropertyControlPointNY
Definition: RSplineEntity.h:59
RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RSplineEntity.h:153
static void init()
Definition: REntity.cpp:82
virtual void setUndone(bool on)
Definition: RSplineEntity.h:102
bool isPeriodic() const
Definition: RSplineEntity.h:187
static QSet< RPropertyTypeId > getStaticPropertyTypeIds()
Definition: RSplineEntity.h:86
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition: REntity.cpp:321
double getLength() const
Definition: RSplineEntity.h:255
RVector getTangentAtEnd() const
Definition: RSplineEntity.h:175
Abstract base class for exporters.
Definition: RExporter.h:71
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RSplineEntity.h:45
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:200
virtual const RSplineData & getData() const
Definition: RSplineEntity.h:111
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RSplineData.h:39
int getDegree() const
Definition: RSplineEntity.h:141
bool reverse()
Definition: RSplineEntity.h:295
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
QList< double > getWeights() const
Definition: RSplineEntity.h:247
static RPropertyTypeId PropertyTotalLength
Definition: RSplineEntity.h:77
void simplify(double tolerance)
Definition: RSplineEntity.h:309
bool hasFitPoints() const
Definition: RSplineEntity.h:231
RS::Side getSideOfPoint(const RVector &point) const
Definition: RSplineEntity.h:299
static RPropertyTypeId PropertyProtected
Definition: RSplineEntity.h:47
virtual RSplineData & getData()
Definition: RSplineEntity.h:107
RVector getEndPoint() const
Definition: RSplineEntity.h:275
static RPropertyTypeId PropertyControlPointNX
Definition: RSplineEntity.h:58
static RPropertyTypeId PropertyFitPointNX
Definition: RSplineEntity.h:61
static const RVector invalid
invalid vector
Definition: RVector.h:317
bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSplineEntity.h:160
QList< RVector > getControlPointsWrapped() const
Definition: RSplineEntity.h:219
void insertFitPointAt(const RVector &point)
Definition: RSplineEntity.h:203
void setStartPoint(const RVector &sp)
Definition: RSplineEntity.h:279
virtual void exportEntity(RExporter &e, bool preview=false, bool forceSelected=false) const =0
Exports the entity to the given exporter.
int countControlPoints() const
Definition: RSplineEntity.h:223
RSplineData data
Definition: RSplineEntity.h:335
RVector getPointAt(double t) const
Definition: RSplineEntity.h:259
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: REntity.cpp:468