From c883d7627a479c8c5b6a9f77b9841fa5631572ad Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 27 Apr 2015 19:39:29 -0400 Subject: 2Geom sync - initial commit (bzr r14059.2.1) --- src/svg/svg-path.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/svg/svg-path.cpp') diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 9ba3c0ebd..8f839eca5 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -61,10 +61,17 @@ Geom::PathVector sp_svg_read_pathv(char const * str) } static void sp_svg_write_curve(Inkscape::SVG::PathString & str, Geom::Curve const * c) { + // TODO: this code needs to removed and replaced by appropriate path sink if(Geom::LineSegment const *line_segment = dynamic_cast(c)) { // don't serialize stitch segments if (!dynamic_cast(c)) { - str.lineTo( (*line_segment)[1][0], (*line_segment)[1][1] ); + if (line_segment->initialPoint()[Geom::X] == line_segment->finalPoint()[Geom::X]) { + str.verticalLineTo( line_segment->finalPoint()[Geom::Y] ); + } else if (line_segment->initialPoint()[Geom::Y] == line_segment->finalPoint()[Geom::Y]) { + str.horizontalLineTo( line_segment->finalPoint()[Geom::X] ); + } else { + str.lineTo( (*line_segment)[1][0], (*line_segment)[1][1] ); + } } } else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast(c)) { @@ -81,12 +88,6 @@ static void sp_svg_write_curve(Inkscape::SVG::PathString & str, Geom::Curve cons Geom::rad_to_deg(svg_elliptical_arc->rotationAngle()), svg_elliptical_arc->largeArc(), svg_elliptical_arc->sweep(), svg_elliptical_arc->finalPoint() ); - } - else if(Geom::HLineSegment const *hline_segment = dynamic_cast(c)) { - str.horizontalLineTo( hline_segment->finalPoint()[0] ); - } - else if(Geom::VLineSegment const *vline_segment = dynamic_cast(c)) { - str.verticalLineTo( vline_segment->finalPoint()[1] ); } else { //this case handles sbasis as well as all other curve types Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c->toSBasis(), 0.1); -- cgit v1.2.3 From e110371c4d69ea0a407d7500b156cf373109787b Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 8 May 2015 08:29:58 +0200 Subject: Fix node editing problems (bzr r14059.2.4) --- src/svg/svg-path.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/svg/svg-path.cpp') diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 8f839eca5..ab51a5537 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -43,16 +43,15 @@ Geom::PathVector sp_svg_read_pathv(char const * str) if (!str) return pathv; // return empty pathvector when str == NULL - - typedef std::back_insert_iterator Inserter; - Inserter iter(pathv); - Geom::PathIteratorSink generator(iter); + Geom::PathBuilder builder(pathv); + Geom::SVGPathParser parser(builder); + parser.setZSnapThreshold(Geom::EPSILON); try { - Geom::parse_svg_path(str, generator); + parser.parse(str); } catch (Geom::SVGPathParseError &e) { - generator.flush(); + builder.flush(); // This warning is extremely annoying when testing //g_warning("Malformed SVG path, truncated path up to where error was found.\n Input path=\"%s\"\n Parsed path=\"%s\"", str, sp_svg_write_path(pathv)); } -- cgit v1.2.3 From 25fa09178b7d0d0befa708e93ea5316ef381caa0 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 22 May 2015 10:23:27 +0200 Subject: Update to 2Geom revision 2396 (bzr r14059.2.16) --- src/svg/svg-path.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/svg/svg-path.cpp') diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index ab51a5537..ba9e11452 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -82,11 +82,11 @@ static void sp_svg_write_curve(Inkscape::SVG::PathString & str, Geom::Curve cons (*cubic_bezier)[2][0], (*cubic_bezier)[2][1], (*cubic_bezier)[3][0], (*cubic_bezier)[3][1] ); } - else if(Geom::SVGEllipticalArc const *svg_elliptical_arc = dynamic_cast(c)) { - str.arcTo( svg_elliptical_arc->ray(Geom::X), svg_elliptical_arc->ray(Geom::Y), - Geom::rad_to_deg(svg_elliptical_arc->rotationAngle()), - svg_elliptical_arc->largeArc(), svg_elliptical_arc->sweep(), - svg_elliptical_arc->finalPoint() ); + else if(Geom::EllipticalArc const *elliptical_arc = dynamic_cast(c)) { + str.arcTo( elliptical_arc->ray(Geom::X), elliptical_arc->ray(Geom::Y), + Geom::rad_to_deg(elliptical_arc->rotationAngle()), + elliptical_arc->largeArc(), elliptical_arc->sweep(), + elliptical_arc->finalPoint() ); } else { //this case handles sbasis as well as all other curve types Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c->toSBasis(), 0.1); -- cgit v1.2.3