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