QCAD
Open Source 2D CAD
RTextLayout.h
Go to the documentation of this file.
1 
20 #ifndef RTEXTLAYOUT_H
21 #define RTEXTLAYOUT_H
22 
23 #include "core_global.h"
24 
25 #include <QTextLayout>
26 #include <QSharedPointer>
27 #include <QList>
28 #include <QTransform>
29 
30 #include "RPainterPath.h"
31 
37 public:
38  RTextLayout() : ttf(false), correspondingPainterPaths(0), height(0.0) {}
39 
43  RTextLayout(QSharedPointer<QTextLayout> layout, const QTransform& transform, const QColor& color) :
44  ttf(true),
45  layout(layout),
46  transform(transform),
47  correspondingPainterPaths(0),
48  color(color),
49  height(0.0) {}
50 
51  RTextLayout(const QList<RPainterPath>& pps, const QColor& color) :
52  ttf(false),
53  painterPaths(pps),
54  correspondingPainterPaths(0),
55  color(color),
56  height(0.0) {}
57 
58  bool isEmpty() const {
59  return layout.isNull() && painterPaths.isEmpty();
60  }
61 
62  bool isTTF() const {
63  return ttf;
64  }
65 
66  bool hasPainterPath() const {
67  return !painterPaths.isEmpty();
68  }
69 
70  QSharedPointer<QTextLayout> getLayout() const {
71  return layout;
72  }
73 
74  QTransform getTransform() const {
75  return transform;
76  }
77 
78  QColor getColor() const {
79  return color;
80  }
81 
82  QString getText() const {
83  if (layout.isNull()) {
84  return QString();
85  }
86  return layout->text();
87  }
88 
89  QString getFont() const {
90  if (layout.isNull()) {
91  return QString();
92  }
93  return layout->font().family();
94  }
95 
96  bool isBold() const {
97  if (layout.isNull()) {
98  return false;
99  }
100  return layout->font().bold();
101  }
102 
103  bool isItalic() const {
104  if (layout.isNull()) {
105  return false;
106  }
107  return layout->font().italic();
108  }
109 
110  bool isUnderline() const {
111  if (layout.isNull()) {
112  return false;
113  }
114  return layout->font().underline();
115  }
116 
117 // RVector getPosition() const {
118 // return position;
119 // }
120 
121  double getHeight() const {
122  return height;
123  }
124 
126  return boundingBox;
127  }
128 
129 public:
130  bool ttf;
131  QSharedPointer<QTextLayout> layout;
132  QTransform transform;
133  // painter paths for CAD font glyphs:
134  QList<RPainterPath> painterPaths;
135  // number of RTextRenderer::painterPaths corresponding to this layout
136  // used to keep track of painter path and layout relationships
138  QColor color;
139  double height;
140  //RVector position;
142 };
143 
146 
147 #endif
RTextLayout::getText
QString getText() const
Definition: RTextLayout.h:82
RTextLayout::RTextLayout
RTextLayout(QSharedPointer< QTextLayout > layout, const QTransform &transform, const QColor &color)
Definition: RTextLayout.h:43
RTextLayout::getHeight
double getHeight() const
Definition: RTextLayout.h:121
RTextLayout::isItalic
bool isItalic() const
Definition: RTextLayout.h:103
RTextLayout::hasPainterPath
bool hasPainterPath() const
Definition: RTextLayout.h:66
RTextLayout::getBoundingBox
RBox getBoundingBox() const
Definition: RTextLayout.h:125
RTextLayout::ttf
bool ttf
Definition: RTextLayout.h:130
RTextLayout::RTextLayout
RTextLayout()
Definition: RTextLayout.h:38
RTextLayout
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RTextLayout.h:36
RTextLayout::correspondingPainterPaths
int correspondingPainterPaths
Definition: RTextLayout.h:137
RTextLayout::isTTF
bool isTTF() const
Definition: RTextLayout.h:62
RTextLayout::getLayout
QSharedPointer< QTextLayout > getLayout() const
Definition: RTextLayout.h:70
RTextLayout::transform
QTransform transform
Definition: RTextLayout.h:132
RTextLayout::isEmpty
bool isEmpty() const
Definition: RTextLayout.h:58
RTextLayout::getFont
QString getFont() const
Definition: RTextLayout.h:89
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(RMath *)
RTextLayout::height
double height
Definition: RTextLayout.h:139
RTextLayout::layout
QSharedPointer< QTextLayout > layout
Definition: RTextLayout.h:131
RTextLayout::isBold
bool isBold() const
Definition: RTextLayout.h:96
RTextLayout::isUnderline
bool isUnderline() const
Definition: RTextLayout.h:110
core_global.h
RTextLayout::boundingBox
RBox boundingBox
Definition: RTextLayout.h:141
RTextLayout::painterPaths
QList< RPainterPath > painterPaths
Definition: RTextLayout.h:134
RTextLayout::getColor
QColor getColor() const
Definition: RTextLayout.h:78
RBox
Represents a box e.g.
Definition: RBox.h:43
RPainterPath.h
RTextLayout::RTextLayout
RTextLayout(const QList< RPainterPath > &pps, const QColor &color)
Definition: RTextLayout.h:51
RTextLayout::getTransform
QTransform getTransform() const
Definition: RTextLayout.h:74
RTextLayout::color
QColor color
Definition: RTextLayout.h:138
QCADCORE_EXPORT
#define QCADCORE_EXPORT
Definition: core_global.h:10