=== modified file 'src/box3d-side.cpp' --- src/box3d-side.cpp 2014-03-09 03:44:03 +0000 +++ src/box3d-side.cpp 2014-03-23 17:30:50 +0000 @@ -209,6 +209,12 @@ this->setCurveInsync( c, TRUE); if (hasPathEffect() && pathEffectsEnabled()) { + //Function in "sp-lpe-item" + //If "this" has mask, the function "sp_apply_lpe_to_mask" apply LPE effects to the mask of "this" + sp_apply_lpe_to_mask(this); + //Function in "sp-lpe-item" + //If "this" has clippath, the function "sp_apply_lpe_to_clippath" apply LPE effects to the clippath of "this" + sp_apply_lpe_to_clippath(this); SPCurve *c_lpe = c->copy(); bool success = this->performPathEffect(c_lpe); === modified file 'src/sp-ellipse.cpp' --- src/sp-ellipse.cpp 2014-01-12 23:25:39 +0000 +++ src/sp-ellipse.cpp 2014-03-23 17:30:50 +0000 @@ -34,7 +34,6 @@ #include "sp-ellipse.h" #include "preferences.h" #include "snap-candidate.h" - #include "sp-factory.h" namespace { @@ -490,6 +489,13 @@ this->setCurveBeforeLPE(curve); if (hasPathEffect() && pathEffectsEnabled()) { + //Function in "sp-lpe-item" + //If "this" has mask, the function "sp_apply_lpe_to_mask" apply LPE effects to the mask of "this" + sp_apply_lpe_to_mask(this); + //Function in "sp-lpe-item" + //If "this" has clippath, the function "sp_apply_lpe_to_clippath" apply LPE effects to the clippath of "this" + sp_apply_lpe_to_clippath(this); + SPCurve *c_lpe = curve->copy(); bool success = this->performPathEffect(c_lpe); === modified file 'src/sp-item-group.cpp' --- src/sp-item-group.cpp 2013-10-26 22:00:51 +0000 +++ src/sp-item-group.cpp 2014-03-23 17:30:50 +0000 @@ -778,17 +778,30 @@ } } +void +sp_gslist_update_by_clip_or_mask(GSList *item_list,SPItem * item) +{ + if(SP_IS_MASK(item->mask_ref->getObject())){ + SPObject * clipormask = item->mask_ref->getObject()->firstChild(); + item_list = g_slist_append(item_list,clipormask); + } + if(SP_IS_CLIPPATH(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(SP_GROUP(group)); + sp_gslist_update_by_clip_or_mask(item_list,SP_ITEM(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)) { + }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 +812,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(SP_ITEM(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(SP_ITEM(group), topgroup).inverse()); + }else{ + c->transform(i2anc_affine(subitem, topgroup).inverse()); + } SP_SHAPE(subitem)->setCurve(c, TRUE); if (write) { === modified file 'src/sp-item-group.h' --- src/sp-item-group.h 2013-11-12 00:51:18 +0000 +++ src/sp-item-group.h 2014-03-23 17:30:50 +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 2013-10-27 16:47:42 +0000 +++ src/sp-lpe-item.cpp 2014-03-23 17:30:50 +0000 @@ -36,6 +36,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 +#include #include @@ -326,6 +331,14 @@ static void sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) { + SPMask * mask = SP_ITEM(lpeitem)->mask_ref->getObject(); + if(SP_IS_MASK(mask)){ + sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clipPath = SP_ITEM(lpeitem)->clip_ref->getObject(); + if(SP_IS_CLIPPATH(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 ) { @@ -346,6 +359,15 @@ static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) { + SPMask * mask = SP_ITEM(lpeitem)->mask_ref->getObject(); + if(SP_IS_MASK(mask)){ + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clipPath = SP_ITEM(lpeitem)->clip_ref->getObject(); + if(SP_IS_CLIPPATH(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 ) { @@ -575,6 +597,86 @@ } } +void +sp_apply_lpe_to_clippath(SPItem * item) +{ + SPClipPath *clipPath = item->clip_ref->getObject(); + if(SP_IS_CLIPPATH(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 { + clip_curve = SP_SHAPE(clip_data)->getCurve(); + } + bool success = false; + if(SP_IS_PATH(item)){ + success = SP_PATH(item)->performPathEffect(clip_curve); + } + else if(SP_IS_GROUP(item)){ + success = SP_GROUP(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_apply_lpe_to_mask(SPItem * item) +{ + SPMask *mask = item->mask_ref->getObject(); + if(SP_IS_MASK(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 { + mask_curve = SP_SHAPE(mask_data)->getCurve(); + } + bool success = false; + if(SP_IS_PATH(item)){ + success = SP_PATH(item)->performPathEffect(mask_curve); + } + else if(SP_IS_GROUP(item)){ + success = SP_GROUP(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(); + } +} + Inkscape::LivePathEffect::Effect* SPLPEItem::getPathEffectOfType(int type) { === modified file 'src/sp-lpe-item.h' --- src/sp-lpe-item.h 2013-10-04 21:57:28 +0000 +++ src/sp-lpe-item.h 2014-03-23 17:30:50 +0000 @@ -96,7 +96,8 @@ void editNextParamOncanvas(SPDesktop *dt); }; - +void sp_apply_lpe_to_mask(SPItem * item); +void sp_apply_lpe_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 2013-11-09 22:36:13 +0000 +++ src/sp-path.cpp 2014-03-23 17:30:50 +0000 @@ -302,6 +302,13 @@ #endif if (_curve_before_lpe && hasPathEffectRecursive()) { + //Function in "sp-lpe-item" + //If "this" has mask, the function "sp_apply_lpe_to_mask" apply LPE effects to the mask of "this" + sp_apply_lpe_to_mask(this); + //Function in "sp-lpe-item" + //If "this" has clippath, the function "sp_apply_lpe_to_clippath" apply LPE effects to the clippath of "this" + sp_apply_lpe_to_clippath(this); + SPCurve *curve = _curve_before_lpe->copy(); /* if a path has an lpeitem applied, then reset the curve to the _curve_before_lpe. * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ === modified file 'src/sp-spiral.cpp' --- src/sp-spiral.cpp 2014-01-06 21:30:35 +0000 +++ src/sp-spiral.cpp 2014-03-23 17:30:50 +0000 @@ -25,7 +25,6 @@ #include #include "xml/repr.h" #include "document.h" - #include "sp-spiral.h" #include "sp-factory.h" @@ -381,6 +380,13 @@ setCurveBeforeLPE( c ); if (hasPathEffect() && pathEffectsEnabled()) { + //Function in "sp-lpe-item" + //If "this" has mask, the function "sp_apply_lpe_to_mask" apply LPE effects to the mask of "this" + sp_apply_lpe_to_mask(this); + //Function in "sp-lpe-item" + //If "this" has clippath, the function "sp_apply_lpe_to_clippath" apply LPE effects to the clippath of "this" + sp_apply_lpe_to_clippath(this); + SPCurve *c_lpe = c->copy(); bool success = this->performPathEffect(c_lpe); === modified file 'src/sp-star.cpp' --- src/sp-star.cpp 2014-01-06 21:30:35 +0000 +++ src/sp-star.cpp 2014-03-23 17:30:50 +0000 @@ -27,7 +27,6 @@ #include "display/curve.h" #include "xml/repr.h" #include "document.h" - #include <2geom/pathvector.h> #include "sp-star.h" @@ -461,6 +460,13 @@ this->setCurveBeforeLPE( c ); if (hasPathEffect() && pathEffectsEnabled()) { + //Function in "sp-lpe-item" + //If "this" has mask, the function "sp_apply_lpe_to_mask" apply LPE effects to the mask of "this" + sp_apply_lpe_to_mask(this); + //Function in "sp-lpe-item" + //If "this" has clippath, the function "sp_apply_lpe_to_clippath" apply LPE effects to the clippath of "this" + sp_apply_lpe_to_clippath(this); + SPCurve *c_lpe = c->copy(); bool success = this->performPathEffect(c_lpe);