Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsvgstructure_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
6
#
ifndef
QSVGSTRUCTURE_P_H
7
#
define
QSVGSTRUCTURE_P_H
8
9
//
10
// W A R N I N G
11
// -------------
12
//
13
// This file is not part of the Qt API. It exists purely as an
14
// implementation detail. This header file may change from version to
15
// version without notice, or even be removed.
16
//
17
// We mean it.
18
//
19
20
#
include
"qsvgnode_p.h"
21
#
include
<
QtSvg
/
private
/
qsvghelper_p
.
h
>
22
#
include
<
QtCore
/
qlist
.
h
>
23
24
#
include
<
list
>
25
#
include
<
utility
>
26
27
QT_BEGIN_NAMESPACE
28
29
class
QSvgDocument;
30
class
QSvgNode;
31
class
QPainter
;
32
class
QSvgDefs;
33
34
class
Q_SVG_EXPORT
QSvgStructureNode
:
public
QSvgNode
35
{
36
public
:
37
QSvgStructureNode(QSvgNode *parent);
38
~QSvgStructureNode() override;
39
40
void
addChild(QSvgDocument *doc, std::unique_ptr<QSvgNode> child,
const
QString &id);
41
QRectF internalBounds(QPainter *p, QSvgExtraStates &states)
const
override;
42
QRectF decoratedInternalBounds(QPainter *p, QSvgExtraStates &states)
const
override;
43
QSvgNode *previousSiblingNode(QSvgNode *n)
const
;
44
const
std::list<std::unique_ptr<QSvgNode>> &renderers()
const
{
return
m_renderers; }
45
46
protected
:
47
void
releaseDescendants();
48
49
protected
:
50
std::list<std::unique_ptr<QSvgNode>> m_renderers;
51
mutable
bool
m_recursing{
false
};
52
};
53
54
class
Q_SVG_EXPORT
QSvgG
:
public
QSvgStructureNode
55
{
56
public
:
57
QSvgG(QSvgNode *parent);
58
~QSvgG() override;
59
60
void
drawCommand(QPainter *, QSvgExtraStates &) override;
61
bool
shouldDrawNode(QPainter *p, QSvgExtraStates &states)
const
override;
62
Type type()
const
override;
63
bool
requiresGroupRendering()
const
override;
64
};
65
66
class
Q_SVG_EXPORT
QSvgDefs
:
public
QSvgStructureNode
67
{
68
public
:
69
QSvgDefs(QSvgNode *parent);
70
~QSvgDefs() override;
71
72
void
drawCommand(QPainter *, QSvgExtraStates &) override {};
73
bool
shouldDrawNode(QPainter *p, QSvgExtraStates &states)
const
override;
74
Type type()
const
override;
75
};
76
77
class
Q_SVG_EXPORT
QSvgSymbolLike
:
public
QSvgStructureNode
78
{
79
// Marker, Symbol and potentially other elements share a lot of common
80
// attributes and functionality. By making a common base class we can
81
// avoid repetition.
82
public
:
83
enum
class
Overflow : quint8 {
84
Visible,
85
Hidden,
86
Scroll = Visible,
//Will not support scrolling
87
Auto = Visible
88
};
89
90
enum
class
PreserveAspectRatio : quint8 {
91
None = 0b000000,
92
xMin = 0b000001,
93
xMid = 0b000010,
94
xMax = 0b000011,
95
yMin = 0b000100,
96
yMid = 0b001000,
97
yMax = 0b001100,
98
meet = 0b010000,
99
slice = 0b100000,
100
xMask = xMin | xMid | xMax,
101
yMask = yMin | yMid | yMax,
102
xyMask = xMask | yMask,
103
meetSliceMask = meet | slice
104
};
105
Q_DECLARE_FLAGS(PreserveAspectRatios, PreserveAspectRatio)
106
107
QSvgSymbolLike(QSvgNode *parent, QRectF bounds, QRectF viewBox, QPointF refP,
108
QSvgSymbolLike::PreserveAspectRatios pAspectRatios, QSvgSymbolLike::Overflow overflow);
109
~QSvgSymbolLike() override;
110
111
void
drawCommand(QPainter *, QSvgExtraStates &) override {};
112
QRectF decoratedInternalBounds(QPainter *p, QSvgExtraStates &states)
const
override;
113
bool
requiresGroupRendering()
const
override;
114
115
QRectF viewBox()
const
116
{
117
return
m_viewBox;
118
}
119
120
QRectF rect()
const
121
{
122
return
m_rect;
123
}
124
125
QPointF refP()
const
126
{
127
return
m_refP;
128
}
129
130
QTransform aspectRatioTransform()
const
;
131
QRectF clipRect()
const
;
132
133
Overflow overflow()
const
134
{
135
return
m_overflow;
136
}
137
138
PreserveAspectRatios preserveAspectRatios()
const
139
{
140
return
m_pAspectRatios;
141
}
142
143
protected
:
144
void
setPainterToRectAndAdjustment(QPainter *p)
const
;
145
protected
:
146
QRectF m_rect;
147
QRectF m_viewBox;
148
QPointF m_refP;
149
PreserveAspectRatios m_pAspectRatios;
150
Overflow m_overflow;
151
};
152
153
Q_DECLARE_OPERATORS_FOR_FLAGS(QSvgSymbolLike::PreserveAspectRatios)
154
155
class
Q_SVG_EXPORT QSvgSymbol :
public
QSvgSymbolLike
156
{
157
public
:
158
QSvgSymbol(QSvgNode *parent, QRectF bounds, QRectF viewBox, QPointF refP,
159
QSvgSymbolLike::PreserveAspectRatios pAspectRatios, QSvgSymbolLike::Overflow overflow);
160
~QSvgSymbol() override;
161
162
void
drawCommand(QPainter *p, QSvgExtraStates &states) override;
163
Type type()
const
override;
164
};
165
166
class
Q_SVG_EXPORT
QSvgMarker
:
public
QSvgSymbolLike
167
{
168
public
:
169
enum
class
Orientation : quint8 {
170
Auto,
171
AutoStartReverse,
172
Value
173
};
174
enum
class
MarkerUnits : quint8 {
175
StrokeWidth,
176
UserSpaceOnUse
177
};
178
179
QSvgMarker(QSvgNode *parent, QRectF bounds, QRectF viewBox, QPointF refP,
180
QSvgSymbolLike::PreserveAspectRatios pAspectRatios, QSvgSymbolLike::Overflow overflow,
181
Orientation orientation, qreal orientationAngle, MarkerUnits markerUnits);
182
~QSvgMarker() override;
183
184
void
drawCommand(QPainter *p, QSvgExtraStates &states) override;
185
static
void
drawMarkersForNode(QSvgNode *node, QPainter *p, QSvgExtraStates &states);
186
static
QRectF markersBoundsForNode(
const
QSvgNode *node, QPainter *p, QSvgExtraStates &states);
187
188
Orientation orientation()
const
{
189
return
m_orientation;
190
}
191
qreal orientationAngle()
const
{
192
return
m_orientationAngle;
193
}
194
MarkerUnits markerUnits()
const
{
195
return
m_markerUnits;
196
}
197
Type type()
const
override;
198
199
private
:
200
static
void
drawHelper(
const
QSvgNode *node, QPainter *p,
201
QSvgExtraStates &states, QRectF *boundingRect =
nullptr
);
202
203
Orientation m_orientation;
204
qreal m_orientationAngle;
205
MarkerUnits m_markerUnits;
206
};
207
208
class
Q_SVG_EXPORT
QSvgFilterContainer
:
public
QSvgStructureNode
209
{
210
public
:
211
QSvgFilterContainer(QSvgNode *parent,
const
QSvgRectF &bounds, QtSvg::UnitTypes filterUnits, QtSvg::UnitTypes primitiveUnits);
212
~QSvgFilterContainer() override;
213
214
void
drawCommand(QPainter *, QSvgExtraStates &) override {};
215
bool
shouldDrawNode(QPainter *, QSvgExtraStates &)
const
override;
216
Type type()
const
override;
217
QImage applyFilter(
const
QImage &buffer, QPainter *p,
const
QRectF &bounds)
const
;
218
void
setSupported(
bool
supported);
219
bool
supported()
const
;
220
QRectF filterRegion(
const
QRectF &itemBounds)
const
;
221
222
QSvgRectF rect()
const
{
return
m_rect; }
223
QtSvg::UnitTypes filterUnits()
const
{
return
m_filterUnits; }
224
QtSvg::UnitTypes primitiveUnits()
const
{
return
m_primitiveUnits; }
225
226
private
:
227
QSvgRectF m_rect;
228
QtSvg::UnitTypes m_filterUnits;
229
QtSvg::UnitTypes m_primitiveUnits;
230
bool
m_supported;
231
};
232
233
234
class
Q_SVG_EXPORT
QSvgSwitch
:
public
QSvgStructureNode
235
{
236
public
:
237
QSvgSwitch(QSvgNode *parent);
238
~QSvgSwitch() override;
239
240
void
drawCommand(QPainter *p, QSvgExtraStates &states) override;
241
Type type()
const
override;
242
243
QSvgNode *childToRender()
const
;
244
private
:
245
void
init();
246
private
:
247
QString m_systemLanguage;
248
QString m_systemLanguagePrefix;
249
};
250
251
class
Q_SVG_EXPORT
QSvgMask
:
public
QSvgStructureNode
252
{
253
public
:
254
QSvgMask(QSvgNode *parent, QSvgRectF bounds,
255
QtSvg::UnitTypes contentsUnits);
256
~QSvgMask() override;
257
258
void
drawCommand(QPainter *, QSvgExtraStates &) override {};
259
bool
shouldDrawNode(QPainter *, QSvgExtraStates &)
const
override;
260
Type type()
const
override;
261
QImage createMask(QPainter *p, QSvgExtraStates &states, QSvgNode *targetNode, QRectF *globalRect)
const
;
262
QImage createMask(QPainter *p, QSvgExtraStates &states,
const
QRectF &localRect, QRectF *globalRect)
const
;
263
264
QSvgRectF rect()
const
265
{
266
return
m_rect;
267
}
268
269
QtSvg::UnitTypes contentUnits()
const
270
{
271
return
m_contentUnits;
272
}
273
274
private
:
275
QSvgRectF m_rect;
276
QtSvg::UnitTypes m_contentUnits;
277
};
278
279
class
Q_SVG_EXPORT
QSvgPattern
:
public
QSvgStructureNode
280
{
281
public
:
282
QSvgPattern(QSvgNode *parent, QSvgRectF bounds, QRectF viewBox,
283
QtSvg::UnitTypes contentUnits, QTransform transform);
284
~QSvgPattern() override;
285
286
void
drawCommand(QPainter *, QSvgExtraStates &) override {};
287
bool
shouldDrawNode(QPainter *, QSvgExtraStates &)
const
override;
288
QImage patternImage(QPainter *p, QSvgExtraStates &states,
const
QSvgNode *patternElement);
289
Type type()
const
override;
290
const
QTransform& appliedTransform()
const
{
return
m_appliedTransform; }
291
const
QTransform &transform()
const
{
return
m_transform; }
292
const
QSvgRectF &rect()
const
{
return
m_rect; }
293
const
QRectF &viewBox()
const
{
return
m_viewBox; }
294
QtSvg::UnitTypes contentUnits()
const
{
return
m_contentUnits; }
295
296
private
:
297
QImage renderPattern(QSize size, std::pair<qreal, qreal> contentScale,
const
QSvgExtraStates &states);
298
void
calculateAppliedTransform(QTransform& worldTransform, QRectF peLocalBB, QSize imageSize);
299
300
private
:
301
QTransform m_appliedTransform;
302
QSvgRectF m_rect;
303
QRectF m_viewBox;
304
QtSvg::UnitTypes m_contentUnits;
305
mutable
bool
m_isRendering;
306
QTransform m_transform;
307
};
308
309
QT_END_NAMESPACE
310
311
#
endif
// QSVGSTRUCTURE_P_H
QByteArray::FromBase64Result
\inmodule QtCore
Definition
qbytearray.h:824
QPaintEngine::QPainter
friend class QPainter
Definition
qpaintengine.h:220
QSvgDefs
Definition
qsvgstructure_p.h:67
QSvgDocument
Definition
qsvgdocument_p.h:42
QSvgFilterContainer
Definition
qsvgstructure_p.h:209
QSvgG
Definition
qsvgstructure_p.h:55
QSvgMarker
Definition
qsvgstructure_p.h:167
QSvgMask
Definition
qsvgstructure_p.h:252
QSvgPattern
Definition
qsvgstructure_p.h:280
QSvgStructureNode
Definition
qsvgstructure_p.h:35
QSvgSwitch
Definition
qsvgstructure_p.h:235
QSvgSymbolLike
Definition
qsvgstructure_p.h:78
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
operator<<
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition
qdir.cpp:2620
qPrintable
#define qPrintable(string)
Definition
qstring.h:1718
qt_inflateSvgzDataFrom
static QByteArray qt_inflateSvgzDataFrom(QIODevice *device, bool doCheckContent=true)
Definition
qsvgdocument.cpp:73
isValidMatrix
static bool isValidMatrix(const QTransform &transform)
Definition
qsvgdocument.cpp:427
hasSvgHeader
static bool hasSvgHeader(const QByteArray &buf)
Definition
qsvgdocument.cpp:51
calculateSizeValue
std::optional< int > calculateSizeValue(bool isPercent, int sizeValue, qreal viewBoxSizeValue)
Definition
qsvgdocument_p.h:130
qtsvg
src
svg
qsvgstructure_p.h
Generated on
for Qt by
1.18.0