From a506492cec55236e824e41656e546cc4abfef53a Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 29 Dec 2017 12:58:39 +0100 Subject: Add fix sugested in mailing list to allow diferent LPE on clones --- src/live_effects/lpe-bendpath.cpp | 21 ++++++++++++------ src/live_effects/lpe-clone-original.cpp | 37 ++++++++++++++++++++++++------- src/live_effects/lpe-clone-original.h | 1 + src/live_effects/lpe-patternalongpath.cpp | 21 ++++++++++++------ 4 files changed, 58 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index dcbf5efd0..093d7ac06 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -84,14 +84,21 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) // get the item bounding box original_bbox(lpeitem); original_height = boundingbox_Y.max() - boundingbox_Y.min(); - if (knot_entity) { - if (hide_knot) { - helper_path.clear(); - knot_entity->knot->hide(); - } else { - knot_entity->knot->show(); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item->getId() == sp_lpe_item->getId() && static_cast(sp_lpe_item->getCurrentLPE()) == this) { + if (knot_entity && knot_entity->knot) { + if (hide_knot) { + helper_path.clear(); + knot_entity->knot->hide(); + } else { + knot_entity->knot->show(); + } + knot_entity->update_knot(); + } } - knot_entity->update_knot(); } } diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index 15968dd56..d376df788 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -147,12 +147,12 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, const char * c_pv *= i2anc_affine(dest, sp_lpe_item); c->set_pathvector(c_pv); if (!path_origin) { - shape_dest->setCurveInsync(c, TRUE); + shape_dest->setCurveBeforeLPE(c); gchar *str = sp_svg_write_path(c_pv); dest->getRepr()->setAttribute(attribute, str); g_free(str); } else { - shape_dest->setCurve(c, TRUE); + shape_dest->setCurveBeforeLPE(c); } c->unref(); } else { @@ -305,15 +305,36 @@ LPECloneOriginal::transform_multiply(Geom::Affine const& postmul, bool set) } } +void LPECloneOriginal::doOnRemove(SPLPEItem const* lpeitem) +{ + if (linkeditem.linksToItem() && lpeitem->path_effect_list->size() == 1 && !keep_paths) { + SPDesktop * dt = SP_ACTIVE_DESKTOP; + SPObject * obj = dynamic_cast(sp_lpe_item); + SPItem * orig = SP_ITEM(linkeditem.getObject()); + const gchar * transform = lpeitem->getRepr()->attribute("transform"); + dt->selection->clear(); + dt->selection->add(orig, true); + dt->selection->clone(); + dt->selection->singleItem()->setAttribute("transform" , transform); + //TODO: get a way to realy delete current LPEItem + obj->getRepr()->setAttribute("original-d", NULL); + obj->getRepr()->setAttribute("d", "0,0"); + obj->getRepr()->setAttribute("inkscape:label", "SAFE TO REMOVE"); + obj->getRepr()->setAttribute("inkscape:connector-curvature", NULL); + obj->getRepr()->setAttribute("transform", NULL); + obj->getRepr()->setAttribute("style", "opacity:0"); + } +} + void LPECloneOriginal::doEffect (SPCurve * curve) { - if (linkeditem.linksToItem()) { - SPShape * shape = getCurrentShape(); - if(shape){ - curve->set_pathvector(shape->getCurve()->get_pathvector()); - } - } +// if (linkeditem.linksToItem()) { +// SPShape * shape = getCurrentShape(); +// if(shape){ +// curve->set_pathvector(shape->getCurveBeforeLPE()->get_pathvector()); +// } +// } } } // namespace LivePathEffect diff --git a/src/live_effects/lpe-clone-original.h b/src/live_effects/lpe-clone-original.h index 8327b6767..a5a84c31a 100644 --- a/src/live_effects/lpe-clone-original.h +++ b/src/live_effects/lpe-clone-original.h @@ -33,6 +33,7 @@ public: virtual ~LPECloneOriginal(); virtual void doEffect (SPCurve * curve); virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual void doOnRemove(SPLPEItem const* lpeitem); virtual void transform_multiply(Geom::Affine const& postmul, bool set); void cloneAttrbutes(SPObject *origin, SPObject *dest, const char * attributes, const char * style_attributes); void modified(SPObject */*obj*/, guint /*flags*/); diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 5be88a2b7..33c07b2cb 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -116,14 +116,21 @@ LPEPatternAlongPath::doBeforeEffect (SPLPEItem const* lpeitem) if (bbox) { original_height = (*bbox)[Geom::Y].max() - (*bbox)[Geom::Y].min(); } - if (knot_entity) { - if (hide_knot) { - helper_path.clear(); - knot_entity->knot->hide(); - } else { - knot_entity->knot->show(); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item->getId() == sp_lpe_item->getId() && static_cast(sp_lpe_item->getCurrentLPE()) == this) { + if (knot_entity && knot_entity->knot) { + if (hide_knot) { + helper_path.clear(); + knot_entity->knot->hide(); + } else { + knot_entity->knot->show(); + } + knot_entity->update_knot(); + } } - knot_entity->update_knot(); } } -- cgit v1.2.3