From 30884b9e814d7baaa2299803e8cb76cf203ca084 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 05:45:58 +0200 Subject: Wholesale cruft removal part 1 (bzr r9508.1.44) --- src/sp-shape.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 3064341b6..30a94302e 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -16,10 +16,6 @@ # include "config.h" #endif -#include -#include -#include -#include #include <2geom/rect.h> #include <2geom/transforms.h> #include <2geom/pathvector.h> @@ -270,7 +266,7 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags) style = SP_OBJECT_STYLE (object); if (style->stroke_width.unit == SP_CSS_UNIT_PERCENT) { SPItemCtx *ictx = (SPItemCtx *) ctx; - double const aw = 1.0 / NR::expansion(ictx->i2vp); + double const aw = 1.0 / ictx->i2vp.descrim(); style->stroke_width.computed = style->stroke_width.value * aw; for (SPItemView *v = ((SPItem *) (shape))->display; v != NULL; v = v->next) { nr_arena_shape_set_style ((NRArenaShape *) v->arenaitem, style); -- 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-shape.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 30a94302e..c6826bfb1 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -605,7 +605,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & // get bbox of the marker with that transform NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); // union it with the shape bbox nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } @@ -633,7 +633,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & } tr = marker_item->transform * marker->c2p * tr * transform; NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } // MID position @@ -660,7 +660,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const & } tr = marker_item->transform * marker->c2p * tr * transform; NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); + sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } -- cgit v1.2.3 From e49d12a439484bead7cf99456d7b8ccb76055f50 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Mar 2011 15:25:50 +0100 Subject: make a strange cast more obvious (bzr r10101) --- src/sp-shape.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index d9a47f76a..e9b0909ed 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -508,6 +508,8 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) { SPShape const *shape = SP_SHAPE (item); + SPItem::BBoxType bboxtype = (SPItem::BBoxType) flags; + if (shape->curve) { Geom::OptRect geombbox = bounds_exact_transformed(shape->curve->get_pathvector(), transform); if (geombbox) { @@ -517,7 +519,7 @@ void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const cbbox.x1 = (*geombbox)[0][1]; cbbox.y1 = (*geombbox)[1][1]; - switch ((SPItem::BBoxType) flags) { + switch (bboxtype) { case SPItem::GEOMETRIC_BBOX: { // do nothing break; -- 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/sp-shape.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index e9b0909ed..72559c63f 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -126,6 +126,7 @@ void SPShape::sp_shape_init(SPShape *shape) shape->marker[i] = NULL; } shape->curve = NULL; + shape->curve_before_lpe = NULL; } void SPShape::sp_shape_finalize(GObject *object) @@ -195,6 +196,9 @@ void SPShape::sp_shape_release(SPObject *object) if (shape->curve) { shape->curve = shape->curve->unref(); } + if (shape->curve_before_lpe) { + shape->curve_before_lpe = shape->curve_before_lpe->unref(); + } if (((SPObjectClass *) SPShapeClass::parent_class)->release) { ((SPObjectClass *) SPShapeClass::parent_class)->release (object); @@ -1114,6 +1118,20 @@ void SPShape::setCurve(SPCurve *curve, unsigned int owner) this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +/** + * Sets curve_before_lpe to refer to the curve. + */ +void +SPShape::setCurveBeforeLPE (SPCurve *curve) +{ + if (this->curve_before_lpe) { + this->curve_before_lpe = this->curve_before_lpe->unref(); + } + if (curve) { + this->curve_before_lpe = curve->ref(); + } +} + /** * Return duplicate of curve (if any exists) or NULL if there is no curve */ @@ -1125,6 +1143,24 @@ SPCurve * SPShape::getCurve() return NULL; } +/** + * Return duplicate of curve *before* LPE (if any exists) or NULL if there is no curve + */ +SPCurve * +SPShape::getCurveBeforeLPE() +{ + if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(this))) { + if (this->curve_before_lpe) { + return this->curve_before_lpe->copy(); + } + } else { + if (this->curve) { + return this->curve->copy(); + } + } + return NULL; +} + /** * Same as sp_shape_set_curve but without updating the display */ -- 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/sp-shape.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 72559c63f..358e2a595 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -725,12 +725,14 @@ sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* s } SPItem* marker_item = sp_item_first_item_child( marker ); - tr = marker_item->transform * marker->c2p * tr; + if (marker_item) { + tr = marker_item->transform * marker->c2p * tr; - Geom::Affine old_tr = marker_item->transform; - marker_item->transform = tr; - marker_item->invoke_print (ctx); - marker_item->transform = old_tr; + Geom::Affine old_tr = marker_item->transform; + marker_item->transform = tr; + marker_item->invoke_print (ctx); + marker_item->transform = old_tr; + } } /** * Prepares shape for printing. Handles printing of comments for printing -- cgit v1.2.3 From bdf703831ff93438d49324ab842052ccaf390a5d Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 26 Jun 2011 22:00:36 +0200 Subject: =?UTF-8?q?-=20Add=20a=20third=20group=20of=20snap=20sources/targe?= =?UTF-8?q?ts,=20called=20=C2=A8others=C2=A8=20(before=20we=20had=20only?= =?UTF-8?q?=20=C2=A8bounding=20box=C2=A8=20and=20nodes=20(see=20bug=20#788?= =?UTF-8?q?178)=20-=20Fix=20the=20display=20of=20the=20snap=20source=20-?= =?UTF-8?q?=20Fix=20snapping=20of=20guides=20to=20other=20guides=20&=20gri?= =?UTF-8?q?ds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r10372) --- src/sp-shape.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index ea79b6cee..24b6b8025 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1190,7 +1190,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide())) { + if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { return; } -- cgit v1.2.3 From 2be2cf32db0668dc64512a98f6c2394152bd10cc Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 16 Jul 2011 00:42:39 -0700 Subject: Cleanup of oudated/redundant SP_ITEM() macro use. (bzr r10461) --- src/sp-shape.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 24b6b8025..bbfa98598 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -225,7 +225,6 @@ Inkscape::XML::Node * SPShape::sp_shape_write(SPObject *object, Inkscape::XML::D */ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) { - SPItem *item = (SPItem *) object; SPShape *shape = (SPShape *) object; if (((SPObjectClass *) (SPShapeClass::parent_class))->update) { @@ -257,7 +256,7 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) /* This is suboptimal, because changing parent style schedules recalculation */ /* But on the other hand - how can we know that parent does not tie style and transform */ Geom::OptRect paintbox = SP_ITEM(object)->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); - for (SPItemView *v = SP_ITEM (shape)->display; v != NULL; v = v->next) { + for (SPItemView *v = shape->display; v != NULL; v = v->next) { NRArenaShape * const s = NR_ARENA_SHAPE(v->arenaitem); if (flags & SP_OBJECT_MODIFIED_FLAG) { nr_arena_shape_set_path(s, shape->curve, (flags & SP_OBJECT_USER_MODIFIED_FLAG_B)); @@ -270,7 +269,7 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) if (shape->hasMarkers ()) { /* Dimension marker views */ - for (SPItemView *v = item->display; v != NULL; v = v->next) { + for (SPItemView *v = shape->display; v != NULL; v = v->next) { if (!v->arenaitem->key) { NR_ARENA_ITEM_SET_KEY (v->arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY)); } @@ -284,7 +283,7 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) } /* Update marker views */ - for (SPItemView *v = item->display; v != NULL; v = v->next) { + for (SPItemView *v = shape->display; v != NULL; v = v->next) { sp_shape_update_marker_view (shape, v->arenaitem); } } @@ -495,7 +494,7 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - for (SPItemView *v = SP_ITEM (shape)->display; v != NULL; v = v->next) { + for (SPItemView *v = shape->display; v != NULL; v = v->next) { nr_arena_shape_set_style (NR_ARENA_SHAPE (v->arenaitem), object->style); } } -- 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/sp-shape.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index bbfa98598..beec860be 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -763,16 +763,16 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) dbox.x1 = item->document->getWidth(); dbox.y1 = item->document->getHeight(); item->getBboxDesktop (&bbox); - Geom::Affine const i2d(item->i2d_affine()); + Geom::Affine const i2dt(item->i2dt_affine()); SPStyle* style = item->style; if (!style->fill.isNone()) { - sp_print_fill (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox); + sp_print_fill (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox); } if (!style->stroke.isNone()) { - sp_print_stroke (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox); + sp_print_stroke (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox); } /** \todo make code prettier */ @@ -1197,10 +1197,10 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectori2d_affine ()); + Geom::Affine const i2dt (item->i2dt_affine ()); if (snapprefs->getSnapObjectMidpoints()) { - Geom::OptRect bbox = item->getBounds(item->i2d_affine()); + Geom::OptRect bbox = item->getBounds(i2dt); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } @@ -1209,7 +1209,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode()) { // Add the first point of the path - p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2d, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); + p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve @@ -1219,7 +1219,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapLineMidpoints()) { // only do this when we're snapping nodes (enforces strict snapping) if (Geom::LineSegment const* line_segment = dynamic_cast(&(*curve_it1))) { - p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2d, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); + p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2dt, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); } } @@ -1227,7 +1227,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && !path_it->closed()) { // Add the last point of the path, but only for open paths // (for closed paths the first and last point will coincide) - p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2d, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); + p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } } else { /* Test whether to add the node between curve_it1 and curve_it2. @@ -1256,7 +1256,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorfinalPoint() * i2d, sst, stt)); + p.push_back(Inkscape::SnapCandidatePoint(curve_it1->finalPoint() * i2dt, sst, stt)); } } @@ -1273,7 +1273,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vector 0) { // There might be multiple intersections... for (Geom::Crossings::const_iterator i = cs.begin(); i != cs.end(); i++) { Geom::Point p_ix = (*path_it).pointAt((*i).ta); - p.push_back(Inkscape::SnapCandidatePoint(p_ix * i2d, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION)); + p.push_back(Inkscape::SnapCandidatePoint(p_ix * i2dt, Inkscape::SNAPSOURCE_PATH_INTERSECTION, Inkscape::SNAPTARGET_PATH_INTERSECTION)); } } } catch (Geom::RangeError &e) { -- cgit v1.2.3 From 4dd33aa4d5c57706c7f64f63391174954160a308 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 6 Aug 2011 14:18:32 +0200 Subject: Rewrite NRArenaItem hierarchy into C++ (bzr r10347.1.21) --- src/sp-shape.cpp | 63 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index beec860be..1512898f5 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -30,7 +30,7 @@ #include #include "macros.h" -#include "display/nr-arena-shape.h" +#include "display/drawing-shape.h" #include "display/curve.h" #include "print.h" #include "document.h" @@ -182,7 +182,7 @@ void SPShape::sp_shape_release(SPObject *object) for (i = 0; i < SP_MARKER_LOC_QTY; i++) { if (shape->marker[i]) { for (v = item->display; v != NULL; v = v->next) { - sp_marker_hide ((SPMarker *) shape->marker[i], NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i); + sp_marker_hide ((SPMarker *) shape->marker[i], v->arenaitem->key() + i); } shape->release_connect[i].disconnect(); shape->modified_connect[i].disconnect(); @@ -247,7 +247,8 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) double const aw = 1.0 / ictx->i2vp.descrim(); style->stroke_width.computed = style->stroke_width.value * aw; for (SPItemView *v = ((SPItem *) (shape))->display; v != NULL; v = v->next) { - nr_arena_shape_set_style ((NRArenaShape *) v->arenaitem, style); + Inkscape::DrawingShape *sh = dynamic_cast(v->arenaitem); + sh->setStyle(style); } } } @@ -257,12 +258,12 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) /* But on the other hand - how can we know that parent does not tie style and transform */ Geom::OptRect paintbox = SP_ITEM(object)->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); for (SPItemView *v = shape->display; v != NULL; v = v->next) { - NRArenaShape * const s = NR_ARENA_SHAPE(v->arenaitem); + Inkscape::DrawingShape *sh = dynamic_cast(v->arenaitem); if (flags & SP_OBJECT_MODIFIED_FLAG) { - nr_arena_shape_set_path(s, shape->curve, (flags & SP_OBJECT_USER_MODIFIED_FLAG_B)); + sh->setPath(shape->curve); } if (paintbox) { - s->setPaintBox(*paintbox); + sh->setPaintBox(*paintbox); } } } @@ -270,13 +271,13 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) if (shape->hasMarkers ()) { /* Dimension marker views */ for (SPItemView *v = shape->display; v != NULL; v = v->next) { - if (!v->arenaitem->key) { - NR_ARENA_ITEM_SET_KEY (v->arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY)); + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new (SP_MARKER_LOC_QTY)); } for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { if (shape->marker[i]) { sp_marker_show_dimension ((SPMarker *) shape->marker[i], - NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i, + v->arenaitem->key() + i, shape->numberOfMarkers (i)); } } @@ -375,7 +376,7 @@ Geom::Affine sp_shape_marker_get_transform_at_end(Geom::Curve const & c) * * @todo figure out what to do when both 'marker' and for instance 'marker-end' are set. */ -void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) +void SPShape::sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) { SPStyle *style = ((SPObject *) shape)->style; @@ -395,7 +396,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START if ( shape->marker[i] ) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -413,7 +414,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID if ( shape->marker[i] ) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -433,7 +434,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID if (shape->marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -450,7 +451,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID if (shape->marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -474,7 +475,7 @@ void SPShape::sp_shape_update_marker_view(SPShape *shape, NRArenaItem *ai) for (int i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END if (shape->marker[i]) { sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, - NR_ARENA_ITEM_GET_KEY(ai) + i, counter[i], m, + ai->key() + i, counter[i], m, style->stroke_width.computed); counter[i]++; } @@ -495,7 +496,8 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = shape->display; v != NULL; v = v->next) { - nr_arena_shape_set_style (NR_ARENA_SHAPE (v->arenaitem), object->style); + Inkscape::DrawingShape *sh = dynamic_cast(v->arenaitem); + sh->setStyle(object->style); } } } @@ -850,15 +852,14 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) /** * Sets style, path, and paintbox. Updates marker views, including dimensions. */ -NRArenaItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) +Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) { SPObject *object = item; SPShape *shape = SP_SHAPE(item); - NRArenaItem *arenaitem = NRArenaShape::create(arena); - NRArenaShape * const s = NR_ARENA_SHAPE(arenaitem); - nr_arena_shape_set_style(s, object->style); - nr_arena_shape_set_path(s, shape->curve, false); + Inkscape::DrawingShape *s = new Inkscape::DrawingShape(arena); + s->setStyle(object->style); + s->setPath(shape->curve); Geom::OptRect paintbox = item->getBounds(Geom::identity()); if (paintbox) { s->setPaintBox(*paintbox); @@ -876,23 +877,23 @@ NRArenaItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int if (shape->hasMarkers ()) { /* provide key and dimension the marker views */ - if (!arenaitem->key) { - NR_ARENA_ITEM_SET_KEY (arenaitem, SPItem::display_key_new (SP_MARKER_LOC_QTY)); + if (!s->key()) { + s->setKey(SPItem::display_key_new (SP_MARKER_LOC_QTY)); } for (int i = 0; i < SP_MARKER_LOC_QTY; i++) { if (shape->marker[i]) { sp_marker_show_dimension ((SPMarker *) shape->marker[i], - NR_ARENA_ITEM_GET_KEY (arenaitem) + i, + s->key() + i, shape->numberOfMarkers (i)); } } /* Update marker views */ - sp_shape_update_marker_view (shape, arenaitem); + sp_shape_update_marker_view (shape, s); } - return arenaitem; + return s; } /** @@ -911,7 +912,7 @@ void SPShape::sp_shape_hide(SPItem *item, unsigned int key) for (v = item->display; v != NULL; v = v->next) { if (key == v->key) { sp_marker_hide ((SPMarker *) shape->marker[i], - NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i); + v->arenaitem->key() + i); } } } @@ -1013,9 +1014,9 @@ sp_shape_marker_release (SPObject *marker, SPShape *shape) SPItemView *v; /* Hide marker */ for (v = item->display; v != NULL; v = v->next) { - sp_marker_hide ((SPMarker *) (shape->marker[i]), NR_ARENA_ITEM_GET_KEY (v->arenaitem) + i); + sp_marker_hide ((SPMarker *) (shape->marker[i]), v->arenaitem->key() + i); /* fixme: Do we need explicit remove here? (Lauris) */ - /* nr_arena_item_set_mask (v->arenaitem, NULL); */ + /* v->arenaitem->setMask(NULL); */ } /* Detach marker */ shape->release_connect[i].disconnect(); @@ -1064,9 +1065,9 @@ sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value) /* Hide marker */ for (v = item->display; v != NULL; v = v->next) { sp_marker_hide ((SPMarker *) (shape->marker[key]), - NR_ARENA_ITEM_GET_KEY (v->arenaitem) + key); + v->arenaitem->key() + key); /* fixme: Do we need explicit remove here? (Lauris) */ - /* nr_arena_item_set_mask (v->arenaitem, NULL); */ + /* v->arenaitem->setMask(NULL); */ } /* Unref marker */ -- cgit v1.2.3 From 75976ea07dba9b97186667524d0a76603de416af Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 7 Aug 2011 12:53:12 +0200 Subject: Rewrite NRArena -> Inkscape::Drawing. Call render and update methods on the Drawing rather than on the root DrawingItem. (bzr r10347.1.25) --- src/sp-shape.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 1512898f5..eff0665af 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -852,12 +852,12 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) /** * Sets style, path, and paintbox. Updates marker views, including dimensions. */ -Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/) +Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) { SPObject *object = item; SPShape *shape = SP_SHAPE(item); - Inkscape::DrawingShape *s = new Inkscape::DrawingShape(arena); + Inkscape::DrawingShape *s = new Inkscape::DrawingShape(drawing); s->setStyle(object->style); s->setPath(shape->curve); Geom::OptRect paintbox = item->getBounds(Geom::identity()); @@ -1015,8 +1015,6 @@ sp_shape_marker_release (SPObject *marker, SPShape *shape) /* Hide marker */ for (v = item->display; v != NULL; v = v->next) { sp_marker_hide ((SPMarker *) (shape->marker[i]), v->arenaitem->key() + i); - /* fixme: Do we need explicit remove here? (Lauris) */ - /* v->arenaitem->setMask(NULL); */ } /* Detach marker */ shape->release_connect[i].disconnect(); @@ -1066,8 +1064,6 @@ sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value) for (v = item->display; v != NULL; v = v->next) { sp_marker_hide ((SPMarker *) (shape->marker[key]), v->arenaitem->key() + key); - /* fixme: Do we need explicit remove here? (Lauris) */ - /* v->arenaitem->setMask(NULL); */ } /* Unref marker */ -- cgit v1.2.3 From babb7a67749cb691674bdd9758f0568d4b094b56 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Aug 2011 20:27:53 +0200 Subject: Refactoring of the snapping preferences; mainly about storing all toggles in a single array, instead of each having its own member variable (bzr r10569) --- src/sp-shape.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index beec860be..7f24dd089 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1188,18 +1188,13 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapModeNode() || snapprefs->getSnapModeGuide() || snapprefs->getSnapModeOthers())) { - return; - } - Geom::PathVector const &pathv = shape->curve->get_pathvector(); if (pathv.empty()) return; Geom::Affine const i2dt (item->i2dt_affine ()); - if (snapprefs->getSnapObjectMidpoints()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { Geom::OptRect bbox = item->getBounds(i2dt); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); @@ -1207,7 +1202,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP)) { // Add the first point of the path p.push_back(Inkscape::SnapCandidatePoint(path_it->initialPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); } @@ -1217,14 +1212,14 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorend_default()) { // For each path: consider midpoints of line segments for snapping - if (snapprefs->getSnapLineMidpoints()) { // only do this when we're snapping nodes (enforces strict snapping) + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT)) { if (Geom::LineSegment const* line_segment = dynamic_cast(&(*curve_it1))) { p.push_back(Inkscape::SnapCandidatePoint(Geom::middle_point(*line_segment) * i2dt, Inkscape::SNAPSOURCE_LINE_MIDPOINT, Inkscape::SNAPTARGET_LINE_MIDPOINT)); } } if (curve_it2 == path_it->end_default()) { // Test will only pass for the last iteration of the while loop - if (snapprefs->getSnapToItemNode() && !path_it->closed()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && !path_it->closed()) { // Add the last point of the path, but only for open paths // (for closed paths the first and last point will coincide) p.push_back(Inkscape::SnapCandidatePoint((*curve_it1).finalPoint() * i2dt, Inkscape::SNAPSOURCE_NODE_CUSP, Inkscape::SNAPTARGET_NODE_CUSP)); @@ -1235,8 +1230,8 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapToItemNode() && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE); - bool c2 = snapprefs->getSnapSmoothNodes() && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM); + bool c1 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP) && (nodetype == Geom::NODE_CUSP || nodetype == Geom::NODE_NONE); + bool c2 = snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH) && (nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM); if (c1 || c2) { Inkscape::SnapSourceType sst; @@ -1266,7 +1261,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectorgetSnapIntersectionCS()) { + if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION)) { Geom::Crossings cs; try { cs = self_crossings(*path_it); -- cgit v1.2.3 From abe953dc63948d78532c0541a56e664dc386810a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 25 Aug 2011 19:39:31 +0200 Subject: Remove duplicate bbox data from DrawingShape (bzr r10347.1.38) --- src/sp-shape.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index eff0665af..0d1ac029e 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -256,15 +256,11 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags) if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) { /* This is suboptimal, because changing parent style schedules recalculation */ /* But on the other hand - how can we know that parent does not tie style and transform */ - Geom::OptRect paintbox = SP_ITEM(object)->getBounds(Geom::identity(), SPItem::GEOMETRIC_BBOX); for (SPItemView *v = shape->display; v != NULL; v = v->next) { Inkscape::DrawingShape *sh = dynamic_cast(v->arenaitem); if (flags & SP_OBJECT_MODIFIED_FLAG) { sh->setPath(shape->curve); } - if (paintbox) { - sh->setPaintBox(*paintbox); - } } } @@ -860,10 +856,6 @@ Inkscape::DrawingItem * SPShape::sp_shape_show(SPItem *item, Inkscape::Drawing & Inkscape::DrawingShape *s = new Inkscape::DrawingShape(drawing); s->setStyle(object->style); s->setPath(shape->curve); - Geom::OptRect paintbox = item->getBounds(Geom::identity()); - if (paintbox) { - s->setPaintBox(*paintbox); - } /* This stanza checks that an object's marker style agrees with * the marker objects it has allocated. sp_shape_set_marker ensures -- 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-shape.cpp | 337 +++++++++++++++++++++++-------------------------------- 1 file changed, 140 insertions(+), 197 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 4fd1deb69..15fa76d65 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -502,212 +502,158 @@ void SPShape::sp_shape_modified(SPObject *object, unsigned int flags) * Calculates the bounding box for item, storing it into bbox. * This also includes the bounding boxes of any markers included in the shape. */ -void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const flags) +Geom::OptRect SPShape::sp_shape_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType bboxtype) { SPShape const *shape = SP_SHAPE (item); - SPItem::BBoxType bboxtype = (SPItem::BBoxType) flags; - - if (shape->curve) { - Geom::OptRect geombbox = bounds_exact_transformed(shape->curve->get_pathvector(), transform); - if (geombbox) { - NRRect cbbox; - cbbox.x0 = (*geombbox)[0][0]; - cbbox.y0 = (*geombbox)[1][0]; - cbbox.x1 = (*geombbox)[0][1]; - cbbox.y1 = (*geombbox)[1][1]; - - switch (bboxtype) { - case SPItem::GEOMETRIC_BBOX: { - // do nothing - break; - } - case SPItem::RENDERING_BBOX: { - // convert the stroke to a path and calculate that path's geometric bbox - SPStyle* style = item->style; - if (!style->stroke.isNone()) { - Geom::PathVector *pathv = item_outline(item); - if (pathv) { - Geom::OptRect geomstrokebbox = bounds_exact_transformed(*pathv, transform); - if (geomstrokebbox) { - NRRect strokebbox; - strokebbox.x0 = (*geomstrokebbox)[0][0]; - strokebbox.y0 = (*geomstrokebbox)[1][0]; - strokebbox.x1 = (*geomstrokebbox)[0][1]; - strokebbox.y1 = (*geomstrokebbox)[1][1]; - nr_rect_d_union (&cbbox, &cbbox, &strokebbox); - } - delete pathv; + Geom::OptRect bbox; + + if (!shape->curve) return bbox; + bbox = bounds_exact_transformed(shape->curve->get_pathvector(), transform); + if (!bbox) return bbox; + + if (bboxtype == SPItem::VISUAL_BBOX) { + // convert the stroke to a path and calculate that path's geometric bbox + SPStyle* style = item->style; + if (!style->stroke.isNone()) { + Geom::PathVector *pathv = item_outline(item); + if (pathv) { + bbox |= bounds_exact_transformed(*pathv, transform); + delete pathv; + } + } + // Union with bboxes of the markers, if any + if ( shape->hasMarkers() && !shape->curve->get_pathvector().empty() ) { + /** \todo make code prettier! */ + Geom::PathVector const & pathv = shape->curve->get_pathvector(); + // START marker + for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START + if ( shape->marker[i] ) { + SPMarker* marker = SP_MARKER (shape->marker[i]); + SPItem* marker_item = sp_item_first_item_child( marker ); + + if (marker_item) { + Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front())); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; } + + // total marker transform + tr = marker_item->transform * marker->c2p * tr * transform; + + // get bbox of the marker with that transform + bbox |= marker_item->visualBounds(tr); } - break; } - default: - case SPItem::APPROXIMATE_BBOX: { - 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(cbbox.x1-cbbox.x0) > -0.00001 && fabs(cbbox.y1-cbbox.y0) > -0.00001 ) { - cbbox.x0-=0.5*width; - cbbox.x1+=0.5*width; - cbbox.y0-=0.5*width; - cbbox.y1+=0.5*width; - } + } + // MID marker + for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID + SPMarker* marker = SP_MARKER (shape->marker[i]); + if ( !shape->marker[i] ) continue; + SPItem* marker_item = sp_item_first_item_child( marker ); + if ( !marker_item ) continue; + + for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { + // START position + if ( path_it != pathv.begin() + && ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there + { + Geom::Affine tr(sp_shape_marker_get_transform_at_start(path_it->front())); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; + } + tr = marker_item->transform * marker->c2p * tr * transform; + bbox |= marker_item->visualBounds(tr); } + // MID position + if ( path_it->size_default() > 1) { + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + while (curve_it2 != path_it->end_default()) + { + /* Put marker between curve_it1 and curve_it2. + * Loop to end_default (so including closing segment), because when a path is closed, + * there should be a midpoint marker between last segment and closing straight line segment */ - // Union with bboxes of the markers, if any - if ( shape->hasMarkers() && !shape->curve->get_pathvector().empty() ) { - /** \todo make code prettier! */ - Geom::PathVector const & pathv = shape->curve->get_pathvector(); - // START marker - for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START - if ( shape->marker[i] ) { - SPMarker* marker = SP_MARKER (shape->marker[i]); - SPItem* marker_item = sp_item_first_item_child( marker ); - - if (marker_item) { - Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front())); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - - // total marker transform - tr = marker_item->transform * marker->c2p * tr * transform; - - // get bbox of the marker with that transform - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - // union it with the shape bbox - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } - } - } - // MID marker - for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID SPMarker* marker = SP_MARKER (shape->marker[i]); - if ( !shape->marker[i] ) continue; SPItem* marker_item = sp_item_first_item_child( marker ); - if ( !marker_item ) continue; - - for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) { - // START position - if ( path_it != pathv.begin() - && ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there - { - Geom::Affine tr(sp_shape_marker_get_transform_at_start(path_it->front())); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - tr = marker_item->transform * marker->c2p * tr * transform; - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } - // MID position - if ( path_it->size_default() > 1) { - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - while (curve_it2 != path_it->end_default()) - { - /* Put marker between curve_it1 and curve_it2. - * Loop to end_default (so including closing segment), because when a path is closed, - * there should be a midpoint marker between last segment and closing straight line segment */ - - SPMarker* marker = SP_MARKER (shape->marker[i]); - SPItem* marker_item = sp_item_first_item_child( marker ); - - if (marker_item) { - Geom::Affine tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - tr = marker_item->transform * marker->c2p * tr * transform; - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } - - ++curve_it1; - ++curve_it2; - } + + if (marker_item) { + Geom::Affine tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); } - // END position - if ( path_it != (pathv.end()-1) && !path_it->empty()) { - Geom::Curve const &lastcurve = path_it->back_default(); - Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - tr = marker_item->transform * marker->c2p * tr * transform; - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; } + tr = marker_item->transform * marker->c2p * tr * transform; + bbox |= marker_item->visualBounds(tr); } + + ++curve_it1; + ++curve_it2; } - // END marker - for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END - if ( shape->marker[i] ) { - SPMarker* marker = SP_MARKER (shape->marker[i]); - SPItem* marker_item = sp_item_first_item_child( marker ); - - if (marker_item) { - /* Get reference to last curve in the path. - * For moveto-only path, this returns the "closing line segment". */ - Geom::Path const &path_last = pathv.back(); - unsigned int index = path_last.size_default(); - if (index > 0) { - index--; - } - Geom::Curve const &lastcurve = path_last[index]; - - Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); - if (!marker->orient_auto) { - Geom::Point transl = tr.translation(); - tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = Geom::Scale(style->stroke_width.computed) * tr; - } - - // total marker transform - tr = marker_item->transform * marker->c2p * tr * transform; - - // get bbox of the marker with that transform - NRRect marker_bbox; - marker_item->invoke_bbox ( &marker_bbox, tr, true); - // union it with the shape bbox - nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); - } - } + } + // END position + if ( path_it != (pathv.end()-1) && !path_it->empty()) { + Geom::Curve const &lastcurve = path_it->back_default(); + Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; } + tr = marker_item->transform * marker->c2p * tr * transform; + bbox |= marker_item->visualBounds(); } - break; - } // end case approximate bbox type - } // end switch bboxtype + } + } + // END marker + for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END + if ( shape->marker[i] ) { + SPMarker* marker = SP_MARKER (shape->marker[i]); + SPItem* marker_item = sp_item_first_item_child( marker ); + + if (marker_item) { + /* Get reference to last curve in the path. + * For moveto-only path, this returns the "closing line segment". */ + Geom::Path const &path_last = pathv.back(); + unsigned int index = path_last.size_default(); + if (index > 0) { + index--; + } + Geom::Curve const &lastcurve = path_last[index]; + + Geom::Affine tr = sp_shape_marker_get_transform_at_end(lastcurve); + if (!marker->orient_auto) { + Geom::Point transl = tr.translation(); + tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl); + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + tr = Geom::Scale(style->stroke_width.computed) * tr; + } - // copy our bbox to the variable we're given - *bbox = cbbox; + // total marker transform + tr = marker_item->transform * marker->c2p * tr * transform; + + // get bbox of the marker with that transform + bbox |= marker_item->visualBounds(tr); + } + } + } } } + return bbox; } static void @@ -736,7 +682,7 @@ sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* s void sp_shape_print (SPItem *item, SPPrintContext *ctx) { - NRRect pbox, dbox, bbox; + Geom::OptRect pbox, dbox, bbox; SPShape *shape = SP_SHAPE(item); @@ -755,22 +701,19 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) } /* fixme: Think (Lauris) */ - item->invoke_bbox( &pbox, Geom::identity(), TRUE); - dbox.x0 = 0.0; - dbox.y0 = 0.0; - dbox.x1 = item->document->getWidth(); - dbox.y1 = item->document->getHeight(); - item->getBboxDesktop (&bbox); + pbox = item->geometricBounds(); + bbox = item->desktopVisualBounds(); + dbox = Geom::Rect::from_xywh(Geom::Point(0,0), item->document->getDimensions()); Geom::Affine const i2dt(item->i2dt_affine()); SPStyle* style = item->style; if (!style->fill.isNone()) { - sp_print_fill (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox); + sp_print_fill (ctx, pathv, &i2dt, style, pbox, dbox, bbox); } if (!style->stroke.isNone()) { - sp_print_stroke (ctx, pathv, &i2dt, style, &pbox, &dbox, &bbox); + sp_print_stroke (ctx, pathv, &i2dt, style, pbox, dbox, bbox); } /** \todo make code prettier */ @@ -1184,7 +1127,7 @@ void SPShape::sp_shape_snappoints(SPItem const *item, std::vectori2dt_affine ()); if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)) { - Geom::OptRect bbox = item->getBounds(i2dt); + Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox) { p.push_back(Inkscape::SnapCandidatePoint(bbox->midpoint(), Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); } -- cgit v1.2.3 From 84194ec2d0b9830437a5470320422265d5dd8c35 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 12:20:13 +0200 Subject: Remove NRRect use from the extension system (bzr r10582.1.2) --- src/sp-shape.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/sp-shape.cpp') diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 15fa76d65..8bfa99392 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -657,7 +657,8 @@ Geom::OptRect SPShape::sp_shape_bbox(SPItem const *item, Geom::Affine const &tra } static void -sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* style, SPPrintContext *ctx) { +sp_shape_print_invoke_marker_printing(SPObject *obj, Geom::Affine tr, SPStyle const *style, SPPrintContext *ctx) +{ SPMarker *marker = SP_MARKER(obj); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { tr = Geom::Scale(style->stroke_width.computed) * tr; @@ -709,11 +710,11 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) SPStyle* style = item->style; if (!style->fill.isNone()) { - sp_print_fill (ctx, pathv, &i2dt, style, pbox, dbox, bbox); + sp_print_fill (ctx, pathv, i2dt, style, pbox, dbox, bbox); } if (!style->stroke.isNone()) { - sp_print_stroke (ctx, pathv, &i2dt, style, pbox, dbox, bbox); + sp_print_stroke (ctx, pathv, i2dt, style, pbox, dbox, bbox); } /** \todo make code prettier */ -- cgit v1.2.3