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
qsvgdebug.cpp
Go to the documentation of this file.
1
// Copyright (C) 2023 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
#
include
"qsvgvisitor_p.h"
7
8
#
include
<
QDebug
>
9
10
QT_BEGIN_NAMESPACE
11
12
class
SvgDebugVisitor
:
public
QSvgVisitor
13
{
14
public
:
15
SvgDebugVisitor
(QDebug &stream) :
debug
(
stream
) {}
16
void
write
(
const
QSvgDocument *doc);
17
18
protected
:
19
void
visitNode
(
const
QSvgNode *)
override
;
20
bool
visitStructureNodeStart
(
const
QSvgStructureNode *node)
override
;
21
void
visitStructureNodeEnd
(
const
QSvgStructureNode *)
override
;
22
void
visitAnimateNode
(
const
QSvgAnimateNode *node)
override
;
23
void
visitEllipseNode
(
const
QSvgEllipse *node)
override
;
24
void
visitImageNode
(
const
QSvgImage *node)
override
;
25
void
visitLineNode
(
const
QSvgLine *node)
override
;
26
void
visitPathNode
(
const
QSvgPath *node)
override
;
27
void
visitPolygonNode
(
const
QSvgPolygon *node)
override
;
28
void
visitPolylineNode
(
const
QSvgPolyline *node)
override
;
29
void
visitRectNode
(
const
QSvgRect *node)
override
;
30
void
visitTextNode
(
const
QSvgText *node)
override
;
31
void
visitUseNode
(
const
QSvgUse *node)
override
;
32
void
visitVideoNode
(
const
QSvgVideo *node)
override
;
33
34
private
:
35
const
char
*indent() { m_indent.fill(
' '
, m_indentLevel * 2);
return
m_indent.constData();}
36
void
handleBaseNode(
const
QSvgNode *node);
37
QDebug &debug;
38
int
m_indentLevel{0};
39
QByteArray m_indent;
40
int
nodeCounter{0};
41
};
42
43
void
SvgDebugVisitor
::handleBaseNode(
const
QSvgNode *node)
44
{
45
debug << indent() << node->typeName() <<
"node, ID:"
<< node->nodeId();
46
nodeCounter++;
47
}
48
49
void
SvgDebugVisitor
::
visitNode
(
const
QSvgNode *node)
50
{
51
handleBaseNode(node);
52
debug << Qt::endl;
53
}
54
55
bool
SvgDebugVisitor
::
visitStructureNodeStart
(
const
QSvgStructureNode *node)
56
{
57
debug << indent() <<
"START node"
<< node->nodeId() <<
"type"
<< node->typeName() << node->type() << Qt::endl;
58
m_indentLevel++;
59
return
true
;
60
}
61
62
void
SvgDebugVisitor
::
visitStructureNodeEnd
(
const
QSvgStructureNode *node)
63
{
64
m_indentLevel--;
65
debug << indent() <<
"END node"
<< node->nodeId() << Qt::endl;
66
}
67
68
void
SvgDebugVisitor
::
visitAnimateNode
(
const
QSvgAnimateNode *node)
69
{
70
handleBaseNode(node);
71
debug << Qt::endl;
72
}
73
74
void
SvgDebugVisitor
::
visitEllipseNode
(
const
QSvgEllipse *node)
75
{
76
handleBaseNode(node);
77
debug <<
"rect:"
<< node->rect() << Qt::endl;
78
}
79
80
void
SvgDebugVisitor
::
visitImageNode
(
const
QSvgImage *node)
81
{
82
handleBaseNode(node);
83
debug <<
"image:"
<< node->image() << Qt::endl;
84
}
85
86
void
SvgDebugVisitor
::
visitLineNode
(
const
QSvgLine *node)
87
{
88
handleBaseNode(node);
89
debug <<
"line:"
<< node->line() << Qt::endl;
90
}
91
92
void
SvgDebugVisitor
::
visitPathNode
(
const
QSvgPath *node)
93
{
94
handleBaseNode(node);
95
debug <<
"path:"
<< node->path().elementCount() <<
"elements."
<< Qt::endl;
96
}
97
98
void
SvgDebugVisitor
::
visitPolygonNode
(
const
QSvgPolygon *node)
99
{
100
handleBaseNode(node);
101
debug <<
"polygon:"
<< node->polygon().size() <<
"elements."
<< Qt::endl;
102
}
103
104
void
SvgDebugVisitor
::
visitPolylineNode
(
const
QSvgPolyline *node)
105
{
106
handleBaseNode(node);
107
debug <<
"polygon:"
<< node->polygon().size() <<
"elements."
<< Qt::endl;
108
}
109
110
void
SvgDebugVisitor
::
visitRectNode
(
const
QSvgRect *node)
111
{
112
handleBaseNode(node);
113
debug <<
"rect:"
<< node->rect() <<
"radius:"
<< node->radius() << Qt::endl;
114
}
115
116
void
SvgDebugVisitor
::
visitTextNode
(
const
QSvgText *node)
117
{
118
handleBaseNode(node);
119
QString text;
120
for
(
const
auto
*tspan : node->tspans()) {
121
if
(!tspan)
122
text += QStringLiteral(
"\\n"
);
123
else
124
text += tspan->text();
125
}
126
debug <<
"text:"
<< text << Qt::endl;
127
}
128
129
void
SvgDebugVisitor
::
visitUseNode
(
const
QSvgUse *node)
130
{
131
handleBaseNode(node);
132
debug <<
"link ID:"
<< node->linkId() << Qt::endl;
133
}
134
135
void
SvgDebugVisitor
::
visitVideoNode
(
const
QSvgVideo *node)
136
{
137
handleBaseNode(node);
138
debug << Qt::endl;
139
}
140
141
void
SvgDebugVisitor
::
write
(
const
QSvgDocument *doc)
142
{
143
debug <<
"SVG"
<< doc->size() <<
"viewBox"
<< doc->viewBox() << Qt::endl;
144
traverse(doc);
145
146
debug <<
"END SVG"
<< nodeCounter <<
"nodes"
;
147
}
148
149
QDebug
operator
<<(QDebug debug,
const
QSvgDocument &doc)
150
{
151
SvgDebugVisitor
visitor(debug);
152
visitor.write(&doc);
153
154
return
debug;
155
}
156
157
QT_END_NAMESPACE
SvgDebugVisitor
Definition
qsvgdebug.cpp:13
SvgDebugVisitor::visitStructureNodeStart
bool visitStructureNodeStart(const QSvgStructureNode *node) override
Definition
qsvgdebug.cpp:55
SvgDebugVisitor::visitLineNode
void visitLineNode(const QSvgLine *node) override
Definition
qsvgdebug.cpp:86
SvgDebugVisitor::visitStructureNodeEnd
void visitStructureNodeEnd(const QSvgStructureNode *) override
Definition
qsvgdebug.cpp:62
SvgDebugVisitor::visitAnimateNode
void visitAnimateNode(const QSvgAnimateNode *node) override
Definition
qsvgdebug.cpp:68
SvgDebugVisitor::visitPathNode
void visitPathNode(const QSvgPath *node) override
Definition
qsvgdebug.cpp:92
SvgDebugVisitor::write
void write(const QSvgDocument *doc)
Definition
qsvgdebug.cpp:141
SvgDebugVisitor::visitEllipseNode
void visitEllipseNode(const QSvgEllipse *node) override
Definition
qsvgdebug.cpp:74
SvgDebugVisitor::visitRectNode
void visitRectNode(const QSvgRect *node) override
Definition
qsvgdebug.cpp:110
SvgDebugVisitor::visitVideoNode
void visitVideoNode(const QSvgVideo *node) override
Definition
qsvgdebug.cpp:135
SvgDebugVisitor::visitTextNode
void visitTextNode(const QSvgText *node) override
Definition
qsvgdebug.cpp:116
SvgDebugVisitor::SvgDebugVisitor
SvgDebugVisitor(QDebug &stream)
Definition
qsvgdebug.cpp:15
SvgDebugVisitor::visitPolygonNode
void visitPolygonNode(const QSvgPolygon *node) override
Definition
qsvgdebug.cpp:98
SvgDebugVisitor::visitImageNode
void visitImageNode(const QSvgImage *node) override
Definition
qsvgdebug.cpp:80
SvgDebugVisitor::visitPolylineNode
void visitPolylineNode(const QSvgPolyline *node) override
Definition
qsvgdebug.cpp:104
SvgDebugVisitor::visitNode
void visitNode(const QSvgNode *) override
Definition
qsvgdebug.cpp:49
SvgDebugVisitor::visitUseNode
void visitUseNode(const QSvgUse *node) override
Definition
qsvgdebug.cpp:129
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
operator<<
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
Definition
qfileinfo.cpp:1830
qtsvg
src
svg
qsvgdebug.cpp
Generated on
for Qt by
1.18.0