Layout SVG export

When the layout is exported as SVG - curves are saved as a series of joined points. Why are the original bezier not exported ?

Because they are converted to paths.

Yes - but they seem to be paths consisting only of lines, cannot paths also have curves, and would not exporting the original curves as curves preserve data that will be of use in the exported SVG.

I understand your need, but this is hard to achieve because because the layout generator doesn’t work with curves. It takes only polygons. And this is the reason why we lose info about original curves.

That’s not big deal for me. And i will not fix it. But if someone want to change this i will merge his pull request.

Is this the way Qt exports SVG?

No. As i understood Qt has method void QPaintEngine::drawPath(const QPainterPath &path). Right now we convert all curves and arcs to polygons and push to QPainterPath, but it also has methods addEllipse, arcTo, cubicTo. So, theoretically it can keep objects. I don’t know if QSvgRenderer support this feature, never tried, but this fact can be checked very easy.

Here is how this could work:

void ::drawPath( const QPainterPath& path )
{
  int pathLength = path.elementCount();
  for ( int i = 0; i < pathLength; ++i )
  {
    const QPainterPath::Element& pathElem = path.elementAt( i );
    if ( pathElem.type == QPainterPath::MoveToElement )
    {
      moveTo( pathElem.x, pathElem.y );
    }
    else if ( pathElem.type == QPainterPath::LineToElement )
    {
      lineTo( pathElem.x, pathElem.y );
    }
    else if ( pathElem.type == QPainterPath::CurveToElement )
    {
      curveTo( pathElem.x, pathElem.y );
    }
    else if ( pathElem.type == QPainterPath::CurveToDataElement )
    {
      mCurrentCurve.append( QPointF( pathElem.x, pathElem.y ) );
    }
  }
  ...
}

So, the main idea is clear.

  • Each object (spline, spline path, arc and elliptical arc) should provide two method that return QPainterPath. One simplified (current way) and one that keep the object.
  • VPiece class should also support this feature and return two versions.
  • When pass objects to layout it should additionally saves not simplified QPainterPath. And letter when we found position use map operation on this not simplified QPainterPath.

Only then QSvgRenderer will get right QPainterPath.

But as i said before, first better to check if QSvgRenderer supports this feature. If @bamba wants this feature i can point him in right direction.

Also my idea has problem when user needs only segment of curve.

As you most like ly realise, I am new here. I had a problem looking at a layout exported to .SVG and did not know inkscape well enough to edit the path of the dart seam. ( have now worked that out ).

As part of the process of working this out I saved a blank .SVG file and then using a text editor copied the “obvious” path element to narrow down what I was looking for. ( the first go I still got the wrong path).

When I got the right path I could not find the curve elements I was expecting to see - only line elements.

There is at least one topic heading where people are looking to do “round trip” exports to other tools for further manipulation, and back again.

Converting curves to lines removes data that might make this acheivable.

We don’t need this feature (original curves) for patternmaking. And if you need you or someone else should hack code and add this information. How? One way i described early. As to me this feature has very low priority.

@bamba At the moment we are working hard toward finishing v0.5. The improvement of the SVG export file is inherent in achieving some of our future goals. Thanks for pointing this out, it is something that will be addressed.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.