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