QCAD
Open Source 2D CAD
RPolylineEntity.h
Go to the documentation of this file.
1 
20 #ifndef RPOLYLINEENTITY_H
21 #define RPOLYLINEENTITY_H
22 
23 #include "entity_global.h"
24 
25 #include "REntity.h"
26 #include "RPolylineData.h"
27 
28 class RDocument;
29 class RExporter;
30 class RArc;
31 class RLine;
32 
41 
42 public:
54 
61 
63 
64 public:
65  RPolylineEntity(RDocument* document, const RPolylineData& data,
66  RObject::Id objectId = RObject::INVALID_ID);
67  RPolylineEntity(const RPolylineEntity& other);
68  virtual ~RPolylineEntity();
69 
70  static void init();
71 
72  static QSet<RPropertyTypeId> getStaticPropertyTypeIds() {
74  }
75 
76  virtual RPolylineEntity* clone() const {
77  return new RPolylineEntity(*this);
78  }
79 
80  virtual RS::EntityType getType() const {
81  return RS::EntityPolyline;
82  }
83 
84  void setShape(const RPolyline& l);
85 
86  bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
87  RTransaction* transaction=NULL);
88  QPair<QVariant, RPropertyAttributes> getProperty(
89  RPropertyTypeId& propertyTypeId,
90  bool humanReadable = false, bool noAttributes = false);
91 
92  virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
93 
94  virtual RPolylineData& getData() {
95  return data;
96  }
97 
98  virtual const RPolylineData& getData() const {
99  return data;
100  }
101 
103  return data.getPolylineShape();
104  }
105 
106  void clear() {
107  data.clear();
108  }
109 
110  void normalize() {
111  data.normalize();
112  }
113 
114  int countVertices() const {
115  return data.countVertices();
116  }
117 
118  void appendVertex(const RVector& vertex, double bulge = 0.0) {
119  data.appendVertex(vertex, bulge);
120  }
121 
122  void prependVertex(const RVector& vertex, double bulge = 0.0) {
123  data.prependVertex(vertex, bulge);
124  }
125 
126  void insertVertex(int index, const RVector& vertex) {
127  data.insertVertex(index, vertex);
128  }
129 
130  RVector getVertexAt(int i) const {
131  return data.getVertexAt(i);
132  }
133 
135  data.removeLastVertex();
136  }
137 
138  void removeVertex(int index) {
139  data.removeVertex(index);
140  }
141 
142  int countSegments() const {
143  return data.countSegments();
144  }
145 
146  QSharedPointer<RShape> getSegmentAt(int i) const {
147  return data.getSegmentAt(i);
148  }
149 
150  double getBulgeAt(int i) const {
151  return data.getBulgeAt(i);
152  }
153 
154  void setBulgeAt(int i, double b) {
155  data.setBulgeAt(i, b);
156  }
157 
158  double getDirection1() const {
159  return data.getDirection1();
160  }
161 
162  double getDirection2() const {
163  return data.getDirection2();
164  }
165 
166  bool reverse() {
167  return data.reverse();
168  }
169 
171  return data.getEndPoint();
172  }
173 
175  return data.getStartPoint();
176  }
177 
178  void setClosed(bool on) {
179  data.setClosed(on);
180  }
181 
182  bool isClosed() const {
183  return data.isClosed();
184  }
185 
186  bool isGeometricallyClosed() const {
187  return data.isGeometricallyClosed();
188  }
189 
190  double getLength() const {
191  return data.getLength();
192  }
193 
194  QList<QSharedPointer<RShape> > getExploded() const {
195  return data.getExploded();
196  }
197 
198  virtual int getComplexity() const {
199  return countSegments();
200  }
201 
202  void simplify(double angleTolerance) {
203  data.simplify(angleTolerance);
204  }
205 
206  void setPolylineGen(bool on) {
207  data.setPolylineGen(on);
208  }
209  bool getPolylineGen() const {
210  return data.getPolylineGen();
211  }
212 
213 protected:
214  virtual void print(QDebug dbg) const;
215 
216 protected:
218 };
219 
221 Q_DECLARE_METATYPE(QSharedPointer<RPolylineEntity>)
222 Q_DECLARE_METATYPE(QSharedPointer<RPolylineEntity>*)
223 
224 #endif
void removeLastVertex()
Definition: RPolylineEntity.h:134
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPolylineData.h:39
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
bool reverse()
Definition: RPolylineEntity.h:166
static RPropertyTypeId PropertyColor
Definition: RPolylineEntity.h:52
QList< QSharedPointer< RShape > > getExploded() const
Definition: RPolylineEntity.h:194
void clear()
Definition: RPolylineEntity.h:106
virtual const RPolylineData & getData() const
Definition: RPolylineEntity.h:98
RVector getVertexAt(int i) const
Definition: RPolylineEntity.h:130
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:75
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
static RPropertyTypeId PropertyBlock
Definition: RPolylineEntity.h:47
static RPropertyTypeId PropertyType
Definition: RPolylineEntity.h:46
bool getPolylineGen() const
Definition: RPolylineEntity.h:209
Low-level mathematical representation of an arc.
Definition: RArc.h:41
static RPropertyTypeId PropertyDrawOrder
Definition: RPolylineEntity.h:53
bool isGeometricallyClosed() const
Definition: RPolylineEntity.h:186
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPropertyTypeId.h:57
double getLength() const
Definition: RPolylineEntity.h:190
virtual RPolylineEntity * clone() const
Definition: RPolylineEntity.h:76
static RPropertyTypeId PropertyVertexNZ
Definition: RPolylineEntity.h:59
int Id
Definition: RObject.h:53
Transaction implementation.
Definition: RTransaction.h:70
static RPropertyTypeId PropertyLayer
Definition: RPolylineEntity.h:48
void setBulgeAt(int i, double b)
Definition: RPolylineEntity.h:154
void setClosed(bool on)
Definition: RPolylineEntity.h:178
RVector getEndPoint() const
Definition: RPolylineEntity.h:170
RVector getStartPoint() const
Definition: RPolylineEntity.h:174
static RPropertyTypeId PropertyClosed
Definition: RPolylineEntity.h:55
static const Id INVALID_ID
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RObject.h:54
virtual RPolylineData & getData()
Definition: RPolylineEntity.h:94
Polyline entity.
Definition: RPolylineEntity.h:40
double getDirection2() const
Definition: RPolylineEntity.h:162
void removeVertex(int index)
Definition: RPolylineEntity.h:138
void setPolylineGen(bool on)
Definition: RPolylineEntity.h:206
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 *)
double getBulgeAt(int i) const
Definition: RPolylineEntity.h:150
void prependVertex(const RVector &vertex, double bulge=0.0)
Definition: RPolylineEntity.h:122
void insertVertex(int index, const RVector &vertex)
Definition: RPolylineEntity.h:126
QSharedPointer< RShape > getSegmentAt(int i) const
Definition: RPolylineEntity.h:146
bool isClosed() const
Definition: RPolylineEntity.h:182
void simplify(double angleTolerance)
Definition: RPolylineEntity.h:202
Polyline.
Definition: RS.h:86
static RPropertyTypeId PropertyProtected
Definition: RPolylineEntity.h:45
static RPropertyTypeId PropertyLineweight
Definition: RPolylineEntity.h:51
void appendVertex(const RVector &vertex, double bulge=0.0)
Definition: RPolylineEntity.h:118
static RPropertyTypeId PropertyLinetype
Definition: RPolylineEntity.h:49
static QSet< RPropertyTypeId > getStaticPropertyTypeIds()
Definition: RPolylineEntity.h:72
RPolylineData data
Definition: RPolylineEntity.h:217
Low-level mathematical representation of a line.
Definition: RLine.h:42
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false)
Definition: REntity.cpp:193
static RPropertyTypeId PropertyBulgeN
Definition: RPolylineEntity.h:60
void normalize()
Definition: RPolylineEntity.h:110
static void init()
Definition: REntity.cpp:71
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPolylineEntity.h:43
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition: REntity.cpp:277
virtual RS::EntityType getType() const
Definition: RPolylineEntity.h:80
Abstract base class for exporters.
Definition: RExporter.h:63
static RPropertyTypeId PropertyVertexNY
Definition: RPolylineEntity.h:58
RPolyline getPolylineShape() const
Definition: RPolylineEntity.h:102
int countSegments() const
Definition: RPolylineEntity.h:142
static RPropertyTypeId PropertyPolylineGen
Definition: RPolylineEntity.h:56
Low-level mathematical representation of an open polyline or closed polyline (= polygon).
Definition: RPolyline.h:49
int countVertices() const
Definition: RPolylineEntity.h:114
static RPropertyTypeId PropertyLength
Definition: RPolylineEntity.h:62
virtual int getComplexity() const
Definition: RPolylineEntity.h:198
static RPropertyTypeId PropertyHandle
Definition: RPolylineEntity.h:44
static RPropertyTypeId PropertyVertexNX
Definition: RPolylineEntity.h:57
double getDirection1() const
Definition: RPolylineEntity.h:158
virtual void exportEntity(RExporter &e, bool preview=false, bool forceSelected=false) const =0
Exports the entity to the given exporter.
static RPropertyTypeId PropertyLinetypeScale
Definition: RPolylineEntity.h:50
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: REntity.cpp:385