Qt 4.8
Public Functions | Static Public Functions | Private Functions | Properties | List of all members
QSvgTinyDocument Class Reference

#include <qsvgtinydocument_p.h>

Inheritance diagram for QSvgTinyDocument:
QSvgStructureNode QSvgNode

Public Functions

void addNamedNode (const QString &id, QSvgNode *node)
 
void addNamedStyle (const QString &id, QSvgFillStyleProperty *style)
 
void addSvgFont (QSvgFont *)
 
bool animated () const
 
int animationDuration () const
 
QRectF boundsOnElement (const QString &id) const
 
int currentElapsed () const
 
int currentFrame () const
 
virtual void draw (QPainter *p, QSvgExtraStates &)
 
void draw (QPainter *p)
 
void draw (QPainter *p, const QRectF &bounds)
 
void draw (QPainter *p, const QString &id, const QRectF &bounds=QRectF())
 
bool elementExists (const QString &id) const
 
int height () const
 
bool heightPercent () const
 
QMatrix matrixForElement (const QString &id) const
 
QSvgNodenamedNode (const QString &id) const
 
QSvgFillStylePropertynamedStyle (const QString &id) const
 
bool preserveAspectRatio () const
 
 QSvgTinyDocument ()
 
void restartAnimation ()
 
void setAnimated (bool a)
 
void setCurrentFrame (int)
 
void setFramesPerSecond (int num)
 
void setHeight (int len, bool percent)
 
void setViewBox (const QRectF &rect)
 
void setWidth (int len, bool percent)
 
QSize size () const
 
QSvgFontsvgFont (const QString &family) const
 
Type type () const
 
QRectF viewBox () const
 
int width () const
 
bool widthPercent () const
 
 ~QSvgTinyDocument ()
 
- Public Functions inherited from QSvgStructureNode
void addChild (QSvgNode *child, const QString &id)
 
virtual QRectF bounds (QPainter *p, QSvgExtraStates &states) const
 
QSvgNodepreviousSiblingNode (QSvgNode *n) const
 
 QSvgStructureNode (QSvgNode *parent)
 
QList< QSvgNode * > renderers () const
 
QSvgNodescopeNode (const QString &id) const
 
 ~QSvgStructureNode ()
 
- Public Functions inherited from QSvgNode
void appendStyleProperty (QSvgStyleProperty *prop, const QString &id)
 
void applyStyle (QPainter *p, QSvgExtraStates &states) const
 
DisplayMode displayMode () const
 
QSvgTinyDocumentdocument () const
 
bool isVisible () const
 
QString nodeId () const
 
QSvgNodeparent () const
 
 QSvgNode (QSvgNode *parent=0)
 
const QStringListrequiredExtensions () const
 
const QStringListrequiredFeatures () const
 
const QStringListrequiredFonts () const
 
const QStringListrequiredFormats () const
 
const QStringListrequiredLanguages () const
 
void revertStyle (QPainter *p, QSvgExtraStates &states) const
 
void setDisplayMode (DisplayMode display)
 
void setNodeId (const QString &i)
 
void setRequiredExtensions (const QStringList &lst)
 
void setRequiredFeatures (const QStringList &lst)
 
void setRequiredFonts (const QStringList &lst)
 
void setRequiredFormats (const QStringList &lst)
 
void setRequiredLanguages (const QStringList &lst)
 
void setVisible (bool visible)
 
void setXmlClass (const QString &str)
 
QSvgStylePropertystyleProperty (QSvgStyleProperty::Type type) const
 
QSvgFillStylePropertystyleProperty (const QString &id) const
 
virtual QRectF transformedBounds (QPainter *p, QSvgExtraStates &states) const
 
QRectF transformedBounds () const
 
QString xmlClass () const
 
virtual ~QSvgNode ()
 

Static Public Functions

static QSvgTinyDocumentload (const QString &file)
 
static QSvgTinyDocumentload (const QByteArray &contents)
 
static QSvgTinyDocumentload (QXmlStreamReader *contents)
 

Private Functions

void mapSourceToTarget (QPainter *p, const QRectF &targetRect, const QRectF &sourceRect=QRectF())
 

Properties

