=== modified file 'src/box3d-side.cpp' --- src/box3d-side.cpp 2014-03-27 01:33:44 +0000 +++ src/box3d-side.cpp 2014-06-04 01:19:40 +0000 @@ -213,6 +213,8 @@ bool success = this->performPathEffect(c_lpe); if (success) { + sp_lpe_item_apply_to_mask(this); + sp_lpe_item_apply_to_clippath(this); this->setCurveInsync(c_lpe, TRUE); } === modified file 'src/selection-chemistry.cpp' --- src/selection-chemistry.cpp 2014-04-24 12:53:30 +0000 +++ src/selection-chemistry.cpp 2014-06-04 09:50:46 +0000 @@ -3950,6 +3950,10 @@ for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { // Collect all clipped paths and masks within a single group Inkscape::XML::Node *copy = SP_OBJECT(child)->getRepr()->duplicate(xml_doc); + if(copy->attribute("inkscape:original-d")) + { + copy->setAttribute("d", copy->attribute("inkscape:original-d")); + } items_to_move = g_slist_prepend(items_to_move, copy); } === modified file 'src/sp-ellipse.cpp' --- src/sp-ellipse.cpp 2014-04-30 18:48:20 +0000 +++ src/sp-ellipse.cpp 2014-06-04 01:19:40 +0000 @@ -467,6 +467,8 @@ bool success = this->performPathEffect(c_lpe); if (success) { + sp_lpe_item_apply_to_mask(this); + sp_lpe_item_apply_to_clippath(this); this->setCurveInsync(c_lpe, TRUE); } === modified file 'src/sp-item-group.cpp' --- src/sp-item-group.cpp 2014-03-27 01:33:44 +0000 +++ src/sp-item-group.cpp 2014-06-04 01:19:40 +0000 @@ -778,17 +778,31 @@ } } + +void +sp_gslist_update_by_clip_or_mask(GSList *item_list,SPItem * item) +{ + if(item->mask_ref->getObject()) { + SPObject * clipormask = item->mask_ref->getObject()->firstChild(); + item_list = g_slist_append(item_list,clipormask); + } + if(item->clip_ref->getObject()) { + SPObject * clipormask = item->clip_ref->getObject()->firstChild(); + item_list = g_slist_append(item_list,clipormask); + } +} + static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - GSList const *item_list = sp_item_group_item_list(SP_GROUP(group)); - - for ( GSList const *iter = item_list; iter; iter = iter->next ) { + GSList *item_list = sp_item_group_item_list(group); + sp_gslist_update_by_clip_or_mask(item_list,group); + for ( GSList *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast(iter->data); - if (SP_IS_GROUP(subitem)) { sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write); } else if (SP_IS_SHAPE(subitem)) { + sp_gslist_update_by_clip_or_mask(item_list,SP_ITEM(subitem)); SPCurve * c = NULL; if (SP_IS_PATH(subitem)) { @@ -799,9 +813,17 @@ // only run LPEs when the shape has a curve defined if (c) { - c->transform(i2anc_affine(subitem, topgroup)); + if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { + c->transform(i2anc_affine(group, topgroup)); + } else { + c->transform(i2anc_affine(subitem, topgroup)); + } SP_LPE_ITEM(topgroup)->performPathEffect(c); - c->transform(i2anc_affine(subitem, topgroup).inverse()); + if(SP_IS_MASK(subitem->parent) || SP_IS_CLIPPATH(subitem->parent)) { + c->transform(i2anc_affine(group, topgroup).inverse()); + } else { + c->transform(i2anc_affine(subitem, topgroup).inverse()); + } SP_SHAPE(subitem)->setCurve(c, TRUE); if (write) { @@ -809,7 +831,7 @@ gchar *str = sp_svg_write_path(c->get_pathvector()); repr->setAttribute("d", str); #ifdef GROUP_VERBOSE -g_message("sp_group_perform_patheffect writes 'd' attribute"); + g_message("sp_group_perform_patheffect writes 'd' attribute"); #endif g_free(str); } === modified file 'src/sp-item-group.h' --- src/sp-item-group.h 2014-03-27 01:33:44 +0000 +++ src/sp-item-group.h 2014-06-04 01:19:40 +0000 @@ -88,7 +88,7 @@ void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = true); - +void sp_gslist_update_by_clip_or_mask(GSList *item_list, SPItem * item); GSList *sp_item_group_item_list (SPGroup *group); SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name); === modified file 'src/sp-lpe-item.cpp' --- src/sp-lpe-item.cpp 2014-04-28 19:51:55 +0000 +++ src/sp-lpe-item.cpp 2014-06-04 01:19:40 +0000 @@ -38,6 +38,11 @@ #include "desktop.h" #include "shape-editor.h" #include "sp-ellipse.h" +#include "display/curve.h" +#include "svg/svg.h" +#include <2geom/pathvector.h> +#include "sp-clippath.h" +#include "sp-mask.h" #include "tools-switch.h" #include "ui/tools/node-tool.h" #include "ui/tools/tool-base.h" @@ -51,6 +56,8 @@ static void sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem); static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem); +static void sp_lpe_item_apply_to_clip_or_mask_group(SPGroup * group, SPItem * item); + typedef std::list HRefList; static std::string patheffectlist_write_svg(PathEffectList const & list); static std::string hreflist_write_svg(HRefList const & list); @@ -332,6 +339,16 @@ static void sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) { + SPMask * mask = lpeitem->mask_ref->getObject(); + if(mask) + { + sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clipPath = lpeitem->clip_ref->getObject(); + if(clipPath) + { + sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + } if (SP_IS_GROUP(lpeitem)) { GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( GSList const *iter = item_list; iter; iter = iter->next ) { @@ -352,6 +369,17 @@ static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) { + SPMask * mask = lpeitem->mask_ref->getObject(); + if(mask) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clipPath = lpeitem->clip_ref->getObject(); + if(clipPath) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + } + if (SP_IS_GROUP(lpeitem)) { GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( GSList const *iter = item_list; iter; iter = iter->next ) { @@ -597,6 +625,124 @@ } } +void +sp_lpe_item_apply_to_clippath(SPItem * item) +{ + SPClipPath *clipPath = item->clip_ref->getObject(); + if(clipPath) { + SPObject * clip_data = clipPath->firstChild(); + SPCurve * clip_curve = NULL; + + if (SP_IS_PATH(clip_data)) { + clip_curve = SP_PATH(clip_data)->get_original_curve(); + } else if(SP_IS_SHAPE(clip_data)) { + clip_curve = SP_SHAPE(clip_data)->getCurve(); + } else if(SP_IS_GROUP(clip_data)) { + sp_lpe_item_apply_to_clip_or_mask_group(SP_GROUP(clip_data), item); + return; + } + if(clip_curve) { + bool success = SP_LPE_ITEM(item)->performPathEffect(clip_curve); + Inkscape::XML::Node *reprClip = clip_data->getRepr(); + if (success) { + gchar *str = sp_svg_write_path(clip_curve->get_pathvector()); + reprClip->setAttribute("d", str); + g_free(str); + } else { + // LPE was unsuccesfull. Read the old 'd'-attribute. + if (gchar const * value = reprClip->attribute("d")) { + Geom::PathVector pv = sp_svg_read_pathv(value); + SPCurve *oldcurve = new SPCurve(pv); + if (oldcurve) { + SP_SHAPE(clip_data)->setCurve(oldcurve, TRUE); + oldcurve->unref(); + } + } + } + clip_curve->unref(); + } + } +} + +void +sp_lpe_item_apply_to_mask(SPItem * item) +{ + SPMask *mask = item->mask_ref->getObject(); + if(mask) { + SPObject * mask_data = mask->firstChild(); + SPCurve * mask_curve = NULL; + mask_data = mask->firstChild(); + if (SP_IS_PATH(mask_data)) { + mask_curve = SP_PATH(mask_data)->get_original_curve(); + } else if(SP_IS_SHAPE(mask_data)) { + mask_curve = SP_SHAPE(mask_data)->getCurve(); + } else if(SP_IS_GROUP(mask_data)) { + sp_lpe_item_apply_to_clip_or_mask_group(SP_GROUP(mask_data), item); + return; + } + if(mask_curve) { + bool success = SP_LPE_ITEM(item)->performPathEffect(mask_curve); + Inkscape::XML::Node *reprmask = mask_data->getRepr(); + if (success) { + gchar *str = sp_svg_write_path(mask_curve->get_pathvector()); + reprmask->setAttribute("d", str); + g_free(str); + } else { + // LPE was unsuccesfull. Read the old 'd'-attribute. + if (gchar const * value = reprmask->attribute("d")) { + Geom::PathVector pv = sp_svg_read_pathv(value); + SPCurve *oldcurve = new SPCurve(pv); + if (oldcurve) { + SP_SHAPE(mask_data)->setCurve(oldcurve, TRUE); + oldcurve->unref(); + } + } + } + mask_curve->unref(); + } + } +} + +static void +sp_lpe_item_apply_to_clip_or_mask_group(SPGroup *group, SPItem *item) +{ + GSList *item_list = sp_item_group_item_list(group); + for ( GSList *iter = item_list; iter; iter = iter->next ) { + SPObject *subitem = static_cast(iter->data); + if (SP_IS_GROUP(subitem)) { + sp_lpe_item_apply_to_clip_or_mask_group(SP_GROUP(subitem), item); + } else if (SP_IS_SHAPE(subitem)) { + SPCurve * c = NULL; + + if (SP_IS_PATH(subitem)) { + c = SP_PATH(subitem)->get_original_curve(); + } else { + c = SP_SHAPE(subitem)->getCurve(); + } + if (c) { + bool success = SP_LPE_ITEM(item)->performPathEffect(c); + Inkscape::XML::Node *repr = subitem->getRepr(); + if (success) { + gchar *str = sp_svg_write_path(c->get_pathvector()); + repr->setAttribute("d", str); + g_free(str); + } else { + // LPE was unsuccesfull. Read the old 'd'-attribute. + if (gchar const * value = repr->attribute("d")) { + Geom::PathVector pv = sp_svg_read_pathv(value); + SPCurve *oldcurve = new SPCurve(pv); + if (oldcurve) { + SP_SHAPE(subitem)->setCurve(oldcurve, TRUE); + oldcurve->unref(); + } + } + } + c->unref(); + } + } + } +} + Inkscape::LivePathEffect::Effect* SPLPEItem::getPathEffectOfType(int type) { === modified file 'src/sp-lpe-item.h' --- src/sp-lpe-item.h 2014-03-27 01:33:44 +0000 +++ src/sp-lpe-item.h 2014-06-04 01:19:40 +0000 @@ -97,6 +97,8 @@ void editNextParamOncanvas(SPDesktop *dt); }; +void sp_lpe_item_apply_to_mask(SPItem * item); +void sp_lpe_item_apply_to_clippath(SPItem * item); void sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write); // careful, class already has method with *very* similar name! #endif /* !SP_LPE_ITEM_H_SEEN */ === modified file 'src/sp-path.cpp' --- src/sp-path.cpp 2014-03-27 01:33:44 +0000 +++ src/sp-path.cpp 2014-06-04 01:19:40 +0000 @@ -310,6 +310,8 @@ bool success = this->performPathEffect(curve); if (success && write) { + sp_lpe_item_apply_to_mask(this); + sp_lpe_item_apply_to_clippath(this); // could also do this->getRepr()->updateRepr(); but only the d attribute needs updating. #ifdef PATH_VERBOSE g_message("sp_path_update_patheffect writes 'd' attribute"); === modified file 'src/sp-spiral.cpp' --- src/sp-spiral.cpp 2014-03-27 01:33:44 +0000 +++ src/sp-spiral.cpp 2014-06-04 01:19:40 +0000 @@ -385,6 +385,8 @@ bool success = this->performPathEffect(c_lpe); if (success) { + sp_lpe_item_apply_to_mask(this); + sp_lpe_item_apply_to_clippath(this); this->setCurveInsync( c_lpe, TRUE); } === modified file 'src/sp-star.cpp' --- src/sp-star.cpp 2014-03-27 01:33:44 +0000 +++ src/sp-star.cpp 2014-06-04 01:19:40 +0000 @@ -465,6 +465,8 @@ bool success = this->performPathEffect(c_lpe); if (success) { + sp_lpe_item_apply_to_mask(this); + sp_lpe_item_apply_to_clippath(this); this->setCurveInsync( c_lpe, TRUE); }