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 RS::EntityType getType() const {
51  return RS::EntitySpline;
52  }
53  virtual RBox getBoundingBox(bool ignoreEmpty=false) const;
54 
55  virtual QList<RRefPoint> getReferencePoints(RS::ProjectionRenderingHint hint = RS::RenderTop) const;
56 
57  virtual bool moveReferencePoint(const RVector& referencePoint,
58  const RVector& targetPoint);
59 
60  void setShape(const RSpline& s) {
61  copySpline(s);
62  }
63 
64  void appendControlPoint(const RVector& point) {
66  }
67 
68  void appendFitPoint(const RVector& point) {
70  }
71 
72  void prependFitPoint(const RVector& point) {
74  }
75 
76  void insertFitPointAt(const RVector& point) {
78  }
79 
80  void removeFitPointAt(const RVector& point) {
82  }
83 
84  void setPeriodic(bool on) {
86  }
87 
88  bool isValid() const {
89  return RSpline::isValid();
90  }
91 
92  int getDegree() const {
93  return RSpline::getDegree();
94  }
95 
96  double getDirection1() const {
97  return RSpline::getDirection1();
98  }
99 
100  double getDirection2() const {
101  return RSpline::getDirection2();
102  }
103 
105  return RSpline::getStartPoint();
106  }
107 
109  return RSpline::getEndPoint();
110  }
111 
112  void setStartPoint(const RVector& sp) {
114  }
115 
116  void setEndPoint(const RVector& ep) {
118  }
119 
120  bool reverse() {
121  return RSpline::reverse();
122  }
123 
124  RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
125  return RSpline::getTrimEnd(trimPoint, clickPoint);
126  }
127  bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
128  return RSpline::trimStartPoint(trimPoint, clickPoint, extend);
129  }
130  bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
131  return RSpline::trimEndPoint(trimPoint, clickPoint, extend);
132  }
133 
134  bool isClosed() const {
135  return RSpline::isClosed();
136  }
137 
138  bool isPeriodic() const {
139  return RSpline::isPeriodic();
140  }
141 
144  }
145 
147  return RSpline::getTangentAtEnd();
148  }
149 
150  //void updateTangentsPeriodic() {
151  // RSpline::updateTangentsPeriodic();
152  //}
153 
154  QList<RVector> getControlPoints() const {
155  return RSpline::getControlPoints();
156  }
157 
158  QList<RVector> getControlPointsWrapped() const {
160  }
161 
162  QList<RVector> getFitPoints() const {
163  return RSpline::getFitPoints();
164  }
165 
166  QList<double> getKnotVector() const {
167  return RSpline::getKnotVector();
168  }
169 
170  QList<double> getActualKnotVector() const {
172  }
173 
174  QList<double> getWeights() const {
175  return RSpline::getWeights();
176  }
177 
178  double getLength() const {
179  return RSpline::getLength();
180  }
181  RVector getPointAt(double t) const {
182  return RSpline::getPointAt(t);
183  }
184  RVector getPointAtDistance(double distance) const {
185  return RSpline::getPointAtDistance(distance);
186  }
187  double getAngleAt(double distance, RS::From from = RS::FromStart) const {
188  return RSpline::getAngleAt(distance, from);
189  }
190 
191  RPolyline toPolyline(int segments) const {
192  return RSpline::toPolyline(segments);
193  }
194 
195  RPolyline approximateWithArcs(double tolerance) const {
196  return RSpline::approximateWithArcs(tolerance);
197  }
198 
199  void simplify(double tolerance) {
200  RSpline s = RSpline::simplify(tolerance);
201  setShape(s);
202  }
203 
204  //RSpline getSubSpline(double d1, double d2) const {
205  // return RSpline::getSubSpline(d1, d2);
206  //}
207 
208  virtual RShape* castToShape() {
209  return this;
210  }
211 
212  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false, bool segment = false) const;
213 
214  virtual void update() const {
215  //RSpline::update();
216  }
217 };
218 
222 Q_DECLARE_METATYPE(QSharedPointer<RSplineData>)
223 
224 #endif
Represents a box e.g.
Definition: RBox.h:43
Ending
Entity ending.
Definition: RS.h:152
int getDegree() const
Definition: RSplineData.h:92
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:1654
RVector getTangentAtStart() const
Definition: RSplineData.h:142
QList< RVector > getFitPoints() const
Definition: RSpline.cpp:421
void setStartPoint(const RVector &sp)
Definition: RSplineData.h:112
virtual RS::EntityType getType() const
Definition: RSplineData.h:50
void setShape(const RSpline &s)
Definition: RSplineEntity.cpp:254
RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RSplineData.h:124
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define RDEFAULT_RBOX
Definition: RBox.h:32
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RSpline.h:55
virtual void update() const
Entities can reimplement this function to invalidate any internal cache (mark the entity as dirty)...
Definition: RSplineData.h:214
bool isValid() const
Definition: RSplineData.h:88
bool isValid() const
Definition: RSpline.cpp:1219
void setEndPoint(const RVector &v)
Definition: RSpline.cpp:674
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
void insertFitPointAt(const RVector &point)
Definition: RSplineData.h:76
QList< RVector > getFitPoints() const
Definition: RSplineData.h:162
void copySpline(const RSpline &other)
Definition: RSpline.cpp:53
void removeFitPointAt(const RVector &point)
Definition: RSplineData.h:80
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false) const
Definition: REntityData.h:104
bool isClosed() const
Definition: RSpline.cpp:533
RVector getPointAt(double t) const
Definition: RSpline.cpp:973
void setPeriodic(bool on)
Definition: RSpline.cpp:512
void simplify(double tolerance)
Definition: RSplineData.h:199
QList< RVector > getControlPoints() const
Definition: RSpline.cpp:284
Spline.
Definition: RS.h:119
void removeFitPointAt(const RVector &point)
Definition: RSpline.cpp:383
bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSplineData.h:127
bool isPeriodic() const
Definition: RSplineData.h:138
QList< double > getWeights() const
Definition: RSpline.cpp:476
QList< double > getWeights() const
Definition: RSplineData.h:174
RPolyline toPolyline(int segments) const
Definition: RSplineData.h:191
QList< RVector > getControlPoints() const
Definition: RSplineData.h:154
virtual RShape * castToShape()
Definition: RSplineData.h:208
virtual RVector getStartPoint() const
Definition: RSpline.cpp:661
bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSplineData.h:130
RVector getEndPoint() const
Definition: RSplineData.h:108
RSpline simplify(double tolerance)
Definition: RSpline.cpp:1345
ProjectionRenderingHint
Sets the current rendering hint for exports.
Definition: RS.h:131
void insertFitPointAt(const RVector &point)
Inserts a fit point at the point on the spline closest to the given position.
Definition: RSpline.cpp:340
RPolyline approximateWithArcs(double tolerance) const
Definition: RSpline.cpp:784
double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RSplineData.h:187
void prependFitPoint(const RVector &point)
Definition: RSplineData.h:72
void setEndPoint(const RVector &ep)
Definition: RSplineData.h:116
void setStartPoint(const RVector &v)
Definition: RSpline.cpp:665
RVector getTangentAtStart() const
Definition: RSpline.cpp:699
RVector getPointAtDistance(double distance) const
Definition: RSplineData.h:184
bool reverse()
Definition: RSplineData.h:120
void setShape(const RSpline &s)
Definition: RSplineData.h:60
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
Definition: REntityData.cpp:275
double getLength() const
Definition: RSplineData.h:178
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:986
QList< double > getActualKnotVector() const
Definition: RSpline.cpp:447
virtual double getDirection1() const
Definition: RSpline.cpp:623
void appendControlPoint(const RVector &point)
Definition: RSplineData.h:64
void setPeriodic(bool on)
Definition: RSplineData.h:84
void appendControlPoint(const RVector &point)
Disabled for splines (bad performance).
Definition: RSpline.cpp:250
QList< double > getActualKnotVector() const
Definition: RSplineData.h:170
Spline entity.
Definition: RSplineEntity.h:42
bool isClosed() const
Definition: RSplineData.h:134
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const =0
Definition: RS.h:201
QList< double > getKnotVector() const
Definition: RSpline.cpp:443
Definition: RS.h:132
QList< double > getKnotVector() const
Definition: RSplineData.h:166
RVector getTangentAtEnd() const
Definition: RSpline.cpp:714
virtual double getDirection2() const
Definition: RSpline.cpp:641
RPolyline approximateWithArcs(double tolerance) const
Definition: RSplineData.h:195
virtual double getLength() const
Definition: RSpline.cpp:948
RVector getTangentAtEnd() const
Definition: RSplineData.h:146
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:200
void appendFitPoint(const RVector &point)
Definition: RSplineData.h:68
double getDirection1() const
Definition: RSplineData.h:96
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RSplineData.h:39
double getDirection2() const
Definition: RSplineData.h:100
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
virtual bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RSpline.cpp:1632
virtual bool reverse()
Definition: RSpline.cpp:1182
virtual double getAngleAt(double distance, RS::From from=RS::FromStart) const
Definition: RSpline.cpp:991
int getDegree() const
Definition: RSpline.cpp:501
Interface for geometrical shape classes.
Definition: RShape.h:52
virtual RVector getEndPoint() const
Definition: RSpline.cpp:670
static const RVector invalid
invalid vector
Definition: RVector.h:317
bool isPeriodic() const
Definition: RSpline.cpp:571
RPolyline toPolyline(int segments) const
Definition: RSpline.cpp:791
void appendFitPoint(const RVector &point)
Appends a fit point.
Definition: RSpline.cpp:324
RVector getStartPoint() const
Definition: RSplineData.h:104
QList< RVector > getControlPointsWrapped() const
Definition: RSplineData.h:158
RVector getPointAt(double t) const
Definition: RSplineData.h:181
RSplineData data
Definition: RSplineEntity.h:335
virtual RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RSpline.cpp:1620
RDocument * document
Definition: RObject.h:271
QList< RVector > getControlPointsWrapped() const
Definition: RSpline.cpp:291
void prependFitPoint(const RVector &point)
Prepends a fit point.
Definition: RSpline.cpp:332