diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/svg/qsvggenerator.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp index cf69b7f..a282614 100644 --- a/src/svg/qsvggenerator.cpp +++ b/src/svg/qsvggenerator.cpp @@ -162,9 +162,11 @@ public: void updateState(const QPaintEngineState &state); void popGroup(); + void drawEllipse(const QRectF &r) Q_DECL_OVERRIDE; void drawPath(const QPainterPath &path); void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr); void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode); + void drawRects(const QRectF *rects, int rectCount) Q_DECL_OVERRIDE; void drawTextItem(const QPointF &pt, const QTextItem &item); void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags = Qt::AutoColor); @@ -967,6 +969,23 @@ void QSvgPaintEngine::updateState(const QPaintEngineState &state) d->afterFirstUpdate = true; } +void QSvgPaintEngine::drawEllipse(const QRectF &r) +{ + Q_D(QSvgPaintEngine); + + const bool isCircle = r.width() == r.height(); + *d->stream << '<' << (isCircle ? "circle" : "ellipse"); + if (state->pen().isCosmetic()) + *d->stream << " vector-effect=\"non-scaling-stroke\""; + const QPointF c = r.center(); + *d->stream << " cx=\"" << c.x() << "\" cy=\"" << c.y(); + if (isCircle) + *d->stream << "\" r=\"" << r.width() / qreal(2.0); + else + *d->stream << "\" rx=\"" << r.width() / qreal(2.0) << "\" ry=\"" << r.height() / qreal(2.0); + *d->stream << "\"/>" << endl; +} + void QSvgPaintEngine::drawPath(const QPainterPath &p) { Q_D(QSvgPaintEngine); @@ -1037,6 +1056,21 @@ void QSvgPaintEngine::drawPolygon(const QPointF *points, int pointCount, } } +void QSvgPaintEngine::drawRects(const QRectF *rects, int rectCount) +{ + Q_D(QSvgPaintEngine); + + for (int i=0; i < rectCount; ++i) { + const QRectF &rect = rects[i]; + *d->stream << "<rect"; + if (state->pen().isCosmetic()) + *d->stream << " vector-effect=\"non-scaling-stroke\""; + *d->stream << " x=\"" << rect.x() << "\" y=\"" << rect.y() + << "\" width=\"" << rect.width() << "\" height=\"" << rect.height() + << "\"/>" << endl; + } +} + void QSvgPaintEngine::drawTextItem(const QPointF &pt, const QTextItem &textItem) { Q_D(QSvgPaintEngine); |