Changeset 846 for trunk/src/svg/qsvgnode.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/svg/qsvgnode.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 46 46 47 47 #include "qdebug.h" 48 #include "qstack.h" 48 49 49 50 QT_BEGIN_NAMESPACE … … 115 116 } 116 117 117 void QSvgNode::applyStyle(QPainter *p, QSvgExtraStates &states) 118 { 119 m_style.apply(p, bounds(),this, states);120 } 121 122 void QSvgNode::revertStyle(QPainter *p, QSvgExtraStates &states) 118 void QSvgNode::applyStyle(QPainter *p, QSvgExtraStates &states) const 119 { 120 m_style.apply(p, this, states); 121 } 122 123 void QSvgNode::revertStyle(QPainter *p, QSvgExtraStates &states) const 123 124 { 124 125 m_style.revert(p, states); … … 196 197 } 197 198 198 QRectF QSvgNode::bounds( ) const199 QRectF QSvgNode::bounds(QPainter *, QSvgExtraStates &) const 199 200 { 200 201 return QRectF(0, 0, 0, 0); 202 } 203 204 QRectF QSvgNode::transformedBounds() const 205 { 206 if (!m_cachedBounds.isEmpty()) 207 return m_cachedBounds; 208 209 QImage dummy(1, 1, QImage::Format_RGB32); 210 QPainter p(&dummy); 211 QSvgExtraStates states; 212 213 QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); 214 pen.setMiterLimit(4); 215 p.setPen(pen); 216 217 QStack<QSvgNode*> parentApplyStack; 218 QSvgNode *parent = m_parent; 219 while (parent) { 220 parentApplyStack.push(parent); 221 parent = parent->parent(); 222 } 223 224 for (int i = parentApplyStack.size() - 1; i >= 0; --i) 225 parentApplyStack[i]->applyStyle(&p, states); 226 227 p.setWorldTransform(QTransform()); 228 229 m_cachedBounds = transformedBounds(&p, states); 230 return m_cachedBounds; 201 231 } 202 232 … … 275 305 } 276 306 277 QRectF QSvgNode::transformedBounds(const QTransform &transform) const 278 { 279 QTransform t = transform; 280 281 QSvgTransformStyle *transStyle = m_style.transform; 282 if (transStyle) { 283 t = transStyle->qtransform() * t; 284 } 285 286 QRectF rect = bounds(); 287 288 rect = t.mapRect(rect); 289 307 QRectF QSvgNode::transformedBounds(QPainter *p, QSvgExtraStates &states) const 308 { 309 applyStyle(p, states); 310 QRectF rect = bounds(p, states); 311 revertStyle(p, states); 290 312 return rect; 291 313 } … … 311 333 } 312 334 313 qreal QSvgNode::strokeWidth() const 314 { 315 QSvgStrokeStyle *stroke = static_cast<QSvgStrokeStyle*>( 316 styleProperty(QSvgStyleProperty::STROKE)); 317 if (!stroke) 335 qreal QSvgNode::strokeWidth(QPainter *p) 336 { 337 QPen pen = p->pen(); 338 if (pen.style() == Qt::NoPen || pen.brush().style() == Qt::NoBrush || pen.isCosmetic()) 318 339 return 0; 319 if (stroke->stroke().brush().style() == Qt::NoBrush) 320 return 0; 321 return stroke->width(); 340 return pen.widthF(); 322 341 } 323 342
Note:
See TracChangeset
for help on using the changeset viewer.