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 // RVector getPosition() const {
111 // return position;
112 // }
113 
114  double getHeight() const {
115  return height;
116  }
117 
119  return boundingBox;
120  }
121 
122 public:
123  bool ttf;
124  QSharedPointer<QTextLayout> layout;
125  QTransform transform;
126  QList<RPainterPath> painterPaths;
127  // number of painter paths corresponding to this layout
128  // used to keep track of painter path and layout relationships
130  QColor color;
131  double height;
132  //RVector position;
134 };
135 
138 
139 #endif
Represents a box e.g.
Definition: RBox.h:43
RTextLayout(const QList< RPainterPath > &pps, const QColor &color)
Definition: RTextLayout.h:51
QColor getColor() const
Definition: RTextLayout.h:78
QTransform getTransform() const
Definition: RTextLayout.h:74
QColor color
Definition: RTextLayout.h:130
double getHeight() const
Definition: RTextLayout.h:114
bool isItalic() const
Definition: RTextLayout.h:103
#define QCADCORE_EXPORT
Definition: core_global.h:10
QList< RPainterPath > painterPaths
Definition: RTextLayout.h:126
RTextLayout(QSharedPointer< QTextLayout > layout, const QTransform &transform, const QColor &color)
Definition: RTextLayout.h:43
RBox boundingBox
Definition: RTextLayout.h:133
bool hasPainterPath() const
Definition: RTextLayout.h:66
Q_DECLARE_METATYPE(RMath *)
RBox getBoundingBox() const
Definition: RTextLayout.h:118
bool isBold() const
Definition: RTextLayout.h:96
QString getFont() const
Definition: RTextLayout.h:89
bool ttf
Definition: RTextLayout.h:123
QSharedPointer< QTextLayout > getLayout() const
Definition: RTextLayout.h:70
QTransform transform
Definition: RTextLayout.h:125
int correspondingPainterPaths
Definition: RTextLayout.h:129
RTextLayout()
Definition: RTextLayout.h:38
QString getText() const
Definition: RTextLayout.h:82
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RTextLayout.h:36
bool isTTF() const
Definition: RTextLayout.h:62
bool isEmpty() const
Definition: RTextLayout.h:58
double height
Definition: RTextLayout.h:131
QSharedPointer< QTextLayout > layout
Definition: RTextLayout.h:124