bool m_animated
 
int m_animationDuration
 
QHash< QString, QSvgRefCounter< QSvgFont > > m_fonts
 
int m_fps
 
bool m_heightPercent
 
QHash< QString, QSvgNode * > m_namedNodes
 
QHash< QString, QSvgRefCounter< QSvgFillStyleProperty > > m_namedStyles
 
QSize m_size
 
QSvgExtraStates m_states
 
QTime m_time
 
QRectF m_viewBox
 
bool m_widthPercent
 

Additional Inherited Members

- Public Types inherited from QSvgNode
enum  DisplayMode {
  InlineMode, BlockMode, ListItemMode, RunInMode,
  CompactMode, MarkerMode, TableMode, InlineTableMode,
  TableRowGroupMode, TableHeaderGroupMode, TableFooterGroupMode, TableRowMode,
  TableColumnGroupMode, TableColumnMode, TableCellMode, TableCaptionMode,
  NoneMode, InheritMode
}
 
enum  Type {
  DOC, G, DEFS, SWITCH,
  ANIMATION, ARC, CIRCLE, ELLIPSE,
  IMAGE, LINE, PATH, POLYGON,
  POLYLINE, RECT, TEXT, TEXTAREA,
  TSPAN, USE, VIDEO
}
 
- Static Protected Functions inherited from QSvgNode
static qreal strokeWidth (QPainter *p)
 
- Protected Variables inherited from QSvgStructureNode
QList< QSvgStructureNode * > m_linkedScopes
 
QList< QSvgNode * > m_renderers
 
QHash< QString, QSvgNode * > m_scope
 
- Protected Variables inherited from QSvgNode
QSvgStyle m_style
 

Detailed Description

Definition at line 74 of file qsvgtinydocument_p.h.

Constructors and Destructors

◆ QSvgTinyDocument()

QSvgTinyDocument::QSvgTinyDocument ( )

Definition at line 63 of file qsvgtinydocument.cpp.

65  , m_widthPercent(false)
66  , m_heightPercent(false)
67  , m_animated(false)
69  , m_fps(30)
70 {
71 }
QSvgStructureNode(QSvgNode *parent)

◆ ~QSvgTinyDocument()

QSvgTinyDocument::~QSvgTinyDocument ( )

Definition at line 73 of file qsvgtinydocument.cpp.

74 {
75 }

Functions

◆ addNamedNode()

void QSvgTinyDocument::addNamedNode ( const QString id,
QSvgNode node 
)

Definition at line 353 of file qsvgtinydocument.cpp.

Referenced by QSvgStructureNode::addChild().

354 {
355  m_namedNodes.insert(id, node);
356 }
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QHash< QString, QSvgNode * > m_namedNodes

◆ addNamedStyle()

void QSvgTinyDocument::addNamedStyle ( const QString id,
QSvgFillStyleProperty style 
)

Definition at line 363 of file qsvgtinydocument.cpp.

Referenced by QSvgNode::appendStyleProperty().

364 {
365  m_namedStyles.insert(id, style);
366 }
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QHash< QString, QSvgRefCounter< QSvgFillStyleProperty > > m_namedStyles

◆ addSvgFont()

void QSvgTinyDocument::addSvgFont ( QSvgFont font)

Definition at line 343 of file qsvgtinydocument.cpp.

Referenced by createFontNode(), parseFontFaceNameNode(), and parseFontFaceNode().

344 {
345  m_fonts.insert(font->familyName(), font);
346 }
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QString familyName() const
Definition: qsvgfont.cpp:66
QHash< QString, QSvgRefCounter< QSvgFont > > m_fonts

◆ animated()

bool QSvgTinyDocument::animated ( ) const

Definition at line 378 of file qsvgtinydocument.cpp.

Referenced by loadDocument().

379 {
380  return m_animated;
381 }

◆ animationDuration()

int QSvgTinyDocument::animationDuration ( ) const
inline

Definition at line 192 of file qsvgtinydocument_p.h.

193 {
194  return m_animationDuration;
195 }

◆ boundsOnElement()

QRectF QSvgTinyDocument::boundsOnElement ( const QString id) const

Definition at line 430 of file qsvgtinydocument.cpp.

