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