diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-03-03 15:16:30 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-03-03 15:16:30 +0000 |
| commit | 8f670aecc6764c0796c89cb4615626d66d4aa849 (patch) | |
| tree | 888cb60349377d62533d0508366aec73ba79b387 /src | |
| parent | Fix a bug with 0 width shapes (diff) | |
| parent | Fix bug: 1552003 Randomize color extension has no limits (diff) | |
| download | inkscape-8f670aecc6764c0796c89cb4615626d66d4aa849.tar.gz inkscape-8f670aecc6764c0796c89cb4615626d66d4aa849.zip | |
update to trunk
(bzr r14648.1.5)
Diffstat (limited to 'src')
23 files changed, 113 insertions, 197 deletions
diff --git a/src/helper/geom-pathstroke.cpp b/src/helper/geom-pathstroke.cpp index 3ef4b15da..d2e9f9a1b 100644 --- a/src/helper/geom-pathstroke.cpp +++ b/src/helper/geom-pathstroke.cpp @@ -557,7 +557,7 @@ void extrapolate_join_internal(join_data jd, int alternative) Geom::Line bisector_chord = make_bisector_line(chord); Geom::Line limit_line; - double miter_limit = 2.0 * width * miter; + double miter_limit = width * miter; bool clipped = false; if (are_parallel(bisector_chord, ortho)) { diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index fe7bf3a97..47fd02554 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -356,7 +356,8 @@ Effect::createAndApply(EffectType type, SPDocument *doc, SPItem *item) } Effect::Effect(LivePathEffectObject *lpeobject) - : _provides_knotholder_entities(false), + : apply_to_clippath_and_mask(false), + _provides_knotholder_entities(false), oncanvasedit_it(0), is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true), show_orig_path(false), diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index ea57ff243..898e089b7 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -121,6 +121,7 @@ public: inline bool isVisible() const { return is_visible; } void editNextParamOncanvas(SPItem * item, SPDesktop * desktop); + bool apply_to_clippath_and_mask; protected: Effect(LivePathEffectObject *lpeobject); @@ -144,6 +145,7 @@ protected: std::vector<Parameter *> param_vector; bool _provides_knotholder_entities; + int oncanvasedit_it; BoolParam is_visible; diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index d7c0b69a4..bc112285f 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -81,6 +81,7 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) : prop_scale.param_set_increments(0.01, 0.10); _provides_knotholder_entities = true; + apply_to_clippath_and_mask = true; concatenate_before_pwd2 = true; } @@ -95,10 +96,6 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) // get the item bounding box original_bbox(lpeitem); original_height = boundingbox_Y.max() - boundingbox_Y.min(); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - - item->apply_to_clippath(item); - item->apply_to_mask(item); } Geom::Piecewise<Geom::D2<Geom::SBasis> > diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 87d8f05a9..8dfaf7525 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -61,6 +61,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : { show_orig_path = true; _provides_knotholder_entities = true; + apply_to_clippath_and_mask = true; // register all your parameters here, so Inkscape knows which parameters this effect has: registerParameter(&copiesTo360); @@ -111,10 +112,6 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem) if(copiesTo360 ){ rot_pos = origin; } - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); - } diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 05a672ae8..e873c0b15 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -42,6 +42,7 @@ LPEEnvelope::LPEEnvelope(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast<Parameter *>(&bend_path3) ); registerParameter( dynamic_cast<Parameter *>(&bend_path4) ); concatenate_before_pwd2 = true; + apply_to_clippath_and_mask = true; } LPEEnvelope::~LPEEnvelope() @@ -54,9 +55,6 @@ LPEEnvelope::doBeforeEffect (SPLPEItem const* lpeitem) { // get the item bounding box original_bbox(lpeitem); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); } Geom::Piecewise<Geom::D2<Geom::SBasis> > diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index c05bae7e1..3c23e349e 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -78,7 +78,7 @@ LPELattice::LPELattice(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast<Parameter *>(&grid_point14) ); registerParameter( dynamic_cast<Parameter *>(&grid_point15) ); - + apply_to_clippath_and_mask = true; } LPELattice::~LPELattice() @@ -176,9 +176,6 @@ void LPELattice::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); } void diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index b749370fa..0c403daec 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -103,6 +103,7 @@ LPELattice2::LPELattice2(LivePathEffectObject *lpeobject) : registerParameter(&grid_point_28x30); registerParameter(&grid_point_29x31); registerParameter(&grid_point_32x33x34x35); + apply_to_clippath_and_mask = true; } LPELattice2::~LPELattice2() @@ -358,9 +359,6 @@ LPELattice2::doBeforeEffect (SPLPEItem const* lpeitem) horizontal(grid_point_17, grid_point_19,horiz); horizontal(grid_point_20x21, grid_point_22x23,horiz); } - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); } void diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 783053df2..c13cffb6a 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -33,7 +33,7 @@ LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) : reflection_line(_("Reflection line:"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100") { show_orig_path = true; - + apply_to_clippath_and_mask = true; registerParameter( dynamic_cast<Parameter *>(&discard_orig_path) ); registerParameter( dynamic_cast<Parameter *>(&reflection_line) ); } @@ -43,14 +43,6 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry() } void -LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) -{ - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); -} - -void LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem) { using namespace Geom; diff --git a/src/live_effects/lpe-mirror_symmetry.h b/src/live_effects/lpe-mirror_symmetry.h index 7a484a473..64a72d7b3 100644 --- a/src/live_effects/lpe-mirror_symmetry.h +++ b/src/live_effects/lpe-mirror_symmetry.h @@ -30,8 +30,6 @@ public: virtual void doOnApply (SPLPEItem const* lpeitem); - virtual void doBeforeEffect (SPLPEItem const* lpeitem); - virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); private: diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index dd7af92a2..d611b88a1 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -31,7 +31,7 @@ LPEOffset::LPEOffset(LivePathEffectObject *lpeobject) : offset_pt(_("Offset"), _("Handle to control the distance of the offset from the curve"), "offset_pt", &wr, this) { show_orig_path = true; - + apply_to_clippath_and_mask = true; registerParameter(dynamic_cast<Parameter *>(&offset_pt)); } @@ -57,14 +57,6 @@ static void append_half_circle(Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2, pwd2.continuousConcat(cap_pwd2); } -void -LPEOffset::doBeforeEffect (SPLPEItem const* lpeitem) -{ - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); -} - Geom::Piecewise<Geom::D2<Geom::SBasis> > LPEOffset::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) { diff --git a/src/live_effects/lpe-offset.h b/src/live_effects/lpe-offset.h index 997311c7d..9966fd45d 100644 --- a/src/live_effects/lpe-offset.h +++ b/src/live_effects/lpe-offset.h @@ -28,8 +28,6 @@ public: virtual void doOnApply (SPLPEItem const* lpeitem); - virtual void doBeforeEffect (SPLPEItem const* lpeitem); - virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); private: diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index 72c1b0e99..5b29df4a7 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -56,6 +56,7 @@ LPEPerspectiveEnvelope::LPEPerspectiveEnvelope(LivePathEffectObject *lpeobject) registerParameter(&up_right_point); registerParameter(&down_left_point); registerParameter(&down_right_point); + apply_to_clippath_and_mask = true; } LPEPerspectiveEnvelope::~LPEPerspectiveEnvelope() @@ -371,9 +372,6 @@ LPEPerspectiveEnvelope::doBeforeEffect (SPLPEItem const* lpeitem) horizontal(up_left_point, down_left_point,horiz); horizontal(up_right_point, down_right_point,horiz); } - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); setDefaults(); } diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index 901519b4f..c8cdd7912 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -64,6 +64,7 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : concatenate_before_pwd2 = true; // don't split the path into its subpaths _provides_knotholder_entities = true; + apply_to_clippath_and_mask = true; } LPEPerspectivePath::~LPEPerspectivePath() @@ -100,8 +101,6 @@ LPEPerspectivePath::doBeforeEffect (SPLPEItem const* lpeitem) Geom::Affine doc2d = Geom::Scale(1, -1) * Geom::Translate(0, item->document->getHeight().value("px")); pmat = pmat * doc2d; pmat.copy_tmat(tmat); - item->apply_to_clippath(item); - item->apply_to_mask(item); } void LPEPerspectivePath::refresh(Gtk::Entry* perspective) { diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index b4ee54f1a..105fe2fc4 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -87,6 +87,7 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) segments.param_set_increments(1, 1); segments.param_set_digits(0); seed = 0; + apply_to_clippath_and_mask = true; } LPERoughen::~LPERoughen() {} @@ -102,9 +103,6 @@ void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) displace_y.resetRandomizer(); global_randomize.resetRandomizer(); srand(1); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); } Gtk::Widget *LPERoughen::newWidget() diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 4b62c6c65..f807bdc8d 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -60,6 +60,7 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) helper_size.param_set_digits(2); radius_helper_nodes = 6.0; + apply_to_clippath_and_mask = true; } LPESimplify::~LPESimplify() {} @@ -71,10 +72,7 @@ LPESimplify::doBeforeEffect (SPLPEItem const* lpeitem) hp.clear(); } bbox = SP_ITEM(lpeitem)->visualBounds(); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); radius_helper_nodes = helper_size; - item->apply_to_clippath(item); - item->apply_to_mask(item); } Gtk::Widget * diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index dd1a29689..1cd59b7fa 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -78,6 +78,7 @@ LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : strech.param_set_range(0, 999.0); strech.param_set_increments(0.01, 0.01); strech.param_set_digits(4); + apply_to_clippath_and_mask = true; } LPETransform2Pts::~LPETransform2Pts() @@ -167,8 +168,6 @@ LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem) previous_angle = transformed.angle(); previous_lenght = Geom::distance((Geom::Point)start, (Geom::Point)end); previous_start = start; - splpeitem->apply_to_clippath(splpeitem); - splpeitem->apply_to_mask(splpeitem); } void diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 7b424e019..7eda7446e 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -64,7 +64,7 @@ LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast<Parameter *>(&drawall) ); registerParameter( dynamic_cast<Parameter *>(&maxComplexity) ); //registerParameter( dynamic_cast<Parameter *>(&draw_boxes) ); - + apply_to_clippath_and_mask = true; nbgenerations.param_make_integer(); nbgenerations.param_set_range(0, Geom::infinity()); maxComplexity.param_make_integer(); @@ -262,9 +262,6 @@ LPEVonKoch::doBeforeEffect (SPLPEItem const* lpeitem) tmp_pathv.push_back(tmp_path); ref_path.set_new_value(tmp_pathv,true); } - SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); } diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 98b77cfe8..e2afbb55b 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -209,7 +209,7 @@ Inkscape::XML::Node* SPLPEItem::write(Inkscape::XML::Document *xml_doc, Inkscape /** * returns true when LPE was successful. */ -bool SPLPEItem::performPathEffect(SPCurve *curve) { +bool SPLPEItem::performPathEffect(SPCurve *curve, bool clip_paths) { if (!this) { return false; } @@ -217,7 +217,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve) { if (!curve) { return false; } - + bool apply_to_clippath_and_mask = false; if (this->hasPathEffect() && this->pathEffectsEnabled()) { for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) { @@ -239,35 +239,42 @@ bool SPLPEItem::performPathEffect(SPCurve *curve) { } if (lpe->isVisible()) { + if(lpe->apply_to_clippath_and_mask){ + apply_to_clippath_and_mask = true; + } if (lpe->acceptsNumClicks() > 0 && !lpe->isReady()) { // if the effect expects mouse input before being applied and the input is not finished // yet, we don't alter the path return false; } + if (clip_paths || lpe->apply_to_clippath_and_mask) { + // Groups have their doBeforeEffect called elsewhere + if (!SP_IS_GROUP(this)) { + lpe->doBeforeEffect_impl(this); + } - // Groups have their doBeforeEffect called elsewhere - if (!SP_IS_GROUP(this)) { - lpe->doBeforeEffect_impl(this); - } - - try { - lpe->doEffect(curve); - } - catch (std::exception & e) { - g_warning("Exception during LPE %s execution. \n %s", lpe->getName().c_str(), e.what()); - if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->messageStack()) { - SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE, - _("An exception occurred during execution of the Path Effect.") ); + try { + lpe->doEffect(curve); + } + catch (std::exception & e) { + g_warning("Exception during LPE %s execution. \n %s", lpe->getName().c_str(), e.what()); + if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->messageStack()) { + SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE, + _("An exception occurred during execution of the Path Effect.") ); + } + return false; + } + if (!SP_IS_GROUP(this)) { + lpe->doAfterEffect(this); } - return false; - } - if (!SP_IS_GROUP(this)) { - lpe->doAfterEffect(this); } } } } - + if(apply_to_clippath_and_mask && clip_paths){ + this->apply_to_clippath((SPItem *)this); + this->apply_to_mask((SPItem *)this); + } return true; } @@ -641,43 +648,7 @@ SPLPEItem::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)) { - apply_to_clip_or_mask_group(SP_ITEM(clip_data), item); - return; - } - if(clip_curve) { - bool success = false; - if(SP_IS_GROUP(this)){ - clip_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this))); - success = this->performPathEffect(clip_curve); - clip_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse()); - } else { - success = this->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(); - } + apply_to_clip_or_mask(SP_ITEM(clip_data), item); } if(SP_IS_GROUP(item)){ std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); @@ -694,42 +665,7 @@ SPLPEItem::apply_to_mask(SPItem *item) SPMask *mask = item->mask_ref->getObject(); if(mask) { SPObject *mask_data = mask->firstChild(); - SPCurve * mask_curve = NULL; - 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)) { - apply_to_clip_or_mask_group(SP_ITEM(mask_data), item); - return; - } - if(mask_curve) { - bool success = false; - if(SP_IS_GROUP(this)){ - mask_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this))); - success = this->performPathEffect(mask_curve); - mask_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse()); - } else { - success = this->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(); - } + apply_to_clip_or_mask(SP_ITEM(mask_data), item); } if(SP_IS_GROUP(item)){ std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); @@ -741,51 +677,57 @@ SPLPEItem::apply_to_mask(SPItem *item) } void -SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item) +SPLPEItem::apply_to_clip_or_mask(SPItem *clip_mask, SPItem *item) { - if (!SP_IS_GROUP(group)) { - return; - } - std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(group)); - for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPObject *subitem = *iter; - if (SP_IS_GROUP(subitem)) { - apply_to_clip_or_mask_group(SP_ITEM(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 = false; - if(SP_IS_GROUP(group)){ + if (SP_IS_GROUP(clip_mask)) { + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(clip_mask)); + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + SPItem *subitem = *iter; + apply_to_clip_or_mask(subitem, item); + } + } else if (SP_IS_SHAPE(clip_mask)) { + SPCurve * c = NULL; + + if (SP_IS_PATH(clip_mask)) { + c = SP_PATH(clip_mask)->get_original_curve(); + } else { + c = SP_SHAPE(clip_mask)->getCurve(); + } + if (c) { + bool success = false; + try { + if(SP_IS_GROUP(this)){ c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this))); - success = this->performPathEffect(c); + success = this->performPathEffect(c, false); c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse()); } else { - success = this->performPathEffect(c); + success = this->performPathEffect(c, false); } - 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(); - } + } catch (std::exception & e) { + g_warning("Exception during LPE execution. \n %s", e.what()); + if (SP_ACTIVE_DESKTOP && SP_ACTIVE_DESKTOP->messageStack()) { + SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE, + _("An exception occurred during execution of the Path Effect.") ); + } + success = false; + } + Inkscape::XML::Node *repr = clip_mask->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(clip_mask)->setCurve(oldcurve, TRUE); + oldcurve->unref(); } } - c->unref(); } + c->unref(); } } } diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index c35ad8411..d5e868b2e 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -69,7 +69,7 @@ public: virtual void update_patheffect(bool write); - bool performPathEffect(SPCurve *curve); + bool performPathEffect(SPCurve *curve, bool clip_paths = true); bool pathEffectsEnabled() const; bool hasPathEffect() const; @@ -93,7 +93,7 @@ public: void addPathEffect(LivePathEffectObject * new_lpeobj); void apply_to_mask(SPItem * item); void apply_to_clippath(SPItem * item); - void apply_to_clip_or_mask_group(SPItem * group, SPItem * item); + void apply_to_clip_or_mask(SPItem * clip_mask, SPItem * item); bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1); void editNextParamOncanvas(SPDesktop *dt); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index b6d7e25ec..b20f71a6a 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -206,6 +206,15 @@ void InkscapePreferences::AddDotSizeSpinbutton(DialogPage &p, Glib::ustring cons false ); } +void InkscapePreferences::AddBaseSimplifySpinbutton(DialogPage &p, Glib::ustring const &prefs_path, double def_value) +{ + PrefSpinButton* sb = Gtk::manage( new PrefSpinButton); + sb->init ( prefs_path + "/base-simplify", 0.0, 100.0, 1.0, 10.0, def_value, false, false); + p.add_line( false, _("Base simplify:"), *sb, _("on dinamic LPE simplify"), + _("Base simplify of dinamic LPE based simplify"), + false ); +} + static void StyleFromSelectionToTool(Glib::ustring const &prefs_path, StyleSwatch *swatch) { @@ -425,6 +434,7 @@ void InkscapePreferences::initPageTools() this->AddSelcueCheckbox(_page_pencil, "/tools/freehand/pencil", true); this->AddNewObjectsStyle(_page_pencil, "/tools/freehand/pencil"); this->AddDotSizeSpinbutton(_page_pencil, "/tools/freehand/pencil", 3.0); + this->AddBaseSimplifySpinbutton(_page_pencil, "/tools/freehand/pencil", 25.0); _page_pencil.add_group_header( _("Sketch mode")); _page_pencil.add_line( true, "", _pencil_average_all_sketches, "", _("If on, the sketch result will be the normal average of all sketches made, instead of averaging the old result with the new sketch")); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index b7696ab8c..d1abcfc58 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -502,6 +502,7 @@ protected: static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddFirstAndLastCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddDotSizeSpinbutton(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, double def_value); + static void AddBaseSimplifySpinbutton(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, double def_value); static void AddNewObjectsStyle(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL); void on_pagelist_selection_changed(); diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index bfb1c67f0..b029ca613 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -634,12 +634,14 @@ void PencilTool::_interpolate() { using Geom::Y; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; - double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0); if(simplify){ - tolerance_sq = 0; + double tol2 = prefs->getDoubleLimited("/tools/freehand/pencil/base-simplify", 25.0, 1.0, 100.0) * 0.4; + tol = std::min(tol,tol2); } + double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent)); this->green_curve->reset(); @@ -705,12 +707,14 @@ void PencilTool::_sketchInterpolate() { } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; - double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0); if(simplify){ - tolerance_sq = 0; + double tol2 = prefs->getDoubleLimited("/tools/freehand/pencil/base-simplify", 25.0, 1.0, 100.0) * 0.4; + tol = std::min(tol,tol2); } + double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + bool average_all_sketches = prefs->getBool("/tools/freehand/pencil/average_all_sketches", true); g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent)); |
