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:
56 
66 
68 
69 public:
70  RSplineEntity(RDocument* document, const RSplineData& data,
71  RObject::Id objectId = RObject::INVALID_ID);
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  int getDegree() const {
117  return data.getDegree();
118  }
119 
120  double getDirection1() const {
121  return data.getDirection1();
122  }
123 
124  double getDirection2() const {
125  return data.getDirection2();
126  }
127 
129  const RVector& trimPoint) {
130  return data.getTrimEnd(coord, trimPoint);
131  }
132 
133  void trimStartPoint(const RVector& p) {
134  return data.trimStartPoint(p);
135  }
136  void trimEndPoint(const RVector& p) {
137  return data.trimEndPoint(p);
138  }
139 
141  return data.getTangentAtStart();
142  }
143 
145  return data.getTangentAtEnd();
146  }
147 
148  bool isClosed() const {
149  return data.isClosed();
150  }
151 
152  bool isGeometricallyClosed() const {
153  return data.isGeometricallyClosed();
154  }
155 
156  bool isPeriodic() const {
157  return data.isPeriodic();
158  }
159 
160  void appendControlPoint(const RVector& point) {
161  data.appendControlPoint(point);
162  }
163 
164  void setPeriodic(bool on) {
165  data.setPeriodic(on);
166  }
167 
168  QList<RVector> getControlPoints() const {
169  return data.getControlPoints();
170  }
171 
172  QList<RVector> getControlPointsWrapped() const {
173  return data.getControlPointsWrapped();
174  }
175 
176  int countControlPoints() const {
177  return data.countControlPoints();
178  }
179 
180  QList<RVector> getFitPoints() const {
181  return data.getFitPoints();
182  }
183 
184  bool hasFitPoints() const {
185  return data.hasFitPoints();
186  }
187 
188  QList<double> getKnotVector() const {
189  return data.getKnotVector();
190  }
191 
192  QList<double> getActualKnotVector() const {
193  return data.getActualKnotVector();
194  }
195 
196  QList<double> getWeights() const {
197  return data.getWeights();
198  }
199 
200  //RSpline getSubSpline(double d1, double d2) const {
201  // return data.getSubSpline(d1, d2);
202  //}
203 
204  double getLength() const {
205  return data.getLength();
206  }
207 
209  return data.getStartPoint();
210  }
211 
213  return data.getEndPoint();
214  }
215 
216  void setStartPoint(const RVector& sp) {
217  return data.setStartPoint(sp);
218  }
219 
220  void setEndPoint(const RVector& ep) {
221  return data.setEndPoint(ep);
222  }
223 
224  bool reverse() {
225  return data.reverse();
226  }
227 
228  virtual int getComplexity() const;
229 
230  QList<QSharedPointer<RShape> > getExploded(int segments = RDEFAULT_MIN1) const {
231  return data.getExploded(segments);
232  }
233 
234  /*
235  double getAngle() const {
236  return data.getAngle();
237  }
238 
239  double getDirection1() const {
240  return data.getDirection1();
241  }
242 
243  double getDirection2() const {
244  return data.getDirection2();
245  }
246 
247  RS::Side getSideOfPoint(const RVector& point) const {
248  return data.getSideOfPoint(point);
249  }
250  */
251 
252 protected:
253  virtual void print(QDebug dbg) const;
254 
255 protected:
257 };
258 
260 Q_DECLARE_METATYPE(QSharedPointer<RSplineEntity>)
261 Q_DECLARE_METATYPE(QSharedPointer<RSplineEntity>*)
262 
263 #endif
QList< QSharedPointer< RShape > > getExploded(int segments=RDEFAULT_MIN1) const
Definition: RSplineEntity.h:230
Ending
Entity ending.
Definition: RS.h:136
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:220
Low-level mathematical representation of a spline.
Definition: RSpline.h:54
double getDirection1() const
Definition: RSplineEntity.h:120
RVector getStartPoint() const
Definition: RSplineEntity.h:208
QList< RVector > getControlPoints() const
Definition: RSplineEntity.h:168
static RPropertyTypeId PropertyDrawOrder
Definition: RSplineEntity.h:55
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:75
RVector getTangentAtStart() const
Definition: RSplineEntity.h:140
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
virtual void setUndone(bool on)
Definition: RObject.cpp:41
QList< RVector > getFitPoints() const
Definition: RSplineEntity.h:180
virtual RS::EntityType getType() const
Definition: RSplineEntity.h:85
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPropertyTypeId.h:57
Spline.
Definition: RS.h:106
QList< double > getKnotVector() const
Definition: RSplineEntity.h:188
void trimStartPoint(const RVector &p)
Definition: RSplineEntity.h:133
int Id
Definition: RObject.h:53
static RPropertyTypeId PropertyLineweight
Definition: RSplineEntity.h:53
Transaction implementation.
Definition: RTransaction.h:70
void appendControlPoint(const RVector &point)
Definition: RSplineEntity.h:160
QList< double > getActualKnotVector() const
Definition: RSplineEntity.h:192
static RPropertyTypeId PropertyFitPointNZ
Definition: RSplineEntity.h:62
#define RDEFAULT_MIN1
Definition: RSplineEntity.h:32
static RPropertyTypeId PropertyLength
Definition: RSplineEntity.h:67
bool isValid() const
Definition: RSplineEntity.h:112
static RPropertyTypeId PropertyLinetypeScale
Definition: RSplineEntity.h:52
static const Id INVALID_ID
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RObject.h:54
static RPropertyTypeId PropertyBlock
Definition: RSplineEntity.h:49
RS::Ending getTrimEnd(const RVector &coord, const RVector &trimPoint)
Definition: RSplineEntity.h:128
static RPropertyTypeId PropertyDegree
Definition: RSplineEntity.h:65
static RPropertyTypeId PropertyPeriodic
Definition: RSplineEntity.h:64
virtual int getComplexity() const
Definition: REntity.h:585
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:63
Q_DECLARE_METATYPE(RMath *)
bool isClosed() const
Definition: RSplineEntity.h:148
static RPropertyTypeId PropertyHandle
Definition: RSplineEntity.h:46
static RPropertyTypeId PropertyType
Definition: RSplineEntity.h:48
static RPropertyTypeId PropertyFitPointNY
Definition: RSplineEntity.h:61
bool isGeometricallyClosed() const
Definition: RSplineEntity.h:152
virtual RSplineEntity * clone() const
Definition: RSplineEntity.h:81
void setPeriodic(bool on)
Definition: RSplineEntity.h:164
static RPropertyTypeId PropertyKnotN
Definition: RSplineEntity.h:63
static RPropertyTypeId PropertyControlPointNZ
Definition: RSplineEntity.h:59
Spline entity.
Definition: RSplineEntity.h:42
double getDirection2() const
Definition: RSplineEntity.h:124
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false)
Definition: REntity.cpp:193
static RPropertyTypeId PropertyControlPointNY
Definition: RSplineEntity.h:58
static void init()
Definition: REntity.cpp:71
virtual void setUndone(bool on)
Definition: RSplineEntity.h:97
bool isPeriodic() const
Definition: RSplineEntity.h:156
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:277
double getLength() const
Definition: RSplineEntity.h:204
RVector getTangentAtEnd() const
Definition: RSplineEntity.h:144
Abstract base class for exporters.
Definition: RExporter.h:63
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RSplineEntity.h:45
virtual const RSplineData & getData() const
Definition: RSplineEntity.h:106
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RSplineData.h:39
int getDegree() const
Definition: RSplineEntity.h:116
bool reverse()
Definition: RSplineEntity.h:224
QList< double > getWeights() const
Definition: RSplineEntity.h:196
bool hasFitPoints() const
Definition: RSplineEntity.h:184
void trimEndPoint(const RVector &p)
Definition: RSplineEntity.h:136
static RPropertyTypeId PropertyProtected
Definition: RSplineEntity.h:47
virtual RSplineData & getData()
Definition: RSplineEntity.h:102
RVector getEndPoint() const
Definition: RSplineEntity.h:212
static RPropertyTypeId PropertyControlPointNX
Definition: RSplineEntity.h:57
static RPropertyTypeId PropertyFitPointNX
Definition: RSplineEntity.h:60
QList< RVector > getControlPointsWrapped() const
Definition: RSplineEntity.h:172
void setStartPoint(const RVector &sp)
Definition: RSplineEntity.h:216
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:176
RSplineData data
Definition: RSplineEntity.h:256
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: REntity.cpp:385