QCAD
Open Source 2D CAD
RSplineData.h
Go to the documentation of this file.
1 
20 #ifndef RSPLINEDATA_H
21 #define RSPLINEDATA_H
22 
23 #include "entity_global.h"
24 
25 #include "RBox.h"
26 #include "RDocument.h"
27 #include "REntity.h"
28 #include "RSpline.h"
29 #include "RVector.h"
30 
40 
41  friend class RSplineEntity;
42 
43 protected:
45 
46 public:
47  RSplineData();
48  RSplineData(const RSpline& spline);
49 
50  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
51 
52  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
53 
54  virtual bool moveReferencePoint(const RVector& referencePoint,
55  const RVector& targetPoint);
56 
57  void setShape(const RSpline& s) {
58  copySpline(s);
59  }
60 
61  void appendControlPoint(const RVector& point) {
63  }
64 
65  void appendFitPoint(const RVector& point) {
67  }
68 
69  void prependFitPoint(const RVector& point) {
71  }
72 
73  void insertFitPointAt(const RVector& point) {
75  }
76 
77  void removeFitPointAt(const RVector& point) {
79  }
80 
81  void setPeriodic(bool on) {
83  }
84 
85  bool isValid() const {
86  return RSpline::isValid();
87  }
88 
89  int getDegree() const {
90  return RSpline::getDegree();
91  }
92 
93  double getDirection1() const {
94  return RSpline::getDirection1();
95  }
96 
97  double getDirection2() const {
98  return RSpline::getDirection2();
99  }
100 
102  return RSpline::getStartPoint();
103  }
104 
106  return RSpline::getEndPoint();
107  }
108 
109  void setStartPoint(const RVector& sp) {
111  }
112 
113  void setEndPoint(const RVector& ep) {
115  }
116 
117  bool reverse() {
118  return RSpline::reverse();
119  }
120 
121  RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
122  return RSpline::getTrimEnd(trimPoint, clickPoint);
123  }
124  bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
125  return RSpline::trimStartPoint(trimPoint, clickPoint);
126  }
127  bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
128  return RSpline::trimEndPoint(trimPoint, clickPoint);
129  }
130 
131  bool isClosed() const {
132  return RSpline::isClosed();
133  }
134 
135  bool isPeriodic() const {
136  return RSpline::isPeriodic();
137  }
138 
141  }
142 
144  return RSpline::getTangentAtEnd();
145  }
146 
147  //void updateTangentsPeriodic() {
148  // RSpline::updateTangentsPeriodic();
149  //}
150 
151  QList<RVector> getControlPoints() const {
152  return RSpline::getControlPoints();
153  }
154 
155  QList<RVector> getControlPointsWrapped() const {
157  }
158 
159  QList<RVector> getFitPoints() const {
160  return RSpline::getFitPoints();
161  }
162 
163  QList<double> getKnotVector() const {
164  return RSpline::getKnotVector();
165  }
166 
167  QList<double> getActualKnotVector() const {
169  }
170 
171  QList<double> getWeights() const {
172  return RSpline::getWeights();
173  }
174 
175  double getLength() const {
176  return RSpline::getLength();
177  }
178  RVector getPointAt(double t) const {
179  return RSpline::getPointAt(t);
180  }
181  RVector getPointAtDistance(double distance) const {
182  return RSpline::getPointAtDistance(distance);
183  }
184  double getAngleAt(double distance, RS::From from = RS::FromStart) const {
185  return RSpline::getAngleAt(distance, from);
186  }
187 
188  RPolyline toPolyline(int segments) const {
189  return RSpline::toPolyline(segments);
190  }
191 
192  RPolyline toBiArcPolyline(double tolerance) const {
193  return RSpline::toBiArcPolyline(tolerance);
194  }
195 
196  void simplify(double tolerance) {
197  RSpline s = RSpline::simplify(tolerance);
198  setShape(s);
199  }
200 
201  //RSpline getSubSpline(double d1, double d2) const {
202  // return RSpline::getSubSpline(d1, d2);
203  //}
204 
205  virtual RShape* castToShape() {
206  return this;
207  }
208 
209  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false) const {
210  Q_UNUSED(queryBox)
211  Q_UNUSED(ignoreComplex)
212 
213  // make sure we copy only splines with updated cache:
214  //getExploded();
215 
216  return QList<QSharedPointer<RShape> >() <<
217  QSharedPointer<RShape>(new RSpline(*this));
218  }
219 
220  virtual void update() const {
221  //RSpline::update();
222  }
223 };
224 
228 Q_DECLARE_METATYPE(QSharedPointer<RSplineData>)
229 
230 #endif
Represents a box e.g.
Definition: RBox.h:43
Ending
Entity ending.
Definition: RS.h:150
int getDegree() const
Definition: RSplineData.h:89
Base class for all entity data classes.
Definition: REntityData.h:65
virtual bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSpline.cpp:1587
RVector getTangentAtStart() const
Definition: RSplineData.h:139
QList< RVector > getFitPoints() const
Definition: RSpline.cpp:393
void setStartPoint(const RVector &sp)
Definition: RSplineData.h:109
void setShape(const RSpline &s)
Definition: RSplineEntity.cpp:191
RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RSplineData.h:121
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define RDEFAULT_RBOX
Definition: RBox.h:32
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSpline.h:56
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: RSplineData.h:220
bool isValid() const
Definition: RSplineData.h:85
bool isValid() const
Definition: RSpline.cpp:1157
void setEndPoint(const RVector &v)
Definition: RSpline.cpp:634
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
void insertFitPointAt(const RVector &point)
Definition: RSplineData.h:73
QList< RVector > getFitPoints() const
Definition: RSplineData.h:159
void copySpline(const RSpline &other)
Definition: RSpline.cpp:53
void removeFitPointAt(const RVector &point)
Definition: RSplineData.h:77
bool isClosed() const
Definition: RSpline.cpp:493
RVector getPointAt(double t) const
Definition: RSpline.cpp:911
RSpline()
Creates a spline object without controlPoints.
Definition: RSpline.cpp:36
void setPeriodic(bool on)
Definition: RSpline.cpp:484
void simplify(double tolerance)
Definition: RSplineData.h:196
QList< RVector > getControlPoints() const
Definition: RSpline.cpp:260
void removeFitPointAt(const RVector &point)
Definition: RSpline.cpp:355
bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSplineData.h:124
bool isPeriodic() const
Definition: RSplineData.h:135
QList< double > getWeights() const
Definition: RSpline.cpp:448
QList< double > getWeights() const
Definition: RSplineData.h:171
RPolyline toPolyline(int segments) const
Definition: RSplineData.h:188
QList< RVector > getControlPoints() const
Definition: RSplineData.h:151
virtual RShape * castToShape()
Definition: RSplineData.h:205
virtual RVector getStartPoint() const
Definition: RSpline.cpp:621
bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSplineData.h:127
RVector getEndPoint() const
Definition: RSplineData.h:105
RSpline simplify(double tolerance)
Definition: RSpline.cpp:1276
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:129
void insertFitPointAt(const RVector &point)
Inserts a git point at the point on the spline closest to the given position.
Definition: RSpline.cpp:316
RPolyline toBiArcPolyline(double tolerance) const
Definition: RSplineData.h:192
double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RSplineData.h:184
void prependFitPoint(const RVector &point)
Definition: RSplineData.h:69
void setEndPoint(const RVector &ep)
Definition: RSplineData.h:113
void setStartPoint(const RVector &v)
Definition: RSpline.cpp:625
RVector getTangentAtStart() const
Definition: RSpline.cpp:659
RVector getPointAtDistance(double distance) const
Definition: RSplineData.h:181
bool reverse()
Definition: RSplineData.h:117
void setShape(const RSpline &s)
Definition: RSplineData.h:57
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:262
double getLength() const
Definition: RSplineData.h:175
A graphics document contains and owns entities, layers, user coordinate systems, variables, block definitions, etc.
Definition: RDocument.h:67
virtual bool moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint)=0
Moves the given reference point to the given target point or does nothing if this entity has no refer...
Q_DECLARE_METATYPE(RMath *)
RVector getPointAtDistance(double distance) const
Definition: RSpline.cpp:924
QList< double > getActualKnotVector() const
Definition: RSpline.cpp:419
virtual double getDirection1() const
Definition: RSpline.cpp:583
void appendControlPoint(const RVector &point)
Definition: RSplineData.h:61
void setPeriodic(bool on)
Definition: RSplineData.h:81
void appendControlPoint(const RVector &point)
Disabled for splines (bad performance).
Definition: RSpline.cpp:226
QList< double > getActualKnotVector() const
Definition: RSplineData.h:167
Spline entity.
Definition: RSplineEntity.h:42
bool isClosed() const
Definition: RSplineData.h:131
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
Definition: RS.h:199
QList< double > getKnotVector() const
Definition: RSpline.cpp:415
Definition: RS.h:130
QList< double > getKnotVector() const
Definition: RSplineData.h:163
RVector getTangentAtEnd() const
Definition: RSpline.cpp:674
virtual double getDirection2() const
Definition: RSpline.cpp:601
virtual double getLength() const
Definition: RSpline.cpp:886
RVector getTangentAtEnd() const
Definition: RSplineData.h:143
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:198
void appendFitPoint(const RVector &point)
Definition: RSplineData.h:65
double getDirection1() const
Definition: RSplineData.h:93
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RSplineData.h:39
double getDirection2() const
Definition: RSplineData.h:97
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:50
virtual bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSpline.cpp:1565
virtual bool reverse()
Definition: RSpline.cpp:1120
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false) const
Definition: RSplineData.h:209
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RSpline.cpp:929
int getDegree() const
Definition: RSpline.cpp:473
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual RVector getEndPoint() const
Definition: RSpline.cpp:630
static const RVector invalid
invalid vector
Definition: RVector.h:309
bool isPeriodic() const
Definition: RSpline.cpp:531
RPolyline toBiArcPolyline(double tolerance) const
Definition: RSpline.cpp:722
RPolyline toPolyline(int segments) const
Definition: RSpline.cpp:729
void appendFitPoint(const RVector &point)
Appends a fit point.
Definition: RSpline.cpp:300
RVector getStartPoint() const
Definition: RSplineData.h:101
QList< RVector > getControlPointsWrapped() const
Definition: RSplineData.h:155
RVector getPointAt(double t) const
Definition: RSplineData.h:178
RSplineData data
Definition: RSplineEntity.h:331
virtual RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RSpline.cpp:1553
RDocument * document
Definition: RObject.h:267
QList< RVector > getControlPointsWrapped() const
Definition: RSpline.cpp:267
void prependFitPoint(const RVector &point)
Prepends a fit point.
Definition: RSpline.cpp:308