Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsvgstyle.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 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 "qsvgstyle_p.h"
7
8#include "qsvgfont_p.h"
9#include "qsvgnode_p.h"
10#include "private/qsvganimate_p.h"
11#include "qsvgdocument_p.h"
12
13#include "qpainter.h"
14#include "qcolor.h"
15#include "qdebug.h"
16
18
19QSvgRefCounted::~QSvgRefCounted()
20 = default;
21
22QSvgExtraStates::QSvgExtraStates()
23 : fillOpacity(1.0),
24 strokeOpacity(1.0),
25 svgFont(0),
26 textAnchor(Qt::AlignLeft),
27 fontWeight(QFont::Normal),
28 fillRule(Qt::WindingFill),
29 strokeDashOffset(0),
30 vectorEffect(false),
31 imageRendering(QSvgQualityStyle::ImageRenderingAuto)
32{
33}
34
35QSvgStyleProperty::~QSvgStyleProperty()
36 = default;
37
38QSvgQualityStyle::QSvgQualityStyle(int color)
39 : m_imageRendering(QSvgQualityStyle::ImageRenderingAuto)
40 , m_oldImageRendering(QSvgQualityStyle::ImageRenderingAuto)
41 , m_imageRenderingSet(0)
42{
43 Q_UNUSED(color);
44}
45
46QSvgQualityStyle::~QSvgQualityStyle()
47 = default;
48
49void QSvgQualityStyle::setImageRendering(ImageRendering hint) {
50 m_imageRendering = hint;
51 m_imageRenderingSet = 1;
52}
53
54void QSvgQualityStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
55{
56 m_oldImageRendering = states.imageRendering;
57 if (m_imageRenderingSet) {
58 states.imageRendering = m_imageRendering;
59 }
60 if (m_imageRenderingSet) {
61 bool smooth = false;
62 if (m_imageRendering == ImageRenderingAuto)
63 // auto (the spec says to prefer quality)
64 smooth = true;
65 else
66 smooth = (m_imageRendering == ImageRenderingOptimizeQuality);
67 p->setRenderHint(QPainter::SmoothPixmapTransform, smooth);
68 }
69}
70
71void QSvgQualityStyle::revert(QPainter *p, QSvgExtraStates &states)
72{
73 if (m_imageRenderingSet) {
74 states.imageRendering = m_oldImageRendering;
75 bool smooth = false;
76 if (m_oldImageRendering == ImageRenderingAuto)
77 smooth = true;
78 else
79 smooth = (m_oldImageRendering == ImageRenderingOptimizeQuality);
80 p->setRenderHint(QPainter::SmoothPixmapTransform, smooth);
81 }
82}
83
84QSvgFillStyle::QSvgFillStyle()
85 : m_fillRuleSet(0)
86 , m_fillOpacitySet(0)
87 , m_fillSet(0)
88{
89}
90
91QSvgFillStyle::~QSvgFillStyle()
92 = default;
93
94void QSvgFillStyle::setFillRule(Qt::FillRule f)
95{
96 m_fillRuleSet = 1;
97 m_fillRule = f;
98}
99
100void QSvgFillStyle::setFillOpacity(qreal opacity)
101{
102 m_fillOpacitySet = 1;
103 m_fillOpacity = opacity;
104}
105
106void QSvgFillStyle::setPaintServer(QSvgPaintServerSharedPtr paintServer)
107{
108 m_paintServer = paintServer;
109 m_fillSet = 1;
110}
111
112void QSvgFillStyle::setBrush(QBrush brush)
113{
114 m_fill = std::move(brush);
115 m_paintServer.reset();
116 m_fillSet = 1;
117}
118
119void QSvgFillStyle::apply(QPainter *p, const QSvgNode *n, QSvgExtraStates &states)
120{
121 m_oldFill = p->brush();
122 m_oldFillRule = states.fillRule;
123 m_oldFillOpacity = states.fillOpacity;
124
125 if (m_fillRuleSet)
126 states.fillRule = m_fillRule;
127 if (m_fillSet) {
128 if (m_paintServer)
129 p->setBrush(m_paintServer->brush(p, n, states));
130 else
131 p->setBrush(m_fill);
132 }
133 if (m_fillOpacitySet)
134 states.fillOpacity = m_fillOpacity;
135}
136
137void QSvgFillStyle::revert(QPainter *p, QSvgExtraStates &states)
138{
139 if (m_fillOpacitySet)
140 states.fillOpacity = m_oldFillOpacity;
141 if (m_fillSet)
142 p->setBrush(m_oldFill);
143 if (m_fillRuleSet)
144 states.fillRule = m_oldFillRule;
145}
146
147QSvgViewportFillStyle::QSvgViewportFillStyle(const QBrush &brush)
148 : m_viewportFill(brush)
149{
150}
151
152QSvgViewportFillStyle::~QSvgViewportFillStyle()
153 = default;
154
155void QSvgViewportFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
156{
157 m_oldFill = p->brush();
158 p->setBrush(m_viewportFill);
159}
160
161void QSvgViewportFillStyle::revert(QPainter *p, QSvgExtraStates &)
162{
163 p->setBrush(m_oldFill);
164}
165
166QSvgFontStyle::QSvgFontStyle(QSvgFont *font, QSvgDocument *doc)
167 : m_svgFont(font)
168 , m_doc(doc)
169 , m_familySet(0)
170 , m_sizeSet(0)
171 , m_styleSet(0)
172 , m_variantSet(0)
173 , m_weightSet(0)
174 , m_textAnchorSet(0)
175{
176}
177
178QSvgFontStyle::QSvgFontStyle()
179 : m_svgFont(0)
180 , m_doc(0)
181 , m_familySet(0)
182 , m_sizeSet(0)
183 , m_styleSet(0)
184 , m_variantSet(0)
185 , m_weightSet(0)
186 , m_textAnchorSet(0)
187{
188}
189
190QSvgFontStyle::~QSvgFontStyle()
191 = default;
192
193void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
194{
195 m_oldQFont = p->font();
196 m_oldSvgFont = states.svgFont;
197 m_oldTextAnchor = states.textAnchor;
198 m_oldWeight = states.fontWeight;
199
200 if (m_textAnchorSet)
201 states.textAnchor = m_textAnchor;
202
203 QFont font = m_oldQFont;
204 if (m_familySet) {
205 states.svgFont = m_svgFont;
206 font.setFamilies(m_qfont.families());
207 }
208
209 if (m_sizeSet)
210 font.setPointSizeF(m_qfont.pointSizeF());
211
212 if (m_styleSet)
213 font.setStyle(m_qfont.style());
214
215 if (m_variantSet)
216 font.setCapitalization(m_qfont.capitalization());
217
218 if (m_weightSet) {
219 if (m_weight == BOLDER) {
220 states.fontWeight = qMin(states.fontWeight + 100, static_cast<int>(QFont::Black));
221 } else if (m_weight == LIGHTER) {
222 states.fontWeight = qMax(states.fontWeight - 100, static_cast<int>(QFont::Thin));
223 } else {
224 states.fontWeight = m_weight;
225 }
226 font.setWeight(QFont::Weight(qBound(static_cast<int>(QFont::Weight::Thin),
227 states.fontWeight,
228 static_cast<int>(QFont::Weight::Black))));
229 }
230
231 p->setFont(font);
232}
233
234void QSvgFontStyle::revert(QPainter *p, QSvgExtraStates &states)
235{
236 p->setFont(m_oldQFont);
237 states.svgFont = m_oldSvgFont;
238 states.textAnchor = m_oldTextAnchor;
239 states.fontWeight = m_oldWeight;
240}
241
242QSvgStrokeStyle::QSvgStrokeStyle()
243 : m_vectorEffect(0)
244 , m_oldVectorEffect(0)
245 , m_strokeSet(0)
246 , m_strokeDashArraySet(0)
247 , m_strokeDashOffsetSet(0)
248 , m_strokeLineCapSet(0)
249 , m_strokeLineJoinSet(0)
250 , m_strokeMiterLimitSet(0)
251 , m_strokeOpacitySet(0)
252 , m_strokeWidthSet(0)
253 , m_vectorEffectSet(0)
254{
255}
256
257QSvgStrokeStyle::~QSvgStrokeStyle()
258 = default;
259
260void QSvgStrokeStyle::apply(QPainter *p, const QSvgNode *n, QSvgExtraStates &states)
261{
262 m_oldStroke = p->pen();
263 m_oldStrokeOpacity = states.strokeOpacity;
264 m_oldStrokeDashOffset = states.strokeDashOffset;
265 m_oldVectorEffect = states.vectorEffect;
266
267 QPen pen = p->pen();
268
269 qreal oldWidth = pen.widthF();
270 qreal width = m_stroke.widthF();
271 if (oldWidth == 0)
272 oldWidth = 1;
273 if (width == 0)
274 width = 1;
275 qreal scale = oldWidth / width;
276
277 if (m_strokeOpacitySet)
278 states.strokeOpacity = m_strokeOpacity;
279
280 if (m_vectorEffectSet)
281 states.vectorEffect = m_vectorEffect;
282
283 if (m_strokeSet) {
284 if (m_paintServer)
285 pen.setBrush(m_paintServer->brush(p, n, states));
286 else
287 pen.setBrush(m_stroke.brush());
288 }
289
290 if (m_strokeWidthSet)
291 pen.setWidthF(m_stroke.widthF());
292
293 bool setDashOffsetNeeded = false;
294
295 if (m_strokeDashOffsetSet) {
296 states.strokeDashOffset = m_strokeDashOffset;
297 setDashOffsetNeeded = true;
298 }
299
300 if (m_strokeDashArraySet) {
301 if (m_stroke.style() == Qt::SolidLine) {
302 pen.setStyle(Qt::SolidLine);
303 } else if (m_strokeWidthSet || oldWidth == 1) {
304 // If both width and dash array was set, the dash array is already scaled correctly.
305 pen.setDashPattern(m_stroke.dashPattern());
306 setDashOffsetNeeded = true;
307 } else {
308 // If dash array was set, but not the width, the dash array has to be scaled with respect to the old width.
309 QList<qreal> dashes = m_stroke.dashPattern();
310 for (int i = 0; i < dashes.size(); ++i)
311 dashes[i] /= oldWidth;
312 pen.setDashPattern(dashes);
313 setDashOffsetNeeded = true;
314 }
315 } else if (m_strokeWidthSet && pen.style() != Qt::SolidLine && scale != 1) {
316 // If the width was set, but not the dash array, the old dash array must be scaled with respect to the new width.
317 QList<qreal> dashes = pen.dashPattern();
318 for (int i = 0; i < dashes.size(); ++i)
319 dashes[i] *= scale;
320 pen.setDashPattern(dashes);
321 setDashOffsetNeeded = true;
322 }
323
324 if (m_strokeLineCapSet)
325 pen.setCapStyle(m_stroke.capStyle());
326 if (m_strokeLineJoinSet)
327 pen.setJoinStyle(m_stroke.joinStyle());
328 if (m_strokeMiterLimitSet)
329 pen.setMiterLimit(m_stroke.miterLimit());
330
331 // You can have dash offset on solid strokes in SVG files, but not in Qt.
332 // QPen::setDashOffset() will set the pen style to Qt::CustomDashLine,
333 // so don't call the method if the pen is solid.
334 if (setDashOffsetNeeded && pen.style() != Qt::SolidLine) {
335 qreal currentWidth = pen.widthF();
336 if (currentWidth == 0)
337 currentWidth = 1;
338 pen.setDashOffset(states.strokeDashOffset / currentWidth);
339 }
340
341 pen.setCosmetic(states.vectorEffect);
342
343 p->setPen(pen);
344}
345
346void QSvgStrokeStyle::revert(QPainter *p, QSvgExtraStates &states)
347{
348 p->setPen(m_oldStroke);
349 states.strokeOpacity = m_oldStrokeOpacity;
350 states.strokeDashOffset = m_oldStrokeDashOffset;
351 states.vectorEffect = m_oldVectorEffect;
352}
353
354void QSvgStrokeStyle::setDashArray(const QList<qreal> &dashes)
355{
356 if (m_strokeWidthSet) {
357 QList<qreal> d = dashes;
358 qreal w = m_stroke.widthF();
359 if (w != 0 && w != 1) {
360 for (int i = 0; i < d.size(); ++i)
361 d[i] /= w;
362 }
363 m_stroke.setDashPattern(d);
364 } else {
365 m_stroke.setDashPattern(dashes);
366 }
367 m_strokeDashArraySet = 1;
368}
369
370QSvgTransformStyle::QSvgTransformStyle(const QTransform &trans)
371 : m_transform(trans)
372{
373}
374
375QSvgTransformStyle::~QSvgTransformStyle()
376 = default;
377
378void QSvgTransformStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
379{
380 m_oldWorldTransform.push(p->worldTransform());
381 p->setWorldTransform(m_transform, true);
382}
383
384void QSvgTransformStyle::revert(QPainter *p, QSvgExtraStates &)
385{
386 p->setWorldTransform(m_oldWorldTransform.pop(), false /* don't combine */);
387}
388
389QSvgStyleProperty::Type QSvgQualityStyle::type() const
390{
391 return QUALITY;
392}
393
394QSvgStyleProperty::Type QSvgFillStyle::type() const
395{
396 return FILL;
397}
398
399QSvgStyleProperty::Type QSvgViewportFillStyle::type() const
400{
401 return VIEWPORT_FILL;
402}
403
404QSvgStyleProperty::Type QSvgFontStyle::type() const
405{
406 return FONT;
407}
408
409QSvgStyleProperty::Type QSvgStrokeStyle::type() const
410{
411 return STROKE;
412}
413
414QSvgStyleProperty::Type QSvgTransformStyle::type() const
415{
416 return TRANSFORM;
417}
418
419
420QSvgCompOpStyle::QSvgCompOpStyle(QPainter::CompositionMode mode)
421 : m_mode(mode)
422{
423
424}
425
426QSvgCompOpStyle::~QSvgCompOpStyle()
427 = default;
428
429void QSvgCompOpStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
430{
431 m_oldMode = p->compositionMode();
432 p->setCompositionMode(m_mode);
433}
434
435void QSvgCompOpStyle::revert(QPainter *p, QSvgExtraStates &)
436{
437 p->setCompositionMode(m_oldMode);
438}
439
440QSvgStyleProperty::Type QSvgCompOpStyle::type() const
441{
442 return COMP_OP;
443}
444
445QSvgOffsetStyle::~QSvgOffsetStyle()
446 = default;
447
448void QSvgOffsetStyle::apply(QPainter *, const QSvgNode *, QSvgExtraStates &)
449{
450}
451
452void QSvgOffsetStyle::revert(QPainter *, QSvgExtraStates &)
453{
454}
455
456QSvgStyleProperty::Type QSvgOffsetStyle::type() const
457{
458 return OFFSET;
459}
460
461QSvgOpacityStyle::QSvgOpacityStyle(qreal opacity)
462 : m_opacity(opacity), m_oldOpacity(0)
463{
464
465}
466
467QSvgOpacityStyle::~QSvgOpacityStyle()
468 = default;
469
470void QSvgOpacityStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
471{
472 m_oldOpacity = p->opacity();
473 p->setOpacity(m_opacity * m_oldOpacity);
474}
475
476void QSvgOpacityStyle::revert(QPainter *p, QSvgExtraStates &)
477{
478 p->setOpacity(m_oldOpacity);
479}
480
481QSvgStyleProperty::Type QSvgOpacityStyle::type() const
482{
483 return OPACITY;
484}
485
486QSvgStaticStyle::QSvgStaticStyle()
487 : quality(0)
488 , fill(0)
489 , viewportFill(0)
490 , font(0)
491 , stroke(0)
492 , transform(0)
493 , opacity(0)
494 , compop(0)
495{
496}
497
498QSvgStaticStyle::~QSvgStaticStyle()
499{
500}
501
502void QSvgStaticStyle::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
503{
504 if (quality) {
505 quality->apply(p, node, states);
506 }
507
508 if (fill) {
509 fill->apply(p, node, states);
510 }
511
512 if (viewportFill) {
513 viewportFill->apply(p, node, states);
514 }
515
516 if (font) {
517 font->apply(p, node, states);
518 }
519
520 if (stroke) {
521 stroke->apply(p, node, states);
522 }
523
524 if (transform) {
525 transform->apply(p, node, states);
526 }
527
528 if (opacity) {
529 opacity->apply(p, node, states);
530 }
531
532 if (compop) {
533 compop->apply(p, node, states);
534 }
535}
536
537void QSvgStaticStyle::revert(QPainter *p, QSvgExtraStates &states)
538{
539 if (quality) {
540 quality->revert(p, states);
541 }
542
543 if (fill) {
544 fill->revert(p, states);
545 }
546
547 if (viewportFill) {
548 viewportFill->revert(p, states);
549 }
550
551 if (font) {
552 font->revert(p, states);
553 }
554
555 if (stroke) {
556 stroke->revert(p, states);
557 }
558
559 if (transform) {
560 transform->revert(p, states);
561 }
562
563 if (opacity) {
564 opacity->revert(p, states);
565 }
566
567 if (compop) {
568 compop->revert(p, states);
569 }
570}
571
572namespace {
573
574QColor sumValue(const QColor &c1, const QColor &c2)
575{
576 QRgb rgb1 = c1.rgba();
577 QRgb rgb2 = c2.rgba();
578 int sumRed = qRed(rgb1) + qRed(rgb2);
579 int sumGreen = qGreen(rgb1) + qGreen(rgb2);
580 int sumBlue = qBlue(rgb1) + qBlue(rgb2);
581
582 QRgb sumRgb = qRgba(qBound(0, sumRed, 255),
583 qBound(0, sumGreen, 255),
584 qBound(0, sumBlue, 255),
585 255);
586
587 return QColor(sumRgb);
588}
589
590qreal sumValue(qreal value1, qreal value2)
591{
592 qreal sumValue = value1 + value2;
593 return qBound(0.0, sumValue, 1.0);
594}
595
596}
597
598QSvgAnimatedStyle::QSvgAnimatedStyle()
599{
600}
601
602QSvgAnimatedStyle::~QSvgAnimatedStyle()
603{
604}
605
606void QSvgAnimatedStyle::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
607{
608 QSharedPointer<QSvgAbstractAnimator> animator = node->document()->animator();
609 QList<QSvgAbstractAnimation *> nodeAnims = animator->animationsForNode(node);
610
611 savePaintingState(p, node, states);
612 if (nodeAnims.isEmpty())
613 return;
614
615 QSvgStyleState currentStyle = m_static;
616 for (const QSvgAbstractAnimation *anim : std::as_const(nodeAnims)) {
617 if (!anim->isActive())
618 continue;
619
620 fetchStyleState(anim, currentStyle);
621 }
622
623 applyStyle(p, states, currentStyle);
624}
625
626void QSvgAnimatedStyle::revert(QPainter *p, QSvgExtraStates &states)
627{
628 p->setWorldTransform(m_worldTransform);
629 p->setBrush(m_static.fill);
630 p->setPen(m_static.stroke);
631 p->setOpacity(m_static.opacity);
632 states.fillOpacity = m_static.fillOpacity;
633 states.strokeOpacity = m_static.strokeOpacity;
634}
635
636void QSvgAnimatedStyle::savePaintingState(const QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
637{
638 QSvgStaticStyle style = node->style();
639 m_worldTransform = p->worldTransform();
640 if (style.transform)
641 m_static.transform = style.transform->qtransform();
642
643 if (style.offset) {
644 m_static.offsetPath = style.offset->path();
645 m_static.offsetRotateType = style.offset->rotateType();
646 m_static.offsetRotate = style.offset->rotateAngle();
647 }
648
649 m_static.fill = p->brush();
650 m_static.stroke = p->pen();
651 m_static.fillOpacity = states.fillOpacity;
652 m_static.strokeOpacity = states.strokeOpacity;
653 m_static.opacity = p->opacity();
654 m_transformToNode = m_static.transform.inverted() * m_worldTransform;
655}
656
657void QSvgAnimatedStyle::fetchStyleState(const QSvgAbstractAnimation *animation, QSvgStyleState &currentStyle)
658{
659 bool replace = animation->animationType() == QSvgAbstractAnimation::CSS ? true :
660 (static_cast<const QSvgAnimateNode *>(animation))->additiveType() == QSvgAnimateNode::Replace;
661
662 QList<QSvgAbstractAnimatedProperty *> properties = animation->properties();
663 for (const QSvgAbstractAnimatedProperty *property : std::as_const(properties)) {
664 if (property->propertyName() == QStringLiteral("fill")) {
665 QBrush brush = currentStyle.fill;
666 QColor brushColor = brush.color();
667 QColor animatedColor = property->interpolatedValue().value<QColor>();
668 QColor sumOrReplaceColor = replace ? animatedColor : sumValue(brushColor, animatedColor);
669 brush.setColor(sumOrReplaceColor);
670 currentStyle.fill = brush;
671 } else if (property->propertyName() == QStringLiteral("stroke")) {
672 QPen &pen = currentStyle.stroke;
673 QBrush penBrush = pen.brush();
674 QColor penColor = penBrush.color();
675 QColor animatedColor = property->interpolatedValue().value<QColor>();
676 QColor sumOrReplaceColor = replace ? animatedColor : sumValue(penColor, animatedColor);
677 penBrush.setColor(sumOrReplaceColor);
678 penBrush.setStyle(Qt::SolidPattern);
679 pen.setBrush(penBrush);
680 } else if (property->propertyName() == QStringLiteral("transform")) {
681 QTransform animatedTransform = property->interpolatedValue().value<QTransform>();
682 QTransform sumOrReplaceTransform = replace ? animatedTransform : animatedTransform * currentStyle.transform;
683 currentStyle.transform = sumOrReplaceTransform;
684 } else if (property->propertyName() == QStringLiteral("fill-opacity")) {
685 qreal animatedFillOpacity = property->interpolatedValue().value<qreal>();
686 qreal sumOrReplaceOpacity = replace ? animatedFillOpacity : sumValue(currentStyle.fillOpacity, animatedFillOpacity);
687 currentStyle.fillOpacity = sumOrReplaceOpacity;
688 } else if (property->propertyName() == QStringLiteral("stroke-opacity")) {
689 qreal animatedStrokeOpacity = property->interpolatedValue().value<qreal>();
690 qreal sumOrReplaceOpacity = replace ? animatedStrokeOpacity : sumValue(currentStyle.strokeOpacity, animatedStrokeOpacity);
691 currentStyle.strokeOpacity = sumOrReplaceOpacity;
692 } else if (property->propertyName() == QStringLiteral("opacity")) {
693 qreal animatedOpacity = property->interpolatedValue().value<qreal>();
694 qreal sumOrReplaceOpacity = replace ? animatedOpacity : sumValue(currentStyle.opacity, animatedOpacity);
695 currentStyle.opacity = sumOrReplaceOpacity;
696 } else if (property->propertyName() == QStringLiteral("offset-distance")) {
697 qreal offsetDistance = property->interpolatedValue().value<qreal>();
698 currentStyle.offsetDistance = offsetDistance;
699 }
700 }
701}
702
703void QSvgAnimatedStyle::applyStyle(QPainter *p, QSvgExtraStates &states, const QSvgStyleState &currentStyle)
704{
705 p->setBrush(currentStyle.fill);
706 states.fillOpacity = currentStyle.fillOpacity;
707 p->setPen(currentStyle.stroke);
708 states.strokeOpacity = currentStyle.strokeOpacity;
709 p->setOpacity(currentStyle.opacity);
710
711 QTransform transform = currentStyle.transform;
712 QTransform offset;
713 if (m_static.offsetPath) {
714 qreal offsetDistance = currentStyle.offsetDistance;
715 qreal angle = m_static.offsetPath.value().angleAtPercent(offsetDistance);
716 QPointF position = m_static.offsetPath.value().pointAtPercent(offsetDistance);
717 offset.translate(position.x(), position.y());
718
719 switch (m_static.offsetRotateType) {
720 case QtSvg::OffsetRotateType::Auto:
721 offset.rotate(-angle);
722 break;
723 case QtSvg::OffsetRotateType::Angle:
724 offset.rotate(m_static.offsetRotate);
725 break;
726 case QtSvg::OffsetRotateType::AutoAngle:
727 offset.rotate(m_static.offsetRotate - angle);
728 break;
729 case QtSvg::OffsetRotateType::Reverse:
730 offset.rotate(180 - angle);
731 break;
732 case QtSvg::OffsetRotateType::ReverseAngle:
733 offset.rotate(180 + m_static.offsetRotate - angle);
734 break;
735 }
736 }
737
738 QTransform combinedTransform = transform * offset * m_transformToNode;
739 p->setWorldTransform(combinedTransform);
740}
741
742QT_END_NAMESPACE
Combined button and popup list for selecting options.
#define QStringLiteral(str)
Definition qstring.h:1825