Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QSVGSTRUCTURE_P_H
5#define QSVGSTRUCTURE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qsvgnode_p.h"
19
20#include "QtCore/qlist.h"
21#include "QtCore/qhash.h"
22
24
26class QSvgNode;
27class QPainter;
28class QSvgDefs;
29
30class Q_SVG_EXPORT QSvgStructureNode : public QSvgNode
31{
32public:
35 QSvgNode *scopeNode(const QString &id) const;
36 void addChild(QSvgNode *child, const QString &id);
37 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
38 QSvgNode *previousSiblingNode(QSvgNode *n) const;
39 QList<QSvgNode*> renderers() const { return m_renderers; }
40protected:
41 QList<QSvgNode*> m_renderers;
42 QHash<QString, QSvgNode*> m_scope;
43 QList<QSvgStructureNode*> m_linkedScopes;
44 mutable bool m_recursing = false;
45};
46
47class Q_SVG_EXPORT QSvgG : public QSvgStructureNode
48{
49public:
50 QSvgG(QSvgNode *parent);
51 void drawCommand(QPainter *, QSvgExtraStates &) override;
52 bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const override;
53 Type type() const override;
54};
55
56class Q_SVG_EXPORT QSvgDefs : public QSvgStructureNode
57{
58public:
59 QSvgDefs(QSvgNode *parent);
60 void drawCommand(QPainter *, QSvgExtraStates &) override {};
61 bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const override;
62 Type type() const override;
63};
64
65class Q_SVG_EXPORT QSvgSymbolLike : public QSvgStructureNode
66{
67 // Marker, Symbol and potentially other elements share a lot of common
68 // attributes and functionality. By making a common base class we can
69 // avoid repetition.
70public:
71 enum class Overflow : quint8 {
72 Visible,
73 Hidden,
74 Scroll = Visible, //Will not support scrolling
75 Auto = Visible
76 };
77
79 None = 0b000000,
80 xMin = 0b000001,
81 xMid = 0b000010,
82 xMax = 0b000011,
83 yMin = 0b000100,
84 yMid = 0b001000,
85 yMax = 0b001100,
86 meet = 0b010000,
87 slice = 0b100000,
88 xMask = xMin | xMid | xMax,
89 yMask = yMin | yMid | yMax,
90 xyMask = xMask | yMask,
91 meetSliceMask = meet | slice
92 };
93 Q_DECLARE_FLAGS(PreserveAspectRatios, PreserveAspectRatio)
94
95 QSvgSymbolLike(QSvgNode *parent, QRectF bounds, QRectF viewBox, QPointF refP,
96 QSvgSymbolLike::PreserveAspectRatios pAspectRatios, QSvgSymbolLike::Overflow overflow);
97 void drawCommand(QPainter *, QSvgExtraStates &) override {};
98protected:
99 void setPainterToRectAndAdjustment(QPainter *p) const;
100protected:
104 PreserveAspectRatios m_pAspectRatios;
106};
107
108Q_DECLARE_OPERATORS_FOR_FLAGS(QSvgSymbolLike::PreserveAspectRatios)
109
110class Q_SVG_EXPORT QSvgSymbol : public QSvgSymbolLike
111{
112public:
113 QSvgSymbol(QSvgNode *parent, QRectF bounds, QRectF viewBox, QPointF refP,
114 QSvgSymbolLike::PreserveAspectRatios pAspectRatios, QSvgSymbolLike::Overflow overflow);
115 void drawCommand(QPainter *p, QSvgExtraStates &states) override;
116 Type type() const override;
117};
118
119class Q_SVG_EXPORT QSvgMarker : public QSvgSymbolLike
120{
121public:
122 enum class Orientation : quint8 {
123 Auto,
124 AutoStartReverse,
125 Value
126 };
127 enum class MarkerUnits : quint8 {
128 StrokeWidth,
129 UserSpaceOnUse
130 };
131
132 QSvgMarker(QSvgNode *parent, QRectF bounds, QRectF viewBox, QPointF refP,
133 QSvgSymbolLike::PreserveAspectRatios pAspectRatios, QSvgSymbolLike::Overflow overflow,
134 Orientation orientation, qreal orientationAngle, MarkerUnits markerUnits);
135 void drawCommand(QPainter *p, QSvgExtraStates &states) override;
136 static void drawMarkersForNode(QSvgNode *node, QPainter *p, QSvgExtraStates &states);
138 return m_orientation;
139 }
141 return m_orientationAngle;
142 }
144 return m_markerUnits;
145 }
146 Type type() const override;
147private:
148 struct PositionMarkerPair {
149 qreal x;
150 qreal y;
151 qreal angle;
152 QString markerId;
153 bool isStartNode = false;
154 };
155 Orientation m_orientation;
156 qreal m_orientationAngle;
157 MarkerUnits m_markerUnits;
158};
159
160class Q_SVG_EXPORT QSvgFilterContainer : public QSvgStructureNode
161{
162public:
163
164 QSvgFilterContainer(QSvgNode *parent, const QSvgRectF &bounds, QtSvg::UnitTypes filterUnits, QtSvg::UnitTypes primitiveUnits);
165 void drawCommand(QPainter *, QSvgExtraStates &) override {};
166 bool shouldDrawNode(QPainter *, QSvgExtraStates &) const override;
167 Type type() const override;
168 QImage applyFilter(QSvgNode *referenceNode, const QImage &buffer, QPainter *p, QRectF bounds) const;
169 void setSupported(bool supported);
170 bool supported() const;
171private:
172 QSvgRectF m_rect;
173 QtSvg::UnitTypes m_filterUnits;
174 QtSvg::UnitTypes m_primitiveUnits;
175 bool m_supported;
176};
177
178
179class Q_SVG_EXPORT QSvgSwitch : public QSvgStructureNode
180{
181public:
182 QSvgSwitch(QSvgNode *parent);
183 void drawCommand(QPainter *p, QSvgExtraStates &states) override;
184 Type type() const override;
185private:
186 void init();
187private:
188 QString m_systemLanguage;
189 QString m_systemLanguagePrefix;
190};
191
192class Q_SVG_EXPORT QSvgMask : public QSvgStructureNode
193{
194public:
195 QSvgMask(QSvgNode *parent, QSvgRectF bounds,
196 QtSvg::UnitTypes contentsUnits);
197 void drawCommand(QPainter *, QSvgExtraStates &) override {};
198 bool shouldDrawNode(QPainter *, QSvgExtraStates &) const override;
199 Type type() const override;
200 QImage createMask(QPainter *p, QSvgExtraStates &states, QSvgNode *targetNode, QRectF *globalRect) const;
201 QImage createMask(QPainter *p, QSvgExtraStates &states, const QRectF &localRect, QRectF *globalRect) const;
202
204 {
205 return m_rect;
206 }
207
209 {
210 return m_contentUnits;
211 }
212
213private:
214 QSvgRectF m_rect;
215 QtSvg::UnitTypes m_contentUnits;
216};
217
218class Q_SVG_EXPORT QSvgPattern : public QSvgStructureNode
219{
220public:
221 QSvgPattern(QSvgNode *parent, QSvgRectF bounds, QRectF viewBox,
223 void drawCommand(QPainter *, QSvgExtraStates &) override {};
224 bool shouldDrawNode(QPainter *, QSvgExtraStates &) const override;
225 QImage patternImage(QPainter *p, QSvgExtraStates &states, const QSvgNode *patternElement);
226 Type type() const override;
227 const QTransform& appliedTransform() const { return m_appliedTransform; }
228
229private:
230 QImage renderPattern(QSize size, qreal contentScaleX, qreal contentScaleY);
231 void calculateAppliedTransform(QTransform& worldTransform, QRectF peLocalBB, QSize imageSize);
232
233private:
234 QTransform m_appliedTransform;
235 QSvgRectF m_rect;
236 QRectF m_viewBox;
237 QtSvg::UnitTypes m_contentUnits;
238 QTransform m_transform;
239};
240
242
243#endif // QSVGSTRUCTURE_P_H
\inmodule QtGui
Definition qimage.h:37
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void drawCommand(QPainter *, QSvgExtraStates &) override
void drawCommand(QPainter *, QSvgExtraStates &) override
MarkerUnits markerUnits() const
qreal orientationAngle() const
Orientation orientation() const
void drawCommand(QPainter *, QSvgExtraStates &) override
QtSvg::UnitTypes contentUnits() const
QSvgRectF rect() const
void drawCommand(QPainter *, QSvgExtraStates &) override
const QTransform & appliedTransform() const
QList< QSvgStructureNode * > m_linkedScopes
QHash< QString, QSvgNode * > m_scope
QList< QSvgNode * > renderers() const
QList< QSvgNode * > m_renderers
void drawCommand(QPainter *, QSvgExtraStates &) override
PreserveAspectRatios m_pAspectRatios
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
@ None
Definition qhash.cpp:531
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint buffer
GLenum type
GLfloat angle
GLfloat n
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei imageSize
GLint y
GLuint GLenum GLenum transform
GLfloat GLfloat p
[1]
GLuint * states
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
double qreal
Definition qtypes.h:187
unsigned char quint8
Definition qtypes.h:46
QLayoutItem * child
[0]
Definition moc.h:23