QCAD
Open Source 2D CAD
RLineEntity.h
Go to the documentation of this file.
1 
20 #ifndef RLINEENTITY_H
21 #define RLINEENTITY_H
22 
23 #include "entity_global.h"
24 
25 #include "REntity.h"
26 #include "RLineData.h"
27 
28 class RDocument;
29 class RExporter;
30 
39 
40 public:
52 
59 
62 
63 public:
64  RLineEntity(RDocument* document, const RLineData& data,
65  RObject::Id objectId = RObject::INVALID_ID);
66  RLineEntity(const RLineEntity& other);
67  virtual ~RLineEntity();
68 
69  static void init();
70 
71  static QSet<RPropertyTypeId> getStaticPropertyTypeIds() {
73  }
74 
75  virtual RLineEntity* clone() const {
76  return new RLineEntity(*this);
77  }
78 
79  virtual RS::EntityType getType() const {
80  return RS::EntityLine;
81  }
82 
83  bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
84  RTransaction* transaction=NULL);
85  QPair<QVariant, RPropertyAttributes> getProperty(
86  RPropertyTypeId& propertyTypeId,
87  bool humanReadable = false, bool noAttributes = false);
88 
89  virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
90 
91  virtual RLineData& getData() {
92  return data;
93  }
94 
95  virtual const RLineData& getData() const {
96  return data;
97  }
98 
99  void setShape(const RLine& l);
100 
101  void setStartPoint(const RVector& p) {
102  data.setStartPoint(p);
103  }
104 
106  return data.getStartPoint();
107  }
108 
109  void setEndPoint(const RVector& p) {
110  data.setEndPoint(p);
111  }
112 
114  return data.getEndPoint();
115  }
116 
117  double getAngle() const {
118  return data.getAngle();
119  }
120 
121  double getDirection1() const {
122  return data.getDirection1();
123  }
124 
125  double getDirection2() const {
126  return data.getDirection2();
127  }
128 
129  bool reverse() {
130  return data.reverse();
131  }
132 
133  RS::Side getSideOfPoint(const RVector& point) const {
134  return data.getSideOfPoint(point);
135  }
136 
138  const RVector& trimPoint) {
139  return data.getTrimEnd(coord, trimPoint);
140  }
141 
142  void trimStartPoint(const RVector& p) {
143  return data.trimStartPoint(p);
144  }
145  void trimEndPoint(const RVector& p) {
146  return data.trimEndPoint(p);
147  }
148 
149  double getLength() const {
150  return data.getLength();
151  }
152 
153 protected:
154  virtual void print(QDebug dbg) const;
155 
156 protected:
158 };
159 
161 Q_DECLARE_METATYPE(QSharedPointer<RLineEntity>)
162 Q_DECLARE_METATYPE(QSharedPointer<RLineEntity>*)
163 
164 #endif
virtual RS::EntityType getType() const
Definition: RLineEntity.h:79
RLineData data
Definition: RLineEntity.h:157
Ending
Entity ending.
Definition: RS.h:136
static RPropertyTypeId PropertyLineweight
Definition: RLineEntity.h:49
static RPropertyTypeId PropertyEndPointY
Definition: RLineEntity.h:57
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
double getAngle() const
Definition: RLineEntity.h:117
static RPropertyTypeId PropertyType
Definition: RLineEntity.h:44
void setStartPoint(const RVector &p)
Definition: RLineEntity.h:101
static RPropertyTypeId PropertyDrawOrder
Definition: RLineEntity.h:51
static RPropertyTypeId PropertyLength
Definition: RLineEntity.h:61
RVector getStartPoint() const
Definition: RLineEntity.h:105
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:75
bool reverse()
Definition: RLineEntity.h:129
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RLineEntity.h:41
RS::Side getSideOfPoint(const RVector &point) const
Definition: RLineEntity.h:133
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RPropertyTypeId.h:57
virtual RLineData & getData()
Definition: RLineEntity.h:91
static RPropertyTypeId PropertyEndPointZ
Definition: RLineEntity.h:58
int Id
Definition: RObject.h:53
virtual const RLineData & getData() const
Definition: RLineEntity.h:95
Transaction implementation.
Definition: RTransaction.h:70
static RPropertyTypeId PropertyLayer
Definition: RLineEntity.h:46
static RPropertyTypeId PropertyStartPointX
Definition: RLineEntity.h:53
void trimStartPoint(const RVector &p)
Definition: RLineEntity.h:142
virtual RLineEntity * clone() const
Definition: RLineEntity.h:75
static const Id INVALID_ID
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RObject.h:54
Side
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:129
static RPropertyTypeId PropertyLinetypeScale
Definition: RLineEntity.h:48
RS::Ending getTrimEnd(const RVector &coord, const RVector &trimPoint)
Definition: RLineEntity.h:137
Line.
Definition: RS.h:83
Line entity.
Definition: RLineEntity.h:38
static RPropertyTypeId PropertyBlock
Definition: RLineEntity.h:45
static RPropertyTypeId PropertyAngle
Definition: RLineEntity.h:60
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 *)
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RLineData.h:39
static RPropertyTypeId PropertyColor
Definition: RLineEntity.h:50
static RPropertyTypeId PropertyHandle
Definition: RLineEntity.h:42
void trimEndPoint(const RVector &p)
Definition: RLineEntity.h:145
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 QSet< RPropertyTypeId > getStaticPropertyTypeIds()
Definition: RLineEntity.h:71
static void init()
Definition: REntity.cpp:71
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition: REntity.cpp:277
Abstract base class for exporters.
Definition: RExporter.h:63
double getDirection2() const
Definition: RLineEntity.h:125
double getDirection1() const
Definition: RLineEntity.h:121
double getLength() const
Definition: RLineEntity.h:149
static RPropertyTypeId PropertyStartPointZ
Definition: RLineEntity.h:55
static RPropertyTypeId PropertyEndPointX
Definition: RLineEntity.h:56
void setEndPoint(const RVector &p)
Definition: RLineEntity.h:109
RVector getEndPoint() const
Definition: RLineEntity.h:113
static RPropertyTypeId PropertyLinetype
Definition: RLineEntity.h:47
static RPropertyTypeId PropertyProtected
Definition: RLineEntity.h:43
virtual void exportEntity(RExporter &e, bool preview=false, bool forceSelected=false) const =0
Exports the entity to the given exporter.
static RPropertyTypeId PropertyStartPointY
Definition: RLineEntity.h:54
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: REntity.cpp:385