本文整理汇总了C++中QSvgNode类的典型用法代码示例。如果您正苦于以下问题:C++ QSvgNode类的具体用法?C++ QSvgNode怎么用?C++ QSvgNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSvgNode类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMatrix
void QSvgTinyDocument::draw(QPainter *p, const QRectF &bounds)
{
if (m_time.isNull()) {
m_time.start();
}
if (m_viewBox.isNull()) {
QMatrix matx = QMatrix();
m_viewBox = transformedBounds(matx);
}
p->save();
//sets default style on the painter
//### not the most optimal way
adjustWindowBounds(p, bounds, m_viewBox);
p->setPen(Qt::NoPen);
p->setBrush(Qt::black);
p->setRenderHint(QPainter::Antialiasing);
p->setRenderHint(QPainter::SmoothPixmapTransform);
QList<QSvgNode*>::iterator itr = m_renderers.begin();
applyStyle(p);
while (itr != m_renderers.end()) {
QSvgNode *node = *itr;
if (node->isVisible())
node->draw(p);
++itr;
}
revertStyle(p);
p->restore();
}
示例2: mapSourceToTarget
void QSvgTinyDocument::draw(QPainter *p, const QRectF &bounds)
{
if (m_time.isNull()) {
m_time.start();
}
if (displayMode() == QSvgNode::NoneMode)
return;
p->save();
//sets default style on the painter
//### not the most optimal way
mapSourceToTarget(p, bounds);
QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
pen.setMiterLimit(4);
p->setPen(pen);
p->setBrush(Qt::black);
p->setRenderHint(QPainter::Antialiasing);
p->setRenderHint(QPainter::SmoothPixmapTransform);
QList<QSvgNode*>::iterator itr = m_renderers.begin();
applyStyle(p, m_states);
while (itr != m_renderers.end()) {
QSvgNode *node = *itr;
if ((node->isVisible()) && (node->displayMode() != QSvgNode::NoneMode))
node->draw(p, m_states);
++itr;
}
revertStyle(p, m_states);
p->restore();
}
示例3: dummy
QRectF QSvgNode::transformedBounds() const
{
if (!m_cachedBounds.isEmpty())
return m_cachedBounds;
QImage dummy(1, 1, QImage::Format_RGB32);
QPainter p(&dummy);
QSvgExtraStates states;
QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::SvgMiterJoin);
pen.setMiterLimit(4);
p.setPen(pen);
QStack<QSvgNode*> parentApplyStack;
QSvgNode *parent = m_parent;
while (parent) {
parentApplyStack.push(parent);
parent = parent->parent();
}
for (int i = parentApplyStack.size() - 1; i >= 0; --i)
parentApplyStack[i]->applyStyle(&p, states);
p.setWorldTransform(QTransform());
m_cachedBounds = transformedBounds(&p, states);
return m_cachedBounds;
}
示例4: while
QSvgTinyDocument * QSvgNode::document() const
{
QSvgTinyDocument *doc = 0;
QSvgNode *node = const_cast<QSvgNode*>(this);
while (node && node->type() != QSvgNode::DOC) {
node = node->parent();
}
doc = static_cast<QSvgTinyDocument*>(node);
return doc;
}
示例5: applyStyle
void QSvgG::draw(QPainter *p, QSvgExtraStates &states)
{
QList<QSvgNode*>::iterator itr = m_renderers.begin();
applyStyle(p, states);
while (itr != m_renderers.end()) {
QSvgNode *node = *itr;
if ((node->isVisible()) && (node->displayMode() != QSvgNode::NoneMode))
node->draw(p, states);
++itr;
}
revertStyle(p, states);
}
示例6: scopeNode
void QSvgTinyDocument::draw(QPainter *p, const QString &id,
const QRectF &bounds)
{
QSvgNode *node = scopeNode(id);
if (!node) {
qDebug("Couldn't find node %s. Skipping rendering.", qPrintable(id));
return;
}
if (m_time.isNull()) {
m_time.start();
}
if (node->displayMode() == QSvgNode::NoneMode)
return;
p->save();
const QRectF elementBounds = node->transformedBounds();
mapSourceToTarget(p, bounds, elementBounds);
QTransform originalTransform = p->worldTransform();
//XXX set default style on the painter
QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
pen.setMiterLimit(4);
p->setPen(pen);
p->setBrush(Qt::black);
p->setRenderHint(QPainter::Antialiasing);
p->setRenderHint(QPainter::SmoothPixmapTransform);
QStack<QSvgNode*> parentApplyStack;
QSvgNode *parent = node->parent();
while (parent) {
parentApplyStack.push(parent);
parent = parent->parent();
}
for (int i = parentApplyStack.size() - 1; i >= 0; --i)
parentApplyStack[i]->applyStyle(p, m_states);
// Reset the world transform so that our parents don't affect
// the position
QTransform currentTransform = p->worldTransform();
p->setWorldTransform(originalTransform);
node->draw(p, m_states);
p->setWorldTransform(currentTransform);
for (int i = 0; i < parentApplyStack.size(); ++i)
parentApplyStack[i]->revertStyle(p, m_states);
//p->fillRect(bounds.adjusted(-5, -5, 5, 5), QColor(0, 0, 255, 100));
p->restore();
}
示例7: scopeNode
void QSvgTinyDocument::draw(QPainter *p, const QString &id,
const QRectF &boundingWindow)
{
QSvgNode *node = scopeNode(id);
if (!node) {
qDebug("Couldn't find node %s. Skipping rendering.", qPrintable(id));
return;
}
p->save();
QMatrix matx = QMatrix();
QRectF bounds = node->transformedBounds(matx);
adjustWindowBounds(p, boundingWindow, bounds);
matx = p->worldMatrix();
//XXX set default style on the painter
p->setPen(Qt::NoPen);
p->setBrush(Qt::black);
p->setRenderHint(QPainter::Antialiasing);
p->setRenderHint(QPainter::SmoothPixmapTransform);
QStack<QSvgNode*> parentApplyStack;
QQueue<QSvgNode*> parentRevertQueue;
QSvgNode *parent = node->parent();
while (parent) {
parentApplyStack.push(parent);
parentRevertQueue.enqueue(parent);
parent = parent->parent();
}
foreach(QSvgNode *par, parentApplyStack) {
par->applyStyle(p);
}