From 57a6fee4d17b6049b95ccf2ef445ed18c8a2a841 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 23:08:41 +0200 Subject: Wholesale cruft removal part 2 (bzr r9508.1.45) --- src/sp-tspan.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 89a86218e..cf1990900 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -40,7 +40,6 @@ #include "sp-textpath.h" #include "text-editing.h" #include "style.h" -#include "libnr/nr-matrix-fns.h" #include "xml/repr.h" #include "document.h" -- cgit v1.2.3 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/sp-tspan.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index cf1990900..463a64aee 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -576,9 +576,10 @@ sp_textpath_to_text(SPObject *tp) { SPObject *text = SP_OBJECT_PARENT(tp); - NRRect bbox; - sp_item_invoke_bbox(SP_ITEM(text), &bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE); - Geom::Point xy(bbox.x0, bbox.y0); + Geom::OptRect bbox; + sp_item_invoke_bbox(SP_ITEM(text), bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE); + if (!bbox) return; + Geom::Point xy = bbox->min(); // make a list of textpath children GSList *tp_reprs = NULL; -- 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/sp-tspan.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/sp-tspan.cpp') diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 199d82e1b..f4e79f7d5 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -56,7 +56,7 @@ static void sp_tspan_release(SPObject *object); static void sp_tspan_set(SPObject *object, unsigned key, gchar const *value); static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_tspan_modified(SPObject *object, unsigned flags); -static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags); +static Geom::OptRect sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static char *sp_tspan_description (SPItem *item); @@ -203,34 +203,30 @@ static void sp_tspan_modified(SPObject *object, unsigned flags) } } -static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/) +static Geom::OptRect +sp_tspan_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + Geom::OptRect bbox; // find out the ancestor text which holds our layout SPObject const *parent_text = item; while (parent_text && !SP_IS_TEXT(parent_text)) { parent_text = parent_text->parent; } if (parent_text == NULL) { - return; + return bbox; } // get the bbox of our portion of the layout - SP_TEXT(parent_text)->layout.getBoundingBox(bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); + bbox = SP_TEXT(parent_text)->layout.bounds(transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1); + if (!bbox) return bbox; // Add stroke width - SPStyle* style = item->style; - if (!style->stroke.isNone()) { - double const scale = transform.descrim(); - if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord - double const width = MAX(0.125, style->stroke_width.computed * scale); - if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { - bbox->x0-=0.5*width; - bbox->x1+=0.5*width; - bbox->y0-=0.5*width; - bbox->y1+=0.5*width; - } - } + // FIXME this code is incorrect + if (type == SPItem::VISUAL_BBOX && !item->style->stroke.isNone()) { + double scale = transform.descrim(); + bbox->expandBy(0.5 * item->style->stroke_width.computed * scale); } + return bbox; } static Inkscape::XML::Node * @@ -592,8 +588,7 @@ sp_textpath_to_text(SPObject *tp) { SPObject *text = tp->parent; - Geom::OptRect bbox; - SP_ITEM(text)->invoke_bbox(bbox, SP_ITEM(text)->i2doc_affine(), TRUE); + Geom::OptRect bbox = SP_ITEM(text)->geometricBounds(SP_ITEM(text)->i2doc_affine()); if (!bbox) return; Geom::Point xy = bbox->min(); -- cgit v1.2.3