Qt 4.8
qsvgstyle.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtSvg module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qsvgstyle_p.h"
43 
44 #ifndef QT_NO_SVG
45 
46 #include "qsvgfont_p.h"
47 #include "qsvggraphics_p.h"
48 #include "qsvgnode_p.h"
49 #include "qsvgtinydocument_p.h"
50 
51 #include "qpainter.h"
52 #include "qpair.h"
53 #include "qcolor.h"
54 #include "qdebug.h"
55 #include "qmath.h"
56 #include "qnumeric.h"
57 
59 
61  : fillOpacity(1.0)
62  , strokeOpacity(1.0)
63  , svgFont(0)
64  , textAnchor(Qt::AlignLeft)
65  , fontWeight(400)
66  , fillRule(Qt::WindingFill)
67  , strokeDashOffset(0)
68  , vectorEffect(false)
69 {
70 }
71 
73 {
74 }
75 
77 {
78  Q_ASSERT(!"This should not be called!");
79 }
80 
82 {
83  Q_ASSERT(!"This should not be called!");
84 }
85 
86 
88  : m_colorRendering(color)
89 {
90 
91 }
93 {
94 
95 }
97 {
98 
99 }
100 
102  : m_style(0)
103  , m_fillRule(Qt::WindingFill)
104  , m_oldFillRule(Qt::WindingFill)
105  , m_fillOpacity(1.0)
106  , m_oldFillOpacity(0)
107  , m_gradientResolved(1)
108  , m_fillRuleSet(0)
109  , m_fillOpacitySet(0)
110  , m_fillSet(0)
111 {
112 }
113 
115 {
116  m_fillRuleSet = 1;
117  m_fillRule = f;
118 }
119 
121 {
122  m_fillOpacitySet = 1;
123  m_fillOpacity = opacity;
124 }
125 
127 {
128  m_style = style;
129  m_fillSet = 1;
130 }
131 
133 {
134  m_fill = brush;
135  m_style = 0;
136  m_fillSet = 1;
137 }
138 
140 {
141  m_oldFill = p->brush();
142  m_oldFillRule = states.fillRule;
143  m_oldFillOpacity = states.fillOpacity;
144 
145  if (m_fillRuleSet)
146  states.fillRule = m_fillRule;
147  if (m_fillSet) {
148  if (m_style)
149  p->setBrush(m_style->brush(p, states));
150  else
151  p->setBrush(m_fill);
152  }
153  if (m_fillOpacitySet)
154  states.fillOpacity = m_fillOpacity;
155 }
156 
158 {
159  if (m_fillOpacitySet)
160  states.fillOpacity = m_oldFillOpacity;
161  if (m_fillSet)
162  p->setBrush(m_oldFill);
163  if (m_fillRuleSet)
164  states.fillRule = m_oldFillRule;
165 }
166 
168  : m_viewportFill(brush)
169 {
170 }
171 
173 {
174  m_oldFill = p->brush();
176 }
177 
179 {
180  p->setBrush(m_oldFill);
181 }
182 
184  : m_svgFont(font)
185  , m_doc(doc)
186  , m_familySet(0)
187  , m_sizeSet(0)
188  , m_styleSet(0)
189  , m_variantSet(0)
190  , m_weightSet(0)
191  , m_textAnchorSet(0)
192 {
193 }
194 
196  : m_svgFont(0)
197  , m_doc(0)
198  , m_familySet(0)
199  , m_sizeSet(0)
200  , m_styleSet(0)
201  , m_variantSet(0)
202  , m_weightSet(0)
203  , m_textAnchorSet(0)
204 {
205 }
206 
208  switch (weight) {
209  case 100:
210  case 200:
211  return QFont::Light;
212  case 300:
213  case 400:
214  return QFont::Normal;
215  case 500:
216  case 600:
217  return QFont::DemiBold;
218  case 700:
219  case 800:
220  return QFont::Bold;
221  case 900:
222  return QFont::Black;
223  }
224  return QFont::Normal;
225 }
226 
228 {
229  m_oldQFont = p->font();
230  m_oldSvgFont = states.svgFont;
231  m_oldTextAnchor = states.textAnchor;
232  m_oldWeight = states.fontWeight;
233 
234  if (m_textAnchorSet)
235  states.textAnchor = m_textAnchor;
236 
237  QFont font = m_oldQFont;
238  if (m_familySet) {
239  states.svgFont = m_svgFont;
240  font.setFamily(m_qfont.family());
241  }
242 
243  if (m_sizeSet)
245 
246  if (m_styleSet)
247  font.setStyle(m_qfont.style());
248 
249  if (m_variantSet)
251 
252  if (m_weightSet) {
253  if (m_weight == BOLDER) {
254  states.fontWeight = qMin(states.fontWeight + 100, 900);
255  } else if (m_weight == LIGHTER) {
256  states.fontWeight = qMax(states.fontWeight - 100, 100);
257  } else {
258  states.fontWeight = m_weight;
259  }
260  font.setWeight(SVGToQtWeight(states.fontWeight));
261  }
262 
263  p->setFont(font);
264 }
265 
267 {
268  p->setFont(m_oldQFont);
269  states.svgFont = m_oldSvgFont;
270  states.textAnchor = m_oldTextAnchor;
271  states.fontWeight = m_oldWeight;
272 }
273 
275  : m_strokeOpacity(1.0)
276  , m_oldStrokeOpacity(0.0)
277  , m_strokeDashOffset(0)
278  , m_oldStrokeDashOffset(0)
279  , m_style(0)
280  , m_gradientResolved(1)
281  , m_vectorEffect(0)
282  , m_oldVectorEffect(0)
283  , m_strokeSet(0)
284  , m_strokeDashArraySet(0)
285  , m_strokeDashOffsetSet(0)
286  , m_strokeLineCapSet(0)
287  , m_strokeLineJoinSet(0)
288  , m_strokeMiterLimitSet(0)
289  , m_strokeOpacitySet(0)
290  , m_strokeWidthSet(0)
291  , m_vectorEffectSet(0)
292 {
293 }
294 
296 {
297  m_oldStroke = p->pen();
301 
302  QPen pen = p->pen();
303 
304  qreal oldWidth = pen.widthF();
306  if (oldWidth == 0)
307  oldWidth = 1;
308  if (width == 0)
309  width = 1;
310  qreal scale = oldWidth / width;
311 
312  if (m_strokeOpacitySet)
314 
315  if (m_vectorEffectSet)
316  states.vectorEffect = m_vectorEffect;
317 
318  if (m_strokeSet) {
319  if (m_style)
320  pen.setBrush(m_style->brush(p, states));
321  else
322  pen.setBrush(m_stroke.brush());
323  }
324 
325  if (m_strokeWidthSet)
326  pen.setWidthF(m_stroke.widthF());
327 
328  bool setDashOffsetNeeded = false;
329 
330  if (m_strokeDashOffsetSet) {
332  setDashOffsetNeeded = true;
333  }
334 
335  if (m_strokeDashArraySet) {
336  if (m_stroke.style() == Qt::SolidLine) {
337  pen.setStyle(Qt::SolidLine);
338  } else if (m_strokeWidthSet || oldWidth == 1) {
339  // If both width and dash array was set, the dash array is already scaled correctly.
341  setDashOffsetNeeded = true;
342  } else {
343  // If dash array was set, but not the width, the dash array has to be scaled with respect to the old width.
345  for (int i = 0; i < dashes.size(); ++i)
346  dashes[i] /= oldWidth;
347  pen.setDashPattern(dashes);
348  setDashOffsetNeeded = true;
349  }
350  } else if (m_strokeWidthSet && pen.style() != Qt::SolidLine && scale != 1) {
351  // If the width was set, but not the dash array, the old dash array must be scaled with respect to the new width.
352  QVector<qreal> dashes = pen.dashPattern();
353  for (int i = 0; i < dashes.size(); ++i)
354  dashes[i] *= scale;
355  pen.setDashPattern(dashes);
356  setDashOffsetNeeded = true;
357  }
358 
359  if (m_strokeLineCapSet)
365 
366  // You can have dash offset on solid strokes in SVG files, but not in Qt.
367  // QPen::setDashOffset() will set the pen style to Qt::CustomDashLine,
368  // so don't call the method if the pen is solid.
369  if (setDashOffsetNeeded && pen.style() != Qt::SolidLine) {
370  qreal currentWidth = pen.widthF();
371  if (currentWidth == 0)
372  currentWidth = 1;
373  pen.setDashOffset(states.strokeDashOffset / currentWidth);
374  }
375 
376  pen.setCosmetic(states.vectorEffect);
377 
378  p->setPen(pen);
379 }
380 
382 {
383  p->setPen(m_oldStroke);
387 }
388 
390 {
391  if (m_strokeWidthSet) {
392  QVector<qreal> d = dashes;
393  qreal w = m_stroke.widthF();
394  if (w != 0 && w != 1) {
395  for (int i = 0; i < d.size(); ++i)
396  d[i] /= w;
397  }
399  } else {
400  m_stroke.setDashPattern(dashes);
401  }
403 }
404 
406  : m_solidColor(color)
407 {
408 }
409 
411  : m_gradient(grad), m_gradientStopsSet(false)
412 {
413 }
414 
416 {
417  if (!m_link.isEmpty()) {
418  resolveStops();
419  }
420 
421  // If the gradient is marked as empty, insert transparent black
422  if (!m_gradientStopsSet) {
423  m_gradient->setStops(QGradientStops() << QGradientStop(0.0, QColor(0, 0, 0, 0)));
424  m_gradientStopsSet = true;
425  }
426 
427  QBrush b(*m_gradient);
428 
429  if (!m_matrix.isIdentity())
430  b.setMatrix(m_matrix);
431 
432  return b;
433 }
434 
435 
437 {
438  m_matrix = mat;
439 }
440 
442  : m_transform(trans)
443 {
444 }
445 
447 {
449  p->setWorldTransform(m_transform, true);
450 }
451 
453 {
454  p->setWorldTransform(m_oldWorldTransform, false /* don't combine */);
455 }
456 
458 {
459  return QUALITY;
460 }
461 
463 {
464  return FILL;
465 }
466 
468 {
469  return VIEWPORT_FILL;
470 }
471 
473 {
474  return FONT;
475 }
476 
478 {
479  return STROKE;
480 }
481 
483 {
484  return SOLID_COLOR;
485 }
486 
488 {
489  return GRADIENT;
490 }
491 
493 {
494  return TRANSFORM;
495 }
496 
497 
499  : m_mode(mode)
500 {
501 
502 }
503 
505 {
506  m_oldMode = p->compositionMode();
508 }
509 
511 {
513 }
514 
516 {
517  return COMP_OP;
518 }
519 
521 {
522 }
523 
524 void QSvgStyle::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
525 {
526  if (quality) {
527  quality->apply(p, node, states);
528  }
529 
530  if (fill) {
531  fill->apply(p, node, states);
532  }
533 
534  if (viewportFill) {
535  viewportFill->apply(p, node, states);
536  }
537 
538  if (font) {
539  font->apply(p, node, states);
540  }
541 
542  if (stroke) {
543  stroke->apply(p, node, states);
544  }
545 
546  if (transform) {
547  transform->apply(p, node, states);
548  }
549 
550  if (animateColor) {
551  animateColor->apply(p, node, states);
552  }
553 
554  //animated transforms have to be applied
555  //_after_ the original object transformations
556  if (!animateTransforms.isEmpty()) {
557  qreal totalTimeElapsed = node->document()->currentElapsed();
558  // Find the last animateTransform with additive="replace", since this will override all
559  // previous animateTransforms.
560  QList<QSvgRefCounter<QSvgAnimateTransform> >::const_iterator itr = animateTransforms.constEnd();
561  do {
562  --itr;
563  if ((*itr)->animActive(totalTimeElapsed)
564  && (*itr)->additiveType() == QSvgAnimateTransform::Replace) {
565  // An animateTransform with additive="replace" will replace the transform attribute.
566  if (transform)
567  transform->revert(p, states);
568  break;
569  }
570  } while (itr != animateTransforms.constBegin());
571 
572  // Apply the animateTransforms after and including the last one with additive="replace".
573  for (; itr != animateTransforms.constEnd(); ++itr) {
574  if ((*itr)->animActive(totalTimeElapsed))
575  (*itr)->apply(p, node, states);
576  }
577  }
578 
579  if (opacity) {
580  opacity->apply(p, node, states);
581  }
582 
583  if (compop) {
584  compop->apply(p, node, states);
585  }
586 }
587 
589 {
590  if (quality) {
591  quality->revert(p, states);
592  }
593 
594  if (fill) {
595  fill->revert(p, states);
596  }
597 
598  if (viewportFill) {
599  viewportFill->revert(p, states);
600  }
601 
602  if (font) {
603  font->revert(p, states);
604  }
605 
606  if (stroke) {
607  stroke->revert(p, states);
608  }
609 
610  //animated transforms need to be reverted _before_
611  //the native transforms
612  if (!animateTransforms.isEmpty()) {
613  QList<QSvgRefCounter<QSvgAnimateTransform> >::const_iterator itr = animateTransforms.constBegin();
614  for (; itr != animateTransforms.constEnd(); ++itr) {
615  if ((*itr)->transformApplied()) {
616  (*itr)->revert(p, states);
617  break;
618  }
619  }
620  for (; itr != animateTransforms.constEnd(); ++itr)
621  (*itr)->clearTransformApplied();
622  }
623 
624  if (transform) {
625  transform->revert(p, states);
626  }
627 
628  if (animateColor) {
629  animateColor->revert(p, states);
630  }
631 
632  if (opacity) {
633  opacity->revert(p, states);
634  }
635 
636  if (compop) {
637  compop->revert(p, states);
638  }
639 }
640 
641 QSvgAnimateTransform::QSvgAnimateTransform(int startMs, int endMs, int byMs )
642  : QSvgStyleProperty(),
643  m_from(startMs), m_to(endMs), m_by(byMs),
644  m_type(Empty), m_additive(Replace), m_count(0), m_finished(false), m_transformApplied(false)
645 {
647 }
648 
650 {
651  m_type = type;
652  m_args = args;
653  m_additive = additive;
654  Q_ASSERT(!(args.count()%3));
655  m_count = args.count() / 3;
656 }
657 
659 {
661  resolveMatrix(node);
662  p->setWorldTransform(m_transform, true);
663  m_transformApplied = true;
664 }
665 
667 {
668  p->setWorldTransform(m_oldWorldTransform, false /* don't combine */);
669  m_transformApplied = false;
670 }
671 
673 {
674  static const qreal deg2rad = qreal(0.017453292519943295769);
675  qreal totalTimeElapsed = node->document()->currentElapsed();
676  if (totalTimeElapsed < m_from || m_finished)
677  return;
678 
679  qreal animationFrame = 0;
680  if (m_totalRunningTime != 0) {
681  animationFrame = (totalTimeElapsed - m_from) / m_totalRunningTime;
682 
683  if (m_repeatCount >= 0 && m_repeatCount < animationFrame) {
684  m_finished = true;
685  animationFrame = m_repeatCount;
686  }
687  }
688 
689  qreal percentOfAnimation = animationFrame;
690  if (percentOfAnimation > 1) {
691  percentOfAnimation -= ((int)percentOfAnimation);
692  }
693 
694  qreal currentPosition = percentOfAnimation * (m_count - 1);
695  int startElem = qFloor(currentPosition);
696  int endElem = qCeil(currentPosition);
697 
698  switch(m_type)
699  {
700  case Translate: {
701  startElem *= 3;
702  endElem *= 3;
703  qreal from1, from2;
704  qreal to1, to2;
705  from1 = m_args[startElem++];
706  from2 = m_args[startElem++];
707  to1 = m_args[endElem++];
708  to2 = m_args[endElem++];
709 
710  qreal transXDiff = (to1-from1) * percentOfAnimation;
711  qreal transX = from1 + transXDiff;
712  qreal transYDiff = (to2-from2) * percentOfAnimation;
713  qreal transY = from2 + transYDiff;
715  m_transform.translate(transX, transY);
716  break;
717  }
718  case Scale: {
719  startElem *= 3;
720  endElem *= 3;
721  qreal from1, from2;
722  qreal to1, to2;
723  from1 = m_args[startElem++];
724  from2 = m_args[startElem++];
725  to1 = m_args[endElem++];
726  to2 = m_args[endElem++];
727 
728  qreal transXDiff = (to1-from1) * percentOfAnimation;
729  qreal transX = from1 + transXDiff;
730  qreal transYDiff = (to2-from2) * percentOfAnimation;
731  qreal transY = from2 + transYDiff;
732  if (transY == 0)
733  transY = transX;
735  m_transform.scale(transX, transY);
736  break;
737  }
738  case Rotate: {
739  startElem *= 3;
740  endElem *= 3;
741  qreal from1, from2, from3;
742  qreal to1, to2, to3;
743  from1 = m_args[startElem++];
744  from2 = m_args[startElem++];
745  from3 = m_args[startElem++];
746  to1 = m_args[endElem++];
747  to2 = m_args[endElem++];
748  to3 = m_args[endElem++];
749 
750  qreal rotationDiff = (to1 - from1) * percentOfAnimation;
751  //qreal rotation = from1 + rotationDiff;
752 
753  qreal transXDiff = (to2-from2) * percentOfAnimation;
754  qreal transX = from2 + transXDiff;
755  qreal transYDiff = (to3-from3) * percentOfAnimation;
756  qreal transY = from3 + transYDiff;
758  m_transform.translate(transX, transY);
759  m_transform.rotate(rotationDiff);
760  m_transform.translate(-transX, -transY);
761  break;
762  }
763  case SkewX: {
764  startElem *= 3;
765  endElem *= 3;
766  qreal from1;
767  qreal to1;
768  from1 = m_args[startElem++];
769  to1 = m_args[endElem++];
770 
771  qreal transXDiff = (to1-from1) * percentOfAnimation;
772  qreal transX = from1 + transXDiff;
774  m_transform.shear(qTan(transX * deg2rad), 0);
775  break;
776  }
777  case SkewY: {
778  startElem *= 3;
779  endElem *= 3;
780  qreal from1;
781  qreal to1;
782  from1 = m_args[startElem++];
783  to1 = m_args[endElem++];
784 
785 
786  qreal transYDiff = (to1 - from1) * percentOfAnimation;
787  qreal transY = from1 + transYDiff;
789  m_transform.shear(0, qTan(transY * deg2rad));
790  break;
791  }
792  default:
793  break;
794  }
795 }
796 
798 {
799  return ANIMATE_TRANSFORM;
800 }
801 
803 {
804  m_freeze = freeze;
805 }
806 
808 {
809  m_repeatCount = repeatCount;
810 }
811 
812 QSvgAnimateColor::QSvgAnimateColor(int startMs, int endMs, int byMs)
813  : QSvgStyleProperty(),
814  m_from(startMs), m_to(endMs), m_by(byMs),
815  m_finished(false)
816 {
818 }
819 
821  const QList<QColor> &colors)
822 {
823  m_fill = fill;
824  m_colors = colors;
825 }
826 
828 {
829  m_freeze = freeze;
830 }
831 
833 {
834  m_repeatCount = repeatCount;
835 }
836 
838 {
839  qreal totalTimeElapsed = node->document()->currentElapsed();
840  if (totalTimeElapsed < m_from || m_finished)
841  return;
842 
843  qreal animationFrame = 0;
844  if (m_totalRunningTime != 0)
845  animationFrame = (totalTimeElapsed - m_from) / m_totalRunningTime;
846 
847  if (m_repeatCount >= 0 && m_repeatCount < animationFrame) {
848  m_finished = true;
849  animationFrame = m_repeatCount;
850  }
851 
852  qreal percentOfAnimation = animationFrame;
853  if (percentOfAnimation > 1) {
854  percentOfAnimation -= ((int)percentOfAnimation);
855  }
856 
857  qreal currentPosition = percentOfAnimation * (m_colors.count() - 1);
858 
859  int startElem = qFloor(currentPosition);
860  int endElem = qCeil(currentPosition);
861  QColor start = m_colors[startElem];
862  QColor end = m_colors[endElem];
863 
864  qreal percentOfColorMorph = currentPosition;
865  if (percentOfColorMorph > 1) {
866  percentOfColorMorph -= ((int)percentOfColorMorph);
867  }
868 
869  // Interpolate between the two fixed colors start and end
870  qreal aDiff = (end.alpha() - start.alpha()) * percentOfColorMorph;
871  qreal rDiff = (end.red() - start.red()) * percentOfColorMorph;
872  qreal gDiff = (end.green() - start.green()) * percentOfColorMorph;
873  qreal bDiff = (end.blue() - start.blue()) * percentOfColorMorph;
874 
875  int alpha = int(start.alpha() + aDiff);
876  int red = int(start.red() + rDiff);
877  int green = int(start.green() + gDiff);
878  int blue = int(start.blue() + bDiff);
879 
880  QColor color(red, green, blue, alpha);
881 
882  if (m_fill) {
883  QBrush b = p->brush();
884  m_oldBrush = b;
885  b.setColor(color);
886  p->setBrush(b);
887  } else {
888  QPen pen = p->pen();
889  m_oldPen = pen;
890  pen.setColor(color);
891  p->setPen(pen);
892  }
893 }
894 
896 {
897  if (m_fill) {
898  p->setBrush(m_oldBrush);
899  } else {
900  p->setPen(m_oldPen);
901  }
902 }
903 
905 {
906  return ANIMATE_COLOR;
907 }
908 
910  : m_opacity(opacity), m_oldOpacity(0)
911 {
912 
913 }
914 
916 {
917  m_oldOpacity = p->opacity();
919 }
920 
922 {
924 }
925 
927 {
928  return OPACITY;
929 }
930 
932 {
933  m_link = link;
934  m_doc = doc;
935 }
936 
938 {
939  if (!m_link.isEmpty() && m_doc) {
940  QSvgStyleProperty *prop = m_doc->styleProperty(m_link);
941  if (prop) {
942  if (prop->type() == QSvgStyleProperty::GRADIENT) {
944  static_cast<QSvgGradientStyle*>(prop);
945  st->resolveStops();
946  m_gradient->setStops(st->qgradient()->stops());
947  m_gradientStopsSet = st->gradientStopsSet();
948  }
949  } else {
950  qWarning("Could not resolve property : %s", qPrintable(m_link));
951  }
952  m_link = QString();
953  }
954 }
955 
957 
958 #endif // QT_NO_SVG
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
QSvgViewportFillStyle(const QBrush &brush)
Definition: qsvgstyle.cpp:167
virtual ~QSvgStyleProperty()
Definition: qsvgstyle.cpp:72
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:658
double d
Definition: qnumeric_p.h:62
qreal m_oldFillOpacity
Definition: qsvgstyle_p.h:295
virtual Type type() const
Definition: qsvgstyle.cpp:797
void setCapitalization(Capitalization)
Sets the capitalization of the text in this font to caps.
Definition: qfont.cpp:1798
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
qreal opacity() const
Returns the opacity of the painter.
Definition: qpainter.cpp:2115
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:96
qreal m_fillOpacity
Definition: qsvgstyle_p.h:294
QBrush m_oldFill
Definition: qsvgstyle_p.h:289
void setBrush(const QBrush &brush)
Sets the brush used to fill strokes generated with this pen to the given brush.
Definition: qpen.cpp:808
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:837
CompositionMode
Defines the modes supported for digital image compositing.
Definition: qpainter.h:138
QSvgQualityStyle(int color)
Definition: qsvgstyle.cpp:87
int qCeil(qreal v)
Definition: qmath.h:63
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
uint m_fillOpacitySet
Definition: qsvgstyle_p.h:301
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:524
qreal m_strokeDashOffset
Definition: qsvgstyle_p.h:529
QTransform & shear(qreal sh, qreal sv)
Shears the coordinate system by sh horizontally and sv vertically, and returns a reference to the mat...
Definition: qtransform.cpp:551
void setCapStyle(Qt::PenCapStyle pcs)
Sets the pen&#39;s cap style to the given style.
Definition: qpen.cpp:723
Qt::PenStyle style() const
Returns the pen style.
Definition: qpen.cpp:428
int qFloor(qreal v)
Definition: qmath.h:73
virtual Type type() const
Definition: qsvgstyle.cpp:487
FillRule
Definition: qnamespace.h:1485
Style style() const
Returns the style of the font.
Definition: qfont.cpp:1223
uint m_strokeDashArraySet
Definition: qsvgstyle_p.h:539
virtual Type type() const
Definition: qsvgstyle.cpp:457
qreal strokeDashOffset
Definition: qsvgstyle_p.h:151
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
Capitalization capitalization() const
Returns the current capitalization type of the font.
Definition: qfont.cpp:1819
QGradient * qgradient() const
Definition: qsvgstyle_p.h:591
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:157
void setCosmetic(bool cosmetic)
Sets this pen to cosmetic or non-cosmetic, depending on the value of cosmetic.
Definition: qpen.cpp:854
virtual Type type() const
Definition: qsvgstyle.cpp:482
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:178
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QTransform m_oldWorldTransform
Definition: qsvgstyle_p.h:700
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
QSvgTinyDocument * m_doc
Definition: qsvgstyle_p.h:390
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:895
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:295
void setArgs(TransformType type, Additive additive, const QVector< qreal > &args)
Definition: qsvgstyle.cpp:649
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void setRepeatCount(qreal repeatCount)
Definition: qsvgstyle.cpp:832
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:76
Qt::Alignment m_textAnchor
Definition: qsvgstyle_p.h:394
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void setFillRule(Qt::FillRule f)
Definition: qsvgstyle.cpp:114
QVector< qreal > dashPattern() const
Returns the dash pattern of this pen.
Definition: qpen.cpp:466
QSvgOpacityStyle(qreal opacity)
Definition: qsvgstyle.cpp:909
void setDashPattern(const QVector< qreal > &pattern)
Sets the dash pattern for this pen to the given pattern.
Definition: qpen.cpp:525
void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:588
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QSvgFillStyleProperty * style() const
Definition: qsvgstyle_p.h:260
void setFamily(const QString &)
Sets the family name of the font.
Definition: qfont.cpp:924
qreal m_oldStrokeDashOffset
Definition: qsvgstyle_p.h:530
virtual QBrush brush(QPainter *p, QSvgExtraStates &states)=0
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:915
void setColor(const QColor &color)
Sets the color of this pen&#39;s brush to the given color.
Definition: qpen.cpp:787
QGradientStops stops() const
Returns the stop points for this gradient.
Definition: qbrush.cpp:1520
Qt::FillRule m_fillRule
Definition: qsvgstyle_p.h:292
uint m_strokeOpacitySet
Definition: qsvgstyle_p.h:544
static int SVGToQtWeight(int weight)
Definition: qsvgstyle.cpp:207
Qt::Alignment m_oldTextAnchor
Definition: qsvgstyle_p.h:398
virtual Type type() const
Definition: qsvgstyle.cpp:462
virtual Type type() const
Definition: qsvgstyle.cpp:904
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
qreal pointSizeF() const
Returns the point size of the font.
Definition: qfont.cpp:1142
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:92
uint m_strokeDashOffsetSet
Definition: qsvgstyle_p.h:540
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:266
void setFreeze(bool freeze)
Definition: qsvgstyle.cpp:827
QSvgFont * m_oldSvgFont
Definition: qsvgstyle_p.h:396
QFont m_oldQFont
Definition: qsvgstyle_p.h:397
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setFillStyle(QSvgFillStyleProperty *style)
Definition: qsvgstyle.cpp:126
Qt::PenJoinStyle joinStyle() const
Returns the pen&#39;s join style.
Definition: qpen.cpp:736
TransformType m_type
Definition: qsvgstyle_p.h:695
void setDashOffset(qreal doffset)
Sets the dash offset (the starting point on the dash pattern) for this pen to the offset specified...
Definition: qpen.cpp:570
void setBrush(QBrush brush)
Definition: qsvgstyle.cpp:132
const QFont & font() const
Returns the currently set font used for drawing text.
Definition: qpainter.cpp:4312
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
int currentElapsed() const
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:504
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:452
CompositionMode compositionMode() const
Returns the current composition mode.
Definition: qpainter.cpp:2466
QSvgFillStyleProperty * m_style
Definition: qsvgstyle_p.h:290
Q_CORE_EXPORT void qWarning(const char *,...)
void setArgs(bool fill, const QList< QColor > &colors)
Definition: qsvgstyle.cpp:820
QSvgFont * svgFont
Definition: qsvgstyle_p.h:147
QSvgAnimateTransform(int startMs, int endMs, int by=0)
Definition: qsvgstyle.cpp:641
static const int BOLDER
Definition: qsvgstyle_p.h:329
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:81
void setJoinStyle(Qt::PenJoinStyle pcs)
Sets the pen&#39;s join style to the given style.
Definition: qpen.cpp:753
QBrush brush() const
Returns the brush used to fill strokes generated with this pen.
Definition: qpen.cpp:797
QList< QColor > m_colors
Definition: qsvgstyle_p.h:721
QSvgFillStyleProperty * m_style
Definition: qsvgstyle_p.h:532
Qt::FillRule fillRule
Definition: qsvgstyle_p.h:150
QGradient * m_gradient
Definition: qsvgstyle_p.h:608
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:510
QSvgGradientStyle(QGradient *grad)
Definition: qsvgstyle.cpp:410
QVector< QGradientStop > QGradientStops
Definition: qbrush.h:199
QSvgCompOpStyle(QPainter::CompositionMode mode)
Definition: qsvgstyle.cpp:498
uint m_vectorEffectSet
Definition: qsvgstyle_p.h:546
const QBrush & brush() const
Returns the painter&#39;s current brush.
Definition: qpainter.cpp:4232
void setColor(const QColor &color)
Sets the brush color to the given color.
Definition: qbrush.cpp:725
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
void setMatrix(const QMatrix &matrix)
Definition: qsvgstyle.cpp:436
const qreal deg2rad
Definition: qmatrix.cpp:970
QSvgFont * m_svgFont
Definition: qsvgstyle_p.h:389
void setFillOpacity(qreal opacity)
Definition: qsvgstyle.cpp:120
uint m_strokeLineCapSet
Definition: qsvgstyle_p.h:541
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
const QTransform & worldTransform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9652
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
Definition: qpainter.cpp:2422
QSvgTransformStyle(const QTransform &transform)
Definition: qsvgstyle.cpp:441
qreal m_oldStrokeOpacity
Definition: qsvgstyle_p.h:528
static const int LIGHTER
Definition: qsvgstyle_p.h:328
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:381
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Definition: qbrush.h:201
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:227
QPair< qreal, QColor > QGradientStop
Definition: qbrush.h:196
void setWidthF(qreal width)
Sets the pen width to the given width in pixels with floating point precision.
Definition: qpen.cpp:690
virtual Type type() const =0
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
qreal miterLimit() const
Returns the miter limit of the pen.
Definition: qpen.cpp:589
QVector< qreal > m_args
Definition: qsvgstyle_p.h:697
QTransform m_transform
Definition: qsvgstyle_p.h:630
void setMatrix(const QMatrix &mat)
Sets matrix as an explicit transformation matrix on the current brush.
Definition: qbrush.cpp:951
QTransform m_oldWorldTransform
Definition: qsvgstyle_p.h:631
#define st(var, type, card)
void setRepeatCount(qreal repeatCount)
Definition: qsvgstyle.cpp:807
virtual Type type() const
Definition: qsvgstyle.cpp:477
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
virtual Type type() const
Definition: qsvgstyle.cpp:467
void setStops(const QGradientStops &stops)
Replaces the current set of stop points with the given stopPoints.
Definition: qbrush.cpp:1504
virtual Type type() const
Definition: qsvgstyle.cpp:926
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:139
void setWeight(int)
Sets the weight the font to weight, which should be a value from the QFont::Weight enumeration...
Definition: qfont.cpp:1278
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
Definition: qnamespace.h:54
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:921
void setWorldTransform(const QTransform &matrix, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9630
qreal qTan(qreal v)
Definition: qmath.h:125
qreal m_strokeOpacity
Definition: qsvgstyle_p.h:527
Qt::Alignment textAnchor
Definition: qsvgstyle_p.h:148
QBrush brush(QPainter *, QSvgExtraStates &)
Definition: qsvgstyle.cpp:415
void setPointSizeF(qreal)
Sets the point size to pointSize.
Definition: qfont.cpp:1121
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:172
QSvgAnimateColor(int startMs, int endMs, int by=0)
Definition: qsvgstyle.cpp:812
virtual Type type() const
Definition: qsvgstyle.cpp:492
void setFreeze(bool freeze)
Definition: qsvgstyle.cpp:802
void setStopLink(const QString &link, QSvgTinyDocument *doc)
Definition: qsvgstyle.cpp:931
bool gradientStopsSet() const
Definition: qsvgstyle_p.h:596
void setDashArray(const QVector< qreal > &dashes)
Definition: qsvgstyle.cpp:389
void setFont(const QFont &f)
Sets the painter&#39;s font to the given font.
Definition: qpainter.cpp:4288
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qtransform.cpp:485
bool isIdentity() const
Returns true if the matrix is the identity matrix, otherwise returns false.
Definition: qmatrix.h:166
uint m_fillRuleSet
Definition: qsvgstyle_p.h:300
QSvgSolidColorStyle(const QColor &color)
Definition: qsvgstyle.cpp:405
virtual Type type() const
Definition: qsvgstyle.cpp:472
uint m_strokeMiterLimitSet
Definition: qsvgstyle_p.h:543
void setOpacity(qreal opacity)
Sets the opacity of the painter to opacity.
Definition: qpainter.cpp:2139
QTransform m_transform
Definition: qsvgstyle_p.h:699
virtual void revert(QPainter *p, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:666
QSvgTinyDocument * document() const
Definition: qsvgnode.cpp:233
Qt::PenCapStyle capStyle() const
Returns the pen&#39;s cap style.
Definition: qpen.cpp:706
static const KeyPair *const end
virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
Definition: qsvgstyle.cpp:446
Qt::FillRule m_oldFillRule
Definition: qsvgstyle_p.h:293
#define qPrintable(string)
Definition: qglobal.h:1750
QPainter::CompositionMode m_oldMode
Definition: qsvgstyle_p.h:747
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
virtual Type type() const
Definition: qsvgstyle.cpp:515
void resolveMatrix(const QSvgNode *node)
Definition: qsvgstyle.cpp:672
uint m_textAnchorSet
Definition: qsvgstyle_p.h:406
void setStyle(Style style)
Sets the style of the font to style.
Definition: qfont.cpp:1234
QPainter::CompositionMode m_mode
Definition: qsvgstyle_p.h:745
uint m_strokeLineJoinSet
Definition: qsvgstyle_p.h:542
void setStyle(Qt::PenStyle)
Sets the pen style to the given style.
Definition: qpen.cpp:450
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
void setMiterLimit(qreal limit)
Sets the miter limit of this pen to the given limit.
Definition: qpen.cpp:611
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
uint m_oldVectorEffect
Definition: qsvgstyle_p.h:536
qreal m_totalRunningTime
Definition: qsvgstyle_p.h:720