src/svg/qsvggenerator.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
   308 
   308 
   309     void generateQtDefaults()
   309     void generateQtDefaults()
   310     {
   310     {
   311         *d_func()->stream << QLatin1String("fill=\"none\" ");
   311         *d_func()->stream << QLatin1String("fill=\"none\" ");
   312         *d_func()->stream << QLatin1String("stroke=\"black\" ");
   312         *d_func()->stream << QLatin1String("stroke=\"black\" ");
   313         *d_func()->stream << QLatin1String("vector-effect=\"non-scaling-stroke\" ");
       
   314         *d_func()->stream << QLatin1String("stroke-width=\"1\" ");
   313         *d_func()->stream << QLatin1String("stroke-width=\"1\" ");
   315         *d_func()->stream << QLatin1String("fill-rule=\"evenodd\" ");
   314         *d_func()->stream << QLatin1String("fill-rule=\"evenodd\" ");
   316         *d_func()->stream << QLatin1String("stroke-linecap=\"square\" ");
   315         *d_func()->stream << QLatin1String("stroke-linecap=\"square\" ");
   317         *d_func()->stream << QLatin1String("stroke-linejoin=\"bevel\" ");
   316         *d_func()->stream << QLatin1String("stroke-linejoin=\"bevel\" ");
   318         *d_func()->stream << QLatin1String(">\n");
   317         *d_func()->stream << QLatin1String(">\n");
   378         default:
   377         default:
   379             qWarning("Unsupported pen style");
   378             qWarning("Unsupported pen style");
   380             break;
   379             break;
   381         }
   380         }
   382 
   381 
   383         if (spen.widthF() == 0) {
   382         if (spen.widthF() == 0)
   384             width = QLatin1String("1");
   383             stream() <<"stroke-width=\"1\" ";
   385             stream() << "vector-effect=\"non-scaling-stroke\" ";
       
   386         }
       
   387         else
   384         else
   388             width = QString::number(spen.widthF());
   385             stream() <<"stroke-width=\"" << spen.widthF() << "\" ";
   389         stream() <<"stroke-width=\""<<width<<"\" ";
       
   390 
   386 
   391         switch (spen.capStyle()) {
   387         switch (spen.capStyle()) {
   392         case Qt::FlatCap:
   388         case Qt::FlatCap:
   393             stream() << "stroke-linecap=\"butt\" ";
   389             stream() << "stroke-linecap=\"butt\" ";
   394             break;
   390             break;
   981 
   977 
   982 void QSvgPaintEngine::drawPath(const QPainterPath &p)
   978 void QSvgPaintEngine::drawPath(const QPainterPath &p)
   983 {
   979 {
   984     Q_D(QSvgPaintEngine);
   980     Q_D(QSvgPaintEngine);
   985 
   981 
   986     *d->stream << "<path "
   982     *d->stream << "<path vector-effect=\""
   987                   "fill-rule=";
   983                << (state->pen().isCosmetic() ? "non-scaling-stroke" : "none")
   988     if (p.fillRule() == Qt::OddEvenFill)
   984                << "\" fill-rule=\""
   989         *d->stream << "\"evenodd\" ";
   985                << (p.fillRule() == Qt::OddEvenFill ? "evenodd" : "nonzero")
   990     else
   986                << "\" d=\"";
   991         *d->stream << "\"nonzero\" ";
       
   992 
       
   993     *d->stream << "d=\"";
       
   994 
   987 
   995     for (int i=0; i<p.elementCount(); ++i) {
   988     for (int i=0; i<p.elementCount(); ++i) {
   996         const QPainterPath::Element &e = p.elementAt(i);
   989         const QPainterPath::Element &e = p.elementAt(i);
   997         switch (e.type) {
   990         switch (e.type) {
   998         case QPainterPath::MoveToElement:
   991         case QPainterPath::MoveToElement:
  1036     QPainterPath path(points[0]);
  1029     QPainterPath path(points[0]);
  1037     for (int i=1; i<pointCount; ++i)
  1030     for (int i=1; i<pointCount; ++i)
  1038         path.lineTo(points[i]);
  1031         path.lineTo(points[i]);
  1039 
  1032 
  1040     if (mode == PolylineMode) {
  1033     if (mode == PolylineMode) {
  1041         stream() << "<polyline fill=\"none\" points=\"";
  1034         stream() << "<polyline fill=\"none\" vector-effect=\""
       
  1035                  << (state->pen().isCosmetic() ? "non-scaling-stroke" : "none")
       
  1036                  << "\" points=\"";
  1042         for (int i = 0; i < pointCount; ++i) {
  1037         for (int i = 0; i < pointCount; ++i) {
  1043             const QPointF &pt = points[i];
  1038             const QPointF &pt = points[i];
  1044             stream() << pt.x() << ',' << pt.y() << ' ';
  1039             stream() << pt.x() << ',' << pt.y() << ' ';
  1045         }
  1040         }
  1046         stream() << "\" />" <<endl;
  1041         stream() << "\" />" <<endl;