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