From 498629f82d9453cb7222ab642b867c183fdf1666 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 5 Aug 2010 01:56:47 +0200 Subject: Wholesale cruft removal part 3 (bzr r9508.1.47) --- src/splivarot.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index db9f72975..a58e3aa88 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -46,7 +46,6 @@ #include "xml/repr.h" #include "xml/repr-sorting.h" #include <2geom/pathvector.h> -#include #include "helper/geom.h" #include "livarot/Path.h" -- cgit v1.2.3 From c870e60f611ffd2dacde5b315c8a1995282eac56 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 12 Mar 2011 23:39:03 +0100 Subject: Allow for item groups in marker definitions when calculating the path outline. Fixed bugs: - https://launchpad.net/bugs/733010 (bzr r10098) --- src/splivarot.cpp | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index fe8d8a894..c01296b0e 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -625,33 +625,52 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine } } +static +void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_transform, Geom::PathVector* pathv_in ) +{ + Geom::Affine tr(marker_transform); + tr = item->transform * tr; + + // note: a marker child item can be an item group! + if (SP_IS_GROUP(item)) { + // recurse through all childs: + for (SPObject const *o = item->firstChild() ; o ; o = o->getNext() ) { + if ( SP_IS_ITEM(o) ) { + item_outline_add_marker_child(SP_ITEM(o), tr, pathv_in); + } + } + } else { + Geom::PathVector* marker_pathv = item_outline(item); + + if (marker_pathv) { + for (unsigned int j=0; j < marker_pathv->size(); j++) { + pathv_in->push_back((*marker_pathv)[j] * tr); + } + delete marker_pathv; + } + } +} + static void item_outline_add_marker( SPObject const *marker_object, Geom::Affine marker_transform, Geom::Scale stroke_scale, Geom::PathVector* pathv_in ) { SPMarker const * marker = SP_MARKER(marker_object); - SPItem const * marker_item = sp_item_first_item_child(marker_object); Geom::Affine tr(marker_transform); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { tr = stroke_scale * tr; } // total marker transform - tr = marker_item->transform * marker->c2p * tr; + tr = marker->c2p * tr; - Geom::PathVector* marker_pathv = item_outline(marker_item); - - if (marker_pathv) { - for (unsigned int j=0; j < marker_pathv->size(); j++) { - pathv_in->push_back((*marker_pathv)[j] * tr); - } - delete marker_pathv; - } + SPItem const * marker_item = sp_item_first_item_child(marker_object); // why only consider the first item? can a marker only consist of a single item (that may be a group)? + item_outline_add_marker_child(marker_item, tr, pathv_in); } /** * Returns a pathvector that is the outline of the stroked item, with markers. - * item must be SPShape of SPText. + * item must be SPShape or SPText. */ Geom::PathVector* item_outline(SPItem const *item) { -- cgit v1.2.3 From ab5c39d6151762215e0fa7e1bbd159e40bc751ab Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 17 Mar 2011 20:13:06 +0100 Subject: Linked Offset. Merge branch lp:~ado-papas/inkscape/bug_167419 (Bug #167419, Bug #184341, Bug #239430). (bzr r10109) --- src/splivarot.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index c01296b0e..9c2fc8ff9 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1487,6 +1487,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat if ( updating ) { //XML Tree being used directly here while it shouldn't be + item->doWriteTransform(item->getRepr(), transform); char const *id = item->getRepr()->attribute("id"); char const *uri = g_strdup_printf("#%s", id); repr->setAttribute("xlink:href", uri); @@ -1505,11 +1506,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat SPItem *nitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); - if ( updating ) { - // on conserve l'original - // we reapply the transform to the original (offset will feel it) - item->doWriteTransform(item->getRepr(), transform); - } else { + if ( !updating ) { // delete original, apply the transform to the offset item->deleteObject(false); nitem->doWriteTransform(repr, transform); -- cgit v1.2.3 From d6978fcea4a2ccd2d9cccefabc6558a74f332a6d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 2 Apr 2011 00:59:01 +0200 Subject: add curve before LPE to SPShape. this is useful for helperpath display. It was inspired from fixing bug 407008 Fixed bugs: - https://launchpad.net/bugs/407008 (bzr r10142) --- src/splivarot.cpp | 75 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 21 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 9c2fc8ff9..0e27ce26d 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1804,19 +1804,10 @@ sp_selected_path_simplify_item(SPDesktop *desktop, false); } - - SPCurve *curve = NULL; - - if (SP_IS_SHAPE(item)) { - curve = SP_SHAPE(item)->getCurve(); - if (!curve) - return false; - } - - if (SP_IS_TEXT(item)) { - curve = SP_TEXT(item)->getNormalizedBpath(); - if (!curve) - return false; + // get path to simplify (note that the path *before* LPE calculation is needed) + Path *orig = Path_for_item_before_LPE(item, false); + if (orig == NULL) { + return false; } // correct virtual size by full transform (bug #166937) @@ -1836,14 +1827,6 @@ sp_selected_path_simplify_item(SPDesktop *desktop, gchar *mask = g_strdup(item->getRepr()->attribute("mask")); gchar *clip_path = g_strdup(item->getRepr()->attribute("clip-path")); - Path *orig = Path_for_item(item, false); - if (orig == NULL) { - g_free(style); - curve->unref(); - return false; - } - - curve->unref(); // remember the position of the item gint pos = item->getRepr()->position(); // remember parent @@ -2106,6 +2089,27 @@ Path_for_item(SPItem *item, bool doTransformation, bool transformFull) return dest; } +/** + * Obtains an item's Path before the LPE stack has been applied. + */ +Path * +Path_for_item_before_LPE(SPItem *item, bool doTransformation, bool transformFull) +{ + SPCurve *curve = curve_for_item_before_LPE(item); + + if (curve == NULL) + return NULL; + + Geom::PathVector *pathv = pathvector_for_curve(item, curve, doTransformation, transformFull, Geom::identity(), Geom::identity()); + curve->unref(); + + Path *dest = new Path; + dest->LoadPathVector(*pathv); + delete pathv; + + return dest; +} + /* * NOTE: Returns empty pathvector if curve == NULL * TODO: see if calling this method can be optimized. All the pathvector copying might be slow. @@ -2132,6 +2136,10 @@ pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool t return dest; } +/** + * Obtains an item's curve. For SPPath, it is the path *before* LPE. For SPShapes other than path, it is the path *after* LPE. + * So the result is somewhat ill-defined, and probably this method should not be used... See curve_for_item_before_LPE. + */ SPCurve* curve_for_item(SPItem *item) { if (!item) @@ -2157,6 +2165,31 @@ SPCurve* curve_for_item(SPItem *item) return curve; // do not forget to unref the curve at some point! } +/** + * Obtains an item's curve *before* LPE. + * The returned SPCurve should be unreffed by the caller. + */ +SPCurve* curve_for_item_before_LPE(SPItem *item) +{ + if (!item) + return NULL; + + SPCurve *curve = NULL; + if (SP_IS_SHAPE(item)) { + curve = SP_SHAPE(item)->getCurveBeforeLPE(); + } + else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) + { + curve = te_get_layout(item)->convertToCurves(); + } + else if (SP_IS_IMAGE(item)) + { + curve = sp_image_get_curve(SP_IMAGE(item)); + } + + return curve; // do not forget to unref the curve at some point! +} + boost::optional get_nearest_position_on_Path(Path *path, Geom::Point p, unsigned seg) { //get nearest position on path -- cgit v1.2.3 From 70829da1b189d6d8f07f12d97b9273d56dbd789e Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 17 Apr 2011 14:51:06 +0200 Subject: add new preference widget for a number with a unit. change Preferences > Steps to this new widget (bzr r10177) --- src/splivarot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 0e27ce26d..ac2acf330 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1264,7 +1264,7 @@ void sp_selected_path_offset(SPDesktop *desktop) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0); + double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); sp_selected_path_do_offset(desktop, true, prefOffset); } @@ -1272,7 +1272,7 @@ void sp_selected_path_inset(SPDesktop *desktop) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0); + double prefOffset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); sp_selected_path_do_offset(desktop, false, prefOffset); } @@ -1398,7 +1398,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0); + o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); } if (o_width < 0.01) -- cgit v1.2.3 From 7f81932011c4ad87db74d62a2843949f4a5a3ffe Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 1 May 2011 16:27:28 +0200 Subject: Fix crashes on empty marker definitions. Fixed bugs: - https://launchpad.net/bugs/774834 (bzr r10195) --- src/splivarot.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index ac2acf330..5ff394782 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -607,6 +607,9 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine { SPMarker* marker = SP_MARKER (marker_object); SPItem* marker_item = sp_item_first_item_child(marker_object); + if (!marker_item) { + return; + } Geom::Affine tr(marker_transform); @@ -665,7 +668,9 @@ void item_outline_add_marker( SPObject const *marker_object, Geom::Affine marker tr = marker->c2p * tr; SPItem const * marker_item = sp_item_first_item_child(marker_object); // why only consider the first item? can a marker only consist of a single item (that may be a group)? - item_outline_add_marker_child(marker_item, tr, pathv_in); + if (marker_item) { + item_outline_add_marker_child(marker_item, tr, pathv_in); + } } /** -- cgit v1.2.3 From eed6e9c2c229b10911a23976c47da79fc70a5b87 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 17 Jul 2011 21:47:09 +0200 Subject: - rename SPItem::i2d_affine to i2dt_affine, to clarify that it is item-to-desktop, not item-to-document. This should make it easier to spot bugs. - tag some instances where the document-to-desktop transform has been hardcoded (bzr r10466) --- 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 3d3027639..d3d6c3db7 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1963,7 +1963,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, continue; if (simplifyIndividualPaths) { - Geom::OptRect itemBbox = item->getBounds(item->i2d_affine()); + Geom::OptRect itemBbox = item->getBounds(item->i2dt_affine()); if (itemBbox) { simplifySize = L2(itemBbox->dimensions()); } else { -- cgit v1.2.3 From 72cc39b9f0b340548f395c7f61ca9662b34aea09 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 11:04:37 +0200 Subject: Refactor SPItem bounding box methods: remove NRRect usage and make code using them more obvious. Fix filter region computation. (bzr r10582.1.1) --- src/splivarot.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/splivarot.cpp') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index d3d6c3db7..28d6f90be 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1942,7 +1942,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, bool didSomething = false; - Geom::OptRect selectionBbox = selection->bounds(); + Geom::OptRect selectionBbox = selection->visualBounds(); if (!selectionBbox) { return false; } @@ -1963,7 +1963,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, continue; if (simplifyIndividualPaths) { - Geom::OptRect itemBbox = item->getBounds(item->i2dt_affine()); + Geom::OptRect itemBbox = item->desktopVisualBounds(); if (itemBbox) { simplifySize = L2(itemBbox->dimensions()); } else { -- cgit v1.2.3 From 4e51446f417ad82d2cdac758d0c5ce908ff88038 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 8 Dec 2011 11:53:54 +0000 Subject: Switch to top-level glib headers. Thanks to DimStar for patch Fixed bugs: - https://launchpad.net/bugs/898538 (bzr r10762) --- 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 28d6f90be..ea035f0ab 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "xml/repr.h" #include "svg/svg.h" #include "sp-path.h" -- cgit v1.2.3