29 QSvgRectF(
const QRectF &r = QRectF(),
30 QtSvg::UnitTypes unitX = QtSvg::UnitTypes::userSpaceOnUse,
31 QtSvg::UnitTypes unitY = QtSvg::UnitTypes::userSpaceOnUse,
32 QtSvg::UnitTypes unitW = QtSvg::UnitTypes::userSpaceOnUse,
33 QtSvg::UnitTypes unitH = QtSvg::UnitTypes::userSpaceOnUse)
41 QPointF translationRelativeToBoundingBox(
const QRectF &boundingBox)
const {
44 if (m_unitX == QtSvg::UnitTypes::objectBoundingBox)
45 result.setX(x() * boundingBox.width());
48 if (m_unitY == QtSvg::UnitTypes::objectBoundingBox)
49 result.setY(y() * boundingBox.height());
55 QRectF resolveRelativeLengths(
const QRectF &localRect)
const {
57 if (m_unitX == QtSvg::UnitTypes::objectBoundingBox)
58 result.setX(localRect.x() + x() * localRect.width());
61 if (m_unitY == QtSvg::UnitTypes::objectBoundingBox)
62 result.setY(localRect.y() + y() * localRect.height());
65 if (m_unitW == QtSvg::UnitTypes::objectBoundingBox)
66 result.setWidth(localRect.width() * width());
68 result.setWidth(width());
69 if (m_unitH == QtSvg::UnitTypes::objectBoundingBox)
70 result.setHeight(localRect.height() * height());
72 result.setHeight(height());
76 QRectF resolveRelativeLengths(
const QRectF &localRect, QtSvg::UnitTypes units)
const {
78 if (units == QtSvg::UnitTypes::objectBoundingBox ||
79 m_unitX == QtSvg::UnitTypes::objectBoundingBox)
80 result.setX(localRect.x() + x() * localRect.width());
83 if (units == QtSvg::UnitTypes::objectBoundingBox ||
84 m_unitY == QtSvg::UnitTypes::objectBoundingBox)
85 result.setY(localRect.y() + y() * localRect.height());
88 if (units == QtSvg::UnitTypes::objectBoundingBox ||
89 m_unitW == QtSvg::UnitTypes::objectBoundingBox)
90 result.setWidth(localRect.width() * width());
92 result.setWidth(width());
93 if (units == QtSvg::UnitTypes::objectBoundingBox ||
94 m_unitH == QtSvg::UnitTypes::objectBoundingBox)
95 result.setHeight(localRect.height() * height());
97 result.setHeight(height());
114 friend QDebug operator<<(QDebug debug,
const QSvgRectF &r)
117 debug.nospace() <<
"QSvgRectF(" << r.x()
118 << (r.unitX() == QtSvg::UnitTypes::unknown ?
"(?)" :
119 (r.unitX() == QtSvg::UnitTypes::objectBoundingBox ?
"(%)" :
""))
121 << (r.unitY() == QtSvg::UnitTypes::unknown ?
"(?)" :
122 (r.unitY() == QtSvg::UnitTypes::objectBoundingBox ?
"(%)" :
""))
124 << (r.unitW() == QtSvg::UnitTypes::unknown ?
"(?)" :
125 (r.unitW() == QtSvg::UnitTypes::objectBoundingBox ?
"(%)" :
""))
127 << (r.unitH() == QtSvg::UnitTypes::unknown ?
"(?)" :
128 (r.unitH() == QtSvg::UnitTypes::objectBoundingBox ?
"(%)" :
""))