From 646534345d309233570969f98fcf9495c19d45ae Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 14 Apr 2014 22:48:12 +0200 Subject: Improve calculation precision of stroke-to-path, for very large user units that make the stroke width a very small number. Fixed bugs: - https://launchpad.net/bugs/1244861 (bzr r13286) --- src/splivarot.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 6aec42c5b..40f3f174a 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -960,16 +960,17 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) Geom::Affine const transform(item->transform); float const scale = transform.descrim(); - float o_width, o_miter; + float o_width = i_style->stroke_width.computed; + if (o_width < Geom::EPSILON) { + // This may result in rounding errors for very small stroke widths (happens e.g. when user unit is large). + // See bug lp:1244861 + o_width = Geom::EPSILON; + } + float o_miter = i_style->stroke_miterlimit.value * o_width; + JoinType o_join; ButtType o_butt; { - o_width = i_style->stroke_width.computed; - if (o_width < 0.01) { - o_width = 0.01; - } - o_miter = i_style->stroke_miterlimit.value * o_width; - switch (i_style->stroke_linejoin.computed) { case SP_STROKE_LINEJOIN_MITER: o_join = join_pointy; -- cgit v1.2.3 From d4c92eb19b82184433aee3f941fb97b2f4818027 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Tue, 29 Apr 2014 19:22:37 -0400 Subject: Fix bug #1290573 and #1310802 (bzr r13323) --- src/splivarot.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 40f3f174a..8bb2a7150 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1457,13 +1457,21 @@ sp_selected_path_outline(SPDesktop *desktop) g_repr, xml_doc, doc ); } } + //bug lp:1290573 : completely destroy the old object first + curve->unref(); + selection->remove(item); + item->deleteObject(false); selection->add(g_repr); Inkscape::GC::release(g_repr); - - } else { + } else + { + //lp:1290573 + curve->unref(); + selection->remove(item); + item->deleteObject(false); // add the new repr to the parent parent->appendChild(repr); @@ -1489,10 +1497,6 @@ sp_selected_path_outline(SPDesktop *desktop) Inkscape::GC::release(repr); - curve->unref(); - selection->remove(item); - item->deleteObject(false); - } if (title) { g_free(title); -- cgit v1.2.3 From 1fd57a41383419cbeddbaef27e52d55c0d02400f Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Fri, 6 Jun 2014 17:01:38 -0400 Subject: Clean up some unnecessary pointer usage in livarot (bzr r13341.1.50) --- src/splivarot.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 8bb2a7150..c8682e6b4 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -156,13 +156,13 @@ sp_pathvector_boolop(Geom::PathVector const &pathva, Geom::PathVector const &pat // get the polygons of each path, with the winding rule specified, and apply the operation iteratively originaux[0]->ConvertWithBackData(0.1); - originaux[0]->Fill(theShape, 0); + originaux[0]->Fill(*theShape, 0); theShapeA->ConvertToShape(theShape, origWind[0]); originaux[1]->ConvertWithBackData(0.1); - originaux[1]->Fill(theShape, 1); + originaux[1]->Fill(*theShape, 1); theShapeB->ConvertToShape(theShape, origWind[1]); @@ -191,13 +191,13 @@ sp_pathvector_boolop(Geom::PathVector const &pathva, Geom::PathVector const &pat } originaux[0]->ConvertWithBackData(1.0); - originaux[0]->Fill(theShape, 0); + originaux[0]->Fill(*theShape, 0); theShapeA->ConvertToShape(theShape, origWind[0]); originaux[1]->ConvertWithBackData(1.0); - originaux[1]->Fill(theShape, 1,false,false,false); //do not closeIfNeeded + originaux[1]->Fill(*theShape, 1,false,false,false); //do not closeIfNeeded theShapeB->ConvertToShape(theShape, fill_justDont); // fill_justDont doesn't computes winding numbers @@ -218,11 +218,11 @@ sp_pathvector_boolop(Geom::PathVector const &pathva, Geom::PathVector const &pat } originaux[0]->ConvertWithBackData(1.0); - originaux[0]->Fill(theShapeA, 0,false,false,false); // don't closeIfNeeded + originaux[0]->Fill(*theShapeA, 0,false,false,false); // don't closeIfNeeded originaux[1]->ConvertWithBackData(1.0); - originaux[1]->Fill(theShapeA, 1,true,false,false);// don't closeIfNeeded and just dump in the shape, don't reset it + originaux[1]->Fill(*theShapeA, 1,true,false,false);// don't closeIfNeeded and just dump in the shape, don't reset it theShape->ConvertToShape(theShapeA, fill_justDont); @@ -467,7 +467,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // get the polygons of each path, with the winding rule specified, and apply the operation iteratively originaux[0]->ConvertWithBackData(0.1); - originaux[0]->Fill(theShape, 0); + originaux[0]->Fill(*theShape, 0); theShapeA->ConvertToShape(theShape, origWind[0]); @@ -475,7 +475,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool for (GSList *l = il->next; l != NULL; l = l->next) { originaux[curOrig]->ConvertWithBackData(0.1); - originaux[curOrig]->Fill(theShape, curOrig); + originaux[curOrig]->Fill(*theShape, curOrig); theShapeB->ConvertToShape(theShape, origWind[curOrig]); @@ -549,16 +549,16 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } originaux[0]->ConvertWithBackData(1.0); - originaux[0]->Fill(theShape, 0); + originaux[0]->Fill(*theShape, 0); theShapeA->ConvertToShape(theShape, origWind[0]); originaux[1]->ConvertWithBackData(1.0); if ((originaux[1]->pts.size() == 2) && originaux[1]->pts[0].isMoveTo && !originaux[1]->pts[1].isMoveTo) - originaux[1]->Fill(theShape, 1,false,true,false); // see LP Bug 177956 + originaux[1]->Fill(*theShape, 1,false,true,false); // see LP Bug 177956 else - originaux[1]->Fill(theShape, 1,false,false,false); //do not closeIfNeeded + originaux[1]->Fill(*theShape, 1,false,false,false); //do not closeIfNeeded theShapeB->ConvertToShape(theShape, fill_justDont); // fill_justDont doesn't computes winding numbers @@ -579,11 +579,11 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } originaux[0]->ConvertWithBackData(1.0); - originaux[0]->Fill(theShapeA, 0,false,false,false); // don't closeIfNeeded + originaux[0]->Fill(*theShapeA, 0,false,false,false); // don't closeIfNeeded originaux[1]->ConvertWithBackData(1.0); - originaux[1]->Fill(theShapeA, 1,true,false,false);// don't closeIfNeeded and just dump in the shape, don't reset it + originaux[1]->Fill(*theShapeA, 1,true,false,false);// don't closeIfNeeded and just dump in the shape, don't reset it theShape->ConvertToShape(theShapeA, fill_justDont); @@ -1014,9 +1014,9 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) orig->DashPolylineFromStyle(i_style, scale, 0); Shape* theShape = new Shape; - orig->Stroke(theShape, false, 0.5*o_width, o_join, o_butt, + orig->Stroke(*theShape, false, 0.5*o_width, o_join, o_butt, 0.5 * o_miter); - orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); + orig->Outline(*res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); if (!bbox_only) { Shape *theRes = new Shape; @@ -1030,7 +1030,7 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) } delete theShape; } else { - orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); + orig->Outline(*res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); if (!bbox_only) { orig->Coalesce(0.5 * o_width); @@ -1038,7 +1038,7 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) Shape *theRes = new Shape; res->ConvertWithBackData(1.0); - res->Fill(theShape, 0); + res->Fill(*theShape, 0); theRes->ConvertToShape(theShape, fill_positive); Path *originaux[1]; @@ -1060,7 +1060,7 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether - ret_pathv = bbox_only ? res->MakePathVector() : orig->MakePathVector(); + ret_pathv = new Geom::PathVector(bbox_only ? (res->MakePathVector()) : (orig->MakePathVector())); if (SP_IS_SHAPE(item) && SP_SHAPE(item)->hasMarkers() && !bbox_only) { SPShape *shape = SP_SHAPE(item); @@ -1283,9 +1283,9 @@ sp_selected_path_outline(SPDesktop *desktop) orig->DashPolylineFromStyle(i_style, scale, 0); Shape* theShape = new Shape; - orig->Stroke(theShape, false, 0.5*o_width, o_join, o_butt, + orig->Stroke(*theShape, false, 0.5*o_width, o_join, o_butt, 0.5 * o_miter); - orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); + orig->Outline(*res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); Shape *theRes = new Shape; @@ -1302,7 +1302,7 @@ sp_selected_path_outline(SPDesktop *desktop) } else { - orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); + orig->Outline(*res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); orig->Coalesce(0.5 * o_width); @@ -1310,7 +1310,7 @@ sp_selected_path_outline(SPDesktop *desktop) Shape *theRes = new Shape; res->ConvertWithBackData(1.0); - res->Fill(theShape, 0); + res->Fill(*theShape, 0); theRes->ConvertToShape(theShape, fill_positive); Path *originaux[1]; @@ -1644,7 +1644,7 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool Shape *theRes = new Shape; orig->ConvertWithBackData(1.0); - orig->Fill(theShape, 0); + orig->Fill(*theShape, 0); SPCSSAttr *css = sp_repr_css_attr(item->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); @@ -1843,7 +1843,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) Shape *theRes = new Shape; orig->ConvertWithBackData(0.03); - orig->Fill(theShape, 0); + orig->Fill(*theShape, 0); SPCSSAttr *css = sp_repr_css_attr(item->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); -- cgit v1.2.3 From 48ddc5ea8c9ee44c7ae388d43f9be9552acf64ae Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Fri, 6 Jun 2014 21:19:18 -0400 Subject: Undo changes in r13391 (bzr r13341.1.51) --- src/splivarot.cpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index c8682e6b4..8bb2a7150 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -156,13 +156,13 @@ sp_pathvector_boolop(Geom::PathVector const &pathva, Geom::PathVector const &pat // get the polygons of each path, with the winding rule specified, and apply the operation iteratively originaux[0]->ConvertWithBackData(0.1); - originaux[0]->Fill(*theShape, 0); + originaux[0]->Fill(theShape, 0); theShapeA->ConvertToShape(theShape, origWind[0]); originaux[1]->ConvertWithBackData(0.1); - originaux[1]->Fill(*theShape, 1); + originaux[1]->Fill(theShape, 1); theShapeB->ConvertToShape(theShape, origWind[1]); @@ -191,13 +191,13 @@ sp_pathvector_boolop(Geom::PathVector const &pathva, Geom::PathVector const &pat } originaux[0]->ConvertWithBackData(1.0); - originaux[0]->Fill(*theShape, 0); + originaux[0]->Fill(theShape, 0); theShapeA->ConvertToShape(theShape, origWind[0]); originaux[1]->ConvertWithBackData(1.0); - originaux[1]->Fill(*theShape, 1,false,false,false); //do not closeIfNeeded + originaux[1]->Fill(theShape, 1,false,false,false); //do not closeIfNeeded theShapeB->ConvertToShape(theShape, fill_justDont); // fill_justDont doesn't computes winding numbers @@ -218,11 +218,11 @@ sp_pathvector_boolop(Geom::PathVector const &pathva, Geom::PathVector const &pat } originaux[0]->ConvertWithBackData(1.0); - originaux[0]->Fill(*theShapeA, 0,false,false,false); // don't closeIfNeeded + originaux[0]->Fill(theShapeA, 0,false,false,false); // don't closeIfNeeded originaux[1]->ConvertWithBackData(1.0); - originaux[1]->Fill(*theShapeA, 1,true,false,false);// don't closeIfNeeded and just dump in the shape, don't reset it + originaux[1]->Fill(theShapeA, 1,true,false,false);// don't closeIfNeeded and just dump in the shape, don't reset it theShape->ConvertToShape(theShapeA, fill_justDont); @@ -467,7 +467,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // get the polygons of each path, with the winding rule specified, and apply the operation iteratively originaux[0]->ConvertWithBackData(0.1); - originaux[0]->Fill(*theShape, 0); + originaux[0]->Fill(theShape, 0); theShapeA->ConvertToShape(theShape, origWind[0]); @@ -475,7 +475,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool for (GSList *l = il->next; l != NULL; l = l->next) { originaux[curOrig]->ConvertWithBackData(0.1); - originaux[curOrig]->Fill(*theShape, curOrig); + originaux[curOrig]->Fill(theShape, curOrig); theShapeB->ConvertToShape(theShape, origWind[curOrig]); @@ -549,16 +549,16 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } originaux[0]->ConvertWithBackData(1.0); - originaux[0]->Fill(*theShape, 0); + originaux[0]->Fill(theShape, 0); theShapeA->ConvertToShape(theShape, origWind[0]); originaux[1]->ConvertWithBackData(1.0); if ((originaux[1]->pts.size() == 2) && originaux[1]->pts[0].isMoveTo && !originaux[1]->pts[1].isMoveTo) - originaux[1]->Fill(*theShape, 1,false,true,false); // see LP Bug 177956 + originaux[1]->Fill(theShape, 1,false,true,false); // see LP Bug 177956 else - originaux[1]->Fill(*theShape, 1,false,false,false); //do not closeIfNeeded + originaux[1]->Fill(theShape, 1,false,false,false); //do not closeIfNeeded theShapeB->ConvertToShape(theShape, fill_justDont); // fill_justDont doesn't computes winding numbers @@ -579,11 +579,11 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } originaux[0]->ConvertWithBackData(1.0); - originaux[0]->Fill(*theShapeA, 0,false,false,false); // don't closeIfNeeded + originaux[0]->Fill(theShapeA, 0,false,false,false); // don't closeIfNeeded originaux[1]->ConvertWithBackData(1.0); - originaux[1]->Fill(*theShapeA, 1,true,false,false);// don't closeIfNeeded and just dump in the shape, don't reset it + originaux[1]->Fill(theShapeA, 1,true,false,false);// don't closeIfNeeded and just dump in the shape, don't reset it theShape->ConvertToShape(theShapeA, fill_justDont); @@ -1014,9 +1014,9 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) orig->DashPolylineFromStyle(i_style, scale, 0); Shape* theShape = new Shape; - orig->Stroke(*theShape, false, 0.5*o_width, o_join, o_butt, + orig->Stroke(theShape, false, 0.5*o_width, o_join, o_butt, 0.5 * o_miter); - orig->Outline(*res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); + orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); if (!bbox_only) { Shape *theRes = new Shape; @@ -1030,7 +1030,7 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) } delete theShape; } else { - orig->Outline(*res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); + orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); if (!bbox_only) { orig->Coalesce(0.5 * o_width); @@ -1038,7 +1038,7 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) Shape *theRes = new Shape; res->ConvertWithBackData(1.0); - res->Fill(*theShape, 0); + res->Fill(theShape, 0); theRes->ConvertToShape(theShape, fill_positive); Path *originaux[1]; @@ -1060,7 +1060,7 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether - ret_pathv = new Geom::PathVector(bbox_only ? (res->MakePathVector()) : (orig->MakePathVector())); + ret_pathv = bbox_only ? res->MakePathVector() : orig->MakePathVector(); if (SP_IS_SHAPE(item) && SP_SHAPE(item)->hasMarkers() && !bbox_only) { SPShape *shape = SP_SHAPE(item); @@ -1283,9 +1283,9 @@ sp_selected_path_outline(SPDesktop *desktop) orig->DashPolylineFromStyle(i_style, scale, 0); Shape* theShape = new Shape; - orig->Stroke(*theShape, false, 0.5*o_width, o_join, o_butt, + orig->Stroke(theShape, false, 0.5*o_width, o_join, o_butt, 0.5 * o_miter); - orig->Outline(*res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); + orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); Shape *theRes = new Shape; @@ -1302,7 +1302,7 @@ sp_selected_path_outline(SPDesktop *desktop) } else { - orig->Outline(*res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); + orig->Outline(res, 0.5 * o_width, o_join, o_butt, 0.5 * o_miter); orig->Coalesce(0.5 * o_width); @@ -1310,7 +1310,7 @@ sp_selected_path_outline(SPDesktop *desktop) Shape *theRes = new Shape; res->ConvertWithBackData(1.0); - res->Fill(*theShape, 0); + res->Fill(theShape, 0); theRes->ConvertToShape(theShape, fill_positive); Path *originaux[1]; @@ -1644,7 +1644,7 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool Shape *theRes = new Shape; orig->ConvertWithBackData(1.0); - orig->Fill(*theShape, 0); + orig->Fill(theShape, 0); SPCSSAttr *css = sp_repr_css_attr(item->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); @@ -1843,7 +1843,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) Shape *theRes = new Shape; orig->ConvertWithBackData(0.03); - orig->Fill(*theShape, 0); + orig->Fill(theShape, 0); SPCSSAttr *css = sp_repr_css_attr(item->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); -- cgit v1.2.3 From 9a0740b27fcad7f06bae507e1957f4bfeb4f9dc7 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 5 Oct 2014 12:58:19 -0400 Subject: Rename marker.cpp -> sp-marker.cpp to reflect inclusion in SP-tree (bzr r13341.1.248) --- src/splivarot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 8bb2a7150..1a75a6f29 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -25,7 +25,7 @@ #include "sp-path.h" #include "sp-shape.h" #include "sp-image.h" -#include "marker.h" +#include "sp-marker.h" #include "enums.h" #include "sp-text.h" #include "sp-flowtext.h" -- cgit v1.2.3