=== modified file 'src/box3d-side.cpp' --- src/box3d-side.cpp 2013-11-09 22:36:13 +0000 +++ src/box3d-side.cpp 2014-01-18 19:07:16 +0000 @@ -23,6 +23,8 @@ #include "preferences.h" #include "desktop-style.h" #include "box3d.h" +#include "sp-clippath.h" +#include "sp-mask.h" static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); @@ -208,6 +210,8 @@ this->setCurveInsync( c, TRUE); if (hasPathEffect() && pathEffectsEnabled()) { + sp_apply_lpe_to_mask(this); + sp_apply_lpe_to_clippath(this); SPCurve *c_lpe = c->copy(); bool success = this->performPathEffect(c_lpe); === modified file 'src/sp-clippath.cpp' --- src/sp-clippath.cpp 2013-08-03 01:03:43 +0000 +++ src/sp-clippath.cpp 2014-01-18 19:13:00 +0000 @@ -26,6 +26,11 @@ #include "sp-item.h" #include "style.h" +#include "display/curve.h" +#include "sp-path.h" +#include "svg/svg.h" +#include <2geom/pathvector.h> + #include <2geom/transforms.h> #include "sp-clippath.h" @@ -305,6 +310,45 @@ return list; } +void +sp_apply_lpe_to_clippath(SPObject * element) +{ + SPClipPath *clipPath = SP_ITEM(element)->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(element)){ + success = SP_PATH(element)->performPathEffect(clip_curve); + } + if(SP_IS_GROUP(element)){ + success = SP_GROUP(element)->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 if (!success) { + // 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(); + } +} // Create a mask element (using passed elements), add it to const gchar *SPClipPath::create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform) { === modified file 'src/sp-clippath.h' --- src/sp-clippath.h 2013-09-15 00:43:49 +0000 +++ src/sp-clippath.h 2014-01-18 18:56:12 +0000 @@ -42,6 +42,7 @@ unsigned int clipPathUnits : 1; SPClipPathView *display; + static const gchar *create(GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); static GType sp_clippath_get_type(void); @@ -111,6 +112,7 @@ return true; } }; +void sp_apply_lpe_to_clippath(SPObject * element); #endif // SEEN_SP_CLIPPATH_H === modified file 'src/sp-ellipse.cpp' --- src/sp-ellipse.cpp 2014-01-12 23:25:39 +0000 +++ src/sp-ellipse.cpp 2014-01-18 19:07:11 +0000 @@ -34,8 +34,9 @@ #include "sp-ellipse.h" #include "preferences.h" #include "snap-candidate.h" - #include "sp-factory.h" +#include "sp-clippath.h" +#include "sp-mask.h" namespace { SPObject *create_ellipse() @@ -490,6 +491,8 @@ this->setCurveBeforeLPE(curve); if (hasPathEffect() && pathEffectsEnabled()) { + sp_apply_lpe_to_mask(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-01-18 20:31:13 +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-01-18 19:59:06 +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-01-18 16:39:34 +0000 @@ -25,6 +25,8 @@ #include "sp-path.h" #include "sp-item-group.h" +#include +#include #include "streq.h" #include "macros.h" #include "attributes.h" @@ -326,6 +328,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 +356,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 ) { === modified file 'src/sp-mask.cpp' --- src/sp-mask.cpp 2013-08-03 01:03:43 +0000 +++ src/sp-mask.cpp 2014-01-18 19:12:21 +0000 @@ -25,6 +25,11 @@ #include "document-private.h" #include "sp-item.h" +#include "display/curve.h" +#include "sp-path.h" +#include "svg/svg.h" +#include <2geom/pathvector.h> + #include "sp-mask.h" struct SPMaskView { @@ -217,6 +222,46 @@ return repr; } +void +sp_apply_lpe_to_mask(SPObject * element) +{ + SPMask *mask = SP_ITEM(element)->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(element)){ + success = SP_PATH(element)->performPathEffect(mask_curve); + } + if(SP_IS_GROUP(element)){ + success = SP_GROUP(element)->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 if (!success) { + // 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(); + } +} + // Create a mask element (using passed elements), add it to const gchar * sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform) === modified file 'src/sp-mask.h' --- src/sp-mask.h 2013-09-15 00:43:49 +0000 +++ src/sp-mask.h 2014-01-18 18:56:02 +0000 @@ -42,7 +42,7 @@ unsigned int maskContentUnits_set : 1; unsigned int maskContentUnits : 1; - SPMaskView *display; + SPMaskView *display; Inkscape::DrawingItem *sp_mask_show(Inkscape::Drawing &drawing, unsigned int key); void sp_mask_hide(unsigned int key); @@ -107,7 +107,7 @@ return true; } }; - +void sp_apply_lpe_to_mask(SPObject * element); const gchar *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); #endif // SEEN_SP_MASK_H === modified file 'src/sp-path.cpp' --- src/sp-path.cpp 2013-11-09 22:36:13 +0000 +++ src/sp-path.cpp 2014-01-18 19:03:42 +0000 @@ -38,6 +38,8 @@ #include "sp-path.h" #include "sp-guide.h" +#include "sp-clippath.h" +#include "sp-mask.h" #include "document.h" #include "desktop.h" @@ -302,6 +304,10 @@ #endif if (_curve_before_lpe && hasPathEffectRecursive()) { + + sp_apply_lpe_to_mask(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-01-18 19:04:08 +0000 @@ -25,7 +25,8 @@ #include #include "xml/repr.h" #include "document.h" - +#include "sp-clippath.h" +#include "sp-mask.h" #include "sp-spiral.h" #include "sp-factory.h" @@ -381,6 +382,9 @@ setCurveBeforeLPE( c ); if (hasPathEffect() && pathEffectsEnabled()) { + sp_apply_lpe_to_mask(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-01-18 19:15:09 +0000 @@ -27,7 +27,8 @@ #include "display/curve.h" #include "xml/repr.h" #include "document.h" - +#include "sp-clippath.h" +#include "sp-mask.h" #include <2geom/pathvector.h> #include "sp-star.h" @@ -461,6 +462,9 @@ this->setCurveBeforeLPE( c ); if (hasPathEffect() && pathEffectsEnabled()) { + sp_apply_lpe_to_mask(this); + sp_apply_lpe_to_clippath(this); + SPCurve *c_lpe = c->copy(); bool success = this->performPathEffect(c_lpe);