QCAD
Open Source 2D CAD
RTextBasedEntity.h
Go to the documentation of this file.
1 
20 #ifndef RTEXTBASEDENTITY_H
21 #define RTEXTBASEDENTITY_H
22 
23 #include "core_global.h"
24 
25 #include "REntity.h"
26 #include "RTextBasedData.h"
27 
28 class RDocument;
29 class RExporter;
30 
39 
40  Q_DECLARE_TR_FUNCTIONS(RTextBasedEntity)
41 
42 public:
54 
70 
71 public:
72  RTextBasedEntity(RDocument* document);
73  virtual ~RTextBasedEntity();
74 
75  static void init();
76 
77  static QSet<RPropertyTypeId> getStaticPropertyTypeIds() {
79  }
80 
81  virtual RTextBasedData& getData() = 0;
82 
83  virtual const RTextBasedData& getData() const = 0;
84 
85  bool setProperty(RPropertyTypeId propertyTypeId, const QVariant& value,
86  RTransaction* transaction=NULL);
87  QPair<QVariant, RPropertyAttributes> getProperty(
88  RPropertyTypeId& propertyTypeId,
89  bool humanReadable = false, bool noAttributes = false);
90 
91  virtual void exportEntity(RExporter& e, bool preview=false, bool forceSelected=false) const;
92 
93  QList<RPainterPath> getPainterPaths(bool draft = false) const {
94  return getData().getPainterPaths(draft);
95  }
96 
97  virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX, bool ignoreComplex = false, bool segment = false) const {
98  return getData().getShapes(queryBox, ignoreComplex, segment);
99  }
100 
101  virtual QList<QSharedPointer<RShape> > getExploded() const {
102  return getData().getExploded();
103  }
104 
106  return getData();
107  }
108 
109  bool isBold() const {
110  return getData().isBold();
111  }
112 
113  void setBold(bool on) {
114  getData().setBold(on);
115  }
116 
117  bool isItalic() const {
118  return getData().isItalic();
119  }
120 
121  void setItalic(bool on) {
122  getData().setItalic(on);
123  }
124 
126  return getData().getPosition();
127  }
128 
129  void setPosition(const RVector& position) {
130  getData().setPosition(position);
131  }
132 
134  return getData().getAlignmentPoint();
135  }
136 
137  void setAlignmentPoint(const RVector& alignmentPoint) {
138  getData().setAlignmentPoint(alignmentPoint);
139  }
140 
141  double getTextHeight() const {
142  return getData().getTextHeight();
143  }
144 
145  void setTextHeight(double h) {
146  getData().setTextHeight(h);
147  }
148 
149  double getTextWidth() const {
150  return getData().getTextWidth();
151  }
152 
153  double getWidth() const {
154  return getData().getWidth();
155  }
156  double getHeight() const {
157  return getData().getHeight();
158  }
159 
161  return getData().getVAlign();
162  }
163 
165  getData().setVAlign(va);
166  }
167 
169  return getData().getHAlign();
170  }
171 
173  getData().setHAlign(ha);
174  }
175 
176  QString getFontName() const {
177  return getData().getFontName();
178  }
179 
180  void setFontName(const QString& fontName) {
181  getData().setFontName(fontName);
182  }
183 
184  QString getFontFile() const {
185  return getData().getFontFile();
186  }
187 
189  getData().setDrawingDirection(drawingDirection);
190  }
191 
193  return getData().getDrawingDirection();
194  }
195 
197  getData().setLineSpacingStyle(lineSpacingStyle);
198  }
199 
201  return getData().getLineSpacingStyle();
202  }
203 
204  void setLineSpacingFactor(double lineSpacingFactor) {
205  getData().setLineSpacingFactor(lineSpacingFactor);
206  }
207 
208  double getLineSpacingFactor() const {
209  return getData().getLineSpacingFactor();
210  }
211 
212  void setAngle(double angle) {
213  getData().setAngle(angle);
214  }
215 
216  double getAngle() const {
217  return getData().getAngle();
218  }
219 
220  void setXScale(double xScale) {
221  getData().setXScale(xScale);
222  }
223 
224  double getXScale() const {
225  return getData().getXScale();
226  }
227 
228  void setSimple(bool on) {
229  getData().setSimple(on);
230  }
231 
232  bool isSimple() const {
233  return getData().isSimple();
234  }
235 
236  QString getEscapedText(bool escapeUnicode = false) const {
237  return getData().getEscapedText(escapeUnicode);
238  }
239 
240  //QString getHtmlText() const {
241  // return getData().getHtmlText();
242  //}
243 
244  QString getPlainText() const {
245  return getData().getPlainText();
246  }
247 
248  void setText(const QString& text) {
249  getData().setText(text);
250  }
251 
252  void sync(const RTextBasedEntity& other) {
253  getData().sync(other.getData());
254  }
255 
256  QList<RTextBasedData> getSimpleTextBlocks() const {
257  return getData().getSimpleTextBlocks();
258  }
259 
260 protected:
261  virtual void print(QDebug dbg) const;
262 };
263 
265 Q_DECLARE_METATYPE(QSharedPointer<RTextBasedEntity>)
266 Q_DECLARE_METATYPE(QSharedPointer<RTextBasedEntity>*)
267 
268 #endif
Represents a box e.g.
Definition: RBox.h:43
double getTextWidth() const
Definition: RTextBasedEntity.h:149
RVector getAlignmentPoint() const
Definition: RTextBasedEntity.h:133
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define RDEFAULT_RBOX
Definition: RBox.h:32
void setAlignmentPoint(const RVector &alignmentPoint)
Definition: RTextBasedEntity.h:137
TextLineSpacingStyle
Line spacing style for texts.
Definition: RS.h:192
static RPropertyTypeId PropertyPositionX
Definition: RTextBasedEntity.h:56
double getLineSpacingFactor() const
Definition: RTextBasedEntity.h:208
VAlign
Vertical alignments.
Definition: RS.h:161
virtual QList< QSharedPointer< RShape > > getExploded() const
Definition: RTextBasedEntity.h:101
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false) const
Definition: REntityData.h:104
static RPropertyTypeId PropertyHeight
Definition: RTextBasedEntity.h:62
static RPropertyTypeId PropertyLayer
Definition: RTextBasedEntity.h:47
QString getEscapedText(bool escapeUnicode=false) const
Definition: RTextBasedEntity.h:236
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RPropertyTypeId.h:58
void setSimple(bool on)
Definition: RTextBasedEntity.h:228
#define QCADCORE_EXPORT
Definition: core_global.h:10
void setHAlign(RS::HAlign ha)
Definition: RTextBasedEntity.h:172
QString getFontFile() const
Definition: RTextBasedEntity.h:184
static RPropertyTypeId PropertyVAlign
Definition: RTextBasedEntity.h:69
static RPropertyTypeId PropertySimple
Definition: RTextBasedEntity.h:55
double getAngle() const
Definition: RTextBasedEntity.h:216
bool isBold() const
Definition: RTextBasedEntity.h:109
Transaction implementation.
Definition: RTransaction.h:74
static RPropertyTypeId PropertyBold
Definition: RTextBasedEntity.h:65
void setTextHeight(double h)
Definition: RTextBasedEntity.h:145
static RPropertyTypeId PropertyBlock
Definition: RTextBasedEntity.h:46
RS::TextLineSpacingStyle getLineSpacingStyle() const
Definition: RTextBasedEntity.h:200
void setBold(bool on)
Definition: RTextBasedEntity.h:113
double getXScale() const
Definition: RTextBasedEntity.h:224
bool isItalic() const
Definition: RTextBasedEntity.h:117
void setAngle(double angle)
Definition: RTextBasedEntity.h:212
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false) const
Definition: RTextBasedEntity.h:97
double getWidth() const
Definition: RTextBasedEntity.h:153
static RPropertyTypeId PropertyType
Definition: RTextBasedEntity.h:45
Stores and manages all data that defines the geometry and appearance of a text based entity (text...
Definition: RTextBasedData.h:44
static RPropertyTypeId PropertyDisplayedColor
Definition: RTextBasedEntity.h:52
void setItalic(bool on)
Definition: RTextBasedEntity.h:121
static RPropertyTypeId PropertyText
Definition: RTextBasedEntity.h:59
static RPropertyTypeId PropertyFontName
Definition: RTextBasedEntity.h:61
void setLineSpacingStyle(RS::TextLineSpacingStyle lineSpacingStyle)
Definition: RTextBasedEntity.h:196
Text entity.
Definition: RTextBasedEntity.h:38
static RPropertyTypeId PropertyDrawOrder
Definition: RTextBasedEntity.h:53
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
static RPropertyTypeId PropertyLinetype
Definition: RTextBasedEntity.h:48
static RPropertyTypeId PropertyHAlign
Definition: RTextBasedEntity.h:68
virtual RTextBasedData & getData()=0
Q_DECLARE_METATYPE(RMath *)
static RPropertyTypeId PropertyAngle
Definition: RTextBasedEntity.h:63
RS::HAlign getHAlign() const
Definition: RTextBasedEntity.h:168
static RPropertyTypeId PropertyCustom
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RTextBasedEntity.h:43
static RPropertyTypeId PropertyHandle
Definition: RTextBasedEntity.h:44
static RPropertyTypeId PropertyLineweight
Definition: RTextBasedEntity.h:50
static RPropertyTypeId PropertyLineSpacingFactor
Definition: RTextBasedEntity.h:67
static RPropertyTypeId PropertyPositionY
Definition: RTextBasedEntity.h:57
void sync(const RTextBasedEntity &other)
Definition: RTextBasedEntity.h:252
static RPropertyTypeId PropertyPositionZ
Definition: RTextBasedEntity.h:58
static RPropertyTypeId PropertyColor
Definition: RTextBasedEntity.h:51
static RPropertyTypeId PropertyLinetypeScale
Definition: RTextBasedEntity.h:49
QList< RTextBasedData > getSimpleTextBlocks() const
Definition: RTextBasedEntity.h:256
QString getPlainText() const
Definition: RTextBasedEntity.h:244
static RPropertyTypeId PropertyXScale
Definition: RTextBasedEntity.h:64
virtual QPair< QVariant, RPropertyAttributes > getProperty(RPropertyTypeId &propertyTypeId, bool humanReadable=false, bool noAttributes=false)
Definition: REntity.cpp:228
void setPosition(const RVector &position)
Definition: RTextBasedEntity.h:129
void setText(const QString &text)
Definition: RTextBasedEntity.h:248
double getTextHeight() const
Definition: RTextBasedEntity.h:141
double getHeight() const
Definition: RTextBasedEntity.h:156
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
static RPropertyTypeId PropertyItalic
Definition: RTextBasedEntity.h:66
static RPropertyTypeId PropertyPlainText
Definition: RTextBasedEntity.h:60
QString getFontName() const
Definition: RTextBasedEntity.h:176
void setXScale(double xScale)
Definition: RTextBasedEntity.h:220
void setVAlign(RS::VAlign va)
Definition: RTextBasedEntity.h:164
bool isSimple() const
Definition: RTextBasedEntity.h:232
virtual REntityData & getData()=0
HAlign
Horizontal alignments.
Definition: RS.h:171
TextDrawingDirection
Text drawing direction.
Definition: RS.h:183
RVector getPosition() const
Definition: RTextBasedEntity.h:125
void setFontName(const QString &fontName)
Definition: RTextBasedEntity.h:180
QList< RPainterPath > getPainterPaths(bool draft=false) const
Definition: RTextBasedEntity.h:93
virtual RTextBasedData & getTextData()
Definition: RTextBasedEntity.h:105
void setLineSpacingFactor(double lineSpacingFactor)
Definition: RTextBasedEntity.h:204
RS::TextDrawingDirection getDrawingDirection() const
Definition: RTextBasedEntity.h:192
RS::VAlign getVAlign() const
Definition: RTextBasedEntity.h:160
virtual void exportEntity(RExporter &e, bool preview=false, bool forceSelected=false) const =0
Exports the entity to the given exporter.
static QSet< RPropertyTypeId > getStaticPropertyTypeIds()
Definition: RTextBasedEntity.h:77
void setDrawingDirection(RS::TextDrawingDirection drawingDirection)
Definition: RTextBasedEntity.h:188
virtual void print(QDebug dbg) const
Stream operator for QDebug.
Definition: REntity.cpp:468