431 {
432  const QSvgNode *node = scopeNode(id);
433  if (!node)
434  node = this;
435  return node->transformedBounds();
436 }
virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:307
QSvgNode * scopeNode(const QString &id) const

◆ currentElapsed()

int QSvgTinyDocument::currentElapsed ( ) const
inline

Definition at line 187 of file qsvgtinydocument_p.h.

Referenced by QSvgAnimateColor::apply(), QSvgStyle::apply(), and QSvgAnimateTransform::resolveMatrix().

188 {
189  return m_time.elapsed();
190 }
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
Definition: qdatetime.cpp:2123

◆ currentFrame()

int QSvgTinyDocument::currentFrame ( ) const

Definition at line 466 of file qsvgtinydocument.cpp.

467 {
468  double runningPercentage = qMin(m_time.elapsed()/double(m_animationDuration), 1.);
469 
470  int totalFrames = m_fps * m_animationDuration;
471 
472  return int(runningPercentage * totalFrames);
473 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
Definition: qdatetime.cpp:2123

◆ draw() [1/4]

void QSvgTinyDocument::draw ( QPainter p,
QSvgExtraStates  
)
virtual

Implements QSvgNode.

Definition at line 393 of file qsvgtinydocument.cpp.

Referenced by draw().

394 {
395  draw(p);
396 }
virtual void draw(QPainter *p, QSvgExtraStates &)

◆ draw() [2/4]

void QSvgTinyDocument::draw ( QPainter p)

Definition at line 388 of file qsvgtinydocument.cpp.

389 {
390  draw(p, QRectF());
391 }
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual void draw(QPainter *p, QSvgExtraStates &)

◆ draw() [3/4]

void QSvgTinyDocument::draw ( QPainter p,
const QRectF bounds 
)

Definition at line 230 of file qsvgtinydocument.cpp.

231 {
232  if (m_time.isNull()) {
233  m_time.start();
234  }
235 
237  return;
238 
239  p->save();
240  //sets default style on the painter
241  //### not the most optimal way
242  mapSourceToTarget(p, bounds);
244  pen.setMiterLimit(4);
245  p->setPen(pen);
246  p->setBrush(Qt::black);
250  applyStyle(p, m_states);
251  while (itr != m_renderers.end()) {
252  QSvgNode *node = *itr;
253  if ((node->isVisible()) && (node->displayMode() != QSvgNode::NoneMode))
254  node->draw(p, m_states);
255  ++itr;
256  }
257  revertStyle(p, m_states);
258  p->restore();
259 }
void mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect=QRectF())
void start()
Sets this time to the current time.
Definition: qdatetime.cpp:2070
bool isNull() const
Returns true if the time is null (i.
Definition: qdatetime.h:158
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
void applyStyle(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:118
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
bool isVisible() const
Definition: qsvgnode_p.h:188
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
DisplayMode displayMode() const
Definition: qsvgnode.cpp:330
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
QSvgExtraStates m_states
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
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 draw(QPainter *p, QSvgExtraStates &states)=0
void revertStyle(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:123
QList< QSvgNode * > m_renderers

◆ draw() [4/4]

void QSvgTinyDocument::draw ( QPainter p,
const QString id,
const QRectF bounds = QRectF() 
)

Definition at line 262 of file qsvgtinydocument.cpp.

264 {
265  QSvgNode *node = scopeNode(id);
266 
267  if (!node) {
268  qDebug("Couldn't find node %s. Skipping rendering.", qPrintable(id));
269  return;
270  }
271  if (m_time.isNull()) {
272  m_time.start();
273  }
274 
275  if (node->displayMode() == QSvgNode::NoneMode)
276  return;
277 
278  p->save();
279 
280  const QRectF elementBounds = node->transformedBounds();
281 
282  mapSourceToTarget(p, bounds, elementBounds);
283  QTransform originalTransform = p->worldTransform();
284 
285  //XXX set default style on the painter
287  pen.setMiterLimit(4);
288  p->setPen(pen);
289  p->setBrush(Qt::black);
292 
293  QStack<QSvgNode*> parentApplyStack;
294  QSvgNode *parent = node->parent();
295  while (parent) {
296  parentApplyStack.push(parent);
297  parent = parent->parent();
298  }
299 
300  for (int i = parentApplyStack.size() - 1; i >= 0; --i)
301  parentApplyStack[i]->applyStyle(p, m_states);
302 
303  // Reset the world transform so that our parents don't affect
304  // the position
305  QTransform currentTransform = p->worldTransform();
306  p->setWorldTransform(originalTransform);
307 
308  node->draw(p, m_states);
309 
310  p->setWorldTransform(currentTransform);
311 
312  for (int i = 0; i < parentApplyStack.size(); ++i)
313  parentApplyStack[i]->revertStyle(p, m_states);
314 
315  //p->fillRect(bounds.adjusted(-5, -5, 5, 5), QColor(0, 0, 255, 100));
316 
317  p->restore();
318 }
virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:307
void mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect=QRectF())
void start()
Sets this time to the current time.
Definition: qdatetime.cpp:2070
bool isNull() const
Returns true if the time is null (i.
Definition: qdatetime.h:158
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
QSvgNode * scopeNode(const QString &id) const
The QStack class is a template class that provides a stack.
Definition: qcontainerfwd.h:63
void applyStyle(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:118
QSvgNode * parent() const
Definition: qsvgnode_p.h:183
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_CORE_EXPORT void qDebug(const char *,...)
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
DisplayMode displayMode() const
Definition: qsvgnode.cpp:330
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
QSvgExtraStates m_states
const QTransform & worldTransform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9652
void setBrush(const QBrush &brush)
Sets the painter&#39;s brush to the given brush.
Definition: qpainter.cpp:4171
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
void setWorldTransform(const QTransform &matrix, bool combine=false)
Sets the world transformation matrix.
Definition: qpainter.cpp:9630
virtual void draw(QPainter *p, QSvgExtraStates &states)=0
void revertStyle(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:123
#define qPrintable(string)
Definition: qglobal.h:1750
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ elementExists()

bool QSvgTinyDocument::elementExists ( const QString id) const

Definition at line 438 of file qsvgtinydocument.cpp.

439 {
440  QSvgNode *node = scopeNode(id);
441 
442  return (node!=0);
443 }
QSvgNode * scopeNode(const QString &id) const

◆ height()

int QSvgTinyDocument::height ( ) const
inline

Definition at line 159 of file qsvgtinydocument_p.h.

160 {
161  return size().height();
162 }
int height() const
Returns the height.
Definition: qsize.h:129

◆ heightPercent()

bool QSvgTinyDocument::heightPercent ( ) const
inline

Definition at line 169 of file qsvgtinydocument_p.h.

170 {
171  return m_heightPercent;
172 }

◆ load() [1/3]

QSvgTinyDocument * QSvgTinyDocument::load ( const QString file)
static

Definition at line 170 of file qsvgtinydocument.cpp.

Referenced by load(), and loadDocument().

171 {
172  QFile file(fileName);
173  if (!file.open(QFile::ReadOnly)) {
174  qWarning("Cannot open file '%s', because: %s",
175  qPrintable(fileName), qPrintable(file.errorString()));
176  return 0;
177  }
178 
179 #ifndef QT_NO_COMPRESS
182  return load(qt_inflateGZipDataFrom(&file));
183  }
184 #endif
185 
186  QSvgTinyDocument *doc = 0;
187  QSvgHandler handler(&file);
188  if (handler.ok()) {
189  doc = handler.document();
190  doc->m_animationDuration = handler.animationDuration();
191  } else {
192  qWarning("Cannot read file '%s', because: %s (line %d)",
193  qPrintable(fileName), qPrintable(handler.errorString()), handler.lineNumber());
194  }
195  return doc;
196 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QByteArray qt_inflateGZipDataFrom(QIODevice *device)
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
QImageIOHandler * handler
static QSvgTinyDocument * load(const QString &file)
#define qPrintable(string)
Definition: qglobal.h:1750
static QString fileName(const QString &fileUrl)

◆ load() [2/3]

QSvgTinyDocument * QSvgTinyDocument::load ( const QByteArray contents)
static

Definition at line 198 of file qsvgtinydocument.cpp.

199 {
200 #ifndef QT_NO_COMPRESS
201  // Check for gzip magic number and inflate if appropriate
202  if (contents.startsWith("\x1f\x8b")) {
203  QBuffer buffer(const_cast<QByteArray *>(&contents));
204  return load(qt_inflateGZipDataFrom(&buffer));
205  }
206 #endif
207 
208  QSvgHandler handler(contents);
209 
210  QSvgTinyDocument *doc = 0;
211  if (handler.ok()) {
212  doc = handler.document();
213  doc->m_animationDuration = handler.animationDuration();
214  }
215  return doc;
216 }
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
static QByteArray qt_inflateGZipDataFrom(QIODevice *device)
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
QImageIOHandler * handler
static QSvgTinyDocument * load(const QString &file)

◆ load() [3/3]

QSvgTinyDocument * QSvgTinyDocument::load ( QXmlStreamReader contents)
static

Definition at line 218 of file qsvgtinydocument.cpp.

219 {
220  QSvgHandler handler(contents);
221 
222  QSvgTinyDocument *doc = 0;
223  if (handler.ok()) {
224  doc = handler.document();
225  doc->m_animationDuration = handler.animationDuration();
226  }
227  return doc;
228 }
QImageIOHandler * handler

◆ mapSourceToTarget()

void QSvgTinyDocument::mapSourceToTarget ( QPainter p,
const QRectF targetRect,
const QRectF sourceRect = QRectF() 
)
private

Definition at line 398 of file qsvgtinydocument.cpp.

Referenced by draw().

399 {
400  QRectF target = targetRect;
401  if (target.isNull()) {
402  QPaintDevice *dev = p->device();
403  QRectF deviceRect(0, 0, dev->width(), dev->height());
404  if (deviceRect.isNull()) {
405  if (sourceRect.isNull())
406  target = QRectF(QPointF(0, 0), size());
407  else
408  target = QRectF(QPointF(0, 0), sourceRect.size());
409  } else {
410  target = deviceRect;
411  }
412  }
413 
414  QRectF source = sourceRect;
415  if (source.isNull())
416  source = viewBox();
417 
418  if (source != target && !source.isNull()) {
419  QTransform transform;
420  transform.scale(target.width() / source.width(),
421  target.height() / source.height());
422  QRectF c2 = transform.mapRect(source);
423  p->translate(target.x() - c2.x(),
424  target.y() - c2.y());
425  p->scale(target.width() / source.width(),
426  target.height() / source.height());
427  }
428 }
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or 0 if the painter is not acti...
Definition: qpainter.cpp:1530
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
int height() const
Definition: qpaintdevice.h:92
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QRect mapRect(const QRect &) const
Creates and returns a QRect object that is a copy of the given rectangle, mapped into the coordinate ...
QRectF viewBox() const
int width() const
Definition: qpaintdevice.h:91
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
void scale(qreal sx, qreal sy)
Scales the coordinate system by ({sx}, {sy}).
Definition: qpainter.cpp:3234
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 isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:655
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
Definition: qpainter.cpp:3311

◆ matrixForElement()

QMatrix QSvgTinyDocument::matrixForElement ( const QString id) const

Definition at line 445 of file qsvgtinydocument.cpp.

446 {
447  QSvgNode *node = scopeNode(id);
448 
449  if (!node) {
450  qDebug("Couldn't find node %s. Skipping rendering.", qPrintable(id));
451  return QMatrix();
452  }
453 
454  QTransform t;
455 
456  node = node->parent();
457  while (node) {
458  if (node->m_style.transform)
459  t *= node->m_style.transform->qtransform();
460  node = node->parent();
461  }
462 
463  return t.toAffine();
464 }
QSvgStyle m_style
Definition: qsvgnode_p.h:160
The QMatrix class specifies 2D transformations of a coordinate system.
Definition: qmatrix.h:61
QSvgNode * scopeNode(const QString &id) const
QSvgNode * parent() const
Definition: qsvgnode_p.h:183
Q_CORE_EXPORT void qDebug(const char *,...)
const QMatrix & toAffine() const
Returns the QTransform as an affine matrix.
const QTransform & qtransform() const
Definition: qsvgstyle_p.h:624
QSvgRefCounter< QSvgTransformStyle > transform
Definition: qsvgstyle_p.h:778
#define qPrintable(string)
Definition: qglobal.h:1750
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ namedNode()

QSvgNode * QSvgTinyDocument::namedNode ( const QString id) const

Definition at line 358 of file qsvgtinydocument.cpp.

Referenced by QSvgStructureNode::scopeNode().

359 {
360  return m_namedNodes.value(id);
361 }
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< QString, QSvgNode * > m_namedNodes

◆ namedStyle()

QSvgFillStyleProperty * QSvgTinyDocument::namedStyle ( const QString id) const

Definition at line 368 of file qsvgtinydocument.cpp.

Referenced by QSvgNode::styleProperty().

369 {
370  return m_namedStyles.value(id);
371 }
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< QString, QSvgRefCounter< QSvgFillStyleProperty > > m_namedStyles

◆ preserveAspectRatio()

bool QSvgTinyDocument::preserveAspectRatio ( ) const
inline

Definition at line 182 of file qsvgtinydocument_p.h.

183 {
184  return false;
185 }

◆ restartAnimation()

void QSvgTinyDocument::restartAnimation ( )

Definition at line 373 of file qsvgtinydocument.cpp.

374 {
375  m_time.restart();
376 }
int restart()
Sets this time to the current time and returns the number of milliseconds that have elapsed since the...
Definition: qdatetime.cpp:2095

◆ setAnimated()

void QSvgTinyDocument::setAnimated ( bool  a)

Definition at line 383 of file qsvgtinydocument.cpp.

Referenced by parseAnimateColorNode(), and parseAnimateTransformNode().

384 {
385  m_animated = a;
386 }
long ASN1_INTEGER_get ASN1_INTEGER * a

◆ setCurrentFrame()

void QSvgTinyDocument::setCurrentFrame ( int  frame)

Definition at line 475 of file qsvgtinydocument.cpp.

476 {
477  int totalFrames = m_fps * m_animationDuration;
478  double framePercentage = frame/double(totalFrames);
479  double timeForFrame = m_animationDuration * framePercentage; //in S
480  timeForFrame *= 1000; //in ms
481  int timeToAdd = int(timeForFrame - m_time.elapsed());
482  m_time = m_time.addMSecs(timeToAdd);
483 }
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
Definition: qdatetime.cpp:2123
QTime addMSecs(int ms) const
Returns a QTime object containing a time ms milliseconds later than the time of this object (or earli...
Definition: qdatetime.cpp:1803

◆ setFramesPerSecond()

void QSvgTinyDocument::setFramesPerSecond ( int  num)

Definition at line 485 of file qsvgtinydocument.cpp.

486 {
487  m_fps = num;
488 }

◆ setHeight()

void QSvgTinyDocument::setHeight ( int  len,
bool  percent 
)

Definition at line 332 of file qsvgtinydocument.cpp.

Referenced by createSvgNode().

333 {
334  m_size.setHeight(len);
335  m_heightPercent = percent;
336 }
void setHeight(int h)
Sets the height to the given height.
Definition: qsize.h:135

◆ setViewBox()

void QSvgTinyDocument::setViewBox ( const QRectF rect)

Definition at line 338 of file qsvgtinydocument.cpp.

Referenced by createSvgNode().

339 {
340  m_viewBox = rect;
341 }

◆ setWidth()

void QSvgTinyDocument::setWidth ( int  len,
bool  percent 
)

Definition at line 326 of file qsvgtinydocument.cpp.

Referenced by createSvgNode().

327 {
328  m_size.setWidth(len);
329  m_widthPercent = percent;
330 }
void setWidth(int w)
Sets the width to the given width.
Definition: qsize.h:132

◆ size()

QSize QSvgTinyDocument::size ( ) const
inline

Definition at line 145 of file qsvgtinydocument_p.h.

Referenced by mapSourceToTarget().

146 {
147  if (m_size.isEmpty()) {
148  return viewBox().size().toSize();
149  } else {
150  return m_size;
151  }
152 }
QSize toSize() const
Returns an integer based copy of this size.
Definition: qsize.h:355
QRectF viewBox() const
QSizeF size() const
Returns the size of the rectangle.
Definition: qrect.h:713
bool isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false...
Definition: qsize.h:120

◆ svgFont()

QSvgFont * QSvgTinyDocument::svgFont ( const QString family) const

Definition at line 348 of file qsvgtinydocument.cpp.

Referenced by createFontNode(), parseFont(), parseFontFaceNameNode(), and parseFontFaceNode().

349 {
350  return m_fonts[family];
351 }
QHash< QString, QSvgRefCounter< QSvgFont > > m_fonts

◆ type()

QSvgNode::Type QSvgTinyDocument::type ( ) const
virtual

Implements QSvgNode.

Definition at line 321 of file qsvgtinydocument.cpp.

322 {
323  return DOC;
324 }

◆ viewBox()

QRectF QSvgTinyDocument::viewBox ( ) const
inline

Definition at line 174 of file qsvgtinydocument_p.h.

Referenced by mapSourceToTarget().

175 {
176  if (m_viewBox.isNull())
178 
179  return m_viewBox;
180 }
QRectF transformedBounds() const
Definition: qsvgnode.cpp:204
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:655

◆ width()

int QSvgTinyDocument::width ( ) const
inline

Definition at line 154 of file qsvgtinydocument_p.h.

155 {
156  return size().width();
157 }
int width() const
Returns the width.
Definition: qsize.h:126

◆ widthPercent()

bool QSvgTinyDocument::widthPercent ( ) const
inline

Definition at line 164 of file qsvgtinydocument_p.h.

165 {
166  return m_widthPercent;
167 }

Properties

◆ m_animated

bool QSvgTinyDocument::m_animated
private

Definition at line 138 of file qsvgtinydocument_p.h.

Referenced by animated(), and setAnimated().

◆ m_animationDuration

int QSvgTinyDocument::m_animationDuration
private

Definition at line 139 of file qsvgtinydocument_p.h.

Referenced by currentFrame(), load(), and setCurrentFrame().

◆ m_fonts

QHash<QString, QSvgRefCounter<QSvgFont> > QSvgTinyDocument::m_fonts
private

Definition at line 133 of file qsvgtinydocument_p.h.

Referenced by addSvgFont(), and svgFont().

◆ m_fps

int QSvgTinyDocument::m_fps
private

Definition at line 140 of file qsvgtinydocument_p.h.

Referenced by currentFrame(), setCurrentFrame(), and setFramesPerSecond().

◆ m_heightPercent

bool QSvgTinyDocument::m_heightPercent
private

Definition at line 129 of file qsvgtinydocument_p.h.

Referenced by setHeight().

◆ m_namedNodes

QHash<QString, QSvgNode *> QSvgTinyDocument::m_namedNodes
private

Definition at line 134 of file qsvgtinydocument_p.h.

Referenced by addNamedNode(), and namedNode().

◆ m_namedStyles

QHash<QString, QSvgRefCounter<QSvgFillStyleProperty> > QSvgTinyDocument::m_namedStyles
private

Definition at line 135 of file qsvgtinydocument_p.h.

Referenced by addNamedStyle(), and namedStyle().

◆ m_size

QSize QSvgTinyDocument::m_size
private

Definition at line 127 of file qsvgtinydocument_p.h.

Referenced by setHeight(), and setWidth().

◆ m_states

QSvgExtraStates QSvgTinyDocument::m_states
private

Definition at line 142 of file qsvgtinydocument_p.h.

Referenced by draw().

◆ m_time

QTime QSvgTinyDocument::m_time
private

Definition at line 137 of file qsvgtinydocument_p.h.

Referenced by currentFrame(), draw(), restartAnimation(), and setCurrentFrame().

◆ m_viewBox

QRectF QSvgTinyDocument::m_viewBox
mutableprivate

Definition at line 131 of file qsvgtinydocument_p.h.

Referenced by setViewBox().

◆ m_widthPercent

bool QSvgTinyDocument::m_widthPercent
private

Definition at line 128 of file qsvgtinydocument_p.h.

Referenced by setWidth().


The documentation for this class was generated from the following files: