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  virtual RS::EntityType getType() const {
95  return RS::EntitySpline;
96  }
97 
98  bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
99  RTransaction* transaction=NULL);
100  QPair<QVariant, RPropertyAttributes> getProperty(
101  RPropertyTypeId& propertyTypeId,
102  bool humanReadable = false, bool noAttributes = false);
103 
104  virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
105 
106  virtual void setUndone(bool on) {
107  REntity::setUndone(on);
108  data.update();
109  }
110 
111  virtual RSplineData& getData() {
112  return data;
113  }
114 
115  virtual const RSplineData& getData() const {
116  return data;
117  }
118 
119  void setShape(const RSpline& s);
120 
121  bool isValid() const {
122  return data.isValid();
123  }
124 
125  double getTDelta() const {
126  return data.getTDelta();
127  }
128 
129  double getTMin() const {
130  return data.getTMin();
131  }
132 
133  double getTMax() const {
134  return data.getTMax();
135  }
136 
137  double getTAtPoint(const RVector& point) const {
138  return data.getTAtPoint(point);
139  }
140 
141  double getTAtDistance(double distance) const {
142  return data.getTAtDistance(distance);
143  }
144 
145  int getDegree() const {
146  return data.getDegree();
147  }
148 
149  double getDirection1() const {
150  return data.getDirection1();
151  }
152 
153  double getDirection2() const {
154  return data.getDirection2();
155  }
156 
157  RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
158  return data.getTrimEnd(trimPoint, clickPoint);
159  }
160 
161  bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
162  return data.trimStartPoint(trimPoint, clickPoint, extend);
163  }
164  bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
165  return data.trimEndPoint(trimPoint, clickPoint, extend);
166  }
167 
168  QList<RSpline> splitAtPoints(const QList<RVector>& points) const {
169  return data.splitAtPoints(points);
170  }
171  QList<RSpline> splitAtParams(const QList<double>& params) const {
172  return data.splitAtParams(params);
173  }
174 
176  return data.getTangentAtStart();
177  }
178 
180  return data.getTangentAtEnd();
181  }
182 
183  bool isClosed() const {
184  return data.isClosed();
185  }
186 
187  bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const {
188  return data.isGeometricallyClosed(tolerance);
189  }
190 
191  bool isPeriodic() const {
192  return data.isPeriodic();
193  }
194 
195  void appendControlPoint(const RVector& point) {
196  data.appendControlPoint(point);
197  }
198 
199  void appendFitPoint(const RVector& point) {
200  data.appendFitPoint(point);
201  }
202 
203  void prependFitPoint(const RVector& point) {
204  data.prependFitPoint(point);
205  }
206 
207  void insertFitPointAt(const RVector& point) {
208  data.insertFitPointAt(point);
209  }
210 
211  void removeFitPointAt(const RVector& point) {
212  data.removeFitPointAt(point);
213  }
214 
215  void setPeriodic(bool on) {
216  data.setPeriodic(on);
217  }
218 
219  QList<RVector> getControlPoints() const {
220  return data.getControlPoints();
221  }
222 
223  QList<RVector> getControlPointsWrapped() const {
224  return data.getControlPointsWrapped();
225  }
226 
227  int countControlPoints() const {
228  return data.countControlPoints();
229  }
230 
231  QList<RVector> getFitPoints() const {
232  return data.getFitPoints();
233  }
234 
235  bool hasFitPoints() const {
236  return data.hasFitPoints();
237  }
238 
239  int countFitPoints() const {
240  return data.countFitPoints();
241  }
242 
243  QList<double> getKnotVector() const {
244  return data.getKnotVector();
245  }
246 
247  QList<double> getActualKnotVector() const {
248  return data.getActualKnotVector();
249  }
250 
251  QList<double> getWeights() const {
252  return data.getWeights();
253  }
254 
255  //RSpline getSubSpline(double d1, double d2) const {
256  // return data.getSubSpline(d1, d2);
257  //}
258 
259  double getLength() const {
260  return data.getLength();
261  }
262 
263  RVector getPointAt(double t) const {
264  return data.getPointAt(t);
265  }
266 
267  RVector getPointAtDistance(double distance) const {
268  return data.getPointAtDistance(distance);
269  }
270 
271  double getAngleAt(double distance, RS::From from = RS::FromStart) const {
272  return data.getAngleAt(distance, from);
273  }
274 
276  return data.getStartPoint();
277  }
278 
280  return data.getEndPoint();
281  }
282 
283  void setStartPoint(const RVector& sp) {
284  return data.setStartPoint(sp);
285  }
286 
287  void setEndPoint(const RVector& ep) {
288  return data.setEndPoint(ep);
289  }
290 
291  RPolyline toPolyline(int segments) const {
292  return data.toPolyline(segments);
293  }
294 
295  RPolyline approximateWithArcs(double tolerance) const {
296  return data.approximateWithArcs(tolerance);
297  }
298 
299  bool reverse() {
300  return data.reverse();
301  }
302 
303  RS::Side getSideOfPoint(const RVector& point) const {
304  return data.getSideOfPoint(point);
305  }
306 
307  virtual int getComplexity() const;
308 
309  QList<QSharedPointer<RShape> > getExploded(int segments = RDEFAULT_MIN1) const {
310  return data.getExploded(segments);
311  }
312 
313  void simplify(double tolerance) {
314  data.simplify(tolerance);
315  }
316 
317  /*
318  double getAngle() const {
319  return data.getAngle();
320  }
321 
322  double getDirection1() const {
323  return data.getDirection1();
324  }
325 
326  double getDirection2() const {
327  return data.getDirection2();
328  }
329 
330  RS::Side getSideOfPoint(const RVector& point) const {
331  return data.getSideOfPoint(point);
332  }
333  */
334 
335 protected:
336  virtual void print(QDebug dbg) const;
337 
338 protected:
340 };
341 
343 Q_DECLARE_METATYPE(QSharedPointer<RSplineEntity>)
344 Q_DECLARE_METATYPE(QSharedPointer<RSplineEntity>*)
345 
346 #endif
static RPropertyTypeId PropertyDisplayedColor
Definition: RSplineEntity.h:55
QList< QSharedPointer< RShape > > getExploded(int segments=RDEFAULT_MIN1) const
Definition: RSplineEntity.h:309
Ending
Entity ending.
Definition: RS.h:152
double getTAtPoint(const RVector &point) const
Definition: RSplineEntity.h:137
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:287
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSpline.h:55
double getDirection1() const
Definition: RSplineEntity.h:149
RVector getStartPoint() const
Definition: RSplineEntity.h:275
QList< RVector > getControlPoints() const
Definition: RSplineEntity.h:219
double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RSplineEntity.h:271
double getTMax() const
Definition: RSplineEntity.h:133
static RPropertyTypeId PropertyDrawOrder
Definition: RSplineEntity.h:56
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
RVector getTangentAtStart() const
Definition: RSplineEntity.h:175
#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:161
QList< RVector > getFitPoints() const
Definition: RSplineEntity.h:231
void removeFitPointAt(const RVector &point)
Definition: RSplineEntity.h:211
virtual RS::EntityType getType() const
Definition: RSplineEntity.h:94
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
double getTMin() const
Definition: RSplineEntity.h:129
Spline.
Definition: RS.h:119
QList< double > getKnotVector() const
Definition: RSplineEntity.h:243
bool isGeometricallyClosed(double tolerance=RS::PointTolerance) const
Definition: RSplineEntity.h:187
void prependFitPoint(const RVector &point)
Definition: RSplineEntity.h:203
static RPropertyTypeId PropertyLineweight
Definition: RSplineEntity.h:53
RPolyline approximateWithArcs(double tolerance) const
Definition: RSplineEntity.h:295
Transaction implementation.
Definition: RTransaction.h:74
void appendControlPoint(const RVector &point)
Definition: RSplineEntity.h:195
QList< double > getActualKnotVector() const
Definition: RSplineEntity.h:247
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:267
bool isValid() const
Definition: RSplineEntity.h:121
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:168
static RPropertyTypeId PropertyDegree
Definition: RSplineEntity.h:66
static RPropertyTypeId PropertyPeriodic
Definition: RSplineEntity.h:65
virtual int getComplexity() const
Definition: REntity.h:619
static const double PointTolerance
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RS.h:554
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:183
double getTDelta() const
Definition: RSplineEntity.h:125
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:171
virtual RSplineEntity * clone() const
Definition: RSplineEntity.h:90
RPolyline toPolyline(int segments) const
Definition: RSplineEntity.h:291
void setPeriodic(bool on)
Definition: RSplineEntity.h:215
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:141
int countFitPoints() const
Definition: RSplineEntity.h:239
double getDirection2() const
Definition: RSplineEntity.h:153
Definition: RS.h:201
void appendFitPoint(const RVector &point)
Definition: RSplineEntity.h:199
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:157
static void init()
Definition: REntity.cpp:82
virtual void setUndone(bool on)
Definition: RSplineEntity.h:106
bool isPeriodic() const
Definition: RSplineEntity.h:191
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:259
RVector getTangentAtEnd() const
Definition: RSplineEntity.h:179
Abstract base class for exporters.
Definition: RExporter.h:71
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2016 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:115
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSplineData.h:39
int getDegree() const
Definition: RSplineEntity.h:145
bool reverse()
Definition: RSplineEntity.h:299
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
QList< double > getWeights() const
Definition: RSplineEntity.h:251
static RPropertyTypeId PropertyTotalLength
Definition: RSplineEntity.h:77
void simplify(double tolerance)
Definition: RSplineEntity.h:313
bool hasFitPoints() const
Definition: RSplineEntity.h:235
RS::Side getSideOfPoint(const RVector &point) const
Definition: RSplineEntity.h:303
static RPropertyTypeId PropertyProtected
Definition: RSplineEntity.h:47
virtual RSplineData & getData()
Definition: RSplineEntity.h:111
RVector getEndPoint() const
Definition: RSplineEntity.h:279
static RPropertyTypeId PropertyControlPointNX
Definition: RSplineEntity.h:58
static RPropertyTypeId PropertyFitPointNX
Definition: RSplineEntity.h:61
static const RVector invalid
invalid vector
Definition: RVector.h:314
bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSplineEntity.h:164
QList< RVector > getControlPointsWrapped() const
Definition: RSplineEntity.h:223
void insertFitPointAt(const RVector &point)
Definition: RSplineEntity.h:207
void setStartPoint(const RVector &sp)
Definition: RSplineEntity.h:283
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:227
RSplineData data
Definition: RSplineEntity.h:339
RVector getPointAt(double t) const
Definition: RSplineEntity.h:263
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: REntity.cpp:428