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:
53 
60 
64 
65 public:
66  RLineEntity(RDocument* document, const RLineData& data);
67  RLineEntity(const RLineEntity& other);
68  virtual ~RLineEntity();
69 
70  static void init();
71 
72  static QSet<RPropertyTypeId> getStaticPropertyTypeIds() {
74  }
75 
76  virtual RLineEntity* clone() const {
77  return new RLineEntity(*this);
78  }
79 
80  virtual RS::EntityType getType() const {
81  return RS::EntityLine;
82  }
83 
84  bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
85  RTransaction* transaction=NULL);
86  QPair<QVariant, RPropertyAttributes> getProperty(
87  RPropertyTypeId& propertyTypeId,
88  bool humanReadable = false, bool noAttributes = false);
89 
90  virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
91 
92  virtual RLineData& getData() {
93  return data;
94  }
95 
96  virtual const RLineData& getData() const {
97  return data;
98  }
99 
100  void setShape(const RLine& l);
101 
102  void setStartPoint(const RVector& p) {
103  data.setStartPoint(p);
104  }
105 
107  return data.getStartPoint();
108  }
109 
110  void setEndPoint(const RVector& p) {
111  data.setEndPoint(p);
112  }
113 
115  return data.getEndPoint();
116  }
117 
119  return getData().getMiddlePoint();
120  }
121 
122  double getAngle() const {
123  return data.getAngle();
124  }
125 
126  double getAngleAt(double distance, RS::From from) const {
127  return data.getAngleAt(distance, from);
128  }
129 
130  double getDirection1() const {
131  return data.getDirection1();
132  }
133 
134  double getDirection2() const {
135  return data.getDirection2();
136  }
137 
138  bool reverse() {
139  return data.reverse();
140  }
141 
142  RS::Side getSideOfPoint(const RVector& point) const {
143  return data.getSideOfPoint(point);
144  }
145 
146  RS::Ending getTrimEnd(const RVector& trimPoint, const RVector& clickPoint) {
147  return data.getTrimEnd(trimPoint, clickPoint);
148  }
149 
150  bool trimStartPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
151  return data.trimStartPoint(trimPoint, clickPoint, extend);
152  }
153  bool trimEndPoint(const RVector& trimPoint, const RVector& clickPoint = RVector::invalid, bool extend = false) {
154  return data.trimEndPoint(trimPoint, clickPoint, extend);
155  }
156 
157  double getLength() const {
158  return data.getLength();
159  }
160 
161 protected:
162  virtual void print(QDebug dbg) const;
163 
164 protected:
166 };
167 
169 Q_DECLARE_METATYPE(QSharedPointer<RLineEntity>)
170 Q_DECLARE_METATYPE(QSharedPointer<RLineEntity>*)
171 
172 #endif
virtual RS::EntityType getType() const
Definition: RLineEntity.h:80
RLineData data
Definition: RLineEntity.h:165
Ending
Entity ending.
Definition: RS.h:150
static RPropertyTypeId PropertyLineweight
Definition: RLineEntity.h:49
bool trimStartPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RLineEntity.h:150
static RPropertyTypeId PropertyEndPointY
Definition: RLineEntity.h:58
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
double getAngle() const
Definition: RLineEntity.h:122
static RPropertyTypeId PropertyType
Definition: RLineEntity.h:44
void setStartPoint(const RVector &p)
Definition: RLineEntity.h:102
static RPropertyTypeId PropertyDrawOrder
Definition: RLineEntity.h:52
static RPropertyTypeId PropertyLength
Definition: RLineEntity.h:62
RVector getStartPoint() const
Definition: RLineEntity.h:106
EntityType
Entity types used for property handling / filtering.
Definition: RS.h:76
bool reverse()
Definition: RLineEntity.h:138
#define QCADENTITY_EXPORT
Definition: entity_global.h:10
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RLineEntity.h:41
RS::Side getSideOfPoint(const RVector &point) const
Definition: RLineEntity.h:142
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
virtual RLineData & getData()
Definition: RLineEntity.h:92
RVector getMiddlePoint() const
Definition: RLineEntity.h:118
RS::Ending getTrimEnd(const RVector &trimPoint, const RVector &clickPoint)
Definition: RLineEntity.h:146
static RPropertyTypeId PropertyEndPointZ
Definition: RLineEntity.h:59
virtual const RLineData & getData() const
Definition: RLineEntity.h:96
Transaction implementation.
Definition: RTransaction.h:74
static RPropertyTypeId PropertyLayer
Definition: RLineEntity.h:46
static RPropertyTypeId PropertyStartPointX
Definition: RLineEntity.h:54
virtual RLineEntity * clone() const
Definition: RLineEntity.h:76
double getAngleAt(double distance, RS::From from) const
Definition: RLineEntity.h:126
Side
Side used for side of a point relativ to an entity (right hand or left hand side) ...
Definition: RS.h:140
static RPropertyTypeId PropertyLinetypeScale
Definition: RLineEntity.h:48
Line.
Definition: RS.h:93
Line entity.
Definition: RLineEntity.h:38
static RPropertyTypeId PropertyBlock
Definition: RLineEntity.h:45
static RPropertyTypeId PropertyAngle
Definition: RLineEntity.h:61
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:67
Q_DECLARE_METATYPE(RMath *)
Copyright (c) 2011-2016 by Andrew Mustun.
Definition: RLineData.h:39
static RPropertyTypeId PropertyColor
Definition: RLineEntity.h:50
static RPropertyTypeId PropertyHandle
Definition: RLineEntity.h:42
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:228
static RPropertyTypeId PropertyTotalLength
Definition: RLineEntity.h:63
static QSet< RPropertyTypeId > getStaticPropertyTypeIds()
Definition: RLineEntity.h:72
static void init()
Definition: REntity.cpp:82
virtual bool setProperty(RPropertyTypeId propertyTypeId, const QVariant &value, RTransaction *transaction=NULL)
Sets the given property to the given value.
Definition: REntity.cpp:321
Abstract base class for exporters.
Definition: RExporter.h:71
double getDirection2() const
Definition: RLineEntity.h:134
double getDirection1() const
Definition: RLineEntity.h:130
double getLength() const
Definition: RLineEntity.h:157
From
End used to specify from which end of a shape to measure a distance.
Definition: RS.h:198
bool trimEndPoint(const RVector &trimPoint, const RVector &clickPoint=RVector::invalid, bool extend=false)
Definition: RLineEntity.h:153
static RPropertyTypeId PropertyStartPointZ
Definition: RLineEntity.h:56
virtual REntityData & getData()=0
static RPropertyTypeId PropertyDisplayedColor
Definition: RLineEntity.h:51
static RPropertyTypeId PropertyEndPointX
Definition: RLineEntity.h:57
static const RVector invalid
invalid vector
Definition: RVector.h:309
void setEndPoint(const RVector &p)
Definition: RLineEntity.h:110
RVector getEndPoint() const
Definition: RLineEntity.h:114
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:55
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: REntity.cpp:428