From 19f8cf337ab1ceed9c654bb48b210fd9b391fcc8 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 2 Aug 2015 13:33:58 +0200 Subject: Added point parameter (bzr r14272.1.1) --- src/live_effects/lpe-bendpath.cpp | 43 +++++++++++++++++++++++- src/live_effects/lpe-bendpath.h | 14 ++++++-- src/live_effects/lpe-patternalongpath.cpp | 56 +++++++++++++++++++++++++++++-- src/live_effects/lpe-patternalongpath.h | 12 ++++++- 4 files changed, 118 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 33171b184..364c77ccb 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -48,17 +48,23 @@ first) but I think we can first forget about them. namespace Inkscape { namespace LivePathEffect { + LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) : Effect(lpeobject), bend_path(_("Bend path:"), _("Path along which to bend the original path"), "bendpath", &wr, this, "M0,0 L1,0"), prop_scale(_("_Width:"), _("Width of the path"), "prop_scale", &wr, this, 1), scale_y_rel(_("W_idth in units of length"), _("Scale the width of the path in units of its length"), "scale_y_rel", &wr, this, false), - vertical_pattern(_("_Original path is vertical"), _("Rotates the original 90 degrees, before bending it along the bend path"), "vertical", &wr, this, false) + vertical_pattern(_("_Original path is vertical"), _("Rotates the original 90 degrees, before bending it along the bend path"), "vertical", &wr, this, false), + width(_("Width distance"), _("Change the width of bend path - Ctrl+Alt+Click: reset"), "width", &wr, this), + height(0), + original_height(0), + prop_scale_previous(1) { registerParameter( dynamic_cast(&bend_path) ); registerParameter( dynamic_cast(&prop_scale) ); registerParameter( dynamic_cast(&scale_y_rel) ); registerParameter( dynamic_cast(&vertical_pattern) ); + registerParameter( dynamic_cast(&width) ); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); @@ -74,8 +80,38 @@ LPEBendPath::~LPEBendPath() void LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) { + hp.clear(); // get the item bounding box original_bbox(lpeitem); + original_height = boundingbox_Y.max() - boundingbox_Y.min(); + bool prop_scale_modified = false; + + Geom::Path path_in = bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); + Geom::Point ptA = path_in.pointAt(Geom::PathTime(0, 0.0)); + Geom::Point B = path_in.pointAt(Geom::PathTime(1, 0.0)); + Geom::Curve const *first_curve = &path_in.curveAt(Geom::PathTime(0, 0.0)); + Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); + Geom::Ray ray(ptA, B); + if (cubic) { + ray.setPoints((*cubic)[1], ptA); + } + if(height == 0){ + height = original_height; + width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA); + } + if( prop_scale_previous != prop_scale ){ + prop_scale_modified = true; + } + if(!prop_scale_modified){ + prop_scale.param_set_value(height/original_height); + } + height = Geom::distance(width,ptA) * 2; + width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), ((original_height*prop_scale)/2.0)) + ptA); + width.param_update_default(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA); + prop_scale_previous = prop_scale; + Geom::Path hp_path(width); + hp_path.appendNew(ptA); + hp.push_back(hp_path); SPLPEItem * item = const_cast(lpeitem); item->apply_to_clippath(item); item->apply_to_mask(item); @@ -148,6 +184,11 @@ LPEBendPath::resetDefaults(SPItem const* item) bend_path.set_new_value( path.toPwSb(), true ); } +void +LPEBendPath::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec) +{ + hp_vec.push_back(hp); +} } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 16b8c6137..6394ce07e 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -14,6 +14,7 @@ #include "live_effects/effect.h" #include "live_effects/parameter/path.h" #include "live_effects/parameter/bool.h" +#include "live_effects/parameter/point.h" #include <2geom/sbasis.h> #include <2geom/sbasis-geometric.h> @@ -27,6 +28,7 @@ namespace Inkscape { namespace LivePathEffect { + //for Bend path on group : we need information concerning the group Bounding box class LPEBendPath : public Effect, GroupBBoxEffect { public: @@ -39,15 +41,21 @@ public: virtual void resetDefaults(SPItem const* item); + void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec); private: - PathParam bend_path; - ScalarParam prop_scale; + PathParam bend_path; + ScalarParam prop_scale; BoolParam scale_y_rel; - BoolParam vertical_pattern; + BoolParam vertical_pattern; + PointParam width; + double height; + double original_height; + double prop_scale_previous; Geom::Piecewise > uskeleton; Geom::Piecewise > n; + Geom::PathVector hp; void on_pattern_pasted(); diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index ed65a0d50..5215f94ec 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -75,7 +75,11 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : vertical_pattern(_("Pattern is _vertical"), _("Rotate pattern 90 deg before applying"), "vertical_pattern", &wr, this, false), fuse_tolerance(_("_Fuse nearby ends:"), _("Fuse ends closer than this number. 0 means don't fuse."), - "fuse_tolerance", &wr, this, 0) + "fuse_tolerance", &wr, this, 0), + width(_("Width distance"), _("Change the width of pattern path - Ctrl+Alt+Click: reset"), "width", &wr, this), + height(0), + original_height(0), + prop_scale_previous(1) { registerParameter( dynamic_cast(&pattern) ); registerParameter( dynamic_cast(©type) ); @@ -87,7 +91,7 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&prop_units) ); registerParameter( dynamic_cast(&vertical_pattern) ); registerParameter( dynamic_cast(&fuse_tolerance) ); - + registerParameter( dynamic_cast(&width) ); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); } @@ -97,6 +101,48 @@ LPEPatternAlongPath::~LPEPatternAlongPath() } +void +LPEPatternAlongPath::doBeforeEffect (SPLPEItem const* lpeitem) +{ + hp.clear(); + // get the pattern bounding box + Geom::OptRect bbox = pattern.get_pathvector().boundsFast(); + if (bbox) { + original_height = (*bbox)[Geom::Y].max() - (*bbox)[Geom::Y].min(); + bool prop_scale_modified = false; + SPShape const *sp_shape = dynamic_cast(lpeitem); + if (sp_shape) { + Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); + Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); + Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); + Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0)); + Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); + Geom::Ray ray(ptA, B); + if (cubic) { + ray.setPoints((*cubic)[1], ptA); + } + if(height == 0){ + height = original_height; + width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA); + prop_scale.param_set_value(1); + } + if( prop_scale_previous != prop_scale ){ + prop_scale_modified = true; + } + height = Geom::distance(width,ptA) * 2; + if(!prop_scale_modified){ + prop_scale.param_set_value(height/original_height); + } + width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), ((original_height*prop_scale)/2.0)) + ptA); + width.param_update_default(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA); + prop_scale_previous = prop_scale; + Geom::Path hp_path(width); + hp_path.appendNew(ptA); + hp.push_back(hp_path); + } + } +} + Geom::Piecewise > LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise > const & pwd2_in) { @@ -238,6 +284,12 @@ LPEPatternAlongPath::transform_multiply(Geom::Affine const& postmul, bool set) } } +void +LPEPatternAlongPath::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec) +{ + hp_vec.push_back(hp); +} + } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h index be2197ddb..440c56548 100644 --- a/src/live_effects/lpe-patternalongpath.h +++ b/src/live_effects/lpe-patternalongpath.h @@ -13,6 +13,7 @@ #include "live_effects/effect.h" #include "live_effects/parameter/path.h" #include "live_effects/parameter/bool.h" +#include "live_effects/parameter/point.h" namespace Inkscape { namespace LivePathEffect { @@ -30,10 +31,15 @@ public: LPEPatternAlongPath(LivePathEffectObject *lpeobject); virtual ~LPEPatternAlongPath(); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); virtual void transform_multiply(Geom::Affine const& postmul, bool set); + void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec); + + PathParam pattern; private: EnumParam copytype; @@ -45,7 +51,11 @@ private: BoolParam prop_units; BoolParam vertical_pattern; ScalarParam fuse_tolerance; - + PointParam width; + double height; + double original_height; + double prop_scale_previous; + Geom::PathVector hp; void on_pattern_pasted(); LPEPatternAlongPath(const LPEPatternAlongPath&); -- cgit v1.2.3 From 7a19998853ca88c2ff03bcf7e0cbb049b693c106 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 5 Aug 2015 22:08:24 +0200 Subject: Fix bug on apply effect from pen/pencil toolbar (bzr r14272.1.2) --- src/live_effects/lpe-bendpath.cpp | 45 ++++++++++++++++++------------- src/live_effects/lpe-bendpath.h | 6 ++--- src/live_effects/lpe-patternalongpath.cpp | 41 ++++++++++++++++------------ src/live_effects/lpe-patternalongpath.h | 4 +-- 4 files changed, 55 insertions(+), 41 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 364c77ccb..4d72af38c 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -52,13 +52,13 @@ namespace LivePathEffect { LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) : Effect(lpeobject), bend_path(_("Bend path:"), _("Path along which to bend the original path"), "bendpath", &wr, this, "M0,0 L1,0"), - prop_scale(_("_Width:"), _("Width of the path"), "prop_scale", &wr, this, 1), + prop_scale(_("_Width:"), _("Width of the path"), "prop_scale", &wr, this, 1.0), + width(_("Width distance"), _("Change the width of bend path - Ctrl+Alt+Click: reset"), "width", &wr, this), scale_y_rel(_("W_idth in units of length"), _("Scale the width of the path in units of its length"), "scale_y_rel", &wr, this, false), vertical_pattern(_("_Original path is vertical"), _("Rotates the original 90 degrees, before bending it along the bend path"), "vertical", &wr, this, false), - width(_("Width distance"), _("Change the width of bend path - Ctrl+Alt+Click: reset"), "width", &wr, this), - height(0), - original_height(0), - prop_scale_previous(1) + height(0.0), + original_height(0.0), + prop_scale_from_widget(1.0) { registerParameter( dynamic_cast(&bend_path) ); registerParameter( dynamic_cast(&prop_scale) ); @@ -84,8 +84,6 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) // get the item bounding box original_bbox(lpeitem); original_height = boundingbox_Y.max() - boundingbox_Y.min(); - bool prop_scale_modified = false; - Geom::Path path_in = bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); Geom::Point ptA = path_in.pointAt(Geom::PathTime(0, 0.0)); Geom::Point B = path_in.pointAt(Geom::PathTime(1, 0.0)); @@ -95,20 +93,29 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) if (cubic) { ray.setPoints((*cubic)[1], ptA); } - if(height == 0){ + //This Hack is to fix a boring bug in the first call to the function, we have + //a wrong "ptA" + if(height == 0.0 && Geom::are_near(width, Geom::Point())){ + height = 0.1; + std::cout << ptA << "ptA0.5\n"; + } else if(height == 0.1 && Geom::are_near(width, Geom::Point())){ + Geom::Point default_point = Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA; + prop_scale.param_set_value(1.0); height = original_height; - width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA); - } - if( prop_scale_previous != prop_scale ){ - prop_scale_modified = true; - } - if(!prop_scale_modified){ - prop_scale.param_set_value(height/original_height); + width.param_setValue(default_point); + width.param_update_default(default_point); + } else { + double distance_knot = Geom::distance(width , ptA); + width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), distance_knot) + ptA); + height = distance_knot * 2; + if(prop_scale_from_widget == prop_scale){ + prop_scale.param_set_value(height/original_height); + } else { + height = original_height * prop_scale; + width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), height/2.0) + ptA); + } } - height = Geom::distance(width,ptA) * 2; - width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), ((original_height*prop_scale)/2.0)) + ptA); - width.param_update_default(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA); - prop_scale_previous = prop_scale; + prop_scale_from_widget = prop_scale; Geom::Path hp_path(width); hp_path.appendNew(ptA); hp.push_back(hp_path); diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 6394ce07e..cb9ced570 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -43,15 +43,15 @@ public: void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec); -private: PathParam bend_path; +private: ScalarParam prop_scale; + PointParam width; BoolParam scale_y_rel; BoolParam vertical_pattern; - PointParam width; double height; double original_height; - double prop_scale_previous; + double prop_scale_from_widget; Geom::Piecewise > uskeleton; Geom::Piecewise > n; diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 5215f94ec..53730d4d4 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -59,7 +59,8 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : pattern(_("Pattern source:"), _("Path to put along the skeleton path"), "pattern", &wr, this, "M0,0 L1,0"), copytype(_("Pattern copies:"), _("How many pattern copies to place along the skeleton path"), "copytype", PAPCopyTypeConverter, &wr, this, PAPCT_SINGLE_STRETCHED), - prop_scale(_("_Width:"), _("Width of the pattern"), "prop_scale", &wr, this, 1), + prop_scale(_("_Width:"), _("Width of the pattern"), "prop_scale", &wr, this, 1.0), + width(_("Width distance"), _("Change the width of pattern path - Ctrl+Alt+Click: reset"), "width", &wr, this), scale_y_rel(_("Wid_th in units of length"), _("Scale the width of the pattern in units of its length"), "scale_y_rel", &wr, this, false), @@ -76,10 +77,9 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : "vertical_pattern", &wr, this, false), fuse_tolerance(_("_Fuse nearby ends:"), _("Fuse ends closer than this number. 0 means don't fuse."), "fuse_tolerance", &wr, this, 0), - width(_("Width distance"), _("Change the width of pattern path - Ctrl+Alt+Click: reset"), "width", &wr, this), height(0), original_height(0), - prop_scale_previous(1) + prop_scale_from_widget(1) { registerParameter( dynamic_cast(&pattern) ); registerParameter( dynamic_cast(©type) ); @@ -109,7 +109,6 @@ LPEPatternAlongPath::doBeforeEffect (SPLPEItem const* lpeitem) Geom::OptRect bbox = pattern.get_pathvector().boundsFast(); if (bbox) { original_height = (*bbox)[Geom::Y].max() - (*bbox)[Geom::Y].min(); - bool prop_scale_modified = false; SPShape const *sp_shape = dynamic_cast(lpeitem); if (sp_shape) { Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); @@ -121,21 +120,29 @@ LPEPatternAlongPath::doBeforeEffect (SPLPEItem const* lpeitem) if (cubic) { ray.setPoints((*cubic)[1], ptA); } - if(height == 0){ + //This Hack is to fix a boring bug in the first call to the function, we have + //a wrong "ptA" + if(height == 0.0 && Geom::are_near(width, Geom::Point())){ + height = 0.1; + std::cout << ptA << "ptA0.5\n"; + } else if(height == 0.1 && Geom::are_near(width, Geom::Point())){ + Geom::Point default_point = Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA; + prop_scale.param_set_value(1.0); height = original_height; - width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA); - prop_scale.param_set_value(1); - } - if( prop_scale_previous != prop_scale ){ - prop_scale_modified = true; - } - height = Geom::distance(width,ptA) * 2; - if(!prop_scale_modified){ - prop_scale.param_set_value(height/original_height); + width.param_setValue(default_point); + width.param_update_default(default_point); + } else { + double distance_knot = Geom::distance(width , ptA); + width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), distance_knot) + ptA); + height = distance_knot * 2; + if(prop_scale_from_widget == prop_scale){ + prop_scale.param_set_value(height/original_height); + } else { + height = original_height * prop_scale; + width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), height/2.0) + ptA); + } } - width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), ((original_height*prop_scale)/2.0)) + ptA); - width.param_update_default(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA); - prop_scale_previous = prop_scale; + prop_scale_from_widget = prop_scale; Geom::Path hp_path(width); hp_path.appendNew(ptA); hp.push_back(hp_path); diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h index 440c56548..df0ae9777 100644 --- a/src/live_effects/lpe-patternalongpath.h +++ b/src/live_effects/lpe-patternalongpath.h @@ -44,6 +44,7 @@ public: private: EnumParam copytype; ScalarParam prop_scale; + PointParam width; BoolParam scale_y_rel; ScalarParam spacing; ScalarParam normal_offset; @@ -51,10 +52,9 @@ private: BoolParam prop_units; BoolParam vertical_pattern; ScalarParam fuse_tolerance; - PointParam width; double height; double original_height; - double prop_scale_previous; + double prop_scale_from_widget; Geom::PathVector hp; void on_pattern_pasted(); -- cgit v1.2.3 From c77df2a9ee1f988a2652528465ba5357a5e72ab2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 6 Aug 2015 02:24:34 +0200 Subject: fix a bug appliening from patheffect list the LPE (bzr r14272.1.5) --- src/live_effects/lpe-bendpath.cpp | 32 ++++++++++++++++++++++---------- src/live_effects/lpe-bendpath.h | 3 ++- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 4d72af38c..9b015245d 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -58,7 +58,9 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) : vertical_pattern(_("_Original path is vertical"), _("Rotates the original 90 degrees, before bending it along the bend path"), "vertical", &wr, this, false), height(0.0), original_height(0.0), - prop_scale_from_widget(1.0) + prop_scale_from_widget(1.0), + firstTime(false), + secondTime(false) { registerParameter( dynamic_cast(&bend_path) ); registerParameter( dynamic_cast(&prop_scale) ); @@ -91,28 +93,38 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); Geom::Ray ray(ptA, B); if (cubic) { - ray.setPoints((*cubic)[1], ptA); + ray.setPoints(ptA,(*cubic)[1]); } + + Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle(); //This Hack is to fix a boring bug in the first call to the function, we have //a wrong "ptA" - if(height == 0.0 && Geom::are_near(width, Geom::Point())){ - height = 0.1; - std::cout << ptA << "ptA0.5\n"; - } else if(height == 0.1 && Geom::are_near(width, Geom::Point())){ - Geom::Point default_point = Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA; + if(!firstTime && Geom::are_near(width, Geom::Point())){ + firstTime = true; + } else if(firstTime && Geom::are_near(width, Geom::Point())){ + Geom::Point default_point = Geom::Point::polar(first_curve_angle, original_height/2.0) + ptA; prop_scale.param_set_value(1.0); height = original_height; width.param_setValue(default_point); width.param_update_default(default_point); } else { double distance_knot = Geom::distance(width , ptA); - width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), distance_knot) + ptA); + width.param_setValue(Geom::Point::polar(first_curve_angle, distance_knot) + ptA); height = distance_knot * 2; - if(prop_scale_from_widget == prop_scale){ + if(secondTime){ + prop_scale.param_set_value(1); + height = original_height; + width.param_setValue(Geom::Point::polar(first_curve_angle, height/2.0) + ptA); + secondTime = false; + } else if(prop_scale_from_widget == prop_scale){ prop_scale.param_set_value(height/original_height); } else { height = original_height * prop_scale; - width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), height/2.0) + ptA); + width.param_setValue(Geom::Point::polar(first_curve_angle, height/2.0) + ptA); + } + if(firstTime){ + firstTime = false; + secondTime = true; } } prop_scale_from_widget = prop_scale; diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index a59d2322a..5d58f3320 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -53,7 +53,8 @@ private: double height; double original_height; double prop_scale_from_widget; - + bool firstTime; + bool secondTime; Geom::Piecewise > uskeleton; Geom::Piecewise > n; Geom::PathVector hp; -- cgit v1.2.3 From 7ffbb0399458946dfdbbd14438521ab52acf48a6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 7 Aug 2015 23:54:00 +0200 Subject: Full refactor of the LPE now too much simple code (bzr r14272.1.6) --- src/live_effects/lpe-bendpath.cpp | 120 ++++++++++++++++-------------- src/live_effects/lpe-bendpath.h | 18 ++--- src/live_effects/lpe-patternalongpath.cpp | 120 ++++++++++++++++++------------ src/live_effects/lpe-patternalongpath.h | 17 +++-- 4 files changed, 158 insertions(+), 117 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 9b015245d..d80f8e33a 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -20,7 +20,13 @@ #include <2geom/d2.h> #include <2geom/piecewise.h> +#include "knot-holder-entity.h" +#include "knotholder.h" + +#include + #include + using std::vector; @@ -48,29 +54,33 @@ first) but I think we can first forget about them. namespace Inkscape { namespace LivePathEffect { +Geom::PathVector bp_helper_path; +namespace BeP { +class KnotHolderEntityWidthBendPath : public LPEKnotHolderEntity { + public: + KnotHolderEntityWidthBendPath(LPEBendPath * effect) : LPEKnotHolderEntity(effect) {} + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; + }; +} // BeP LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) : Effect(lpeobject), bend_path(_("Bend path:"), _("Path along which to bend the original path"), "bendpath", &wr, this, "M0,0 L1,0"), + original_height(0.0), prop_scale(_("_Width:"), _("Width of the path"), "prop_scale", &wr, this, 1.0), - width(_("Width distance"), _("Change the width of bend path - Ctrl+Alt+Click: reset"), "width", &wr, this), scale_y_rel(_("W_idth in units of length"), _("Scale the width of the path in units of its length"), "scale_y_rel", &wr, this, false), - vertical_pattern(_("_Original path is vertical"), _("Rotates the original 90 degrees, before bending it along the bend path"), "vertical", &wr, this, false), - height(0.0), - original_height(0.0), - prop_scale_from_widget(1.0), - firstTime(false), - secondTime(false) + vertical_pattern(_("_Original path is vertical"), _("Rotates the original 90 degrees, before bending it along the bend path"), "vertical", &wr, this, false) { registerParameter( dynamic_cast(&bend_path) ); registerParameter( dynamic_cast(&prop_scale) ); registerParameter( dynamic_cast(&scale_y_rel) ); registerParameter( dynamic_cast(&vertical_pattern) ); - registerParameter( dynamic_cast(&width) ); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); + _provides_knotholder_entities = true; concatenate_before_pwd2 = true; } @@ -82,56 +92,11 @@ LPEBendPath::~LPEBendPath() void LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) { - hp.clear(); // get the item bounding box original_bbox(lpeitem); original_height = boundingbox_Y.max() - boundingbox_Y.min(); - Geom::Path path_in = bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); - Geom::Point ptA = path_in.pointAt(Geom::PathTime(0, 0.0)); - Geom::Point B = path_in.pointAt(Geom::PathTime(1, 0.0)); - Geom::Curve const *first_curve = &path_in.curveAt(Geom::PathTime(0, 0.0)); - Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); - Geom::Ray ray(ptA, B); - if (cubic) { - ray.setPoints(ptA,(*cubic)[1]); - } - - Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle(); - //This Hack is to fix a boring bug in the first call to the function, we have - //a wrong "ptA" - if(!firstTime && Geom::are_near(width, Geom::Point())){ - firstTime = true; - } else if(firstTime && Geom::are_near(width, Geom::Point())){ - Geom::Point default_point = Geom::Point::polar(first_curve_angle, original_height/2.0) + ptA; - prop_scale.param_set_value(1.0); - height = original_height; - width.param_setValue(default_point); - width.param_update_default(default_point); - } else { - double distance_knot = Geom::distance(width , ptA); - width.param_setValue(Geom::Point::polar(first_curve_angle, distance_knot) + ptA); - height = distance_knot * 2; - if(secondTime){ - prop_scale.param_set_value(1); - height = original_height; - width.param_setValue(Geom::Point::polar(first_curve_angle, height/2.0) + ptA); - secondTime = false; - } else if(prop_scale_from_widget == prop_scale){ - prop_scale.param_set_value(height/original_height); - } else { - height = original_height * prop_scale; - width.param_setValue(Geom::Point::polar(first_curve_angle, height/2.0) + ptA); - } - if(firstTime){ - firstTime = false; - secondTime = true; - } - } - prop_scale_from_widget = prop_scale; - Geom::Path hp_path(width); - hp_path.appendNew(ptA); - hp.push_back(hp_path); SPLPEItem * item = const_cast(lpeitem); + item->apply_to_clippath(item); item->apply_to_mask(item); } @@ -206,9 +171,54 @@ LPEBendPath::resetDefaults(SPItem const* item) void LPEBendPath::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec) { - hp_vec.push_back(hp); + hp_vec.push_back(bp_helper_path); } +void +LPEBendPath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) +{ + KnotHolderEntity *e = new BeP::KnotHolderEntityWidthBendPath(this); + e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Change the width"), SP_KNOT_SHAPE_CIRCLE); + knotholder->add(e); +} + +namespace BeP { + +void +KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const& /*origin*/, guint state) +{ + LPEBendPath *lpe = dynamic_cast (_effect); + + Geom::Point const s = snap_knot_position(p, state); + Geom::Path path_in = lpe->bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); + Geom::Point ptA = path_in.pointAt(Geom::PathTime(0, 0.0)); + lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); +} + +Geom::Point +KnotHolderEntityWidthBendPath::knot_get() const +{ + LPEBendPath *lpe = dynamic_cast (_effect); + + bp_helper_path.clear(); + Geom::Path path_in = lpe->bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); + Geom::Point ptA = path_in.pointAt(Geom::PathTime(0, 0.0)); + Geom::Point B = path_in.pointAt(Geom::PathTime(1, 0.0)); + Geom::Curve const *first_curve = &path_in.curveAt(Geom::PathTime(0, 0.0)); + Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); + Geom::Ray ray(ptA, B); + if (cubic) { + ray.setPoints(ptA,(*cubic)[1]); + } + Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle(); + Geom::Point result_point = Geom::Point::polar(first_curve_angle, (lpe->original_height * lpe->prop_scale)/2.0) + ptA; + Geom::Path hp_path(result_point); + hp_path.appendNew(ptA); + bp_helper_path.push_back(hp_path); + return result_point; +} +} // namespace BeP } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 5d58f3320..eeda86a5e 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -14,7 +14,6 @@ #include "live_effects/effect.h" #include "live_effects/parameter/path.h" #include "live_effects/parameter/bool.h" -#include "live_effects/parameter/point.h" #include <2geom/sbasis.h> #include <2geom/sbasis-geometric.h> @@ -28,6 +27,9 @@ namespace Inkscape { namespace LivePathEffect { +namespace BeP { +class KnotHolderEntityWidthBendPath; +} //for Bend path on group : we need information concerning the group Bounding box class LPEBendPath : public Effect, GroupBBoxEffect { @@ -43,21 +45,19 @@ public: void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec); + virtual void addKnotHolderEntities(KnotHolder * knotholder, SPDesktop * desktop, SPItem * item); + PathParam bend_path; -private: + friend class BeP::KnotHolderEntityWidthBendPath; +protected: + double original_height; ScalarParam prop_scale; - PointParam width; +private: BoolParam scale_y_rel; BoolParam vertical_pattern; - double height; - double original_height; - double prop_scale_from_widget; - bool firstTime; - bool secondTime; Geom::Piecewise > uskeleton; Geom::Piecewise > n; - Geom::PathVector hp; void on_pattern_pasted(); diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 53730d4d4..72e1892ef 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -18,6 +18,9 @@ #include <2geom/d2.h> #include <2geom/piecewise.h> +#include "knot-holder-entity.h" +#include "knotholder.h" + #include using std::vector; @@ -45,6 +48,16 @@ first) but I think we can first forget about them. namespace Inkscape { namespace LivePathEffect { +Geom::PathVector pap_helper_path; + +namespace WPAP { + class KnotHolderEntityWidthPatternAlongPath : public LPEKnotHolderEntity { + public: + KnotHolderEntityWidthPatternAlongPath(LPEPatternAlongPath * effect) : LPEKnotHolderEntity(effect) {} + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; + }; +} // WPAP static const Util::EnumData PAPCopyTypeData[PAPCT_END] = { {PAPCT_SINGLE, N_("Single"), "single"}, @@ -57,10 +70,10 @@ static const Util::EnumDataConverter PAPCopyTypeConverter(PAPCopyTy LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : Effect(lpeobject), pattern(_("Pattern source:"), _("Path to put along the skeleton path"), "pattern", &wr, this, "M0,0 L1,0"), + original_height(0), + prop_scale(_("_Width:"), _("Width of the pattern"), "prop_scale", &wr, this, 1.0), copytype(_("Pattern copies:"), _("How many pattern copies to place along the skeleton path"), "copytype", PAPCopyTypeConverter, &wr, this, PAPCT_SINGLE_STRETCHED), - prop_scale(_("_Width:"), _("Width of the pattern"), "prop_scale", &wr, this, 1.0), - width(_("Width distance"), _("Change the width of pattern path - Ctrl+Alt+Click: reset"), "width", &wr, this), scale_y_rel(_("Wid_th in units of length"), _("Scale the width of the pattern in units of its length"), "scale_y_rel", &wr, this, false), @@ -76,10 +89,7 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : vertical_pattern(_("Pattern is _vertical"), _("Rotate pattern 90 deg before applying"), "vertical_pattern", &wr, this, false), fuse_tolerance(_("_Fuse nearby ends:"), _("Fuse ends closer than this number. 0 means don't fuse."), - "fuse_tolerance", &wr, this, 0), - height(0), - original_height(0), - prop_scale_from_widget(1) + "fuse_tolerance", &wr, this, 0) { registerParameter( dynamic_cast(&pattern) ); registerParameter( dynamic_cast(©type) ); @@ -91,9 +101,11 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast(&prop_units) ); registerParameter( dynamic_cast(&vertical_pattern) ); registerParameter( dynamic_cast(&fuse_tolerance) ); - registerParameter( dynamic_cast(&width) ); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); + + _provides_knotholder_entities = true; + } LPEPatternAlongPath::~LPEPatternAlongPath() @@ -104,49 +116,10 @@ LPEPatternAlongPath::~LPEPatternAlongPath() void LPEPatternAlongPath::doBeforeEffect (SPLPEItem const* lpeitem) { - hp.clear(); // get the pattern bounding box Geom::OptRect bbox = pattern.get_pathvector().boundsFast(); if (bbox) { original_height = (*bbox)[Geom::Y].max() - (*bbox)[Geom::Y].min(); - SPShape const *sp_shape = dynamic_cast(lpeitem); - if (sp_shape) { - Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); - Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); - Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); - Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0)); - Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); - Geom::Ray ray(ptA, B); - if (cubic) { - ray.setPoints((*cubic)[1], ptA); - } - //This Hack is to fix a boring bug in the first call to the function, we have - //a wrong "ptA" - if(height == 0.0 && Geom::are_near(width, Geom::Point())){ - height = 0.1; - std::cout << ptA << "ptA0.5\n"; - } else if(height == 0.1 && Geom::are_near(width, Geom::Point())){ - Geom::Point default_point = Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), (original_height/2.0)) + ptA; - prop_scale.param_set_value(1.0); - height = original_height; - width.param_setValue(default_point); - width.param_update_default(default_point); - } else { - double distance_knot = Geom::distance(width , ptA); - width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), distance_knot) + ptA); - height = distance_knot * 2; - if(prop_scale_from_widget == prop_scale){ - prop_scale.param_set_value(height/original_height); - } else { - height = original_height * prop_scale; - width.param_setValue(Geom::Point::polar(ray.angle() + Geom::deg_to_rad(90), height/2.0) + ptA); - } - } - prop_scale_from_widget = prop_scale; - Geom::Path hp_path(width); - hp_path.appendNew(ptA); - hp.push_back(hp_path); - } } } @@ -294,9 +267,62 @@ LPEPatternAlongPath::transform_multiply(Geom::Affine const& postmul, bool set) void LPEPatternAlongPath::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec) { - hp_vec.push_back(hp); + hp_vec.push_back(pap_helper_path); } + +void +LPEPatternAlongPath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) +{ + KnotHolderEntity *e = new WPAP::KnotHolderEntityWidthPatternAlongPath(this); + e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Change the width"), SP_KNOT_SHAPE_CIRCLE); + knotholder->add(e); +} + +namespace WPAP { + +void +KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Point const& /*origin*/, guint state) +{ + LPEPatternAlongPath *lpe = dynamic_cast (_effect); + + Geom::Point const s = snap_knot_position(p, state); + SPShape const *sp_shape = dynamic_cast(SP_LPE_ITEM(item)); + if (sp_shape) { + Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); + Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); + lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + } + sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); +} + +Geom::Point +KnotHolderEntityWidthPatternAlongPath::knot_get() const +{ + LPEPatternAlongPath *lpe = dynamic_cast (_effect); + + SPShape const *sp_shape = dynamic_cast(SP_LPE_ITEM(item)); + if (sp_shape) { + pap_helper_path.clear(); + Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); + Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); + Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); + Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0)); + Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); + Geom::Ray ray(ptA, B); + if (cubic) { + ray.setPoints((*cubic)[1], ptA); + } + Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle(); + Geom::Point result_point = Geom::Point::polar(first_curve_angle, (lpe->original_height * lpe->prop_scale)/2.0) + ptA; + Geom::Path hp_path(result_point); + hp_path.appendNew(ptA); + pap_helper_path.push_back(hp_path); + return result_point; + } + return Geom::Point(); +} +} // namespace WPAP } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h index df0ae9777..3b9a17ab0 100644 --- a/src/live_effects/lpe-patternalongpath.h +++ b/src/live_effects/lpe-patternalongpath.h @@ -18,6 +18,10 @@ namespace Inkscape { namespace LivePathEffect { +namespace WPAP { +class KnotHolderEntityWidthPatternAlongPath; +} + enum PAPCopyType { PAPCT_SINGLE = 0, PAPCT_SINGLE_STRETCHED, @@ -39,12 +43,17 @@ public: void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec); + virtual void addKnotHolderEntities(KnotHolder * knotholder, SPDesktop * desktop, SPItem * item); PathParam pattern; + + friend class WPAP::KnotHolderEntityWidthPatternAlongPath; +protected: + double original_height; + ScalarParam prop_scale; + private: EnumParam copytype; - ScalarParam prop_scale; - PointParam width; BoolParam scale_y_rel; ScalarParam spacing; ScalarParam normal_offset; @@ -52,10 +61,6 @@ private: BoolParam prop_units; BoolParam vertical_pattern; ScalarParam fuse_tolerance; - double height; - double original_height; - double prop_scale_from_widget; - Geom::PathVector hp; void on_pattern_pasted(); LPEPatternAlongPath(const LPEPatternAlongPath&); -- cgit v1.2.3 From ec559a5dfe4b9ab24a9e8a0799fa490b70c1f0a4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 8 Aug 2015 12:28:31 +0200 Subject: minor changes (bzr r14272.1.10) --- src/live_effects/lpe-bendpath.cpp | 12 ++++++++---- src/live_effects/lpe-patternalongpath.cpp | 13 ++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index d80f8e33a..5c20a7f9e 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -193,6 +193,7 @@ KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const& Geom::Path path_in = lpe->bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); Geom::Point ptA = path_in.pointAt(Geom::PathTime(0, 0.0)); lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } @@ -201,7 +202,6 @@ KnotHolderEntityWidthBendPath::knot_get() const { LPEBendPath *lpe = dynamic_cast (_effect); - bp_helper_path.clear(); Geom::Path path_in = lpe->bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); Geom::Point ptA = path_in.pointAt(Geom::PathTime(0, 0.0)); Geom::Point B = path_in.pointAt(Geom::PathTime(1, 0.0)); @@ -213,9 +213,13 @@ KnotHolderEntityWidthBendPath::knot_get() const } Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle(); Geom::Point result_point = Geom::Point::polar(first_curve_angle, (lpe->original_height * lpe->prop_scale)/2.0) + ptA; - Geom::Path hp_path(result_point); - hp_path.appendNew(ptA); - bp_helper_path.push_back(hp_path); + + bp_helper_path.clear(); + Geom::Path hp(result_point); + hp.appendNew(ptA); + bp_helper_path.push_back(hp); + hp.clear(); + return result_point; } } // namespace BeP diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 72e1892ef..ed377e7f9 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -285,7 +285,7 @@ void KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Point const& /*origin*/, guint state) { LPEPatternAlongPath *lpe = dynamic_cast (_effect); - + Geom::Point const s = snap_knot_position(p, state); SPShape const *sp_shape = dynamic_cast(SP_LPE_ITEM(item)); if (sp_shape) { @@ -303,7 +303,6 @@ KnotHolderEntityWidthPatternAlongPath::knot_get() const SPShape const *sp_shape = dynamic_cast(SP_LPE_ITEM(item)); if (sp_shape) { - pap_helper_path.clear(); Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); @@ -315,9 +314,13 @@ KnotHolderEntityWidthPatternAlongPath::knot_get() const } Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle(); Geom::Point result_point = Geom::Point::polar(first_curve_angle, (lpe->original_height * lpe->prop_scale)/2.0) + ptA; - Geom::Path hp_path(result_point); - hp_path.appendNew(ptA); - pap_helper_path.push_back(hp_path); + + pap_helper_path.clear(); + Geom::Path hp(result_point); + hp.appendNew(ptA); + pap_helper_path.push_back(hp); + hp.clear(); + return result_point; } return Geom::Point(); -- cgit v1.2.3 From c784ad5d3cf8ba7d6ea82529757717cf62d9227e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 1 Sep 2015 23:08:41 +0200 Subject: Changed some strings to BSPLine widgets (bzr r14339) --- src/live_effects/lpe-bspline.cpp | 28 ++++++++++++++-------------- src/live_effects/lpe-bspline.h | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 08ef7ca1b..b17caa0f6 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -27,16 +27,16 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : Effect(lpeobject), steps(_("Steps with CTRL:"), _("Change number of steps with CTRL pressed"), "steps", &wr, this, 2), helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 0), - apply_cusp(_("Apply on cusp nodes"), _("Apply on cusp nodes"), "apply_cusp", &wr, this, true), - apply_non_cusp(_("Apply on non cusp nodes"), _("Apply on non cusp nodes"), "apply_non_cusp", &wr, this, true), + apply_no_weight(_("Apply changes if weight = 0%"), _("Apply changes if weight = 0%"), "apply_no_weight", &wr, this, true), + apply_with_weight(_("Apply changes if weight > 0%"), _("Apply changes if weight > 0%"), "apply_with_weight", &wr, this, true), only_selected(_("Change only selected nodes"), _("Change only selected nodes"), "only_selected", &wr, this, false), weight(_("Change weight %:"), _("Change weight percent of the effect"), "weight", &wr, this, DEFAULT_START_POWER * 100) { registerParameter(&weight); registerParameter(&steps); registerParameter(&helper_size); - registerParameter(&apply_cusp); - registerParameter(&apply_non_cusp); + registerParameter(&apply_no_weight); + registerParameter(&apply_with_weight); registerParameter(&only_selected); weight.param_set_range(NO_POWER, 100.0); @@ -116,7 +116,7 @@ Gtk::Widget *LPEBSpline::newWidget() entry_widget->set_width_chars(9); } } - if (param->param_key == "only_selected" || param->param_key == "apply_cusp" || param->param_key == "apply_non_cusp") { + if (param->param_key == "only_selected" || param->param_key == "apply_no_weight" || param->param_key == "apply_with_weight") { Gtk::CheckButton *widg_registered = Gtk::manage(dynamic_cast(widg)); widg = dynamic_cast(widg_registered); @@ -363,9 +363,9 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) point_at3 = in->first_segment()->finalPoint(); sbasis_in = in->first_segment()->toSBasis(); if (cubic) { - if ((apply_cusp && apply_non_cusp) || - (apply_cusp && Geom::are_near((*cubic)[1], point_at0)) || - (apply_non_cusp && !Geom::are_near((*cubic)[1], point_at0))) + if ((apply_no_weight && apply_with_weight) || + (apply_no_weight && Geom::are_near((*cubic)[1], point_at0)) || + (apply_with_weight && !Geom::are_near((*cubic)[1], point_at0))) { if (isNodePointSelected(point_at0) || !only_selected) { point_at1 = sbasis_in.valueAt(weight_ammount); @@ -379,9 +379,9 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) } else { point_at1 = (*cubic)[1]; } - if ((apply_cusp && apply_non_cusp) || - (apply_cusp && Geom::are_near((*cubic)[2], point_at3)) || - (apply_non_cusp && !Geom::are_near((*cubic)[2], point_at3))) + if ((apply_no_weight && apply_with_weight) || + (apply_no_weight && Geom::are_near((*cubic)[2], point_at3)) || + (apply_with_weight && !Geom::are_near((*cubic)[2], point_at3))) { if (isNodePointSelected(point_at3) || !only_selected) { point_at2 = sbasis_in.valueAt(1 - weight_ammount); @@ -396,9 +396,9 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) point_at2 = (*cubic)[2]; } } else { - if ((apply_cusp && apply_non_cusp) || - (apply_cusp && weight_ammount == NO_POWER) || - (apply_non_cusp && weight_ammount != NO_POWER)) + if ((apply_no_weight && apply_with_weight) || + (apply_no_weight && weight_ammount == NO_POWER) || + (apply_with_weight && weight_ammount != NO_POWER)) { if (isNodePointSelected(point_at0) || !only_selected) { point_at1 = sbasis_in.valueAt(weight_ammount); diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index b9cd336a9..7823f00f0 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -38,8 +38,8 @@ public: private: ScalarParam helper_size; - BoolParam apply_cusp; - BoolParam apply_non_cusp; + BoolParam apply_no_weight; + BoolParam apply_with_weight; BoolParam only_selected; ScalarParam weight; -- cgit v1.2.3 From 15b9bd1a8987237146b229f6d837d6327f22da19 Mon Sep 17 00:00:00 2001 From: jtx Date: Tue, 8 Sep 2015 18:37:44 +0200 Subject: fixes bug:1492704 in bspline Fixed bugs: - https://launchpad.net/bugs/1492704 (bzr r14347) --- src/live_effects/lpe-bspline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index b17caa0f6..b77de5cb1 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -140,7 +140,7 @@ Gtk::Widget *LPEBSpline::newWidget() void LPEBSpline::toDefaultWeight() { - changeWeight(DEFAULT_START_POWER); + changeWeight(DEFAULT_START_POWER * 100); } void LPEBSpline::toMakeCusp() -- cgit v1.2.3 From 8361587f222bbf3178fa3732607813b96bdf2909 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 8 Sep 2015 21:43:42 +0200 Subject: Fix a bug in BSpline on straight lines when press a default width button (bzr r14350) --- src/live_effects/lpe-bspline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index b77de5cb1..2b4a5c4a7 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -408,7 +408,7 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) point_at1 = in->first_segment()->initialPoint(); } if (isNodePointSelected(point_at3) || !only_selected) { - point_at2 = sbasis_in.valueAt(weight_ammount); + point_at2 = sbasis_in.valueAt(1 - weight_ammount); point_at2 = Geom::Point(point_at2[X] + HANDLE_CUBIC_GAP, point_at2[Y] + HANDLE_CUBIC_GAP); } else { -- cgit v1.2.3 From 602ccc3691b189bee118c08ec2982a6af93a4a3e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 8 Sep 2015 22:59:15 +0200 Subject: Fix for bug 1492711 Fixed bugs: - https://launchpad.net/bugs/1492711 (bzr r14351) --- src/live_effects/parameter/parameter.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/live_effects') diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 527bc06fe..70adc3084 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -11,6 +11,7 @@ #include "live_effects/effect.h" #include "svg/svg.h" #include "xml/repr.h" +#include "document-undo.h" #include "svg/stringstream.h" @@ -40,6 +41,8 @@ void Parameter::param_write_to_repr(const char * svgd) { param_effect->getRepr()->setAttribute(param_key.c_str(), svgd); + DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Updated value to scalar parameter")); } void Parameter::write_to_SVG(void) -- cgit v1.2.3 From 2c2ba3e0fe8c030229114e38aeadf8cf60acca75 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 9 Sep 2015 00:48:30 +0200 Subject: Better fix for bug 1492711 Fixed bugs: - https://launchpad.net/bugs/1492711 (bzr r14353) --- src/live_effects/parameter/parameter.cpp | 12 +++++++++--- src/live_effects/parameter/parameter.h | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 70adc3084..64464f200 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -41,8 +41,6 @@ void Parameter::param_write_to_repr(const char * svgd) { param_effect->getRepr()->setAttribute(param_key.c_str(), svgd); - DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - _("Updated value to scalar parameter")); } void Parameter::write_to_SVG(void) @@ -73,6 +71,7 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, ScalarParam::~ScalarParam() { + _value_changed_connection.disconnect(); } bool @@ -146,6 +145,13 @@ ScalarParam::param_make_integer(bool yes) inc_page = 10; } +void +ScalarParam::on_value_changed() +{ + DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, + _("Change scalar parameter")); +} + Gtk::Widget * ScalarParam::param_newWidget() { @@ -162,7 +168,7 @@ ScalarParam::param_newWidget() } rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); - + _value_changed_connection = rsu->signal_value_changed().connect (sigc::mem_fun (*this, &ScalarParam::on_value_changed)); return dynamic_cast (rsu); } diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index cc2c4f3d6..c24033c42 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -12,6 +12,7 @@ #include #include <2geom/forward.h> #include <2geom/pathvector.h> +#include // In gtk2, this wasn't an issue; we could toss around // G_MAXDOUBLE and not worry about size allocations. But @@ -111,6 +112,7 @@ public: virtual void param_set_default(); void param_set_value(gdouble val); void param_make_integer(bool yes = true); + void on_value_changed(); void param_set_range(gdouble min, gdouble max); void param_set_digits(unsigned digits); void param_set_increments(double step, double page); @@ -122,6 +124,7 @@ public: inline operator gdouble() const { return value; }; protected: + sigc::connection _value_changed_connection; gdouble value; gdouble min; gdouble max; -- cgit v1.2.3 From 9484c04f9676c7b6588f2918742c6cd08fd51f95 Mon Sep 17 00:00:00 2001 From: jtx Date: Fri, 11 Sep 2015 11:12:55 +0200 Subject: fixes bug:1492711 in bspline and fillet chamfer Fixed bugs: - https://launchpad.net/bugs/1492711 (bzr r14356) --- src/live_effects/lpe-bspline.cpp | 7 +++++++ src/live_effects/lpe-fillet-chamfer.cpp | 10 ++++++++++ src/live_effects/parameter/parameter.cpp | 16 +++++++--------- src/live_effects/parameter/parameter.h | 5 ++--- 4 files changed, 26 insertions(+), 12 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 2b4a5c4a7..731b5d645 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -10,6 +10,8 @@ #include "svg/svg.h" #include "xml/repr.h" #include "preferences.h" +#include "document-undo.h" +#include "verbs.h" // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -42,10 +44,12 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) weight.param_set_range(NO_POWER, 100.0); weight.param_set_increments(0.1, 0.1); weight.param_set_digits(4); + weight.param_overwrite_widget(true); steps.param_set_range(1, 10); steps.param_set_increments(1, 1); steps.param_set_digits(0); + steps.param_overwrite_widget(true); helper_size.param_set_range(0.0, 999.0); helper_size.param_set_increments(1, 1); @@ -141,16 +145,19 @@ Gtk::Widget *LPEBSpline::newWidget() void LPEBSpline::toDefaultWeight() { changeWeight(DEFAULT_START_POWER * 100); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change to default weight")); } void LPEBSpline::toMakeCusp() { changeWeight(NO_POWER); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change to 0 weight")); } void LPEBSpline::toWeight() { changeWeight(weight); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } void LPEBSpline::changeWeight(double weight_ammount) diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index a9a96864a..209805da3 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -76,12 +76,15 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : radius.param_set_range(0., infinity()); radius.param_set_increments(1, 1); radius.param_set_digits(4); + radius.param_overwrite_widget(true); chamfer_steps.param_set_range(1, 999); chamfer_steps.param_set_increments(1, 1); chamfer_steps.param_set_digits(0); + chamfer_steps.param_overwrite_widget(true); helper_size.param_set_range(0, infinity()); helper_size.param_set_increments(5, 5); helper_size.param_set_digits(0); + helper_size.param_overwrite_widget(true); fillet_chamfer_values.set_chamfer_steps(3); } @@ -226,18 +229,21 @@ void LPEFilletChamfer::updateFillet() } Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); doUpdateFillet(path_from_piecewise(pwd2, tolerance), power); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } void LPEFilletChamfer::fillet() { Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); doChangeType(path_from_piecewise(pwd2, tolerance), 1); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Convert to fillet")); } void LPEFilletChamfer::inverseFillet() { Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); doChangeType(path_from_piecewise(pwd2, tolerance), 2); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Convert to inverse fillet")); } void LPEFilletChamfer::chamferSubdivisions() @@ -245,6 +251,7 @@ void LPEFilletChamfer::chamferSubdivisions() fillet_chamfer_values.set_chamfer_steps(chamfer_steps); Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 5000); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } void LPEFilletChamfer::chamfer() @@ -252,6 +259,7 @@ void LPEFilletChamfer::chamfer() fillet_chamfer_values.set_chamfer_steps(chamfer_steps); Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 3000); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Convert to chamfer")); } void LPEFilletChamfer::inverseChamfer() @@ -259,6 +267,7 @@ void LPEFilletChamfer::inverseChamfer() fillet_chamfer_values.set_chamfer_steps(chamfer_steps); Piecewise > const &pwd2 = fillet_chamfer_values.get_pwd2(); doChangeType(path_from_piecewise(pwd2, tolerance), chamfer_steps + 4000); + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Convert to inverse fillet")); } void LPEFilletChamfer::refreshKnots() @@ -270,6 +279,7 @@ void LPEFilletChamfer::refreshKnots() tools_switch(desktop, TOOLS_SELECT); tools_switch(desktop, TOOLS_NODES); } + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Knots and helper paths refreshed")); } void LPEFilletChamfer::doUpdateFillet(Geom::PathVector const &original_pathv, double power) diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 64464f200..98aab287f 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -11,7 +11,6 @@ #include "live_effects/effect.h" #include "svg/svg.h" #include "xml/repr.h" -#include "document-undo.h" #include "svg/stringstream.h" @@ -65,13 +64,13 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, digits(2), inc_step(0.1), inc_page(1), - add_slider(false) + add_slider(false), + overwrite_widget(false) { } ScalarParam::~ScalarParam() { - _value_changed_connection.disconnect(); } bool @@ -146,10 +145,9 @@ ScalarParam::param_make_integer(bool yes) } void -ScalarParam::on_value_changed() +ScalarParam::param_overwrite_widget(bool overwrite_widget) { - DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, - _("Change scalar parameter")); + this->overwrite_widget = overwrite_widget; } Gtk::Widget * @@ -166,9 +164,9 @@ ScalarParam::param_newWidget() if (add_slider) { rsu->addSlider(); } - - rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); - _value_changed_connection = rsu->signal_value_changed().connect (sigc::mem_fun (*this, &ScalarParam::on_value_changed)); + if(!overwrite_widget){ + rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); + } return dynamic_cast (rsu); } diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index c24033c42..8cda42a8e 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -12,7 +12,6 @@ #include #include <2geom/forward.h> #include <2geom/pathvector.h> -#include // In gtk2, this wasn't an issue; we could toss around // G_MAXDOUBLE and not worry about size allocations. But @@ -112,19 +111,18 @@ public: virtual void param_set_default(); void param_set_value(gdouble val); void param_make_integer(bool yes = true); - void on_value_changed(); void param_set_range(gdouble min, gdouble max); void param_set_digits(unsigned digits); void param_set_increments(double step, double page); void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; + void param_overwrite_widget(bool overwrite_widget); virtual Gtk::Widget * param_newWidget(); inline operator gdouble() const { return value; }; protected: - sigc::connection _value_changed_connection; gdouble value; gdouble min; gdouble max; @@ -134,6 +132,7 @@ protected: double inc_step; double inc_page; bool add_slider; + bool overwrite_widget; private: ScalarParam(const ScalarParam&); -- cgit v1.2.3 From 288eceeafde73ce1ad21a9f8c38d13072cb805be Mon Sep 17 00:00:00 2001 From: jtx Date: Thu, 17 Sep 2015 16:15:55 +0200 Subject: Improvements to transform by two knots pointed by Ivan Louette (bzr r14375) --- src/live_effects/lpe-transform_2pts.cpp | 76 ++++++++++++++++++++++++++++----- src/live_effects/lpe-transform_2pts.h | 4 ++ 2 files changed, 70 insertions(+), 10 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index 79ffd74de..8326bd6f1 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -19,7 +19,8 @@ #include "sp-path.h" #include "ui/icon-names.h" #include "svg/svg.h" - +#include "verbs.h" +// TODO due to internal breakage in glibmm headers, this must be last: #include namespace Inkscape { @@ -31,8 +32,12 @@ LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : from_original_width(_("From original width"), _("From original width"), "from_original_width", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), lock_lenght(_("Lock lenght"), _("Lock lenght to current distance"), "lock_lenght", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), lock_angle(_("Lock angle"), _("Lock angle"), "lock_angle", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), + flip_horizontal(_("Flip horizontal"), _("Flip horizontal"), "flip_horizontal", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), + flip_vertical(_("Flip vertical"), _("Flip vertical"), "flip_vertical", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), start(_("Start"), _("Start point"), "start", &wr, this, "Start point"), end(_("End"), _("End point"), "end", &wr, this, "End point"), + strech(_("Strech"), _("Strech the result"), "strech", &wr, this, 1), + offset(_("Offset"), _("Offset from knots"), "offset", &wr, this, 0), first_knot(_("First Knot"), _("First Knot"), "first_knot", &wr, this, 1), last_knot(_("Last Knot"), _("Last Knot"), "last_knot", &wr, this, 1), helper_size(_("Helper size:"), _("Rotation helper size"), "helper_size", &wr, this, 3), @@ -45,21 +50,34 @@ LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : previous_start(Geom::Point()), previous_lenght(-1) { - registerParameter(&start); - registerParameter(&end); + registerParameter(&first_knot); registerParameter(&last_knot); registerParameter(&helper_size); + registerParameter(&strech); + registerParameter(&offset); + registerParameter(&start); + registerParameter(&end); registerParameter(&elastic); registerParameter(&from_original_width); + registerParameter(&flip_vertical); + registerParameter(&flip_horizontal); registerParameter(&lock_lenght); registerParameter(&lock_angle); first_knot.param_make_integer(true); + first_knot.param_overwrite_widget(true); last_knot.param_make_integer(true); + last_knot.param_overwrite_widget(true); helper_size.param_set_range(0, 999); helper_size.param_set_increments(1, 1); helper_size.param_set_digits(0); + offset.param_set_range(-999999.0, 999999.0); + offset.param_set_increments(1, 1); + offset.param_set_digits(2); + strech.param_set_range(0, 999.0); + strech.param_set_increments(0.01, 0.01); + strech.param_set_digits(4); } LPETransform2Pts::~LPETransform2Pts() @@ -176,6 +194,7 @@ LPETransform2Pts::updateIndex() start.param_set_default(); end.param_set_default(); } + DocumentUndo::done(getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change index of knot")); } //todo migrate to PathVector class? size_t @@ -259,6 +278,7 @@ Gtk::Widget *LPETransform2Pts::newWidget() Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0)); Gtk::HBox * button2 = Gtk::manage(new Gtk::HBox(true,0)); Gtk::HBox * button3 = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::HBox * button4 = Gtk::manage(new Gtk::HBox(true,0)); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { Parameter *param = *it; @@ -292,7 +312,7 @@ Gtk::Widget *LPETransform2Pts::newWidget() widg->set_has_tooltip(false); } } - } else if (param->param_key == "lock_angle" || param->param_key == "lock_lenght") { + } else if (param->param_key == "flip_horizontal" || param->param_key == "flip_vertical") { Glib::ustring * tip = param->param_getTooltip(); if (widg) { button2->pack_start(*widg, true, true, 2); @@ -303,6 +323,17 @@ Gtk::Widget *LPETransform2Pts::newWidget() widg->set_has_tooltip(false); } } + } else if (param->param_key == "lock_angle" || param->param_key == "lock_lenght") { + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + button3->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } } else if (widg) { vbox->pack_start(*widg, true, true, 2); if (tip) { @@ -318,10 +349,11 @@ Gtk::Widget *LPETransform2Pts::newWidget() } Gtk::Button *reset = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); reset->signal_clicked().connect(sigc::mem_fun(*this, &LPETransform2Pts::reset)); - button3->pack_start(*reset, true, true, 2); + button4->pack_start(*reset, true, true, 2); vbox->pack_start(*button1, true, true, 2); vbox->pack_start(*button2, true, true, 2); vbox->pack_start(*button3, true, true, 2); + vbox->pack_start(*button4, true, true, 2); return dynamic_cast(vbox); } @@ -337,8 +369,26 @@ LPETransform2Pts::doEffect_pwd2 (Geom::Piecewise > const helper.start(point_a); helper.appendNew(point_b); Geom::Affine m; + Geom::Angle original_angle = original.angle(); + if(flip_horizontal && flip_vertical){ + m *= Geom::Rotate(-original_angle); + m *= Geom::Scale(-1,-1); + m *= Geom::Rotate(original_angle); + } else if(flip_vertical){ + m *= Geom::Rotate(-original_angle); + m *= Geom::Scale(1,-1); + m *= Geom::Rotate(original_angle); + } else if(flip_horizontal){ + m *= Geom::Rotate(-original_angle); + m *= Geom::Scale(-1,1); + m *= Geom::Rotate(original_angle); + } + if(strech != 1){ + m *= Geom::Rotate(-original_angle); + m *= Geom::Scale(1,strech); + m *= Geom::Rotate(original_angle); + } if(elastic) { - Geom::Angle original_angle = original.angle(); m *= Geom::Rotate(-original_angle); if(sca > 1){ m *= Geom::Scale(sca, 1.0); @@ -346,14 +396,20 @@ LPETransform2Pts::doEffect_pwd2 (Geom::Piecewise > const m *= Geom::Scale(sca, 1.0-((1.0-sca)/2.0)); } m *= Geom::Rotate(transformed.angle()); - helper *= m; - m *= Geom::Translate((Geom::Point)start - helper.initialPoint()); } else { m *= Geom::Scale(sca); m *= Geom::Rotate(rot); - helper *= m; - m *= Geom::Translate((Geom::Point)start - helper.initialPoint()); } + helper *= m; + Geom::Point trans = (Geom::Point)start - helper.initialPoint(); + if(flip_horizontal){ + trans = (Geom::Point)end - helper.initialPoint(); + } + if(offset != 0){ + trans = Geom::Point::polar(transformed.angle() + Geom::deg_to_rad(-90),offset) + trans; + } + m *= Geom::Translate(trans); + output.concat(pwd2_in * m); return output; diff --git a/src/live_effects/lpe-transform_2pts.h b/src/live_effects/lpe-transform_2pts.h index 947243c82..c20d56206 100644 --- a/src/live_effects/lpe-transform_2pts.h +++ b/src/live_effects/lpe-transform_2pts.h @@ -53,8 +53,12 @@ private: ToggleButtonParam from_original_width; ToggleButtonParam lock_lenght; ToggleButtonParam lock_angle; + ToggleButtonParam flip_horizontal; + ToggleButtonParam flip_vertical; PointParam start; PointParam end; + ScalarParam strech; + ScalarParam offset; ScalarParam first_knot; ScalarParam last_knot; ScalarParam helper_size; -- cgit v1.2.3 From af1bbe5ddd52aef9e74a778006b01b3a0e249e5d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 13 Oct 2015 12:11:48 +0200 Subject: Fix position node splited Added parameter to Symm move nodes, Todo:Get better english strings (bzr r14407) --- src/live_effects/lpe-roughen.cpp | 125 +++++++++++++++++++++++++++++++++------ src/live_effects/lpe-roughen.h | 7 ++- 2 files changed, 111 insertions(+), 21 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 33ffd96d6..108b34a26 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -49,8 +49,10 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) "global_randomize", &wr, this, 1.), shift_nodes(_("Shift nodes"), _("Shift nodes"), "shift_nodes", &wr, this, true), - shift_node_handles(_("Shift node handles"), _("Shift node handles"), - "shift_node_handles", &wr, this, true) + shift_handles(_("Shift node handles"), _("Shift node handles"), + "shift_handles", &wr, this, true), + shift_handles_sym(_("Sym shift node handles"), _("Sym shift node handles"), + "shift_handles_sym", &wr, this, false) { registerParameter(&method); registerParameter(&max_segment_size); @@ -59,7 +61,8 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) registerParameter(&displace_y); registerParameter(&global_randomize); registerParameter(&shift_nodes); - registerParameter(&shift_node_handles); + registerParameter(&shift_handles); + registerParameter(&shift_handles_sym); displace_x.param_set_range(0., Geom::infinity()); displace_y.param_set_range(0., Geom::infinity()); global_randomize.param_set_range(0., Geom::infinity()); @@ -170,6 +173,7 @@ void LPERoughen::doEffect(SPCurve *curve) Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); Geom::Path::const_iterator curve_endit = path_it->end_default(); SPCurve *nCurve = new SPCurve(); + Geom::Point prev(0, 0); if (path_it->closed()) { const Geom::Curve &closingline = path_it->back_closed(); @@ -212,18 +216,26 @@ void LPERoughen::doEffect(SPCurve *curve) } else { splits = ceil(length / max_segment_size); } - for (unsigned int t = splits; t >= 1; t--) { - if (t == 1 && splits != 1) { + Geom::Curve const * original = nCurve->last_segment()->duplicate() ; + for (unsigned int t = 1; t <= splits; t++) { + if(t == splits && splits != 1){ continue; } - const SPCurve *tmp; + SPCurve const * tmp; if (splits == 1) { tmp = jitter(nCurve->last_segment()); } else { - tmp = addNodesAndJitter(nCurve->last_segment(), 1. / t); + bool last = false; + if(t == splits-1){ + last = true; + } + double time = Geom::nearest_time(original->pointAt((1. / (double)splits) * t), *nCurve->last_segment()); + tmp = addNodesAndJitter(nCurve->last_segment(), prev, time, last); } if (nCurve->get_segment_count() > 1) { - nCurve->backspace(); + if(t!= splits){ + nCurve->backspace(); + } nCurve->append_continuous(tmp, 0.001); } else { nCurve = tmp->copy(); @@ -237,6 +249,27 @@ void LPERoughen::doEffect(SPCurve *curve) first = false; } if (path_it->closed()) { + if(shift_handles_sym && curve_it2 == curve_endit){ + SPCurve *out = new SPCurve(); + nCurve = nCurve->create_reverse(); + Geom::CubicBezier const *cubic_start = dynamic_cast(nCurve->first_segment()); + Geom::CubicBezier const *cubic = dynamic_cast(nCurve->last_segment()); + Geom::Point oposite = nCurve->first_segment()->initialPoint(); + if(cubic_start){ + Geom::Ray ray((*cubic_start)[1], (*cubic_start)[0]); + double dist = Geom::distance((*cubic_start)[1], (*cubic_start)[0]); + oposite = Geom::Point::polar(ray.angle(),dist) + (*cubic_start)[0]; + } + if(cubic){ + out->moveto((*cubic)[0]); + out->curveto((*cubic)[1], oposite, (*cubic)[3]); + } else { + out->moveto(nCurve->last_segment()->initialPoint()); + out->curveto(nCurve->last_segment()->initialPoint(), oposite, nCurve->last_segment()->finalPoint()); + } + nCurve->backspace(); + nCurve->append_continuous(out, 0.001); + } nCurve->closepath_current(); } curve->append(nCurve, false); @@ -245,7 +278,7 @@ void LPERoughen::doEffect(SPCurve *curve) } } -SPCurve *LPERoughen::addNodesAndJitter(const Geom::Curve *A, double t) +SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, double t, bool last) { SPCurve *out = new SPCurve(); Geom::CubicBezier const *cubic = dynamic_cast(&*A); @@ -259,38 +292,94 @@ SPCurve *LPERoughen::addNodesAndJitter(const Geom::Curve *A, double t) point3 = randomize(); point_b3 = randomize(); } - if (shift_node_handles) { + if (shift_handles && !shift_handles_sym) { point1 = randomize(); point2 = randomize(); point_b1 = randomize(); point_b2 = randomize(); - } else { + } else if(shift_handles_sym) { + Geom::Ray ray(prev,A->initialPoint()); + double dist = Geom::distance(prev, A->initialPoint()); + point1 = Geom::Point::polar(ray.angle(),dist) + A->initialPoint(); + if(prev==Geom::Point(0,0)){ + point1 = A->pointAt(t / 3) + randomize(); + } + point2 = A->pointAt((t / 3) * 2) + randomize(); + Geom::Ray ray2(point2, point3); + double dist2 = Geom::distance(point2, point3); + point_b1 = Geom::Point::polar(ray2.angle(),dist2) + point3; + point1 = point1 - A->pointAt(t / 3); + point2 = point2 - A->pointAt((t / 3) * 2); + point_b1 = randomize(); + point_b2 = randomize(); + }else { point2 = point3; point_b1 = point3; point_b2 = point_b3; } - if (cubic) { + if(shift_handles_sym && cubic) { + std::pair div = cubic->subdivide(t); + std::vector seg1 = div.first.controlPoints(), + seg2 = div.second.controlPoints(); + out->moveto(seg1[0]); + Geom::Ray ray(prev,A->initialPoint()); + double dist = Geom::distance(seg1[1], A->initialPoint()); + point1 = Geom::Point::polar(ray.angle(),dist) + A->initialPoint(); + point2 = seg1[2] + point2; + point3 = seg1[3] + point3; + if(prev==Geom::Point(0,0)){ + point1 = seg1[1] + randomize(); + } + out->curveto(point1, point2, point3); + + Geom::Ray ray2(point2, point3); + double dist2 = Geom::distance(seg2[1], point3); + point_b1 = Geom::Point::polar(ray2.angle(),dist2) + point3; + point_b2 = seg2[2]; + out->curveto(point_b1, point_b2, seg2[3]); + } else if(shift_handles_sym && !cubic) { + out->moveto(A->initialPoint()); + Geom::Ray ray(prev,A->initialPoint()); + double dist = Geom::distance(A->pointAt(t / 3) + randomize(), A->initialPoint()); + point1 = Geom::Point::polar(ray.angle(),dist) + A->initialPoint(); + point2 = A->pointAt((t / 3) * 2) + point2; + point3 = A->pointAt(t) + point3; + if(prev==Geom::Point(0,0)){ + point1 = A->pointAt(t / 3) + randomize(); + } + out->curveto(point1, point2, point3); + Geom::Ray ray2(point2, point3); + double dist2 = Geom::distance(A->pointAt(t + ((t / 3) * 2)) + point_b2, point3); + point_b1 = Geom::Point::polar(ray2.angle(),dist2) + point3; + point_b2 = A->pointAt(t + ((t / 3) * 2)) + point_b2; + out->curveto(point_b1, point_b2, A->finalPoint()); + } else if (cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); out->moveto(seg1[0]); out->curveto(seg1[1] + point1, seg1[2] + point2, seg1[3] + point3); out->curveto(seg2[1] + point_b1, seg2[2], seg2[3]); - } else if (shift_node_handles) { + } else if (shift_handles) { out->moveto(A->initialPoint()); out->curveto(A->pointAt(t / 3) + point1, A->pointAt((t / 3) * 2) + point2, A->pointAt(t) + point3); - out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t + ((t / 3) * 2)), - A->finalPoint()); + out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t + ((t / 3) * 2)) + point_b2, + A->finalPoint()); } else { out->moveto(A->initialPoint()); out->lineto(A->pointAt(t) + point3); out->lineto(A->finalPoint()); } + if(last){ + prev = point_b2; + } else { + prev = point2; + } return out; } -SPCurve *LPERoughen::jitter(const Geom::Curve *A) +SPCurve *LPERoughen::jitter(Geom::Curve const * A) { SPCurve *out = new SPCurve(); Geom::CubicBezier const *cubic = dynamic_cast(&*A); @@ -300,7 +389,7 @@ SPCurve *LPERoughen::jitter(const Geom::Curve *A) if (shift_nodes) { point3 = randomize(); } - if (shift_node_handles) { + if (shift_handles) { point1 = randomize(); point2 = randomize(); } else { @@ -309,7 +398,7 @@ SPCurve *LPERoughen::jitter(const Geom::Curve *A) if (cubic) { out->moveto((*cubic)[0]); out->curveto((*cubic)[1] + point1, (*cubic)[2] + point2, (*cubic)[3] + point3); - } else if (shift_node_handles) { + } else if (shift_handles) { out->moveto(A->initialPoint()); out->curveto(A->pointAt(0.3333) + point1, A->pointAt(0.6666) + point2, A->finalPoint() + point3); diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index 2b285cd40..8241cedca 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -38,8 +38,8 @@ public: virtual double sign(double randNumber); virtual Geom::Point randomize(); virtual void doBeforeEffect(SPLPEItem const * lpeitem); - virtual SPCurve *addNodesAndJitter(const Geom::Curve *A, double t); - virtual SPCurve *jitter(const Geom::Curve *A); + virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, double t, bool last); + virtual SPCurve *jitter(Geom::Curve const * A); virtual Geom::Point tPoint(Geom::Point A, Geom::Point B, double t = 0.5); virtual Gtk::Widget *newWidget(); @@ -51,7 +51,8 @@ private: RandomParam displace_y; RandomParam global_randomize; BoolParam shift_nodes; - BoolParam shift_node_handles; + BoolParam shift_handles; + BoolParam shift_handles_sym; LPERoughen(const LPERoughen &); LPERoughen &operator=(const LPERoughen &); -- cgit v1.2.3 From f886fd682e7e4ea2622fbb523dc3a14ba75569a3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 13 Oct 2015 22:09:54 +0200 Subject: Added a parameter to roughen LPE to allow fixed displacement of points (bzr r14408) --- src/live_effects/lpe-roughen.cpp | 235 +++++++++++++++++++++------------------ src/live_effects/lpe-roughen.h | 5 +- 2 files changed, 127 insertions(+), 113 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 108b34a26..6f24c288d 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -52,7 +52,9 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) shift_handles(_("Shift node handles"), _("Shift node handles"), "shift_handles", &wr, this, true), shift_handles_sym(_("Sym shift node handles"), _("Sym shift node handles"), - "shift_handles_sym", &wr, this, false) + "shift_handles_sym", &wr, this, false), + fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment lenght"), + "fixed_displacement", &wr, this, false) { registerParameter(&method); registerParameter(&max_segment_size); @@ -63,6 +65,7 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) registerParameter(&shift_nodes); registerParameter(&shift_handles); registerParameter(&shift_handles_sym); + registerParameter(&fixed_displacement); displace_x.param_set_range(0., Geom::infinity()); displace_y.param_set_range(0., Geom::infinity()); global_randomize.param_set_range(0., Geom::infinity()); @@ -150,12 +153,15 @@ double LPERoughen::sign(double random_number) return random_number; } -Geom::Point LPERoughen::randomize() +Geom::Point LPERoughen::randomize(double max_lenght) { double displace_x_parsed = displace_x * global_randomize; double displace_y_parsed = displace_y * global_randomize; - Geom::Point output = Geom::Point(sign(displace_x_parsed), sign(displace_y_parsed)); + if( fixed_displacement ){ + Geom::Ray ray(Geom::Point(0,0),output); + output = Geom::Point::polar(ray.angle(), max_lenght); + } return output; } @@ -181,33 +187,24 @@ void LPERoughen::doEffect(SPCurve *curve) curve_endit = path_it->end_open(); } } - Geom::Point initialMove(0, 0); - if (shift_nodes) { - initialMove = randomize(); - } - Geom::Point initialPoint = curve_it1->initialPoint() + initialMove; - nCurve->moveto(initialPoint); + nCurve->moveto(curve_it1->initialPoint()); Geom::Point point0(0, 0); - Geom::Point point1(0, 0); - Geom::Point point2(0, 0); - Geom::Point point3(0, 0); - bool first = true; + Geom::Point point_a1(0, 0); + Geom::Point point_a2(0, 0); + Geom::Point point_a3(0, 0); while (curve_it1 != curve_endit) { Geom::CubicBezier const *cubic = NULL; point0 = curve_it1->initialPoint(); - point1 = curve_it1->initialPoint(); - point2 = curve_it1->finalPoint(); - point3 = curve_it1->finalPoint(); + point_a1 = curve_it1->initialPoint(); + point_a2 = curve_it1->finalPoint(); + point_a3 = curve_it1->finalPoint(); cubic = dynamic_cast(&*curve_it1); if (cubic) { - point1 = (*cubic)[1]; - if (shift_nodes && first) { - point1 = (*cubic)[1] + initialMove; - } - point2 = (*cubic)[2]; - nCurve->curveto(point1, point2, point3); + point_a1 = (*cubic)[1]; + point_a2 = (*cubic)[2]; + nCurve->curveto(point_a1, point_a2, point_a3); } else { - nCurve->lineto(point3); + nCurve->lineto(point_a3); } double length = curve_it1->length(0.001); std::size_t splits = 0; @@ -223,7 +220,7 @@ void LPERoughen::doEffect(SPCurve *curve) } SPCurve const * tmp; if (splits == 1) { - tmp = jitter(nCurve->last_segment()); + tmp = jitter(nCurve->last_segment(), prev); } else { bool last = false; if(t == splits-1){ @@ -233,9 +230,7 @@ void LPERoughen::doEffect(SPCurve *curve) tmp = addNodesAndJitter(nCurve->last_segment(), prev, time, last); } if (nCurve->get_segment_count() > 1) { - if(t!= splits){ - nCurve->backspace(); - } + nCurve->backspace(); nCurve->append_continuous(tmp, 0.001); } else { nCurve = tmp->copy(); @@ -246,7 +241,6 @@ void LPERoughen::doEffect(SPCurve *curve) if(curve_it2 != curve_endit) { ++curve_it2; } - first = false; } if (path_it->closed()) { if(shift_handles_sym && curve_it2 == curve_endit){ @@ -254,7 +248,7 @@ void LPERoughen::doEffect(SPCurve *curve) nCurve = nCurve->create_reverse(); Geom::CubicBezier const *cubic_start = dynamic_cast(nCurve->first_segment()); Geom::CubicBezier const *cubic = dynamic_cast(nCurve->last_segment()); - Geom::Point oposite = nCurve->first_segment()->initialPoint(); + Geom::Point oposite = nCurve->first_segment()->pointAt(1.0/3.0); if(cubic_start){ Geom::Ray ray((*cubic_start)[1], (*cubic_start)[0]); double dist = Geom::distance((*cubic_start)[1], (*cubic_start)[0]); @@ -269,7 +263,9 @@ void LPERoughen::doEffect(SPCurve *curve) } nCurve->backspace(); nCurve->append_continuous(out, 0.001); + nCurve = nCurve->create_reverse(); } + nCurve->move_endpoints(nCurve->last_segment()->finalPoint(), nCurve->last_segment()->finalPoint()); nCurve->closepath_current(); } curve->append(nCurve, false); @@ -282,129 +278,146 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point { SPCurve *out = new SPCurve(); Geom::CubicBezier const *cubic = dynamic_cast(&*A); - Geom::Point point1(0, 0); - Geom::Point point2(0, 0); - Geom::Point point3(0, 0); + double max_lenght = Geom::distance(A->initialPoint(),A->pointAt(t)) / 3.0; + Geom::Point point_a1(0, 0); + Geom::Point point_a2(0, 0); + Geom::Point point_a3(0, 0); Geom::Point point_b1(0, 0); Geom::Point point_b2(0, 0); Geom::Point point_b3(0, 0); if (shift_nodes) { - point3 = randomize(); - point_b3 = randomize(); + point_a3 = randomize(max_lenght); + if(last){ + point_b3 = randomize(max_lenght); + } } - if (shift_handles && !shift_handles_sym) { - point1 = randomize(); - point2 = randomize(); - point_b1 = randomize(); - point_b2 = randomize(); - } else if(shift_handles_sym) { - Geom::Ray ray(prev,A->initialPoint()); - double dist = Geom::distance(prev, A->initialPoint()); - point1 = Geom::Point::polar(ray.angle(),dist) + A->initialPoint(); - if(prev==Geom::Point(0,0)){ - point1 = A->pointAt(t / 3) + randomize(); + if (shift_handles || shift_handles_sym) { + point_a1 = randomize(max_lenght); + point_a2 = randomize(max_lenght); + point_b1 = randomize(max_lenght); + if(last){ + point_b2 = randomize(max_lenght); + } + } else { + point_a2 = point_a3; + point_b1 = point_a3; + if(last){ + point_b2 = point_b3; } - point2 = A->pointAt((t / 3) * 2) + randomize(); - Geom::Ray ray2(point2, point3); - double dist2 = Geom::distance(point2, point3); - point_b1 = Geom::Point::polar(ray2.angle(),dist2) + point3; - point1 = point1 - A->pointAt(t / 3); - point2 = point2 - A->pointAt((t / 3) * 2); - point_b1 = randomize(); - point_b2 = randomize(); - }else { - point2 = point3; - point_b1 = point3; - point_b2 = point_b3; } if(shift_handles_sym && cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); - out->moveto(seg1[0]); Geom::Ray ray(prev,A->initialPoint()); - double dist = Geom::distance(seg1[1], A->initialPoint()); - point1 = Geom::Point::polar(ray.angle(),dist) + A->initialPoint(); - point2 = seg1[2] + point2; - point3 = seg1[3] + point3; - if(prev==Geom::Point(0,0)){ - point1 = seg1[1] + randomize(); + point_a1 = Geom::Point::polar(ray.angle(), max_lenght); + if(prev == Geom::Point(0,0)){ + point_a1 = randomize(max_lenght); + } + if(last){ + prev = A->pointAt(1 - (t / 3)) + point_b2; + } else { + point_b3 = Geom::Point(0,0); + point_b2 = Geom::Point(0,0); + } + Geom::Ray ray2(seg2[1] + point_b1, seg1[3] + point_a3); + point_a2 = Geom::Point::polar(ray2.angle(), max_lenght); + if(!last){ + prev = seg1[3] + point_a3 + point_a2; + } + out->moveto(seg1[0]); + out->curveto(seg1[0] + point_a1, seg1[3] + point_a3 + point_a2, seg1[3] + point_a3); + if(last){ + out->curveto(seg2[1] + point_b1, A->pointAt(1 - (t / 3)) + point_b2, seg2[3] + point_b3); + } else { + out->curveto(seg2[1] + point_b1, seg2[2] + point_b2, seg2[3] + point_b3); } - out->curveto(point1, point2, point3); - - Geom::Ray ray2(point2, point3); - double dist2 = Geom::distance(seg2[1], point3); - point_b1 = Geom::Point::polar(ray2.angle(),dist2) + point3; - point_b2 = seg2[2]; - out->curveto(point_b1, point_b2, seg2[3]); } else if(shift_handles_sym && !cubic) { - out->moveto(A->initialPoint()); Geom::Ray ray(prev,A->initialPoint()); - double dist = Geom::distance(A->pointAt(t / 3) + randomize(), A->initialPoint()); - point1 = Geom::Point::polar(ray.angle(),dist) + A->initialPoint(); - point2 = A->pointAt((t / 3) * 2) + point2; - point3 = A->pointAt(t) + point3; + point_a1 = Geom::Point::polar(ray.angle(), max_lenght); if(prev==Geom::Point(0,0)){ - point1 = A->pointAt(t / 3) + randomize(); + point_a1 = randomize(max_lenght); + } + if(last){ + prev = A->pointAt(1 - (t / 3)) + point_b2; + } else { + point_b3 = Geom::Point(0,0); + point_b2 = Geom::Point(0,0); + } + Geom::Ray ray2(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t) + point_a3); + point_a2 = Geom::Point::polar(ray2.angle(), max_lenght); + if(!last){ + prev = A->pointAt((t / 3) * 2) + point_a2; + } + out->moveto(A->initialPoint()); + out->curveto(A->initialPoint() + point_a1, A->pointAt(t) + point_a3 + point_a2, A->pointAt(t) + point_a3); + if(last){ + out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(1 - (t / 3)) + point_b2, A->finalPoint() + point_b3); + } else { + out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2, A->finalPoint() + point_b3); } - out->curveto(point1, point2, point3); - Geom::Ray ray2(point2, point3); - double dist2 = Geom::distance(A->pointAt(t + ((t / 3) * 2)) + point_b2, point3); - point_b1 = Geom::Point::polar(ray2.angle(),dist2) + point3; - point_b2 = A->pointAt(t + ((t / 3) * 2)) + point_b2; - out->curveto(point_b1, point_b2, A->finalPoint()); } else if (cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); out->moveto(seg1[0]); - out->curveto(seg1[1] + point1, seg1[2] + point2, seg1[3] + point3); - out->curveto(seg2[1] + point_b1, seg2[2], seg2[3]); + out->curveto(seg1[1] + point_a1, seg1[2] + point_a2, seg1[3] + point_a3); + out->curveto(seg2[1] + point_b1, seg2[2] + point_b2, seg2[3] + point_b3); } else if (shift_handles) { out->moveto(A->initialPoint()); - out->curveto(A->pointAt(t / 3) + point1, A->pointAt((t / 3) * 2) + point2, - A->pointAt(t) + point3); - out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t + ((t / 3) * 2)) + point_b2, - A->finalPoint()); + out->curveto(A->pointAt(t / 3) + point_a1, A->pointAt((t / 3) * 2) + point_a2, A->pointAt(t) + point_a3); + out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2, A->finalPoint() + point_b3); } else { out->moveto(A->initialPoint()); - out->lineto(A->pointAt(t) + point3); - out->lineto(A->finalPoint()); - } - if(last){ - prev = point_b2; - } else { - prev = point2; + out->lineto(A->pointAt(t) + point_a3); + out->lineto(A->finalPoint() + point_b3); } return out; } -SPCurve *LPERoughen::jitter(Geom::Curve const * A) +SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev) { SPCurve *out = new SPCurve(); Geom::CubicBezier const *cubic = dynamic_cast(&*A); - Geom::Point point1(0, 0); - Geom::Point point2(0, 0); - Geom::Point point3(0, 0); + double max_lenght = Geom::distance(A->initialPoint(),A->finalPoint()) / 3.0; + Geom::Point point_a1(0, 0); + Geom::Point point_a2(0, 0); + Geom::Point point_a3(0, 0); if (shift_nodes) { - point3 = randomize(); + point_a3 = randomize(max_lenght); } - if (shift_handles) { - point1 = randomize(); - point2 = randomize(); - } else { - point2 = point3; + if (shift_handles || shift_handles_sym) { + point_a1 = randomize(max_lenght); + point_a2 = randomize(max_lenght); } - if (cubic) { + if(shift_handles_sym && cubic) { + Geom::Ray ray(prev,A->initialPoint()); + point_a1 = Geom::Point::polar(ray.angle(), max_lenght); + if(prev == Geom::Point(0,0)){ + point_a1 = A->pointAt(1.0/3.0) + randomize(max_lenght); + } + prev = (*cubic)[2] + point_a2; + out->moveto((*cubic)[0]); + out->curveto((*cubic)[0] + point_a1, (*cubic)[2] + point_a2, (*cubic)[3] + point_a3); + } else if(shift_handles_sym && !cubic) { + Geom::Ray ray(prev,A->initialPoint()); + point_a1 = Geom::Point::polar(ray.angle(), max_lenght); + if(prev==Geom::Point(0,0)){ + point_a1 = A->pointAt(1.0/3.0) + randomize(max_lenght); + } + prev = A->pointAt((1.0/3.0) * 2) + point_a2; + out->moveto(A->initialPoint()); + out->curveto(A->initialPoint() + point_a1, A->pointAt((1.0/3.0) * 2) + point_a2, A->finalPoint() + point_a3); + } else if (cubic) { out->moveto((*cubic)[0]); - out->curveto((*cubic)[1] + point1, (*cubic)[2] + point2, (*cubic)[3] + point3); + out->curveto((*cubic)[1] + point_a1, (*cubic)[2] + point_a2, (*cubic)[3] + point_a3); } else if (shift_handles) { out->moveto(A->initialPoint()); - out->curveto(A->pointAt(0.3333) + point1, A->pointAt(0.6666) + point2, - A->finalPoint() + point3); + out->curveto(A->pointAt(0.3333) + point_a1, A->pointAt(0.6666) + point_a2, + A->finalPoint() + point_a3); } else { out->moveto(A->initialPoint()); - out->lineto(A->finalPoint() + point3); + out->lineto(A->finalPoint() + point_a3); } return out; } diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index 8241cedca..e221e95fb 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -36,10 +36,10 @@ public: virtual void doEffect(SPCurve *curve); virtual double sign(double randNumber); - virtual Geom::Point randomize(); + virtual Geom::Point randomize(double max_lenght); virtual void doBeforeEffect(SPLPEItem const * lpeitem); virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, double t, bool last); - virtual SPCurve *jitter(Geom::Curve const * A); + virtual SPCurve *jitter(Geom::Curve const * A, Geom::Point &prev); virtual Geom::Point tPoint(Geom::Point A, Geom::Point B, double t = 0.5); virtual Gtk::Widget *newWidget(); @@ -53,6 +53,7 @@ private: BoolParam shift_nodes; BoolParam shift_handles; BoolParam shift_handles_sym; + BoolParam fixed_displacement; LPERoughen(const LPERoughen &); LPERoughen &operator=(const LPERoughen &); -- cgit v1.2.3 From d6926d4ffcd9fdf0c1e69fb3bf9397eac0f54f81 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 14 Oct 2015 20:42:56 +0200 Subject: improved results of roughen LPE (bzr r14410) --- src/live_effects/lpe-roughen.cpp | 44 ++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 6f24c288d..dec3f955f 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -314,23 +314,19 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - if(last){ - prev = A->pointAt(1 - (t / 3)) + point_b2; - } else { - point_b3 = Geom::Point(0,0); - point_b2 = Geom::Point(0,0); - } - Geom::Ray ray2(seg2[1] + point_b1, seg1[3] + point_a3); - point_a2 = Geom::Point::polar(ray2.angle(), max_lenght); + ray.setPoints(seg2[1] + point_a3 + point_b1, seg1[3] + point_a3); + point_a2 = Geom::Point::polar(ray.angle(), max_lenght); if(!last){ prev = seg1[3] + point_a3 + point_a2; + } else { + prev = A->pointAt(1 - (t / 3)) + point_b2 + point_b3; } out->moveto(seg1[0]); - out->curveto(seg1[0] + point_a1, seg1[3] + point_a3 + point_a2, seg1[3] + point_a3); + out->curveto(seg1[0] + point_a1, seg1[2] + point_a3 + point_a2, seg1[3] + point_a3); if(last){ - out->curveto(seg2[1] + point_b1, A->pointAt(1 - (t / 3)) + point_b2, seg2[3] + point_b3); + out->curveto(seg2[1] + point_a3 + point_b1, A->pointAt(1 - (t / 3)) + point_b2 + point_b3, seg2[3] + point_b3); } else { - out->curveto(seg2[1] + point_b1, seg2[2] + point_b2, seg2[3] + point_b3); + out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); } } else if(shift_handles_sym && !cubic) { Geom::Ray ray(prev,A->initialPoint()); @@ -338,35 +334,31 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point if(prev==Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - if(last){ - prev = A->pointAt(1 - (t / 3)) + point_b2; - } else { - point_b3 = Geom::Point(0,0); - point_b2 = Geom::Point(0,0); - } - Geom::Ray ray2(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t) + point_a3); - point_a2 = Geom::Point::polar(ray2.angle(), max_lenght); + ray.setPoints(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3); + point_a2 = Geom::Point::polar(ray.angle(), max_lenght); if(!last){ prev = A->pointAt((t / 3) * 2) + point_a2; + } else { + prev = A->pointAt(1 - (t / 3)) + point_b2 + point_b3; } out->moveto(A->initialPoint()); - out->curveto(A->initialPoint() + point_a1, A->pointAt(t) + point_a3 + point_a2, A->pointAt(t) + point_a3); + out->curveto(A->initialPoint() + point_a1, A->pointAt((t / 3) * 2) + point_a3 + point_a2, A->pointAt(t) + point_a3); if(last){ - out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(1 - (t / 3)) + point_b2, A->finalPoint() + point_b3); + out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(1 - (t / 3)) + point_b2 + point_b3, A->finalPoint() + point_b3); } else { - out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2, A->finalPoint() + point_b3); + out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); } } else if (cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); out->moveto(seg1[0]); - out->curveto(seg1[1] + point_a1, seg1[2] + point_a2, seg1[3] + point_a3); - out->curveto(seg2[1] + point_b1, seg2[2] + point_b2, seg2[3] + point_b3); + out->curveto(seg1[1] + point_a1, seg1[2] + point_a2 + point_a3, seg1[3] + point_a3); + out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); } else if (shift_handles) { out->moveto(A->initialPoint()); - out->curveto(A->pointAt(t / 3) + point_a1, A->pointAt((t / 3) * 2) + point_a2, A->pointAt(t) + point_a3); - out->curveto(A->pointAt(t + (t / 3)) + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2, A->finalPoint() + point_b3); + out->curveto(A->pointAt(t / 3) + point_a1, A->pointAt((t / 3) * 2) + point_a2 + point_a3, A->pointAt(t) + point_a3); + out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); } else { out->moveto(A->initialPoint()); out->lineto(A->pointAt(t) + point_a3); -- cgit v1.2.3 From f8a67994cf1d608c6f14e7c41497b62f4a402392 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 15 Oct 2015 17:15:00 +0200 Subject: Bug fixes in roughen and added uption to retract handles (bzr r14418) --- src/live_effects/lpe-roughen.cpp | 82 ++++++++++++++++++---------------------- src/live_effects/lpe-roughen.h | 1 + 2 files changed, 38 insertions(+), 45 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index dec3f955f..ed1ddcaf8 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -51,6 +51,8 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) true), shift_handles(_("Shift node handles"), _("Shift node handles"), "shift_handles", &wr, this, true), + retract_handles(_("Retract node handles"), _("Retract node handles"), + "retract_handles", &wr, this, false), shift_handles_sym(_("Sym shift node handles"), _("Sym shift node handles"), "shift_handles_sym", &wr, this, false), fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment lenght"), @@ -64,6 +66,7 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) registerParameter(&global_randomize); registerParameter(&shift_nodes); registerParameter(&shift_handles); + registerParameter(&retract_handles); registerParameter(&shift_handles_sym); registerParameter(&fixed_displacement); displace_x.param_set_range(0., Geom::infinity()); @@ -167,8 +170,7 @@ Geom::Point LPERoughen::randomize(double max_lenght) void LPERoughen::doEffect(SPCurve *curve) { - Geom::PathVector const original_pathv = - pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); + Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); curve->reset(); for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { @@ -180,31 +182,14 @@ void LPERoughen::doEffect(SPCurve *curve) Geom::Path::const_iterator curve_endit = path_it->end_default(); SPCurve *nCurve = new SPCurve(); Geom::Point prev(0, 0); - if (path_it->closed()) { - const Geom::Curve &closingline = - path_it->back_closed(); - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - curve_endit = path_it->end_open(); - } - } nCurve->moveto(curve_it1->initialPoint()); - Geom::Point point0(0, 0); - Geom::Point point_a1(0, 0); - Geom::Point point_a2(0, 0); - Geom::Point point_a3(0, 0); while (curve_it1 != curve_endit) { Geom::CubicBezier const *cubic = NULL; - point0 = curve_it1->initialPoint(); - point_a1 = curve_it1->initialPoint(); - point_a2 = curve_it1->finalPoint(); - point_a3 = curve_it1->finalPoint(); cubic = dynamic_cast(&*curve_it1); if (cubic) { - point_a1 = (*cubic)[1]; - point_a2 = (*cubic)[2]; - nCurve->curveto(point_a1, point_a2, point_a3); + nCurve->curveto((*cubic)[1], (*cubic)[2], curve_it1->finalPoint()); } else { - nCurve->lineto(point_a3); + nCurve->lineto(curve_it1->finalPoint()); } double length = curve_it1->length(0.001); std::size_t splits = 0; @@ -238,12 +223,10 @@ void LPERoughen::doEffect(SPCurve *curve) delete tmp; } ++curve_it1; - if(curve_it2 != curve_endit) { - ++curve_it2; - } + ++curve_it2; } if (path_it->closed()) { - if(shift_handles_sym && curve_it2 == curve_endit){ + if(shift_handles_sym && curve_it1 == curve_endit && !retract_handles){ SPCurve *out = new SPCurve(); nCurve = nCurve->create_reverse(); Geom::CubicBezier const *cubic_start = dynamic_cast(nCurve->first_segment()); @@ -305,7 +288,17 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point point_b2 = point_b3; } } - if(shift_handles_sym && cubic) { + if(retract_handles){ + out->moveto(A->initialPoint()); + out->lineto(A->pointAt(t) + point_a3); + if(cubic && !last){ + std::pair div = cubic->subdivide(t); + std::vector seg2 = div.second.controlPoints(); + out->curveto(seg2[1], seg2[2], seg2[3]); + } else { + out->lineto(A->finalPoint() + point_b3); + } + } else if(shift_handles_sym && cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); @@ -314,15 +307,15 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - ray.setPoints(seg2[1] + point_a3 + point_b1, seg1[3] + point_a3); + ray.setPoints(seg2[1] + point_a3 + point_b1, seg2[0] + point_a3); point_a2 = Geom::Point::polar(ray.angle(), max_lenght); - if(!last){ - prev = seg1[3] + point_a3 + point_a2; - } else { + if(last){ prev = A->pointAt(1 - (t / 3)) + point_b2 + point_b3; + } else { + prev = seg1[3] + point_a2 + point_a3; } out->moveto(seg1[0]); - out->curveto(seg1[0] + point_a1, seg1[2] + point_a3 + point_a2, seg1[3] + point_a3); + out->curveto(seg1[0] + point_a1, seg1[3] + point_a2 + point_a3, seg1[3] + point_a3); if(last){ out->curveto(seg2[1] + point_a3 + point_b1, A->pointAt(1 - (t / 3)) + point_b2 + point_b3, seg2[3] + point_b3); } else { @@ -336,18 +329,14 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point } ray.setPoints(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3); point_a2 = Geom::Point::polar(ray.angle(), max_lenght); - if(!last){ - prev = A->pointAt((t / 3) * 2) + point_a2; - } else { - prev = A->pointAt(1 - (t / 3)) + point_b2 + point_b3; - } - out->moveto(A->initialPoint()); - out->curveto(A->initialPoint() + point_a1, A->pointAt((t / 3) * 2) + point_a3 + point_a2, A->pointAt(t) + point_a3); if(last){ - out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(1 - (t / 3)) + point_b2 + point_b3, A->finalPoint() + point_b3); + prev = A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3; } else { - out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); + prev = A->pointAt(t) + point_a3 + point_a2; } + out->moveto(A->initialPoint()); + out->curveto(A->initialPoint() + point_a1, A->pointAt(t) + point_a3 + point_a2, A->pointAt(t) + point_a3); + out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); } else if (cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), @@ -382,7 +371,10 @@ SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev) point_a1 = randomize(max_lenght); point_a2 = randomize(max_lenght); } - if(shift_handles_sym && cubic) { + if(retract_handles){ + out->moveto(A->initialPoint()); + out->lineto(A->finalPoint() + point_a3); + } else if(shift_handles_sym && cubic) { Geom::Ray ray(prev,A->initialPoint()); point_a1 = Geom::Point::polar(ray.angle(), max_lenght); if(prev == Geom::Point(0,0)){ @@ -390,7 +382,7 @@ SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev) } prev = (*cubic)[2] + point_a2; out->moveto((*cubic)[0]); - out->curveto((*cubic)[0] + point_a1, (*cubic)[2] + point_a2, (*cubic)[3] + point_a3); + out->curveto((*cubic)[0] + point_a1, (*cubic)[2] + point_a2 + point_a3, (*cubic)[3] + point_a3); } else if(shift_handles_sym && !cubic) { Geom::Ray ray(prev,A->initialPoint()); point_a1 = Geom::Point::polar(ray.angle(), max_lenght); @@ -399,13 +391,13 @@ SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev) } prev = A->pointAt((1.0/3.0) * 2) + point_a2; out->moveto(A->initialPoint()); - out->curveto(A->initialPoint() + point_a1, A->pointAt((1.0/3.0) * 2) + point_a2, A->finalPoint() + point_a3); + out->curveto(A->initialPoint() + point_a1, A->pointAt((1.0/3.0) * 2) + point_a2 + point_a3, A->finalPoint() + point_a3); } else if (cubic) { out->moveto((*cubic)[0]); - out->curveto((*cubic)[1] + point_a1, (*cubic)[2] + point_a2, (*cubic)[3] + point_a3); + out->curveto((*cubic)[1] + point_a1, (*cubic)[2] + point_a2 + point_a3, (*cubic)[3] + point_a3); } else if (shift_handles) { out->moveto(A->initialPoint()); - out->curveto(A->pointAt(0.3333) + point_a1, A->pointAt(0.6666) + point_a2, + out->curveto(A->pointAt(0.3333) + point_a1, A->pointAt(0.6666) + point_a2 + point_a3, A->finalPoint() + point_a3); } else { out->moveto(A->initialPoint()); diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index e221e95fb..57a516310 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -52,6 +52,7 @@ private: RandomParam global_randomize; BoolParam shift_nodes; BoolParam shift_handles; + BoolParam retract_handles; BoolParam shift_handles_sym; BoolParam fixed_displacement; -- cgit v1.2.3 From 7d224d1cf9bfb0d6555721c24c06ebed11b1b15f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 18 Oct 2015 21:13:13 +0200 Subject: Added "Spray Friendly" Parameter to roughen LPE Adds, but not used by the moment a extra parameter to bool and scalar LPE parameter to hide the widget. This allow to store scalar values and bool values inside the LPEObject to intermediate use by the LPE, whithout disturbing to the user. (bzr r14420) --- src/live_effects/lpe-roughen.cpp | 23 +++++++++++++++++--- src/live_effects/lpe-roughen.h | 1 + src/live_effects/parameter/bool.cpp | 32 +++++++++++++++------------ src/live_effects/parameter/bool.h | 4 +++- src/live_effects/parameter/parameter.cpp | 37 ++++++++++++++++++-------------- src/live_effects/parameter/parameter.h | 4 +++- 6 files changed, 66 insertions(+), 35 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index ed1ddcaf8..136190b8f 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -18,6 +18,7 @@ #include "live_effects/lpe-roughen.h" #include "display/curve.h" #include "live_effects/parameter/parameter.h" +#include #include "helper/geom.h" #include #include @@ -56,7 +57,9 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) shift_handles_sym(_("Sym shift node handles"), _("Sym shift node handles"), "shift_handles_sym", &wr, this, false), fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment lenght"), - "fixed_displacement", &wr, this, false) + "fixed_displacement", &wr, this, false), + spray_tool_friendly(_("Spray Tool friendly"), _("For use with spray tool"), + "spray_tool_friendly", &wr, this, false) { registerParameter(&method); registerParameter(&max_segment_size); @@ -69,6 +72,7 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) registerParameter(&retract_handles); registerParameter(&shift_handles_sym); registerParameter(&fixed_displacement); + registerParameter(&spray_tool_friendly); displace_x.param_set_range(0., Geom::infinity()); displace_y.param_set_range(0., Geom::infinity()); global_randomize.param_set_range(0., Geom::infinity()); @@ -86,7 +90,12 @@ void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) { displace_x.resetRandomizer(); displace_y.resetRandomizer(); - global_randomize.resetRandomizer(); + if(!spray_tool_friendly){ + global_randomize.resetRandomizer(); + } else { + boost::hash string_hash; + global_randomize.param_set_value(global_randomize.get_value(), static_cast(string_hash(lpeitem->getId()))); + } srand(1); SPLPEItem * item = const_cast(lpeitem); item->apply_to_clippath(item); @@ -131,6 +140,15 @@ Gtk::Widget *LPERoughen::newWidget() vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET); } + if (param->param_key == "shift_nodes") { + Gtk::Label *options = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Options Modify options to rough")), + Gtk::ALIGN_START)); + options->set_use_markup(true); + vbox->pack_start(*options, false, false, 2); + vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), + Gtk::PACK_EXPAND_WIDGET); + } Glib::ustring *tip = param->param_getTooltip(); if (widg) { vbox->pack_start(*widg, true, true, 2); @@ -142,7 +160,6 @@ Gtk::Widget *LPERoughen::newWidget() } } } - ++it; } return dynamic_cast(vbox); diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index 57a516310..178c3b657 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -55,6 +55,7 @@ private: BoolParam retract_handles; BoolParam shift_handles_sym; BoolParam fixed_displacement; + BoolParam spray_tool_friendly; LPERoughen(const LPERoughen &); LPERoughen &operator=(const LPERoughen &); diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index c1e8f8a7b..9ecadbdeb 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -21,8 +21,8 @@ namespace LivePathEffect { BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, bool default_value ) - : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value) + Effect* effect, bool default_value , bool no_widget) + : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value), hide_widget(no_widget) { } @@ -53,20 +53,24 @@ BoolParam::param_getSVGValue() const Gtk::Widget * BoolParam::param_newWidget() { - Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredCheckButton( param_label, - param_tooltip, - param_key, - *param_wr, - false, - param_effect->getRepr(), - param_effect->getSPDoc()) ); + if(!hide_widget){ + Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( + new Inkscape::UI::Widget::RegisteredCheckButton( param_label, + param_tooltip, + param_key, + *param_wr, + false, + param_effect->getRepr(), + param_effect->getSPDoc()) ); - checkwdg->setActive(value); - checkwdg->setProgrammatically = false; - checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter")); + checkwdg->setActive(value); + checkwdg->setProgrammatically = false; + checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter")); - return dynamic_cast (checkwdg); + return dynamic_cast (checkwdg); + } else { + return NULL; + } } void diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index b45eeb0b3..403dd0b87 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -25,7 +25,8 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - bool default_value = false); + bool default_value = false, + bool no_widget = false); virtual ~BoolParam(); virtual Gtk::Widget * param_newWidget(); @@ -46,6 +47,7 @@ private: bool value; bool defvalue; + bool hide_widget; }; diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 98aab287f..d4e213948 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -54,7 +54,7 @@ void Parameter::write_to_SVG(void) */ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, gdouble default_value) + Effect* effect, gdouble default_value, bool no_widget) : Parameter(label, tip, key, wr, effect), value(default_value), min(-SCALARPARAM_G_MAXDOUBLE), @@ -65,7 +65,8 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, inc_step(0.1), inc_page(1), add_slider(false), - overwrite_widget(false) + overwrite_widget(false), + hide_widget(no_widget) { } @@ -153,21 +154,25 @@ ScalarParam::param_overwrite_widget(bool overwrite_widget) Gtk::Widget * ScalarParam::param_newWidget() { - Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( - param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); - - rsu->setValue(value); - rsu->setDigits(digits); - rsu->setIncrements(inc_step, inc_page); - rsu->setRange(min, max); - rsu->setProgrammatically = false; - if (add_slider) { - rsu->addSlider(); - } - if(!overwrite_widget){ - rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); + if(!hide_widget){ + Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( + param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); + + rsu->setValue(value); + rsu->setDigits(digits); + rsu->setIncrements(inc_step, inc_page); + rsu->setRange(min, max); + rsu->setProgrammatically = false; + if (add_slider) { + rsu->addSlider(); + } + if(!overwrite_widget){ + rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); + } + return dynamic_cast (rsu); + } else { + return NULL; } - return dynamic_cast (rsu); } void diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 8cda42a8e..0ef28650a 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -102,7 +102,8 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - gdouble default_value = 1.0); + gdouble default_value = 1.0, + bool no_widget = false); virtual ~ScalarParam(); virtual bool param_readSVGValue(const gchar * strvalue); @@ -133,6 +134,7 @@ protected: double inc_page; bool add_slider; bool overwrite_widget; + bool hide_widget; private: ScalarParam(const ScalarParam&); -- cgit v1.2.3 From 58dd8e4f061599778f4c6d8c958b13f0fc99f06f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Oct 2015 11:13:44 +0200 Subject: Change oprions of handles to a enum widget Add parameter to limit angle in mode smooth Bug fixes and improvements to "Spray Friendly" option (bzr r14421) --- src/live_effects/lpe-roughen.cpp | 135 ++++++++++++++++++++++++++++----------- src/live_effects/lpe-roughen.h | 22 +++++-- 2 files changed, 113 insertions(+), 44 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 136190b8f..d40d549a7 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -33,13 +33,22 @@ static const Util::EnumData DivisionMethodData[DM_END] = { static const Util::EnumDataConverter DMConverter(DivisionMethodData, DM_END); +static const Util::EnumData HandlesMethodData[HM_END] = { + { HM_ALONG_NODES, N_("Along nodes"), "along" }, + { HM_RAND, N_("Rand"), "rand" }, + { HM_RETRACT, N_("Retract"), "retract" }, + { HM_SMOOTH, N_("Smooth"), "smooth" } +}; +static const Util::EnumDataConverter +HMConverter(HandlesMethodData, HM_END); + LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: method(_("Method"), _("Division method"), "method", DMConverter, &wr, this, DM_SEGMENTS), max_segment_size(_("Max. segment size"), _("Max. segment size"), - "max_segment_size", &wr, this, 10.), + "max_segment_size", &wr, this, 10), segments(_("Number of segments"), _("Number of segments"), "segments", &wr, this, 2), displace_x(_("Max. displacement in X"), _("Max. displacement in X"), @@ -48,14 +57,12 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) "displace_y", &wr, this, 10.), global_randomize(_("Global randomize"), _("Global randomize"), "global_randomize", &wr, this, 1.), + handles(_("Handles"), _("Handles options"), "handles", HMConverter, &wr, + this, HM_ALONG_NODES), + max_smooth_angle(_("Max. smooth handle angle"), _("Max. smooth handle angle"), + "max_smooth_angle", &wr, this, 20), shift_nodes(_("Shift nodes"), _("Shift nodes"), "shift_nodes", &wr, this, true), - shift_handles(_("Shift node handles"), _("Shift node handles"), - "shift_handles", &wr, this, true), - retract_handles(_("Retract node handles"), _("Retract node handles"), - "retract_handles", &wr, this, false), - shift_handles_sym(_("Sym shift node handles"), _("Sym shift node handles"), - "shift_handles_sym", &wr, this, false), fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment lenght"), "fixed_displacement", &wr, this, false), spray_tool_friendly(_("Spray Tool friendly"), _("For use with spray tool"), @@ -67,10 +74,9 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) registerParameter(&displace_x); registerParameter(&displace_y); registerParameter(&global_randomize); + registerParameter(&handles); + registerParameter(&max_smooth_angle); registerParameter(&shift_nodes); - registerParameter(&shift_handles); - registerParameter(&retract_handles); - registerParameter(&shift_handles_sym); registerParameter(&fixed_displacement); registerParameter(&spray_tool_friendly); displace_x.param_set_range(0., Geom::infinity()); @@ -82,20 +88,24 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) segments.param_set_range(1, Geom::infinity()); segments.param_set_increments(1, 1); segments.param_set_digits(0); + max_smooth_angle.param_set_range(0, 359); + max_smooth_angle.param_set_increments(1, 1); + max_smooth_angle.param_set_digits(0); + seed = 0; } LPERoughen::~LPERoughen() {} void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) { + if(spray_tool_friendly && seed == 0){ + std::string id_item(SP_OBJECT(lpeitem)->getId()); + long seed = static_cast(boost::hash_value(id_item)); + global_randomize.param_set_value(global_randomize.get_value(), seed); + } displace_x.resetRandomizer(); displace_y.resetRandomizer(); - if(!spray_tool_friendly){ - global_randomize.resetRandomizer(); - } else { - boost::hash string_hash; - global_randomize.param_set_value(global_randomize.get_value(), static_cast(string_hash(lpeitem->getId()))); - } + global_randomize.resetRandomizer(); srand(1); SPLPEItem * item = const_cast(lpeitem); item->apply_to_clippath(item); @@ -140,7 +150,7 @@ Gtk::Widget *LPERoughen::newWidget() vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET); } - if (param->param_key == "shift_nodes") { + if (param->param_key == "handles") { Gtk::Label *options = Gtk::manage(new Gtk::Label( Glib::ustring(_("Options Modify options to rough")), Gtk::ALIGN_START)); @@ -173,11 +183,19 @@ double LPERoughen::sign(double random_number) return random_number; } -Geom::Point LPERoughen::randomize(double max_lenght) +Geom::Point LPERoughen::randomize(double max_lenght, double direction) { double displace_x_parsed = displace_x * global_randomize; double displace_y_parsed = displace_y * global_randomize; Geom::Point output = Geom::Point(sign(displace_x_parsed), sign(displace_y_parsed)); + if( direction != 0){ + int angle = (int)max_smooth_angle; + if (angle == 0){ + angle = 1; + } + double dist = Geom::distance(Geom::Point(0,0),output); + output = Geom::Point::polar(direction + sign(Geom::deg_to_rad(rand() % angle)), dist); + } if( fixed_displacement ){ Geom::Ray ray(Geom::Point(0,0),output); output = Geom::Point::polar(ray.angle(), max_lenght); @@ -199,6 +217,7 @@ void LPERoughen::doEffect(SPCurve *curve) Geom::Path::const_iterator curve_endit = path_it->end_default(); SPCurve *nCurve = new SPCurve(); Geom::Point prev(0, 0); + Geom::Point last_move(0, 0); nCurve->moveto(curve_it1->initialPoint()); while (curve_it1 != curve_endit) { Geom::CubicBezier const *cubic = NULL; @@ -222,14 +241,14 @@ void LPERoughen::doEffect(SPCurve *curve) } SPCurve const * tmp; if (splits == 1) { - tmp = jitter(nCurve->last_segment(), prev); + tmp = jitter(nCurve->last_segment(), prev, last_move); } else { bool last = false; if(t == splits-1){ last = true; } double time = Geom::nearest_time(original->pointAt((1. / (double)splits) * t), *nCurve->last_segment()); - tmp = addNodesAndJitter(nCurve->last_segment(), prev, time, last); + tmp = addNodesAndJitter(nCurve->last_segment(), prev, last_move, time, last); } if (nCurve->get_segment_count() > 1) { nCurve->backspace(); @@ -243,7 +262,7 @@ void LPERoughen::doEffect(SPCurve *curve) ++curve_it2; } if (path_it->closed()) { - if(shift_handles_sym && curve_it1 == curve_endit && !retract_handles){ + if(handles == HM_SMOOTH && curve_it1 == curve_endit){ SPCurve *out = new SPCurve(); nCurve = nCurve->create_reverse(); Geom::CubicBezier const *cubic_start = dynamic_cast(nCurve->first_segment()); @@ -265,6 +284,18 @@ void LPERoughen::doEffect(SPCurve *curve) nCurve->append_continuous(out, 0.001); nCurve = nCurve->create_reverse(); } + if(handles == HM_ALONG_NODES && curve_it1 == curve_endit){ + SPCurve *out = new SPCurve(); + nCurve = nCurve->create_reverse(); + Geom::CubicBezier const *cubic = dynamic_cast(nCurve->last_segment()); + if(cubic){ + out->moveto((*cubic)[0]); + out->curveto((*cubic)[1], (*cubic)[2] - last_move, (*cubic)[3]); + nCurve->backspace(); + nCurve->append_continuous(out, 0.001); + } + nCurve = nCurve->create_reverse(); + } nCurve->move_endpoints(nCurve->last_segment()->finalPoint(), nCurve->last_segment()->finalPoint()); nCurve->closepath_current(); } @@ -274,7 +305,7 @@ void LPERoughen::doEffect(SPCurve *curve) } } -SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, double t, bool last) +SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move, double t, bool last) { SPCurve *out = new SPCurve(); Geom::CubicBezier const *cubic = dynamic_cast(&*A); @@ -291,7 +322,7 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point point_b3 = randomize(max_lenght); } } - if (shift_handles || shift_handles_sym) { + if (handles == HM_RAND || handles == HM_SMOOTH) { point_a1 = randomize(max_lenght); point_a2 = randomize(max_lenght); point_b1 = randomize(max_lenght); @@ -305,7 +336,7 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point point_b2 = point_b3; } } - if(retract_handles){ + if(handles == HM_RETRACT){ out->moveto(A->initialPoint()); out->lineto(A->pointAt(t) + point_a3); if(cubic && !last){ @@ -315,7 +346,7 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point } else { out->lineto(A->finalPoint() + point_b3); } - } else if(shift_handles_sym && cubic) { + } else if(handles == HM_SMOOTH && cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); @@ -324,6 +355,12 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } + ray.setPoints(seg1[3] + point_a3, seg2[1] + point_a3); + point_b1 = randomize(max_lenght, ray.angle()); + if(last){ + ray.setPoints(seg2[3] + point_b3, A->pointAt(1 - (t / 3)) + point_b3); + point_b2 = randomize(max_lenght, ray.angle()); + } ray.setPoints(seg2[1] + point_a3 + point_b1, seg2[0] + point_a3); point_a2 = Geom::Point::polar(ray.angle(), max_lenght); if(last){ @@ -338,12 +375,18 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point } else { out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); } - } else if(shift_handles_sym && !cubic) { + } else if(handles == HM_SMOOTH && !cubic) { Geom::Ray ray(prev,A->initialPoint()); point_a1 = Geom::Point::polar(ray.angle(), max_lenght); if(prev==Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } + ray.setPoints(A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)) + point_a3); + point_b1 = randomize(max_lenght, ray.angle()); + if(last){ + ray.setPoints(A->finalPoint() + point_b3, A->pointAt(t +((t / 3) * 2)) + point_b3); + point_b2 = randomize(max_lenght, ray.angle()); + } ray.setPoints(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3); point_a2 = Geom::Point::polar(ray.angle(), max_lenght); if(last){ @@ -359,9 +402,18 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); out->moveto(seg1[0]); - out->curveto(seg1[1] + point_a1, seg1[2] + point_a2 + point_a3, seg1[3] + point_a3); - out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); - } else if (shift_handles) { + if(handles == HM_ALONG_NODES){ + out->curveto(seg1[1] + last_move, seg1[2] + point_a3, seg1[3] + point_a3); + last_move = point_a3; + if(last){ + last_move = point_b3; + } + out->curveto(seg2[1] + point_a3, seg2[2] + point_b3, seg2[3] + point_b3); + } else { + out->curveto(seg1[1] + point_a1, seg1[2] + point_a2 + point_a3, seg1[3] + point_a3); + out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); + } + } else if (handles == HM_RAND) { out->moveto(A->initialPoint()); out->curveto(A->pointAt(t / 3) + point_a1, A->pointAt((t / 3) * 2) + point_a2 + point_a3, A->pointAt(t) + point_a3); out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); @@ -373,7 +425,7 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point return out; } -SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev) +SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move) { SPCurve *out = new SPCurve(); Geom::CubicBezier const *cubic = dynamic_cast(&*A); @@ -384,35 +436,44 @@ SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev) if (shift_nodes) { point_a3 = randomize(max_lenght); } - if (shift_handles || shift_handles_sym) { + if (handles == HM_RAND || handles == HM_SMOOTH) { point_a1 = randomize(max_lenght); point_a2 = randomize(max_lenght); } - if(retract_handles){ + if(handles == HM_RETRACT){ out->moveto(A->initialPoint()); out->lineto(A->finalPoint() + point_a3); - } else if(shift_handles_sym && cubic) { + } else if(handles == HM_SMOOTH && cubic) { Geom::Ray ray(prev,A->initialPoint()); point_a1 = Geom::Point::polar(ray.angle(), max_lenght); if(prev == Geom::Point(0,0)){ point_a1 = A->pointAt(1.0/3.0) + randomize(max_lenght); } + ray.setPoints((*cubic)[3] + point_a3, (*cubic)[2] + point_a3); + point_a2 = randomize(max_lenght, ray.angle()); prev = (*cubic)[2] + point_a2; out->moveto((*cubic)[0]); out->curveto((*cubic)[0] + point_a1, (*cubic)[2] + point_a2 + point_a3, (*cubic)[3] + point_a3); - } else if(shift_handles_sym && !cubic) { + } else if(handles == HM_SMOOTH && !cubic) { Geom::Ray ray(prev,A->initialPoint()); point_a1 = Geom::Point::polar(ray.angle(), max_lenght); if(prev==Geom::Point(0,0)){ point_a1 = A->pointAt(1.0/3.0) + randomize(max_lenght); } - prev = A->pointAt((1.0/3.0) * 2) + point_a2; + ray.setPoints(A->finalPoint() + point_a3, A->pointAt((1.0/3.0) * 2) + point_a3); + point_a2 = randomize(max_lenght, ray.angle()); + prev = A->pointAt((1.0/3.0) * 2) + point_a2 + point_a3; out->moveto(A->initialPoint()); out->curveto(A->initialPoint() + point_a1, A->pointAt((1.0/3.0) * 2) + point_a2 + point_a3, A->finalPoint() + point_a3); } else if (cubic) { out->moveto((*cubic)[0]); - out->curveto((*cubic)[1] + point_a1, (*cubic)[2] + point_a2 + point_a3, (*cubic)[3] + point_a3); - } else if (shift_handles) { + if(handles == HM_ALONG_NODES){ + out->curveto((*cubic)[1] + last_move, (*cubic)[2] + point_a3, (*cubic)[3] + point_a3); + last_move = point_a3; + } else { + out->curveto((*cubic)[1] + point_a1, (*cubic)[2] + point_a2 + point_a3, (*cubic)[3] + point_a3); + } + } else if (handles == HM_RAND) { out->moveto(A->initialPoint()); out->curveto(A->pointAt(0.3333) + point_a1, A->pointAt(0.6666) + point_a2 + point_a3, A->finalPoint() + point_a3); diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index 178c3b657..e3ede2c2d 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -28,6 +28,15 @@ enum DivisionMethod { DM_END }; +enum HandlesMethod { + HM_ALONG_NODES, + HM_RAND, + HM_RETRACT, + HM_SMOOTH, + HM_END +}; + + class LPERoughen : public Effect { public: @@ -36,10 +45,10 @@ public: virtual void doEffect(SPCurve *curve); virtual double sign(double randNumber); - virtual Geom::Point randomize(double max_lenght); + virtual Geom::Point randomize(double max_lenght, double direction = 0); virtual void doBeforeEffect(SPLPEItem const * lpeitem); - virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, double t, bool last); - virtual SPCurve *jitter(Geom::Curve const * A, Geom::Point &prev); + virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move, double t, bool last); + virtual SPCurve *jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move); virtual Geom::Point tPoint(Geom::Point A, Geom::Point B, double t = 0.5); virtual Gtk::Widget *newWidget(); @@ -50,13 +59,12 @@ private: RandomParam displace_x; RandomParam displace_y; RandomParam global_randomize; + EnumParam handles; + ScalarParam max_smooth_angle; BoolParam shift_nodes; - BoolParam shift_handles; - BoolParam retract_handles; - BoolParam shift_handles_sym; BoolParam fixed_displacement; BoolParam spray_tool_friendly; - + long seed; LPERoughen(const LPERoughen &); LPERoughen &operator=(const LPERoughen &); -- cgit v1.2.3 From ec23a0d460ce389d91e3e8d71d786cf0599ab01e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Oct 2015 13:40:43 +0200 Subject: Fix first handle position on along nodes mode (bzr r14422) --- src/live_effects/lpe-roughen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index d40d549a7..cea91509e 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -290,7 +290,7 @@ void LPERoughen::doEffect(SPCurve *curve) Geom::CubicBezier const *cubic = dynamic_cast(nCurve->last_segment()); if(cubic){ out->moveto((*cubic)[0]); - out->curveto((*cubic)[1], (*cubic)[2] - last_move, (*cubic)[3]); + out->curveto((*cubic)[1], (*cubic)[2] - ((*cubic)[3] - nCurve->first_segment()->initialPoint()) , (*cubic)[3]); nCurve->backspace(); nCurve->append_continuous(out, 0.001); } -- cgit v1.2.3 From cea94017f3a35b0f678affd5b0a012a84885dea6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Oct 2015 19:48:53 +0200 Subject: fixing roughen (bzr r14422.1.1) --- src/live_effects/lpe-roughen.cpp | 69 +++++++++++++++++++++------------------- src/live_effects/lpe-roughen.h | 3 +- 2 files changed, 39 insertions(+), 33 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index cea91509e..44f9c6be5 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -183,19 +183,15 @@ double LPERoughen::sign(double random_number) return random_number; } -Geom::Point LPERoughen::randomize(double max_lenght, double direction) +Geom::Point LPERoughen::randomize(double max_lenght, bool is_node) { - double displace_x_parsed = displace_x * global_randomize; - double displace_y_parsed = displace_y * global_randomize; - Geom::Point output = Geom::Point(sign(displace_x_parsed), sign(displace_y_parsed)); - if( direction != 0){ - int angle = (int)max_smooth_angle; - if (angle == 0){ - angle = 1; - } - double dist = Geom::distance(Geom::Point(0,0),output); - output = Geom::Point::polar(direction + sign(Geom::deg_to_rad(rand() % angle)), dist); + double factor = 1.0/3.0; + if(is_node){ + factor = 1.0; } + double displace_x_parsed = displace_x * global_randomize * factor; + double displace_y_parsed = displace_y * global_randomize * factor; + Geom::Point output = Geom::Point(sign(displace_x_parsed), sign(displace_y_parsed)); if( fixed_displacement ){ Geom::Ray ray(Geom::Point(0,0),output); output = Geom::Point::polar(ray.angle(), max_lenght); @@ -203,6 +199,19 @@ Geom::Point LPERoughen::randomize(double max_lenght, double direction) return output; } +Geom::Point LPERoughen::randomize(double lenght, Geom::Point start, Geom::Point end) +{ + int angle = (int)max_smooth_angle; + if (angle == 0){ + angle = 1; + } + Geom::Ray ray(start, end); + if(!fixed_displacement ){ + lenght = Geom::distance(start, end); + } + return Geom::Point::polar(ray.angle() + sign(Geom::deg_to_rad(rand() % angle)), lenght) + start; +} + void LPERoughen::doEffect(SPCurve *curve) { Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); @@ -317,9 +326,9 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point Geom::Point point_b2(0, 0); Geom::Point point_b3(0, 0); if (shift_nodes) { - point_a3 = randomize(max_lenght); + point_a3 = randomize(max_lenght, true); if(last){ - point_b3 = randomize(max_lenght); + point_b3 = randomize(max_lenght, true); } } if (handles == HM_RAND || handles == HM_SMOOTH) { @@ -350,42 +359,38 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); + point_b3 = seg2[3] + point_b3; + point_a3 = seg1[3] + point_a3; + point_b1 = randomize(max_lenght, point_a3, seg2[1]); + point_b2 = seg1[2] + point_b2; Geom::Ray ray(prev,A->initialPoint()); - point_a1 = Geom::Point::polar(ray.angle(), max_lenght); + point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - ray.setPoints(seg1[3] + point_a3, seg2[1] + point_a3); - point_b1 = randomize(max_lenght, ray.angle()); if(last){ - ray.setPoints(seg2[3] + point_b3, A->pointAt(1 - (t / 3)) + point_b3); - point_b2 = randomize(max_lenght, ray.angle()); + ray.setPoints(point_b3, point_a3); + point_b2 = randomize(max_lenght, point_b3, ray.pointAt(100.0/3.0)); } - ray.setPoints(seg2[1] + point_a3 + point_b1, seg2[0] + point_a3); - point_a2 = Geom::Point::polar(ray.angle(), max_lenght); + ray.setPoints(point_b1, point_a3); + point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); if(last){ - prev = A->pointAt(1 - (t / 3)) + point_b2 + point_b3; + prev = point_b2; } else { - prev = seg1[3] + point_a2 + point_a3; + prev = point_a2; } out->moveto(seg1[0]); - out->curveto(seg1[0] + point_a1, seg1[3] + point_a2 + point_a3, seg1[3] + point_a3); - if(last){ - out->curveto(seg2[1] + point_a3 + point_b1, A->pointAt(1 - (t / 3)) + point_b2 + point_b3, seg2[3] + point_b3); - } else { - out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); - } + out->curveto(point_a1,point_a2,point_a3); + out->curveto(point_b1, point_b2, point_b3); } else if(handles == HM_SMOOTH && !cubic) { Geom::Ray ray(prev,A->initialPoint()); point_a1 = Geom::Point::polar(ray.angle(), max_lenght); if(prev==Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - ray.setPoints(A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)) + point_a3); - point_b1 = randomize(max_lenght, ray.angle()); + point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)) + point_a3); if(last){ - ray.setPoints(A->finalPoint() + point_b3, A->pointAt(t +((t / 3) * 2)) + point_b3); - point_b2 = randomize(max_lenght, ray.angle()); + point_b2 = randomize(max_lenght, A->finalPoint() + point_b3, A->pointAt(t +((t / 3) * 2)) + point_b3); } ray.setPoints(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3); point_a2 = Geom::Point::polar(ray.angle(), max_lenght); diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index e3ede2c2d..6224c09fa 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -45,7 +45,8 @@ public: virtual void doEffect(SPCurve *curve); virtual double sign(double randNumber); - virtual Geom::Point randomize(double max_lenght, double direction = 0); + virtual Geom::Point randomize(double max_lenght, bool is_node = false); + virtual Geom::Point randomize(double lenght, Geom::Point start, Geom::Point end); virtual void doBeforeEffect(SPLPEItem const * lpeitem); virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move, double t, bool last); virtual SPCurve *jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move); -- cgit v1.2.3 From ccdb4ca4cc4aa57445c770c8410d68f777cf6ba2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 20 Oct 2015 01:06:16 +0200 Subject: working 2 ways (bzr r14422.1.2) --- src/live_effects/lpe-roughen.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 44f9c6be5..55ca77e9c 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -359,18 +359,19 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); + point_b1 = randomize(max_lenght, seg1[3] + point_a3, seg2[1] + point_a3); + point_b2 = seg1[2]; point_b3 = seg2[3] + point_b3; point_a3 = seg1[3] + point_a3; - point_b1 = randomize(max_lenght, point_a3, seg2[1]); - point_b2 = seg1[2] + point_b2; Geom::Ray ray(prev,A->initialPoint()); point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } if(last){ - ray.setPoints(point_b3, point_a3); - point_b2 = randomize(max_lenght, point_b3, ray.pointAt(100.0/3.0)); + Geom::Path b2(point_b3); + b2.appendNew(point_a3); + point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0)); } ray.setPoints(point_b1, point_a3); point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); @@ -383,25 +384,30 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point out->curveto(point_a1,point_a2,point_a3); out->curveto(point_b1, point_b2, point_b3); } else if(handles == HM_SMOOTH && !cubic) { + point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3))); + point_b2 = A->pointAt(t +((t / 3) * 2)); + point_b3 = A->finalPoint() + point_b3; + point_a3 = A->pointAt(t) + point_a3; Geom::Ray ray(prev,A->initialPoint()); - point_a1 = Geom::Point::polar(ray.angle(), max_lenght); - if(prev==Geom::Point(0,0)){ + point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); + if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)) + point_a3); if(last){ - point_b2 = randomize(max_lenght, A->finalPoint() + point_b3, A->pointAt(t +((t / 3) * 2)) + point_b3); + Geom::Path b2(point_b3); + b2.appendNew(point_a3); + point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0)); } - ray.setPoints(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3); - point_a2 = Geom::Point::polar(ray.angle(), max_lenght); + ray.setPoints(point_b1, point_a3); + point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); if(last){ - prev = A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3; + prev = point_b2; } else { - prev = A->pointAt(t) + point_a3 + point_a2; + prev = point_a2; } out->moveto(A->initialPoint()); - out->curveto(A->initialPoint() + point_a1, A->pointAt(t) + point_a3 + point_a2, A->pointAt(t) + point_a3); - out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); + out->curveto(point_a1,point_a2,point_a3); + out->curveto(point_b1, point_b2, point_b3); } else if (cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), -- cgit v1.2.3 From cd7e100476cf935ebbac947109012bcba2f44875 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 25 Oct 2015 17:52:07 +0100 Subject: Removing new roughen changes to create a new Spray branch (bzr r14422.1.11) --- src/live_effects/lpe-roughen.cpp | 91 ++++++++++++++++++---------------------- src/live_effects/lpe-roughen.h | 3 +- 2 files changed, 41 insertions(+), 53 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 55ca77e9c..cea91509e 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -183,15 +183,19 @@ double LPERoughen::sign(double random_number) return random_number; } -Geom::Point LPERoughen::randomize(double max_lenght, bool is_node) +Geom::Point LPERoughen::randomize(double max_lenght, double direction) { - double factor = 1.0/3.0; - if(is_node){ - factor = 1.0; - } - double displace_x_parsed = displace_x * global_randomize * factor; - double displace_y_parsed = displace_y * global_randomize * factor; + double displace_x_parsed = displace_x * global_randomize; + double displace_y_parsed = displace_y * global_randomize; Geom::Point output = Geom::Point(sign(displace_x_parsed), sign(displace_y_parsed)); + if( direction != 0){ + int angle = (int)max_smooth_angle; + if (angle == 0){ + angle = 1; + } + double dist = Geom::distance(Geom::Point(0,0),output); + output = Geom::Point::polar(direction + sign(Geom::deg_to_rad(rand() % angle)), dist); + } if( fixed_displacement ){ Geom::Ray ray(Geom::Point(0,0),output); output = Geom::Point::polar(ray.angle(), max_lenght); @@ -199,19 +203,6 @@ Geom::Point LPERoughen::randomize(double max_lenght, bool is_node) return output; } -Geom::Point LPERoughen::randomize(double lenght, Geom::Point start, Geom::Point end) -{ - int angle = (int)max_smooth_angle; - if (angle == 0){ - angle = 1; - } - Geom::Ray ray(start, end); - if(!fixed_displacement ){ - lenght = Geom::distance(start, end); - } - return Geom::Point::polar(ray.angle() + sign(Geom::deg_to_rad(rand() % angle)), lenght) + start; -} - void LPERoughen::doEffect(SPCurve *curve) { Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); @@ -326,9 +317,9 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point Geom::Point point_b2(0, 0); Geom::Point point_b3(0, 0); if (shift_nodes) { - point_a3 = randomize(max_lenght, true); + point_a3 = randomize(max_lenght); if(last){ - point_b3 = randomize(max_lenght, true); + point_b3 = randomize(max_lenght); } } if (handles == HM_RAND || handles == HM_SMOOTH) { @@ -359,55 +350,53 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); - point_b1 = randomize(max_lenght, seg1[3] + point_a3, seg2[1] + point_a3); - point_b2 = seg1[2]; - point_b3 = seg2[3] + point_b3; - point_a3 = seg1[3] + point_a3; Geom::Ray ray(prev,A->initialPoint()); - point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); + point_a1 = Geom::Point::polar(ray.angle(), max_lenght); if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } + ray.setPoints(seg1[3] + point_a3, seg2[1] + point_a3); + point_b1 = randomize(max_lenght, ray.angle()); if(last){ - Geom::Path b2(point_b3); - b2.appendNew(point_a3); - point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0)); + ray.setPoints(seg2[3] + point_b3, A->pointAt(1 - (t / 3)) + point_b3); + point_b2 = randomize(max_lenght, ray.angle()); } - ray.setPoints(point_b1, point_a3); - point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); + ray.setPoints(seg2[1] + point_a3 + point_b1, seg2[0] + point_a3); + point_a2 = Geom::Point::polar(ray.angle(), max_lenght); if(last){ - prev = point_b2; + prev = A->pointAt(1 - (t / 3)) + point_b2 + point_b3; } else { - prev = point_a2; + prev = seg1[3] + point_a2 + point_a3; } out->moveto(seg1[0]); - out->curveto(point_a1,point_a2,point_a3); - out->curveto(point_b1, point_b2, point_b3); + out->curveto(seg1[0] + point_a1, seg1[3] + point_a2 + point_a3, seg1[3] + point_a3); + if(last){ + out->curveto(seg2[1] + point_a3 + point_b1, A->pointAt(1 - (t / 3)) + point_b2 + point_b3, seg2[3] + point_b3); + } else { + out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); + } } else if(handles == HM_SMOOTH && !cubic) { - point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3))); - point_b2 = A->pointAt(t +((t / 3) * 2)); - point_b3 = A->finalPoint() + point_b3; - point_a3 = A->pointAt(t) + point_a3; Geom::Ray ray(prev,A->initialPoint()); - point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); - if(prev == Geom::Point(0,0)){ + point_a1 = Geom::Point::polar(ray.angle(), max_lenght); + if(prev==Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } + ray.setPoints(A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)) + point_a3); + point_b1 = randomize(max_lenght, ray.angle()); if(last){ - Geom::Path b2(point_b3); - b2.appendNew(point_a3); - point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0)); + ray.setPoints(A->finalPoint() + point_b3, A->pointAt(t +((t / 3) * 2)) + point_b3); + point_b2 = randomize(max_lenght, ray.angle()); } - ray.setPoints(point_b1, point_a3); - point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); + ray.setPoints(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3); + point_a2 = Geom::Point::polar(ray.angle(), max_lenght); if(last){ - prev = point_b2; + prev = A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3; } else { - prev = point_a2; + prev = A->pointAt(t) + point_a3 + point_a2; } out->moveto(A->initialPoint()); - out->curveto(point_a1,point_a2,point_a3); - out->curveto(point_b1, point_b2, point_b3); + out->curveto(A->initialPoint() + point_a1, A->pointAt(t) + point_a3 + point_a2, A->pointAt(t) + point_a3); + out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); } else if (cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index 6224c09fa..e3ede2c2d 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -45,8 +45,7 @@ public: virtual void doEffect(SPCurve *curve); virtual double sign(double randNumber); - virtual Geom::Point randomize(double max_lenght, bool is_node = false); - virtual Geom::Point randomize(double lenght, Geom::Point start, Geom::Point end); + virtual Geom::Point randomize(double max_lenght, double direction = 0); virtual void doBeforeEffect(SPLPEItem const * lpeitem); virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move, double t, bool last); virtual SPCurve *jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move); -- cgit v1.2.3 From d3e163d627550bf1016b35d4afb75c024a508922 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 25 Oct 2015 17:54:27 +0100 Subject: Cleanup Spray tool improvements (bzr r14422.3.1) --- src/live_effects/lpe-roughen.cpp | 91 ++++++++++++++++++++++------------------ src/live_effects/lpe-roughen.h | 3 +- 2 files changed, 53 insertions(+), 41 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index cea91509e..55ca77e9c 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -183,19 +183,15 @@ double LPERoughen::sign(double random_number) return random_number; } -Geom::Point LPERoughen::randomize(double max_lenght, double direction) +Geom::Point LPERoughen::randomize(double max_lenght, bool is_node) { - double displace_x_parsed = displace_x * global_randomize; - double displace_y_parsed = displace_y * global_randomize; - Geom::Point output = Geom::Point(sign(displace_x_parsed), sign(displace_y_parsed)); - if( direction != 0){ - int angle = (int)max_smooth_angle; - if (angle == 0){ - angle = 1; - } - double dist = Geom::distance(Geom::Point(0,0),output); - output = Geom::Point::polar(direction + sign(Geom::deg_to_rad(rand() % angle)), dist); + double factor = 1.0/3.0; + if(is_node){ + factor = 1.0; } + double displace_x_parsed = displace_x * global_randomize * factor; + double displace_y_parsed = displace_y * global_randomize * factor; + Geom::Point output = Geom::Point(sign(displace_x_parsed), sign(displace_y_parsed)); if( fixed_displacement ){ Geom::Ray ray(Geom::Point(0,0),output); output = Geom::Point::polar(ray.angle(), max_lenght); @@ -203,6 +199,19 @@ Geom::Point LPERoughen::randomize(double max_lenght, double direction) return output; } +Geom::Point LPERoughen::randomize(double lenght, Geom::Point start, Geom::Point end) +{ + int angle = (int)max_smooth_angle; + if (angle == 0){ + angle = 1; + } + Geom::Ray ray(start, end); + if(!fixed_displacement ){ + lenght = Geom::distance(start, end); + } + return Geom::Point::polar(ray.angle() + sign(Geom::deg_to_rad(rand() % angle)), lenght) + start; +} + void LPERoughen::doEffect(SPCurve *curve) { Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); @@ -317,9 +326,9 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point Geom::Point point_b2(0, 0); Geom::Point point_b3(0, 0); if (shift_nodes) { - point_a3 = randomize(max_lenght); + point_a3 = randomize(max_lenght, true); if(last){ - point_b3 = randomize(max_lenght); + point_b3 = randomize(max_lenght, true); } } if (handles == HM_RAND || handles == HM_SMOOTH) { @@ -350,53 +359,55 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); + point_b1 = randomize(max_lenght, seg1[3] + point_a3, seg2[1] + point_a3); + point_b2 = seg1[2]; + point_b3 = seg2[3] + point_b3; + point_a3 = seg1[3] + point_a3; Geom::Ray ray(prev,A->initialPoint()); - point_a1 = Geom::Point::polar(ray.angle(), max_lenght); + point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - ray.setPoints(seg1[3] + point_a3, seg2[1] + point_a3); - point_b1 = randomize(max_lenght, ray.angle()); if(last){ - ray.setPoints(seg2[3] + point_b3, A->pointAt(1 - (t / 3)) + point_b3); - point_b2 = randomize(max_lenght, ray.angle()); + Geom::Path b2(point_b3); + b2.appendNew(point_a3); + point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0)); } - ray.setPoints(seg2[1] + point_a3 + point_b1, seg2[0] + point_a3); - point_a2 = Geom::Point::polar(ray.angle(), max_lenght); + ray.setPoints(point_b1, point_a3); + point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); if(last){ - prev = A->pointAt(1 - (t / 3)) + point_b2 + point_b3; + prev = point_b2; } else { - prev = seg1[3] + point_a2 + point_a3; + prev = point_a2; } out->moveto(seg1[0]); - out->curveto(seg1[0] + point_a1, seg1[3] + point_a2 + point_a3, seg1[3] + point_a3); - if(last){ - out->curveto(seg2[1] + point_a3 + point_b1, A->pointAt(1 - (t / 3)) + point_b2 + point_b3, seg2[3] + point_b3); - } else { - out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); - } + out->curveto(point_a1,point_a2,point_a3); + out->curveto(point_b1, point_b2, point_b3); } else if(handles == HM_SMOOTH && !cubic) { + point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3))); + point_b2 = A->pointAt(t +((t / 3) * 2)); + point_b3 = A->finalPoint() + point_b3; + point_a3 = A->pointAt(t) + point_a3; Geom::Ray ray(prev,A->initialPoint()); - point_a1 = Geom::Point::polar(ray.angle(), max_lenght); - if(prev==Geom::Point(0,0)){ + point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); + if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); } - ray.setPoints(A->pointAt(t) + point_a3, A->pointAt(t + (t / 3)) + point_a3); - point_b1 = randomize(max_lenght, ray.angle()); if(last){ - ray.setPoints(A->finalPoint() + point_b3, A->pointAt(t +((t / 3) * 2)) + point_b3); - point_b2 = randomize(max_lenght, ray.angle()); + Geom::Path b2(point_b3); + b2.appendNew(point_a3); + point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0)); } - ray.setPoints(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t) + point_a3); - point_a2 = Geom::Point::polar(ray.angle(), max_lenght); + ray.setPoints(point_b1, point_a3); + point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); if(last){ - prev = A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3; + prev = point_b2; } else { - prev = A->pointAt(t) + point_a3 + point_a2; + prev = point_a2; } out->moveto(A->initialPoint()); - out->curveto(A->initialPoint() + point_a1, A->pointAt(t) + point_a3 + point_a2, A->pointAt(t) + point_a3); - out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); + out->curveto(point_a1,point_a2,point_a3); + out->curveto(point_b1, point_b2, point_b3); } else if (cubic) { std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index e3ede2c2d..6224c09fa 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -45,7 +45,8 @@ public: virtual void doEffect(SPCurve *curve); virtual double sign(double randNumber); - virtual Geom::Point randomize(double max_lenght, double direction = 0); + virtual Geom::Point randomize(double max_lenght, bool is_node = false); + virtual Geom::Point randomize(double lenght, Geom::Point start, Geom::Point end); virtual void doBeforeEffect(SPLPEItem const * lpeitem); virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move, double t, bool last); virtual SPCurve *jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move); -- cgit v1.2.3 From 443350ec9520e6cf501c8d1137d276df18f58b4f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 25 Oct 2015 23:57:41 +0100 Subject: working on roughen (bzr r14422.3.2) --- src/live_effects/lpe-roughen.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 55ca77e9c..37a244603 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -201,15 +201,15 @@ Geom::Point LPERoughen::randomize(double max_lenght, bool is_node) Geom::Point LPERoughen::randomize(double lenght, Geom::Point start, Geom::Point end) { - int angle = (int)max_smooth_angle; - if (angle == 0){ - angle = 1; + int angle = 0; + if((int)max_smooth_angle != 0){ + angle = sign(Geom::deg_to_rad(rand() % (int)max_smooth_angle)); } Geom::Ray ray(start, end); if(!fixed_displacement ){ lenght = Geom::distance(start, end); } - return Geom::Point::polar(ray.angle() + sign(Geom::deg_to_rad(rand() % angle)), lenght) + start; + return Geom::Point::polar(ray.angle() + angle , lenght) + start; } void LPERoughen::doEffect(SPCurve *curve) @@ -360,7 +360,7 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); point_b1 = randomize(max_lenght, seg1[3] + point_a3, seg2[1] + point_a3); - point_b2 = seg1[2]; + point_b2 = seg2[2]; point_b3 = seg2[3] + point_b3; point_a3 = seg1[3] + point_a3; Geom::Ray ray(prev,A->initialPoint()); @@ -371,7 +371,10 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point if(last){ Geom::Path b2(point_b3); b2.appendNew(point_a3); - point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0)); + double dist = Geom::distance(b2.pointAt(1.0/3.0), point_b3); + ray.setPoints(point_b3, b2.pointAt(1.0/3.0)); + point_b2 = point_b3 + Geom::Point::polar(ray.angle(), dist); + point_b2 = randomize(max_lenght, point_b3, point_b2); } ray.setPoints(point_b1, point_a3); point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); @@ -396,7 +399,10 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point if(last){ Geom::Path b2(point_b3); b2.appendNew(point_a3); - point_b2 = randomize(max_lenght, point_b3, b2.pointAt(1.0/3.0)); + double dist = Geom::distance(b2.pointAt(1.0/3.0), point_b3); + ray.setPoints(point_b3, b2.pointAt(1.0/3.0)); + point_b2 = point_b3 + Geom::Point::polar(ray.angle(), dist); + point_b2 = randomize(max_lenght, point_b3, point_b2); } ray.setPoints(point_b1, point_a3); point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); -- cgit v1.2.3 From a853619b54d05d6cc785a12fa747a3e702122b69 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 28 Oct 2015 21:28:43 +0100 Subject: typo (bzr r14431) --- src/live_effects/lpe-simplify.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index f6842a030..2d79d5b34 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -29,7 +29,7 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) : Effect(lpeobject), steps(_("Steps:"),_("Change number of simplify steps "), "steps", &wr, this,1), threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.003), - smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to preform a smooth"), "smooth_angles", &wr, this, 20.), + smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to perform a smooth"), "smooth_angles", &wr, this, 20.), helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5), simplify_individual_paths(_("Paths separately"), _("Simplifying paths (separately)"), "simplify_individual_paths", &wr, this, false, "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), -- cgit v1.2.3 From 2e1f86061452fc6cad648a3370236bf2cb1f1a7d Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 28 Oct 2015 21:43:30 +0100 Subject: static code analysis (bzr r14432) --- src/live_effects/lpe-taperstroke.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-taperstroke.cpp b/src/live_effects/lpe-taperstroke.cpp index ef616f802..f2ddd4929 100644 --- a/src/live_effects/lpe-taperstroke.cpp +++ b/src/live_effects/lpe-taperstroke.cpp @@ -408,9 +408,8 @@ Piecewise > stretch_along(Piecewise > pwd2_in, Geom::Path n = force_continuity(remove_short_cuts(n,.1)); int nbCopies = 0; - double scaling = 1; + double scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); nbCopies = 1; - scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); double pattWidth = pattBndsX->extent() * scaling; -- cgit v1.2.3 From fd5fce801e86b3e9ab0d56a702e89b11dbf7484e Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 29 Oct 2015 23:24:26 +0100 Subject: static code analysis (bzr r14436) --- src/live_effects/lpe-fill-between-many.cpp | 2 +- src/live_effects/parameter/filletchamferpointarray.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index 3e0810cfc..574ec3580 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -37,7 +37,7 @@ void LPEFillBetweenMany::doEffect (SPCurve * curve) { Geom::PathVector res_pathv; SPItem * firstObj = NULL; - for (std::vector::iterator iter = linked_paths._vector.begin(); iter != linked_paths._vector.end(); iter++) { + for (std::vector::iterator iter = linked_paths._vector.begin(); iter != linked_paths._vector.end(); ++iter) { SPObject *obj; if ((*iter)->ref.isAttached() && (obj = (*iter)->ref.getObject()) && SP_IS_ITEM(obj) && !(*iter)->_pathvector.empty()) { Geom::Path linked_path; diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp index b089213fd..399307502 100644 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ b/src/live_effects/parameter/filletchamferpointarray.cpp @@ -159,9 +159,8 @@ void FilletChamferPointArrayParam::recalculate_controlpoints_for_new_pwd2( //todo: if the path remove some nodes whith the result of a straight //line but with handles, the node inserted into dont fire the knot // because is not handle as cusp node by get_nodetype function - bool this_is_line = true; bool next_is_line = is_straight_curve(*curve_it1); - this_is_line = is_straight_curve((*path_it)[counterCurves - 1]); + bool this_is_line = is_straight_curve((*path_it)[counterCurves - 1]); nodetype = get_nodetype((*path_it)[counterCurves - 1], *curve_it1); if (this_is_line || next_is_line) { nodetype = NODE_CUSP; @@ -307,9 +306,8 @@ void FilletChamferPointArrayParam::recalculate_knots( nodetype = NODE_NONE; } } else { - bool this_is_line = true; bool next_is_line = is_straight_curve(*curve_it1); - this_is_line = is_straight_curve((*path_it)[counterCurves - 1]); + bool this_is_line = is_straight_curve((*path_it)[counterCurves - 1]); nodetype = get_nodetype((*path_it)[counterCurves - 1], *curve_it1); if (this_is_line || next_is_line) { nodetype = NODE_CUSP; @@ -467,12 +465,12 @@ double FilletChamferPointArrayParam::len_to_rad(int index, double len) Geom::Point endArcPoint = B->toSBasis().valueAt(times[2]); Curve *knotCurve1 = A->portion(times[0], times[1]); Curve *knotCurve2 = B->portion(times[2], 1); - Geom::CubicBezier const *cubic1 = dynamic_cast(&*knotCurve1); + Geom::CubicBezier const *cubic1 = dynamic_cast(knotCurve1); Ray ray1(startArcPoint, A->finalPoint()); if (cubic1) { ray1.setPoints((*cubic1)[2], startArcPoint); } - Geom::CubicBezier const *cubic2 = dynamic_cast(&*knotCurve2); + Geom::CubicBezier const *cubic2 = dynamic_cast(knotCurve2); Ray ray2(B->initialPoint(), endArcPoint); if (cubic2) { ray2.setPoints(endArcPoint, (*cubic2)[1]); -- cgit v1.2.3 From e40c7e81cc683c8c937486c4a53f9758752bbbe6 Mon Sep 17 00:00:00 2001 From: Yuri Chornoivan <> Date: Sun, 1 Nov 2015 13:49:27 +0100 Subject: Typo fix (bzr r14439) --- src/live_effects/lpe-roughen.cpp | 2 +- src/live_effects/lpe-transform_2pts.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index cea91509e..29cfc9839 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -63,7 +63,7 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) "max_smooth_angle", &wr, this, 20), shift_nodes(_("Shift nodes"), _("Shift nodes"), "shift_nodes", &wr, this, true), - fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment lenght"), + fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment length"), "fixed_displacement", &wr, this, false), spray_tool_friendly(_("Spray Tool friendly"), _("For use with spray tool"), "spray_tool_friendly", &wr, this, false) diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index 8326bd6f1..f2b756567 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -30,13 +30,13 @@ LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : Effect(lpeobject), elastic(_("Elastic"), _("Elastic transform mode"), "elastic", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), from_original_width(_("From original width"), _("From original width"), "from_original_width", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), - lock_lenght(_("Lock lenght"), _("Lock lenght to current distance"), "lock_lenght", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), + lock_lenght(_("Lock length"), _("Lock length to current distance"), "lock_lenght", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), lock_angle(_("Lock angle"), _("Lock angle"), "lock_angle", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), flip_horizontal(_("Flip horizontal"), _("Flip horizontal"), "flip_horizontal", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), flip_vertical(_("Flip vertical"), _("Flip vertical"), "flip_vertical", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), start(_("Start"), _("Start point"), "start", &wr, this, "Start point"), end(_("End"), _("End point"), "end", &wr, this, "End point"), - strech(_("Strech"), _("Strech the result"), "strech", &wr, this, 1), + strech(_("Stretch"), _("Stretch the result"), "strech", &wr, this, 1), offset(_("Offset"), _("Offset from knots"), "offset", &wr, this, 0), first_knot(_("First Knot"), _("First Knot"), "first_knot", &wr, this, 1), last_knot(_("Last Knot"), _("Last Knot"), "last_knot", &wr, this, 1), -- cgit v1.2.3 From 23935ad410a79d6f82e0ce90e5efba32a55cda4c Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 5 Nov 2015 22:27:44 +0100 Subject: static code analysis (bzr r14446) --- src/live_effects/parameter/originalpatharray.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 78e061e66..9e03e2c02 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -215,7 +215,7 @@ void OriginalPathArrayParam::on_up_button_click() int i = -1; std::vector::iterator piter = _vector.begin(); - for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); piter = iter, i++, iter++) { + for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); piter = iter, i++, ++iter) { if (*iter == row[_model->_colObject]) { _vector.erase(iter); _vector.insert(piter, row[_model->_colObject]); @@ -241,7 +241,7 @@ void OriginalPathArrayParam::on_down_button_click() Gtk::TreeModel::Row row = *iter; int i = 0; - for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); i++, iter++) { + for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); i++, ++iter) { if (*iter == row[_model->_colObject]) { std::vector::iterator niter = _vector.erase(iter); if (niter != _vector.end()) { @@ -295,7 +295,7 @@ OriginalPathArrayParam::on_link_button_click() Inkscape::SVGOStringStream os; bool foundOne = false; - for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); iter++) { + for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { if (foundOne) { os << "|"; } else { @@ -330,7 +330,7 @@ void OriginalPathArrayParam::unlink(PathAndDirection* to) void OriginalPathArrayParam::remove_link(PathAndDirection* to) { unlink(to); - for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); iter++) { + for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { if (*iter == to) { PathAndDirection *w = *iter; _vector.erase(iter); @@ -455,7 +455,7 @@ gchar * OriginalPathArrayParam::param_getSVGValue() const { Inkscape::SVGOStringStream os; bool foundOne = false; - for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); iter++) { + for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { if (foundOne) { os << "|"; } else { -- cgit v1.2.3 From 7d77133cec471ae1e3e40937ebb637876f1c9a47 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 13 Nov 2015 12:54:14 +0100 Subject: Fixed a bug on Spray Friendly when SPLPEITEM has clones. POinted by Ivan Louette (bzr r14422.3.5) --- src/live_effects/lpe-roughen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 6c2ec0227..00f7b8012 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -98,7 +98,7 @@ LPERoughen::~LPERoughen() {} void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) { - if(spray_tool_friendly && seed == 0){ + if(spray_tool_friendly && seed == 0 && SP_OBJECT(lpeitem)->getId()){ std::string id_item(SP_OBJECT(lpeitem)->getId()); long seed = static_cast(boost::hash_value(id_item)); global_randomize.param_set_value(global_randomize.get_value(), seed); -- cgit v1.2.3 From bbb9eba40d9bd611af330c40897378adcfd60001 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 13 Nov 2015 15:55:42 +0100 Subject: Fix a bug on bspline, duplicating end nodes (bzr r14462) --- src/live_effects/lpe-bspline.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 731b5d645..7e92e767d 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -206,6 +206,18 @@ void sp_bspline_do_effect(SPCurve *curve, double helper_size) Geom::D2 sbasis_helper; Geom::CubicBezier const *cubic = NULL; curve_n->moveto(curve_it1->initialPoint()); + if (path_it->closed()) { + const Geom::Curve &closingline = path_it->back_closed(); + // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } while (curve_it1 != curve_endit) { SPCurve *in = new SPCurve(); in->moveto(curve_it1->initialPoint()); @@ -361,6 +373,18 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) Geom::D2 sbasis_out; Geom::CubicBezier const *cubic = NULL; curve_n->moveto(curve_it1->initialPoint()); + if (path_it->closed()) { + const Geom::Curve &closingline = path_it->back_closed(); + // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } while (curve_it1 != curve_endit) { SPCurve *in = new SPCurve(); in->moveto(curve_it1->initialPoint()); -- cgit v1.2.3 From e8ec23b80082d4c1c20675c83f5a6fad18c3392d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 13 Nov 2015 16:11:51 +0100 Subject: Fix bug end node, start calculate size based in number of nodes and lenght (bzr r14422.3.6) --- src/live_effects/lpe-roughen.cpp | 67 +++++++++++++++++++++++++++++++++++++++- src/live_effects/lpe-roughen.h | 1 + 2 files changed, 67 insertions(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 00f7b8012..6b18cf14e 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -65,7 +65,7 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) true), fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment length"), "fixed_displacement", &wr, this, false), - spray_tool_friendly(_("Spray Tool friendly"), _("For use with spray tool"), + spray_tool_friendly(_("Spray Tool friendly"), _("For use with spray tool in copy mode"), "spray_tool_friendly", &wr, this, false) { registerParameter(&method); @@ -96,6 +96,59 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) LPERoughen::~LPERoughen() {} +void LPERoughen::doOnApply(SPLPEItem const* lpeitem) +{ + SPLPEItem* item = const_cast(lpeitem); + //calculamos el tamaño mas optimo para el roughen en función del número de nodos y la distancia del trazado +} + +static void +sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) +{ + std::vector const item_list = sp_item_group_item_list(group); + + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = *iter; + + SPGroup *subGroup = dynamic_cast(subitem); + if (subGroup) { + sp_group_perform_patheffect(subGroup, topgroup, write); + } else { + SPShape *subShape = dynamic_cast(subitem); + if (subShape) { + SPCurve * c = NULL; + + SPPath *subPath = dynamic_cast(subShape); + if (subPath) { + c = subPath->get_original_curve(); + } else { + c = subShape->getCurve(); + } + + // only run LPEs when the shape has a curve defined + if (c) { + c->transform(i2anc_affine(subitem, topgroup)); + topgroup->performPathEffect(c); + c->transform(i2anc_affine(subitem, topgroup).inverse()); + subShape->setCurve(c, TRUE); + + if (write) { + Inkscape::XML::Node *repr = subitem->getRepr(); + 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"); +#endif + g_free(str); + } + + c->unref(); + } + } + } + } +} + void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) { if(spray_tool_friendly && seed == 0 && SP_OBJECT(lpeitem)->getId()){ @@ -228,6 +281,18 @@ void LPERoughen::doEffect(SPCurve *curve) Geom::Point prev(0, 0); Geom::Point last_move(0, 0); nCurve->moveto(curve_it1->initialPoint()); + if (path_it->closed()) { + const Geom::Curve &closingline = path_it->back_closed(); + // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } while (curve_it1 != curve_endit) { Geom::CubicBezier const *cubic = NULL; cubic = dynamic_cast(&*curve_it1); diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index 6224c09fa..b12bd08af 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -45,6 +45,7 @@ public: virtual void doEffect(SPCurve *curve); virtual double sign(double randNumber); + virtual void doOnApply(SPLPEItem const* lpeitem); virtual Geom::Point randomize(double max_lenght, bool is_node = false); virtual Geom::Point randomize(double lenght, Geom::Point start, Geom::Point end); virtual void doBeforeEffect(SPLPEItem const * lpeitem); -- cgit v1.2.3 From b833d034eeaa8bc144f6bdb2edd300056ed67b34 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 13 Nov 2015 19:29:13 +0100 Subject: Fix a compile problem (bzr r14422.3.7) --- src/live_effects/lpe-roughen.cpp | 46 ---------------------------------------- 1 file changed, 46 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 6b18cf14e..2be3bae31 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -98,56 +98,10 @@ LPERoughen::~LPERoughen() {} void LPERoughen::doOnApply(SPLPEItem const* lpeitem) { - SPLPEItem* item = const_cast(lpeitem); //calculamos el tamaño mas optimo para el roughen en función del número de nodos y la distancia del trazado } -static void -sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) -{ - std::vector const item_list = sp_item_group_item_list(group); - - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPObject *subitem = *iter; - - SPGroup *subGroup = dynamic_cast(subitem); - if (subGroup) { - sp_group_perform_patheffect(subGroup, topgroup, write); - } else { - SPShape *subShape = dynamic_cast(subitem); - if (subShape) { - SPCurve * c = NULL; - - SPPath *subPath = dynamic_cast(subShape); - if (subPath) { - c = subPath->get_original_curve(); - } else { - c = subShape->getCurve(); - } - - // only run LPEs when the shape has a curve defined - if (c) { - c->transform(i2anc_affine(subitem, topgroup)); - topgroup->performPathEffect(c); - c->transform(i2anc_affine(subitem, topgroup).inverse()); - subShape->setCurve(c, TRUE); - if (write) { - Inkscape::XML::Node *repr = subitem->getRepr(); - 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"); -#endif - g_free(str); - } - - c->unref(); - } - } - } - } -} void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) { -- cgit v1.2.3 From 151126ef45cb00bab461181388a433e751a27bc3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 14 Nov 2015 18:32:14 +0100 Subject: adding default width (bzr r14422.3.8) --- src/live_effects/lpe-roughen.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 2be3bae31..87046ef4a 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -20,6 +20,7 @@ #include "live_effects/parameter/parameter.h" #include #include "helper/geom.h" +#include "sp-item-group.h" #include #include @@ -42,6 +43,35 @@ static const Util::EnumData HandlesMethodData[HM_END] = { static const Util::EnumDataConverter HMConverter(HandlesMethodData, HM_END); +static void +sp_get_better_default_size(SPItem *item, double &value) +{ + if (SP_IS_GROUP(item)) { + std::vector const item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPItem *subitem = *iter; + value += sp_get_better_default_size(subitem, value); + } + if(item_list.size() > 0){ + value /= item_list.size(); + } + } else { + SPShape *shape = dynamic_cast(item); + if (shape) { + SPCurve * c = NULL; + SPPath *path = dynamic_cast(shape); + if (path) { + c = path->get_original_curve(); + } else { + c = shape->getCurve(); + } + if (c) { + value = Geom::length(paths_to_pw(c->get_pathvector()))/(c->get_segment_count () * 3); + } + } + } +} + LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: @@ -98,11 +128,13 @@ LPERoughen::~LPERoughen() {} void LPERoughen::doOnApply(SPLPEItem const* lpeitem) { - //calculamos el tamaño mas optimo para el roughen en función del número de nodos y la distancia del trazado + SPLPEItem * splpeitem = const_cast(lpeitem); + double initial = 0; + sp_get_better_default_size(SP_ITEM(splpeitem), initial); + displace_x.param_set_value(initial, displace_x.defseed); + displace_y.param_set_value(initial, displace_y.defseed); } - - void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) { if(spray_tool_friendly && seed == 0 && SP_OBJECT(lpeitem)->getId()){ -- cgit v1.2.3 From 7c89ed9dc03fb5f83eac25823c54edd91c123f7f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 14 Nov 2015 19:21:59 +0100 Subject: Fixing compile problem (bzr r14422.3.10) --- src/live_effects/lpe-roughen.cpp | 58 ++++++++++++++++++------------------- src/live_effects/parameter/random.h | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 87046ef4a..0d0debd24 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -43,35 +43,6 @@ static const Util::EnumData HandlesMethodData[HM_END] = { static const Util::EnumDataConverter HMConverter(HandlesMethodData, HM_END); -static void -sp_get_better_default_size(SPItem *item, double &value) -{ - if (SP_IS_GROUP(item)) { - std::vector const item_list = sp_item_group_item_list(SP_GROUP(item)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPItem *subitem = *iter; - value += sp_get_better_default_size(subitem, value); - } - if(item_list.size() > 0){ - value /= item_list.size(); - } - } else { - SPShape *shape = dynamic_cast(item); - if (shape) { - SPCurve * c = NULL; - SPPath *path = dynamic_cast(shape); - if (path) { - c = path->get_original_curve(); - } else { - c = shape->getCurve(); - } - if (c) { - value = Geom::length(paths_to_pw(c->get_pathvector()))/(c->get_segment_count () * 3); - } - } - } -} - LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: @@ -126,6 +97,35 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) LPERoughen::~LPERoughen() {} +static void +sp_get_better_default_size(SPItem *item, double &value) +{ + if (SP_IS_GROUP(item)) { + std::vector const item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPItem *subitem = *iter; + sp_get_better_default_size(subitem, value); + } + if(item_list.size() > 0){ + value /= item_list.size(); + } + } else { + SPShape *shape = dynamic_cast(item); + if (shape) { + SPCurve * c = NULL; + SPPath *path = dynamic_cast(shape); + if (path) { + c = path->get_original_curve(); + } else { + c = shape->getCurve(); + } + if (c) { + value += Geom::length(paths_to_pw(c->get_pathvector()))/(c->get_segment_count () * 3); + } + } + } +} + void LPERoughen::doOnApply(SPLPEItem const* lpeitem) { SPLPEItem * splpeitem = const_cast(lpeitem); diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h index ca4440336..52e3cc0a6 100644 --- a/src/live_effects/parameter/random.h +++ b/src/live_effects/parameter/random.h @@ -43,11 +43,11 @@ public: operator gdouble(); inline gdouble get_value() { return value; } ; + long defseed; protected: long startseed; long seed; - long defseed; gdouble value; gdouble min; -- cgit v1.2.3 From 43a821aaa9b8749b9c373925c8334efa77d9c34e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 15 Nov 2015 02:20:30 +0100 Subject: max_smooth_angle working, now deleted after because dont think a good improvement in realtion of UX complication (bzr r14422.3.11) --- src/live_effects/lpe-roughen.cpp | 224 ++++++++++++++++++++------------------- 1 file changed, 117 insertions(+), 107 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 0d0debd24..5253c0b85 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -120,7 +120,7 @@ sp_get_better_default_size(SPItem *item, double &value) c = shape->getCurve(); } if (c) { - value += Geom::length(paths_to_pw(c->get_pathvector()))/(c->get_segment_count () * 3); + value += Geom::length(paths_to_pw(c->get_pathvector()))/(c->get_segment_count () * 6); } } } @@ -240,10 +240,11 @@ Geom::Point LPERoughen::randomize(double max_lenght, bool is_node) Geom::Point LPERoughen::randomize(double lenght, Geom::Point start, Geom::Point end) { - int angle = 0; + double angle = 0; if((int)max_smooth_angle != 0){ angle = sign(Geom::deg_to_rad(rand() % (int)max_smooth_angle)); } + std::cout << angle << "anggggle\n"; Geom::Ray ray(start, end); if(!fixed_displacement ){ lenght = Geom::distance(start, end); @@ -283,10 +284,11 @@ void LPERoughen::doEffect(SPCurve *curve) Geom::CubicBezier const *cubic = NULL; cubic = dynamic_cast(&*curve_it1); if (cubic) { - nCurve->curveto((*cubic)[1], (*cubic)[2], curve_it1->finalPoint()); + nCurve->curveto((*cubic)[1] + last_move, (*cubic)[2], curve_it1->finalPoint()); } else { nCurve->lineto(curve_it1->finalPoint()); } + last_move = Geom::Point(0, 0); double length = curve_it1->length(0.001); std::size_t splits = 0; if (method == DM_SEGMENTS) { @@ -396,7 +398,68 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point point_b2 = point_b3; } } - if(handles == HM_RETRACT){ + if(handles == HM_SMOOTH){ + if(cubic) { + std::pair div = cubic->subdivide(t); + std::vector seg1 = div.first.controlPoints(), + seg2 = div.second.controlPoints(); + point_b1 = randomize(max_lenght, seg1[3] + point_a3, seg2[1] + point_a3); + point_b2 = seg2[2]; + point_b3 = seg2[3] + point_b3; + point_a3 = seg1[3] + point_a3; + Geom::Ray ray(prev,A->initialPoint()); + point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); + if(prev == Geom::Point(0,0)){ + point_a1 = randomize(max_lenght); + } + if(last){ + Geom::Path b2(point_b3); + b2.appendNew(point_a3); + double dist = Geom::distance(b2.pointAt(1.0/3.0), point_b3); + ray.setPoints(point_b3, b2.pointAt(1.0/3.0)); + point_b2 = point_b3 + Geom::Point::polar(ray.angle(), dist); + point_b2 = randomize(max_lenght, point_b3, point_b2); + } + ray.setPoints(point_b1, point_a3); + point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); + if(last){ + prev = point_b2; + } else { + prev = point_a2; + } + out->moveto(seg1[0]); + out->curveto(point_a1,point_a2,point_a3); + out->curveto(point_b1, point_b2, point_b3); + } else { + point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3))); + point_b2 = A->pointAt(t +((t / 3) * 2)); + point_b3 = A->finalPoint() + point_b3; + point_a3 = A->pointAt(t) + point_a3; + Geom::Ray ray(prev,A->initialPoint()); + point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); + if(prev == Geom::Point(0,0)){ + point_a1 = randomize(max_lenght); + } + if(last){ + Geom::Path b2(point_b3); + b2.appendNew(point_a3); + double dist = Geom::distance(b2.pointAt(1.0/3.0), point_b3); + ray.setPoints(point_b3, b2.pointAt(1.0/3.0)); + point_b2 = point_b3 + Geom::Point::polar(ray.angle(), dist); + point_b2 = randomize(max_lenght, point_b3, point_b2); + } + ray.setPoints(point_b1, point_a3); + point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); + if(last){ + prev = point_b2; + } else { + prev = point_a2; + } + out->moveto(A->initialPoint()); + out->curveto(point_a1,point_a2,point_a3); + out->curveto(point_b1, point_b2, point_b3); + } + } else if(handles == HM_RETRACT){ out->moveto(A->initialPoint()); out->lineto(A->pointAt(t) + point_a3); if(cubic && !last){ @@ -406,71 +469,12 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point } else { out->lineto(A->finalPoint() + point_b3); } - } else if(handles == HM_SMOOTH && cubic) { - std::pair div = cubic->subdivide(t); - std::vector seg1 = div.first.controlPoints(), - seg2 = div.second.controlPoints(); - point_b1 = randomize(max_lenght, seg1[3] + point_a3, seg2[1] + point_a3); - point_b2 = seg2[2]; - point_b3 = seg2[3] + point_b3; - point_a3 = seg1[3] + point_a3; - Geom::Ray ray(prev,A->initialPoint()); - point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); - if(prev == Geom::Point(0,0)){ - point_a1 = randomize(max_lenght); - } - if(last){ - Geom::Path b2(point_b3); - b2.appendNew(point_a3); - double dist = Geom::distance(b2.pointAt(1.0/3.0), point_b3); - ray.setPoints(point_b3, b2.pointAt(1.0/3.0)); - point_b2 = point_b3 + Geom::Point::polar(ray.angle(), dist); - point_b2 = randomize(max_lenght, point_b3, point_b2); - } - ray.setPoints(point_b1, point_a3); - point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); - if(last){ - prev = point_b2; - } else { - prev = point_a2; - } - out->moveto(seg1[0]); - out->curveto(point_a1,point_a2,point_a3); - out->curveto(point_b1, point_b2, point_b3); - } else if(handles == HM_SMOOTH && !cubic) { - point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3))); - point_b2 = A->pointAt(t +((t / 3) * 2)); - point_b3 = A->finalPoint() + point_b3; - point_a3 = A->pointAt(t) + point_a3; - Geom::Ray ray(prev,A->initialPoint()); - point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); - if(prev == Geom::Point(0,0)){ - point_a1 = randomize(max_lenght); - } - if(last){ - Geom::Path b2(point_b3); - b2.appendNew(point_a3); - double dist = Geom::distance(b2.pointAt(1.0/3.0), point_b3); - ray.setPoints(point_b3, b2.pointAt(1.0/3.0)); - point_b2 = point_b3 + Geom::Point::polar(ray.angle(), dist); - point_b2 = randomize(max_lenght, point_b3, point_b2); - } - ray.setPoints(point_b1, point_a3); - point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); - if(last){ - prev = point_b2; - } else { - prev = point_a2; - } - out->moveto(A->initialPoint()); - out->curveto(point_a1,point_a2,point_a3); - out->curveto(point_b1, point_b2, point_b3); - } else if (cubic) { - std::pair div = cubic->subdivide(t); - std::vector seg1 = div.first.controlPoints(), - seg2 = div.second.controlPoints(); - out->moveto(seg1[0]); - if(handles == HM_ALONG_NODES){ + } else if(handles == HM_ALONG_NODES){ + if (cubic) { + std::pair div = cubic->subdivide(t); + std::vector seg1 = div.first.controlPoints(), + seg2 = div.second.controlPoints(); + out->moveto(seg1[0]); out->curveto(seg1[1] + last_move, seg1[2] + point_a3, seg1[3] + point_a3); last_move = point_a3; if(last){ @@ -478,17 +482,23 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point } out->curveto(seg2[1] + point_a3, seg2[2] + point_b3, seg2[3] + point_b3); } else { + out->moveto(A->initialPoint()); + out->lineto(A->pointAt(t) + point_a3); + out->lineto(A->finalPoint() + point_b3); + } + } else if(handles == HM_RAND) { + if (cubic) { + std::pair div = cubic->subdivide(t); + std::vector seg1 = div.first.controlPoints(), + seg2 = div.second.controlPoints(); + out->moveto(seg1[0]); out->curveto(seg1[1] + point_a1, seg1[2] + point_a2 + point_a3, seg1[3] + point_a3); out->curveto(seg2[1] + point_a3 + point_b1, seg2[2] + point_b2 + point_b3, seg2[3] + point_b3); + } else { + out->moveto(A->initialPoint()); + out->lineto(A->pointAt(t) + point_a3); + out->lineto(A->finalPoint() + point_b3); } - } else if (handles == HM_RAND) { - out->moveto(A->initialPoint()); - out->curveto(A->pointAt(t / 3) + point_a1, A->pointAt((t / 3) * 2) + point_a2 + point_a3, A->pointAt(t) + point_a3); - out->curveto(A->pointAt(t + (t / 3)) + point_a3 + point_b1, A->pointAt(t +((t / 3) * 2)) + point_b2 + point_b3, A->finalPoint() + point_b3); - } else { - out->moveto(A->initialPoint()); - out->lineto(A->pointAt(t) + point_a3); - out->lineto(A->finalPoint() + point_b3); } return out; } @@ -508,46 +518,46 @@ SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Poin point_a1 = randomize(max_lenght); point_a2 = randomize(max_lenght); } - if(handles == HM_RETRACT){ - out->moveto(A->initialPoint()); - out->lineto(A->finalPoint() + point_a3); - } else if(handles == HM_SMOOTH && cubic) { - Geom::Ray ray(prev,A->initialPoint()); - point_a1 = Geom::Point::polar(ray.angle(), max_lenght); - if(prev == Geom::Point(0,0)){ - point_a1 = A->pointAt(1.0/3.0) + randomize(max_lenght); - } - ray.setPoints((*cubic)[3] + point_a3, (*cubic)[2] + point_a3); - point_a2 = randomize(max_lenght, ray.angle()); - prev = (*cubic)[2] + point_a2; - out->moveto((*cubic)[0]); - out->curveto((*cubic)[0] + point_a1, (*cubic)[2] + point_a2 + point_a3, (*cubic)[3] + point_a3); - } else if(handles == HM_SMOOTH && !cubic) { - Geom::Ray ray(prev,A->initialPoint()); - point_a1 = Geom::Point::polar(ray.angle(), max_lenght); - if(prev==Geom::Point(0,0)){ - point_a1 = A->pointAt(1.0/3.0) + randomize(max_lenght); + if(handles == HM_SMOOTH) { + if (cubic) { + Geom::Ray ray(prev,A->initialPoint()); + point_a1 = Geom::Point::polar(ray.angle(), max_lenght); + if(prev == Geom::Point(0,0)){ + point_a1 = A->pointAt(1.0/3.0) + randomize(max_lenght); + } + ray.setPoints((*cubic)[3] + point_a3, (*cubic)[2] + point_a3); + point_a2 = randomize(max_lenght, ray.angle()); + prev = (*cubic)[2] + point_a2; + out->moveto((*cubic)[0]); + out->curveto((*cubic)[0] + point_a1, (*cubic)[2] + point_a2 + point_a3, (*cubic)[3] + point_a3); + } else { + Geom::Ray ray(prev,A->initialPoint()); + point_a1 = Geom::Point::polar(ray.angle(), max_lenght); + if(prev==Geom::Point(0,0)){ + point_a1 = A->pointAt(1.0/3.0) + randomize(max_lenght); + } + ray.setPoints(A->finalPoint() + point_a3, A->pointAt((1.0/3.0) * 2) + point_a3); + point_a2 = randomize(max_lenght, ray.angle()); + prev = A->pointAt((1.0/3.0) * 2) + point_a2 + point_a3; + out->moveto(A->initialPoint()); + out->curveto(A->initialPoint() + point_a1, A->pointAt((1.0/3.0) * 2) + point_a2 + point_a3, A->finalPoint() + point_a3); } - ray.setPoints(A->finalPoint() + point_a3, A->pointAt((1.0/3.0) * 2) + point_a3); - point_a2 = randomize(max_lenght, ray.angle()); - prev = A->pointAt((1.0/3.0) * 2) + point_a2 + point_a3; + } else if(handles == HM_RETRACT){ out->moveto(A->initialPoint()); - out->curveto(A->initialPoint() + point_a1, A->pointAt((1.0/3.0) * 2) + point_a2 + point_a3, A->finalPoint() + point_a3); - } else if (cubic) { - out->moveto((*cubic)[0]); - if(handles == HM_ALONG_NODES){ + out->lineto(A->finalPoint() + point_a3); + } else if (handles == HM_ALONG_NODES) { + if(cubic){ + out->moveto((*cubic)[0]); out->curveto((*cubic)[1] + last_move, (*cubic)[2] + point_a3, (*cubic)[3] + point_a3); last_move = point_a3; } else { - out->curveto((*cubic)[1] + point_a1, (*cubic)[2] + point_a2 + point_a3, (*cubic)[3] + point_a3); + out->moveto(A->initialPoint()); + out->lineto(A->finalPoint() + point_a3); } } else if (handles == HM_RAND) { out->moveto(A->initialPoint()); out->curveto(A->pointAt(0.3333) + point_a1, A->pointAt(0.6666) + point_a2 + point_a3, A->finalPoint() + point_a3); - } else { - out->moveto(A->initialPoint()); - out->lineto(A->finalPoint() + point_a3); } return out; } -- cgit v1.2.3 From 3a2f830fc5c0c0f3901e64277e6871b9615d283b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 15 Nov 2015 03:47:20 +0100 Subject: End fixing roughen (bzr r14422.3.12) --- src/live_effects/lpe-roughen.cpp | 64 +++++++++++++++++-------------------- src/live_effects/lpe-roughen.h | 2 -- src/live_effects/parameter/random.h | 2 +- 3 files changed, 30 insertions(+), 38 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 5253c0b85..310f791a1 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -60,8 +60,6 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) "global_randomize", &wr, this, 1.), handles(_("Handles"), _("Handles options"), "handles", HMConverter, &wr, this, HM_ALONG_NODES), - max_smooth_angle(_("Max. smooth handle angle"), _("Max. smooth handle angle"), - "max_smooth_angle", &wr, this, 20), shift_nodes(_("Shift nodes"), _("Shift nodes"), "shift_nodes", &wr, this, true), fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment length"), @@ -76,7 +74,6 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) registerParameter(&displace_y); registerParameter(&global_randomize); registerParameter(&handles); - registerParameter(&max_smooth_angle); registerParameter(&shift_nodes); registerParameter(&fixed_displacement); registerParameter(&spray_tool_friendly); @@ -89,9 +86,6 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) segments.param_set_range(1, Geom::infinity()); segments.param_set_increments(1, 1); segments.param_set_digits(0); - max_smooth_angle.param_set_range(0, 359); - max_smooth_angle.param_set_increments(1, 1); - max_smooth_angle.param_set_digits(0); seed = 0; } @@ -131,8 +125,8 @@ void LPERoughen::doOnApply(SPLPEItem const* lpeitem) SPLPEItem * splpeitem = const_cast(lpeitem); double initial = 0; sp_get_better_default_size(SP_ITEM(splpeitem), initial); - displace_x.param_set_value(initial, displace_x.defseed); - displace_y.param_set_value(initial, displace_y.defseed); + displace_x.param_set_value(initial, 0); + displace_y.param_set_value(initial, 0); } void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) @@ -238,20 +232,6 @@ Geom::Point LPERoughen::randomize(double max_lenght, bool is_node) return output; } -Geom::Point LPERoughen::randomize(double lenght, Geom::Point start, Geom::Point end) -{ - double angle = 0; - if((int)max_smooth_angle != 0){ - angle = sign(Geom::deg_to_rad(rand() % (int)max_smooth_angle)); - } - std::cout << angle << "anggggle\n"; - Geom::Ray ray(start, end); - if(!fixed_displacement ){ - lenght = Geom::distance(start, end); - } - return Geom::Point::polar(ray.angle() + angle , lenght) + start; -} - void LPERoughen::doEffect(SPCurve *curve) { Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); @@ -403,11 +383,16 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point std::pair div = cubic->subdivide(t); std::vector seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); - point_b1 = randomize(max_lenght, seg1[3] + point_a3, seg2[1] + point_a3); + Geom::Ray ray(seg1[3] + point_a3, seg2[1] + point_a3); + double lenght = max_lenght; + if(!fixed_displacement ){ + lenght = Geom::distance(seg1[3] + point_a3, seg2[1] + point_a3); + } + point_b1 = seg1[3] + point_a3 + Geom::Point::polar(ray.angle() , lenght); point_b2 = seg2[2]; point_b3 = seg2[3] + point_b3; point_a3 = seg1[3] + point_a3; - Geom::Ray ray(prev,A->initialPoint()); + ray.setPoints(prev,A->initialPoint()); point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); @@ -415,10 +400,12 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point if(last){ Geom::Path b2(point_b3); b2.appendNew(point_a3); - double dist = Geom::distance(b2.pointAt(1.0/3.0), point_b3); - ray.setPoints(point_b3, b2.pointAt(1.0/3.0)); - point_b2 = point_b3 + Geom::Point::polar(ray.angle(), dist); - point_b2 = randomize(max_lenght, point_b3, point_b2); + lenght = max_lenght; + ray.setPoints(point_b3, point_b2); + if(!fixed_displacement ){ + lenght = Geom::distance(b2.pointAt(1.0/3.0), point_b3); + } + point_b2 = point_b3 + Geom::Point::polar(ray.angle() , lenght); } ray.setPoints(point_b1, point_a3); point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); @@ -431,11 +418,16 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point out->curveto(point_a1,point_a2,point_a3); out->curveto(point_b1, point_b2, point_b3); } else { - point_b1 = randomize(max_lenght, A->pointAt(t) + point_a3, A->pointAt(t + (t / 3))); + Geom::Ray ray(A->pointAt(t) + point_a3, A->pointAt(t + (t / 3))); + double lenght = max_lenght; + if(!fixed_displacement ){ + lenght = Geom::distance(A->pointAt(t) + point_a3, A->pointAt(t + (t / 3))); + } + point_b1 = A->pointAt(t) + point_a3 + Geom::Point::polar(ray.angle() , lenght); point_b2 = A->pointAt(t +((t / 3) * 2)); point_b3 = A->finalPoint() + point_b3; point_a3 = A->pointAt(t) + point_a3; - Geom::Ray ray(prev,A->initialPoint()); + ray.setPoints(prev,A->initialPoint()); point_a1 = A->initialPoint() + Geom::Point::polar(ray.angle(), max_lenght); if(prev == Geom::Point(0,0)){ point_a1 = randomize(max_lenght); @@ -443,10 +435,12 @@ SPCurve const * LPERoughen::addNodesAndJitter(Geom::Curve const * A, Geom::Point if(last){ Geom::Path b2(point_b3); b2.appendNew(point_a3); - double dist = Geom::distance(b2.pointAt(1.0/3.0), point_b3); - ray.setPoints(point_b3, b2.pointAt(1.0/3.0)); - point_b2 = point_b3 + Geom::Point::polar(ray.angle(), dist); - point_b2 = randomize(max_lenght, point_b3, point_b2); + lenght = max_lenght; + ray.setPoints(point_b3, point_b2); + if(!fixed_displacement ){ + lenght = Geom::distance(b2.pointAt(1.0/3.0), point_b3); + } + point_b2 = point_b3 + Geom::Point::polar(ray.angle() , lenght); } ray.setPoints(point_b1, point_a3); point_a2 = point_a3 + Geom::Point::polar(ray.angle(), max_lenght); @@ -512,7 +506,7 @@ SPCurve *LPERoughen::jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Poin Geom::Point point_a2(0, 0); Geom::Point point_a3(0, 0); if (shift_nodes) { - point_a3 = randomize(max_lenght); + point_a3 = randomize(max_lenght, true); } if (handles == HM_RAND || handles == HM_SMOOTH) { point_a1 = randomize(max_lenght); diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index b12bd08af..7e6a19d5a 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -47,7 +47,6 @@ public: virtual double sign(double randNumber); virtual void doOnApply(SPLPEItem const* lpeitem); virtual Geom::Point randomize(double max_lenght, bool is_node = false); - virtual Geom::Point randomize(double lenght, Geom::Point start, Geom::Point end); virtual void doBeforeEffect(SPLPEItem const * lpeitem); virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move, double t, bool last); virtual SPCurve *jitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move); @@ -62,7 +61,6 @@ private: RandomParam displace_y; RandomParam global_randomize; EnumParam handles; - ScalarParam max_smooth_angle; BoolParam shift_nodes; BoolParam fixed_displacement; BoolParam spray_tool_friendly; diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h index 52e3cc0a6..ca4440336 100644 --- a/src/live_effects/parameter/random.h +++ b/src/live_effects/parameter/random.h @@ -43,11 +43,11 @@ public: operator gdouble(); inline gdouble get_value() { return value; } ; - long defseed; protected: long startseed; long seed; + long defseed; gdouble value; gdouble min; -- cgit v1.2.3 From 8bd87961810251cac534f8f308a4b91e5d21afe0 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 16 Nov 2015 23:57:28 +0100 Subject: removes warnings when compiling with c++11 using uniqueptr instead of autoptr (bzr r14475) --- src/live_effects/lpe-interpolate_points.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-interpolate_points.cpp b/src/live_effects/lpe-interpolate_points.cpp index 4ac139752..cf70832ee 100644 --- a/src/live_effects/lpe-interpolate_points.cpp +++ b/src/live_effects/lpe-interpolate_points.cpp @@ -52,8 +52,11 @@ Geom::PathVector LPEInterpolatePoints::doEffect_path (Geom::PathVector const & path_in) { Geom::PathVector path_out; - +#if __cplusplus <= 199711L std::auto_ptr interpolator( Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())) ); +#else + std::unique_ptr interpolator( Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())) ); +#endif for(Geom::PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) { if (path_it->empty()) -- cgit v1.2.3 From 50e28d20c9262114fa1e5e10dfbce20ffdffe65b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Nov 2015 20:44:50 +0100 Subject: Bug fixes for simplify LPE and applied fix also affected #166937 (bzr r14495) --- src/live_effects/lpe-simplify.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 2d79d5b34..a919756df 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -28,8 +28,8 @@ namespace LivePathEffect { LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) : Effect(lpeobject), steps(_("Steps:"),_("Change number of simplify steps "), "steps", &wr, this,1), - threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.003), - smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to perform a smooth"), "smooth_angles", &wr, this, 20.), + threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.002), + smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to perform a smooth"), "smooth_angles", &wr, this, 0.), helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5), simplify_individual_paths(_("Paths separately"), _("Simplifying paths (separately)"), "simplify_individual_paths", &wr, this, false, "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), @@ -51,7 +51,7 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) steps.param_set_increments(1, 1); steps.param_set_digits(0); - smooth_angles.param_set_range(0.0, 365.0); + smooth_angles.param_set_range(0.0, 360.0); smooth_angles.param_set_increments(10, 10); smooth_angles.param_set_digits(2); @@ -138,6 +138,7 @@ LPESimplify::doEffect(SPCurve *curve) if(simplify_individual_paths) { size = Geom::L2(Geom::bounds_fast(original_pathv)->dimensions()); } + size /= sp_lpe_item->i2doc_affine().descrim(); for (int unsigned i = 0; i < steps; i++) { if ( simplify_just_coalesce ) { pathliv->Coalesce(threshold * size); @@ -198,13 +199,15 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) Geom::Point point_at2 = curve_it1->finalPoint(); Geom::Point point_at3 = curve_it1->finalPoint(); Geom::Point point_at4 = curve_it1->finalPoint(); + + if(start == Geom::Point(0,0)) { + start = point_at1; + } + if (cubic) { point_at1 = (*cubic)[1]; point_at2 = (*cubic)[2]; } - if(start == Geom::Point(0,0)) { - start = point_at1; - } if(path_it->closed() && curve_it2 == curve_endit) { point_at4 = start; @@ -219,11 +222,11 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) Geom::Ray ray2(point_at3, point_at4); double angle1 = Geom::rad_to_deg(ray1.angle()); double angle2 = Geom::rad_to_deg(ray2.angle()); - if((smooth_angles >= angle2 - angle1) && !are_near(point_at4,point_at3) && !are_near(point_at2,point_at3)) { + if((smooth_angles >= std::abs(angle2 - angle1)) && !are_near(point_at4,point_at3) && !are_near(point_at2,point_at3)) { double dist = Geom::distance(point_at2,point_at3); Geom::Angle angleFixed = ray2.angle(); angleFixed -= Geom::Angle::from_degrees(180.0); - point_at2 = Geom::Point::polar(angleFixed,dist) + point_at3; + point_at2 = Geom::Point::polar(angleFixed, dist) + point_at3; } nCurve->curveto(point_at1, point_at2, curve_it1->finalPoint()); cubic = dynamic_cast(nCurve->last_segment()); -- cgit v1.2.3 From a4b8f88b71de0fc72eb14e5f36ccad9c8292ceb2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 3 Dec 2015 00:21:43 +0100 Subject: Removed auto calulate distances in roughen LPE because strange resulton apply on LPE copy effect (bzr r14502) --- src/live_effects/lpe-roughen.cpp | 38 -------------------------------------- src/live_effects/lpe-roughen.h | 1 - 2 files changed, 39 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 310f791a1..b4ee54f1a 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -91,44 +91,6 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) LPERoughen::~LPERoughen() {} -static void -sp_get_better_default_size(SPItem *item, double &value) -{ - if (SP_IS_GROUP(item)) { - std::vector const item_list = sp_item_group_item_list(SP_GROUP(item)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPItem *subitem = *iter; - sp_get_better_default_size(subitem, value); - } - if(item_list.size() > 0){ - value /= item_list.size(); - } - } else { - SPShape *shape = dynamic_cast(item); - if (shape) { - SPCurve * c = NULL; - SPPath *path = dynamic_cast(shape); - if (path) { - c = path->get_original_curve(); - } else { - c = shape->getCurve(); - } - if (c) { - value += Geom::length(paths_to_pw(c->get_pathvector()))/(c->get_segment_count () * 6); - } - } - } -} - -void LPERoughen::doOnApply(SPLPEItem const* lpeitem) -{ - SPLPEItem * splpeitem = const_cast(lpeitem); - double initial = 0; - sp_get_better_default_size(SP_ITEM(splpeitem), initial); - displace_x.param_set_value(initial, 0); - displace_y.param_set_value(initial, 0); -} - void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem) { if(spray_tool_friendly && seed == 0 && SP_OBJECT(lpeitem)->getId()){ diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h index 7e6a19d5a..44a723c89 100644 --- a/src/live_effects/lpe-roughen.h +++ b/src/live_effects/lpe-roughen.h @@ -45,7 +45,6 @@ public: virtual void doEffect(SPCurve *curve); virtual double sign(double randNumber); - virtual void doOnApply(SPLPEItem const* lpeitem); virtual Geom::Point randomize(double max_lenght, bool is_node = false); virtual void doBeforeEffect(SPLPEItem const * lpeitem); virtual SPCurve const * addNodesAndJitter(Geom::Curve const * A, Geom::Point &prev, Geom::Point &last_move, double t, bool last); -- cgit v1.2.3 From 25fbd2cc032dd472c3f85468c957b52e2a10d446 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 7 Dec 2015 21:20:33 +0100 Subject: static code analysis (bzr r14510) --- src/live_effects/lpe-knot.cpp | 2 +- src/live_effects/parameter/originalpatharray.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index c3000fe0d..bf84e645d 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -507,7 +507,7 @@ static void collectPathsAndWidths (SPLPEItem const *lpeitem, Geom::PathVector &paths, std::vector &stroke_widths){ if (SP_IS_GROUP(lpeitem)) { std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( std::vector::const_iterator iter = item_list.begin(); iter != item_list.end(); iter++) { + for ( std::vector::const_iterator iter = item_list.begin(); iter != item_list.end(); ++iter) { SPObject *subitem = *iter; if (SP_IS_LPE_ITEM(subitem)) { collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 9e03e2c02..7e3a6f5fe 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -245,7 +245,7 @@ void OriginalPathArrayParam::on_down_button_click() if (*iter == row[_model->_colObject]) { std::vector::iterator niter = _vector.erase(iter); if (niter != _vector.end()) { - niter++; + ++niter; i++; } _vector.insert(niter, row[_model->_colObject]); -- cgit v1.2.3 From 5ffdf79a6ed7d33ca03d7da3d78cf75389486477 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 8 Dec 2015 14:18:15 +0100 Subject: add negative values to bend and pattern along path whith knot (bzr r14516) --- src/live_effects/lpe-bendpath.cpp | 20 +++++++++++++++++--- src/live_effects/lpe-patternalongpath.cpp | 23 +++++++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 5c20a7f9e..874e23c4c 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -192,7 +192,21 @@ KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const& Geom::Point const s = snap_knot_position(p, state); Geom::Path path_in = lpe->bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); Geom::Point ptA = path_in.pointAt(Geom::PathTime(0, 0.0)); - lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + Geom::Point B = path_in.pointAt(Geom::PathTime(1, 0.0)); + Geom::Curve const *first_curve = &path_in.curveAt(Geom::PathTime(0, 0.0)); + Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); + Geom::Ray ray(ptA, B); + if (cubic) { + ray.setPoints(ptA, (*cubic)[1]); + } + ray.setAngle(ray.angle() + Geom::deg_to_rad(90)); + Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse(); + Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos); + if(nearest_to_ray == 0){ + lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0)); + } else { + lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + } sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } @@ -211,8 +225,8 @@ KnotHolderEntityWidthBendPath::knot_get() const if (cubic) { ray.setPoints(ptA,(*cubic)[1]); } - Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle(); - Geom::Point result_point = Geom::Point::polar(first_curve_angle, (lpe->original_height * lpe->prop_scale)/2.0) + ptA; + ray.setAngle(ray.angle() + Geom::deg_to_rad(90)); + Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA; bp_helper_path.clear(); Geom::Path hp(result_point); diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index ed377e7f9..706091be9 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -291,7 +291,22 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin if (sp_shape) { Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); - lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); + Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0)); + Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); + Geom::Ray ray(ptA, B); + if (cubic) { + ray.setPoints(ptA, (*cubic)[1]); + } + ray.setAngle(ray.angle() + Geom::deg_to_rad(90)); + Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse(); + Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos); + if(nearest_to_ray == 0){ + lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0)); + } else { + lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + } + } sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } @@ -310,10 +325,10 @@ KnotHolderEntityWidthPatternAlongPath::knot_get() const Geom::CubicBezier const *cubic = dynamic_cast(&*first_curve); Geom::Ray ray(ptA, B); if (cubic) { - ray.setPoints((*cubic)[1], ptA); + ray.setPoints(ptA, (*cubic)[1]); } - Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle(); - Geom::Point result_point = Geom::Point::polar(first_curve_angle, (lpe->original_height * lpe->prop_scale)/2.0) + ptA; + ray.setAngle(ray.angle() + Geom::deg_to_rad(90)); + Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA; pap_helper_path.clear(); Geom::Path hp(result_point); -- cgit v1.2.3 From 695d61abbef5af697f01e1b046e5ecc89c9aab80 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 5 Jan 2016 16:30:09 +0100 Subject: Improve constant definitions (bzr r14561) --- src/live_effects/lpe-bspline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 7e92e767d..1423e670a 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -20,8 +20,8 @@ namespace LivePathEffect { const double HANDLE_CUBIC_GAP = 0.001; const double NO_POWER = 0.0; -const double DEFAULT_START_POWER = 0.333334; -const double DEFAULT_END_POWER = 0.666667; +const double DEFAULT_START_POWER = 1.0/3.0; +const double DEFAULT_END_POWER = 2.0/3.0; Geom::PathVector hp; void sp_bspline_drawHandle(Geom::Point p, double helper_size); -- cgit v1.2.3 From b3719f65d1bb2ee5ab7fd3bc67f92a657732580d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 17 Jan 2016 20:18:53 +0100 Subject: Add option to Lattice2 to update LPE only on release knot. This could be useful if item is too complex, making previous knots unusable This can be used in other LPE if anyone want or ping me to it. Maybe could be usefull add similar thing to path parameter, Same slow item become tooooo slow with bend path. (bzr r14604) --- src/live_effects/lpe-lattice2.cpp | 37 +++++++++++++++++++++++++++++++----- src/live_effects/lpe-lattice2.h | 1 + src/live_effects/parameter/point.cpp | 16 ++++++++++++---- src/live_effects/parameter/point.h | 7 +++++-- 4 files changed, 50 insertions(+), 11 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index 8c7f46cbd..b749370fa 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -46,6 +46,7 @@ LPELattice2::LPELattice2(LivePathEffectObject *lpeobject) : Effect(lpeobject), horizontal_mirror(_("Mirror movements in horizontal"), _("Mirror movements in horizontal"), "horizontal_mirror", &wr, this, false), vertical_mirror(_("Mirror movements in vertical"), _("Mirror movements in vertical"), "vertical_mirror", &wr, this, false), + live_update(_("Update while moving knots (maybe slow)"), _("Update while moving knots (maybe slow)"), "live_update", &wr, this, true), grid_point_0(_("Control 0:"), _("Control 0 - Ctrl+Alt+Click: reset, Ctrl: move along axes"), "gridpoint0", &wr, this), grid_point_1(_("Control 1:"), _("Control 1 - Ctrl+Alt+Click: reset, Ctrl: move along axes"), "gridpoint1", &wr, this), grid_point_2(_("Control 2:"), _("Control 2 - Ctrl+Alt+Click: reset, Ctrl: move along axes"), "gridpoint2", &wr, this), @@ -76,6 +77,7 @@ LPELattice2::LPELattice2(LivePathEffectObject *lpeobject) : // register all your parameters here, so Inkscape knows which parameters this effect has: registerParameter(&horizontal_mirror); registerParameter(&vertical_mirror); + registerParameter(&live_update); registerParameter(&grid_point_0); registerParameter(&grid_point_1); registerParameter(&grid_point_2); @@ -248,7 +250,7 @@ LPELattice2::newWidget() } Glib::ustring * tip = param->param_getTooltip(); if (widg) { - if (param->param_key == "horizontal_mirror" || param->param_key == "vertical_mirror") { + if (param->param_key == "horizontal_mirror" || param->param_key == "vertical_mirror" || param->param_key == "live_update") { vbox->pack_start(*widg, true, true, 2); } else { vbox_expander->pack_start(*widg, true, true, 2); @@ -300,8 +302,8 @@ LPELattice2::vertical(PointParam ¶m_one, PointParam ¶m_two, Geom::Line v } A[Geom::X] = nearest[Geom::X] - distance_middle; B[Geom::X] = nearest[Geom::X] + distance_middle; - param_one.param_setValue(A, true); - param_two.param_setValue(B, true); + param_one.param_setValue(A, live_update); + param_two.param_setValue(B, live_update); } void @@ -321,8 +323,8 @@ LPELattice2::horizontal(PointParam ¶m_one, PointParam ¶m_two, Geom::Line } A[Geom::Y] = nearest[Geom::Y] - distance_middle; B[Geom::Y] = nearest[Geom::Y] + distance_middle; - param_one.param_setValue(A, true); - param_two.param_setValue(B, true); + param_one.param_setValue(A, live_update); + param_two.param_setValue(B, live_update); } void @@ -464,6 +466,31 @@ LPELattice2::setDefaults() grid_point_28x30.param_update_default(gp28x30); grid_point_29x31.param_update_default(gp29x31); grid_point_32x33x34x35.param_update_default(gp32x33x34x35); + grid_point_0.param_set_liveupdate(live_update); + grid_point_1.param_set_liveupdate(live_update); + grid_point_2.param_set_liveupdate(live_update); + grid_point_3.param_set_liveupdate(live_update); + grid_point_4.param_set_liveupdate(live_update); + grid_point_5.param_set_liveupdate(live_update); + grid_point_6.param_set_liveupdate(live_update); + grid_point_7.param_set_liveupdate(live_update); + grid_point_8x9.param_set_liveupdate(live_update); + grid_point_10x11.param_set_liveupdate(live_update); + grid_point_12.param_set_liveupdate(live_update); + grid_point_13.param_set_liveupdate(live_update); + grid_point_14.param_set_liveupdate(live_update); + grid_point_15.param_set_liveupdate(live_update); + grid_point_16.param_set_liveupdate(live_update); + grid_point_17.param_set_liveupdate(live_update); + grid_point_18.param_set_liveupdate(live_update); + grid_point_19.param_set_liveupdate(live_update); + grid_point_20x21.param_set_liveupdate(live_update); + grid_point_22x23.param_set_liveupdate(live_update); + grid_point_24x26.param_set_liveupdate(live_update); + grid_point_25x27.param_set_liveupdate(live_update); + grid_point_28x30.param_set_liveupdate(live_update); + grid_point_29x31.param_set_liveupdate(live_update); + grid_point_32x33x34x35.param_set_liveupdate(live_update); } void diff --git a/src/live_effects/lpe-lattice2.h b/src/live_effects/lpe-lattice2.h index b32903c9e..8d0c18a3a 100644 --- a/src/live_effects/lpe-lattice2.h +++ b/src/live_effects/lpe-lattice2.h @@ -63,6 +63,7 @@ private: BoolParam horizontal_mirror; BoolParam vertical_mirror; + BoolParam live_update; PointParam grid_point_0; PointParam grid_point_1; PointParam grid_point_2; diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index 4c4d2cd9c..ca3471b29 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -25,9 +25,11 @@ namespace LivePathEffect { PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const gchar *htip, Geom::Point default_value) + Effect* effect, const gchar *htip, Geom::Point default_value, + bool live_update ) : Parameter(label, tip, key, wr, effect), defvalue(default_value), + liveupdate(live_update), knoth(NULL) { knot_shape = SP_KNOT_SHAPE_DIAMOND; @@ -48,6 +50,12 @@ PointParam::param_set_default() param_setValue(defvalue,true); } +void +PointParam::param_set_liveupdate( bool live_update) +{ + liveupdate = live_update; +} + Geom::Point PointParam::param_get_default() const{ return defvalue; @@ -70,7 +78,7 @@ PointParam::param_setValue(Geom::Point newpoint, bool write) param_write_to_repr(str); g_free(str); } - if(knoth){ + if(knoth && liveupdate){ knoth->update_knots(); } } @@ -166,9 +174,9 @@ PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &or s = A; } } - pparam->param_setValue(s, true); + pparam->param_setValue(s, this->pparam->liveupdate); SPLPEItem * splpeitem = dynamic_cast(item); - if(splpeitem){ + if(splpeitem && this->pparam->liveupdate){ sp_lpe_item_update_patheffect(splpeitem, false, false); } } diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 471fbc993..4329e0bcd 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -29,8 +29,9 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const gchar *handle_tip = NULL, - Geom::Point default_value = Geom::Point(0,0) ); // tip for automatically associated on-canvas handle + const gchar *handle_tip = NULL,// tip for automatically associated on-canvas handle + Geom::Point default_value = Geom::Point(0,0), + bool live_update = true ); virtual ~PointParam(); virtual Gtk::Widget * param_newWidget(); @@ -41,6 +42,7 @@ public: void param_setValue(Geom::Point newpoint, bool write = false); void param_set_default(); Geom::Point param_get_default() const; + void param_set_liveupdate(bool live_update); void param_update_default(Geom::Point newpoint); virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); @@ -54,6 +56,7 @@ private: PointParam(const PointParam&); PointParam& operator=(const PointParam&); Geom::Point defvalue; + bool liveupdate; KnotHolder *knoth; SPKnotShapeType knot_shape; SPKnotModeType knot_mode; -- cgit v1.2.3 From 61eff0365783b13f583255231684f76c653ce3d9 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 29 Jan 2016 11:12:58 +0100 Subject: Add an advert to fillet chamfer users that the coming version in 'pointwise' branch is not compatible. I hope soon I can commit the code (bzr r14623) --- src/live_effects/lpe-fillet-chamfer.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 209805da3..afa405b59 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -99,6 +99,14 @@ Gtk::Widget *LPEFilletChamfer::newWidget() vbox->set_border_width(5); vbox->set_homogeneous(false); vbox->set_spacing(2); + Gtk::HBox *advertaising = Gtk::manage(new Gtk::HBox(true, 0)); + Gtk::Button *advert = Gtk::manage(new Gtk::Button(Glib::ustring(_("IMPORTANT! New version soon...")))); + advertaising->pack_start(*advert, true, true, 2); + vbox->pack_start(*advertaising, true, true, 2); + Gtk::HBox *advertaising2 = Gtk::manage(new Gtk::HBox(true, 0)); + Gtk::Button *advert2 = Gtk::manage(new Gtk::Button(Glib::ustring(_("Not compatible. Convert works to paths.")))); + advertaising2->pack_start(*advert2, true, true, 2); + vbox->pack_start(*advertaising2, true, true, 2); std::vector::iterator it = param_vector.begin(); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { -- cgit v1.2.3 From 895095e1a30ae78ec98d7a0e60af953c56abe02b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 29 Jan 2016 17:56:53 +0100 Subject: Improve advertaising to Fillet-Chamfer (bzr r14625) --- src/live_effects/lpe-fillet-chamfer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index afa405b59..07760b172 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -104,7 +104,7 @@ Gtk::Widget *LPEFilletChamfer::newWidget() advertaising->pack_start(*advert, true, true, 2); vbox->pack_start(*advertaising, true, true, 2); Gtk::HBox *advertaising2 = Gtk::manage(new Gtk::HBox(true, 0)); - Gtk::Button *advert2 = Gtk::manage(new Gtk::Button(Glib::ustring(_("Not compatible. Convert works to paths.")))); + Gtk::Button *advert2 = Gtk::manage(new Gtk::Button(Glib::ustring(_("Not compatible. Convert to path after.")))); advertaising2->pack_start(*advert2, true, true, 2); vbox->pack_start(*advertaising2, true, true, 2); std::vector::iterator it = param_vector.begin(); -- cgit v1.2.3 From 0a2477feea6e1df586b926b8482afbf79e2355e1 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 7 Feb 2016 23:32:51 -0800 Subject: Sync 2Geom to commit 5ee51c1c4f2066faa3e2c82021fc92671ad44ba4 (bzr r14639) --- src/live_effects/lpe-bendpath.cpp | 4 ++-- src/live_effects/lpe-copy_rotate.cpp | 15 +++++++-------- src/live_effects/lpe-dynastroke.cpp | 1 - src/live_effects/lpe-interpolate.cpp | 1 - src/live_effects/lpe-knot.cpp | 1 - src/live_effects/lpe-patternalongpath.cpp | 4 ++-- src/live_effects/lpe-simplify.cpp | 4 ++-- src/live_effects/lpe-transform_2pts.cpp | 8 ++++---- src/live_effects/parameter/filletchamferpointarray.cpp | 2 +- 9 files changed, 18 insertions(+), 22 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 874e23c4c..d7c0b69a4 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -199,7 +199,7 @@ KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const& if (cubic) { ray.setPoints(ptA, (*cubic)[1]); } - ray.setAngle(ray.angle() + Geom::deg_to_rad(90)); + ray.setAngle(ray.angle() + Geom::rad_from_deg(90)); Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse(); Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos); if(nearest_to_ray == 0){ @@ -225,7 +225,7 @@ KnotHolderEntityWidthBendPath::knot_get() const if (cubic) { ray.setPoints(ptA,(*cubic)[1]); } - ray.setAngle(ray.angle() + Geom::deg_to_rad(90)); + ray.setAngle(ray.angle() + Geom::rad_from_deg(90)); Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA; bp_helper_path.clear(); diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index fd9b853d5..87d8f05a9 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -17,7 +17,6 @@ #include "live_effects/lpe-copy_rotate.h" #include <2geom/path.h> #include <2geom/transforms.h> -#include <2geom/d2-sbasis.h> #include <2geom/angle.h> #include "knot-holder-entity.h" @@ -107,8 +106,8 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem) dir = unit_vector(B - A); // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) - start_pos = origin + dir * Rotate(-deg_to_rad(starting_angle)) * dist_angle_handle; - rot_pos = origin + dir * Rotate(-deg_to_rad(rotation_angle+starting_angle)) * dist_angle_handle; + start_pos = origin + dir * Rotate(-rad_from_deg(starting_angle)) * dist_angle_handle; + rot_pos = origin + dir * Rotate(-rad_from_deg(rotation_angle+starting_angle)) * dist_angle_handle; if(copiesTo360 ){ rot_pos = origin; } @@ -129,9 +128,9 @@ LPECopyRotate::doEffect_pwd2 (Geom::Piecewise > const & p } Piecewise > output; - Affine pre = Translate(-origin) * Rotate(-deg_to_rad(starting_angle)); + Affine pre = Translate(-origin) * Rotate(-rad_from_deg(starting_angle)); for (int i = 0; i < num_copies; ++i) { - Rotate rot(-deg_to_rad(rotation_angle * i)); + Rotate rot(-rad_from_deg(rotation_angle * i)); Affine t = pre * rot * Translate(origin); output.concat(pwd2_in * t); } @@ -146,7 +145,7 @@ LPECopyRotate::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector((Geom::Point)origin); - hp.appendNew(origin + dir * Rotate(-deg_to_rad(rotation_angle+starting_angle)) * dist_angle_handle); + hp.appendNew(origin + dir * Rotate(-rad_from_deg(rotation_angle+starting_angle)) * dist_angle_handle); Geom::PathVector pathv; pathv.push_back(hp); hp_vec.push_back(pathv); @@ -188,7 +187,7 @@ KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) - lpe->starting_angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, s - lpe->origin))); + lpe->starting_angle.param_set_value(deg_from_rad(-angle_between(lpe->dir, s - lpe->origin))); if (state & GDK_SHIFT_MASK) { lpe->dist_angle_handle = L2(lpe->B - lpe->A); } else { @@ -208,7 +207,7 @@ KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) - lpe->rotation_angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, s - lpe->origin)) - lpe->starting_angle); + lpe->rotation_angle.param_set_value(deg_from_rad(-angle_between(lpe->dir, s - lpe->origin)) - lpe->starting_angle); if (state & GDK_SHIFT_MASK) { lpe->dist_angle_handle = L2(lpe->B - lpe->A); } else { diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index c60db4fc4..aeecd5d5c 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -20,7 +20,6 @@ #include <2geom/bezier-to-sbasis.h> #include <2geom/sbasis-to-bezier.h> #include <2geom/d2.h> -#include <2geom/d2-sbasis.h> #include <2geom/sbasis-math.h> #include <2geom/piecewise.h> diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index b1ad07d23..74c7efd90 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -16,7 +16,6 @@ #include <2geom/path.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/d2-sbasis.h> #include <2geom/piecewise.h> #include <2geom/sbasis-geometric.h> diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index bf84e645d..a033a6c4a 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -27,7 +27,6 @@ #include <2geom/sbasis-to-bezier.h> #include <2geom/sbasis.h> #include <2geom/d2.h> -#include <2geom/d2-sbasis.h> #include <2geom/path.h> #include <2geom/bezier-to-sbasis.h> #include <2geom/basic-intersection.h> diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 706091be9..9397d848f 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -298,7 +298,7 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin if (cubic) { ray.setPoints(ptA, (*cubic)[1]); } - ray.setAngle(ray.angle() + Geom::deg_to_rad(90)); + ray.setAngle(ray.angle() + Geom::rad_from_deg(90)); Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse(); Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos); if(nearest_to_ray == 0){ @@ -327,7 +327,7 @@ KnotHolderEntityWidthPatternAlongPath::knot_get() const if (cubic) { ray.setPoints(ptA, (*cubic)[1]); } - ray.setAngle(ray.angle() + Geom::deg_to_rad(90)); + ray.setAngle(ray.angle() + Geom::rad_from_deg(90)); Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA; pap_helper_path.clear(); diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index a919756df..4b62c6c65 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -220,8 +220,8 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) } Geom::Ray ray1(point_at2, point_at3); Geom::Ray ray2(point_at3, point_at4); - double angle1 = Geom::rad_to_deg(ray1.angle()); - double angle2 = Geom::rad_to_deg(ray2.angle()); + double angle1 = Geom::deg_from_rad(ray1.angle()); + double angle2 = Geom::deg_from_rad(ray2.angle()); if((smooth_angles >= std::abs(angle2 - angle1)) && !are_near(point_at4,point_at3) && !are_near(point_at2,point_at3)) { double dist = Geom::distance(point_at2,point_at3); Geom::Angle angleFixed = ray2.angle(); diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index f2b756567..dd1a29689 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -46,7 +46,7 @@ LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : point_b(Geom::Point()), pathvector(), append_path(false), - previous_angle(Geom::deg_to_rad(0)), + previous_angle(Geom::rad_from_deg(0)), previous_start(Geom::Point()), previous_lenght(-1) { @@ -151,10 +151,10 @@ LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem) } if(lock_lenght && !lock_angle && previous_lenght != -1) { Geom::Ray transformed((Geom::Point)start,(Geom::Point)end); - if(previous_start == start || previous_angle == Geom::deg_to_rad(0)) { + if(previous_start == start || previous_angle == Geom::rad_from_deg(0)) { previous_angle = transformed.angle(); } - } else if(lock_angle && !lock_lenght && previous_angle != Geom::deg_to_rad(0)) { + } else if(lock_angle && !lock_lenght && previous_angle != Geom::rad_from_deg(0)) { if(previous_start == start){ previous_lenght = Geom::distance((Geom::Point)start, (Geom::Point)end); } @@ -406,7 +406,7 @@ LPETransform2Pts::doEffect_pwd2 (Geom::Piecewise > const trans = (Geom::Point)end - helper.initialPoint(); } if(offset != 0){ - trans = Geom::Point::polar(transformed.angle() + Geom::deg_to_rad(-90),offset) + trans; + trans = Geom::Point::polar(transformed.angle() + Geom::rad_from_deg(-90),offset) + trans; } m *= Geom::Translate(trans); diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp index 399307502..117d57460 100644 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ b/src/live_effects/parameter/filletchamferpointarray.cpp @@ -392,7 +392,7 @@ void FilletChamferPointArrayParam::updateCanvasIndicators() Geom::PathVector pathv = sp_svg_read_pathv(svgd); Geom::Affine aff = Geom::Affine(); aff *= Geom::Scale(helper_size); - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270)); + aff *= Geom::Rotate(ray1.angle() - rad_from_deg(270)); aff *= Geom::Translate(last_pwd2[i].valueAt(Xvalue)); pathv *= aff; hp.push_back(pathv[0]); -- cgit v1.2.3 From 3baced40739b8b12bc5d258f05a209681e900cd6 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 15 Feb 2016 10:52:41 +0100 Subject: Temporary: Add different fallback strategies for 'line-join' LPE with 'arcs' line join. (bzr r14653) --- src/live_effects/lpe-jointype.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-jointype.cpp b/src/live_effects/lpe-jointype.cpp index 28f99eb94..2eef315dd 100644 --- a/src/live_effects/lpe-jointype.cpp +++ b/src/live_effects/lpe-jointype.cpp @@ -33,6 +33,9 @@ static const Util::EnumData JoinTypeData[] = { {JOIN_MITER, N_("Miter"), "miter"}, {JOIN_MITER_CLIP, N_("Miter Clip"), "miter-clip"}, {JOIN_EXTRAPOLATE, N_("Extrapolated arc"), "extrp_arc"}, + {JOIN_EXTRAPOLATE1, N_("Extrapolated arc Alt1"), "extrp_arc1"}, + {JOIN_EXTRAPOLATE2, N_("Extrapolated arc Alt2"), "extrp_arc2"}, + {JOIN_EXTRAPOLATE3, N_("Extrapolated arc Alt3"), "extrp_arc3"}, }; static const Util::EnumData CapTypeData[] = { -- cgit v1.2.3 From 4aba6b92f30733f400891d2c3a6d77c1ae1d7a47 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 2 Mar 2016 20:34:31 +0100 Subject: Fix for bug 1540070 Fixed bugs: - https://launchpad.net/bugs/1540070 (bzr r14678) --- src/live_effects/effect.cpp | 3 ++- src/live_effects/effect.h | 2 ++ src/live_effects/lpe-bendpath.cpp | 5 +---- src/live_effects/lpe-copy_rotate.cpp | 5 +---- src/live_effects/lpe-envelope.cpp | 4 +--- src/live_effects/lpe-lattice.cpp | 5 +---- src/live_effects/lpe-lattice2.cpp | 4 +--- src/live_effects/lpe-mirror_symmetry.cpp | 10 +--------- src/live_effects/lpe-mirror_symmetry.h | 2 -- src/live_effects/lpe-offset.cpp | 10 +--------- src/live_effects/lpe-offset.h | 2 -- src/live_effects/lpe-perspective-envelope.cpp | 4 +--- src/live_effects/lpe-perspective_path.cpp | 3 +-- src/live_effects/lpe-roughen.cpp | 4 +--- src/live_effects/lpe-simplify.cpp | 4 +--- src/live_effects/lpe-transform_2pts.cpp | 3 +-- src/live_effects/lpe-vonkoch.cpp | 5 +---- 17 files changed, 17 insertions(+), 58 deletions(-) (limited to 'src/live_effects') 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 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(lpeitem); - - item->apply_to_clippath(item); - item->apply_to_mask(item); } Geom::Piecewise > 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(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(&bend_path3) ); registerParameter( dynamic_cast(&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(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); } Geom::Piecewise > 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(&grid_point14) ); registerParameter( dynamic_cast(&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(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(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(&discard_orig_path) ); registerParameter( dynamic_cast(&reflection_line) ); } @@ -42,14 +42,6 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry() { } -void -LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) -{ - SPLPEItem * item = const_cast(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); -} - void LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem) { 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(&offset_pt)); } @@ -57,14 +57,6 @@ static void append_half_circle(Geom::Piecewise > &pwd2, pwd2.continuousConcat(cap_pwd2); } -void -LPEOffset::doBeforeEffect (SPLPEItem const* lpeitem) -{ - SPLPEItem * item = const_cast(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); -} - Geom::Piecewise > LPEOffset::doEffect_pwd2 (Geom::Piecewise > 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 > doEffect_pwd2 (Geom::Piecewise > 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(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(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(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(&drawall) ); registerParameter( dynamic_cast(&maxComplexity) ); //registerParameter( dynamic_cast(&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(lpeitem); - item->apply_to_clippath(item); - item->apply_to_mask(item); } -- cgit v1.2.3 From 78abefac4fdb9cd2a453818d09fc868366327b7a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 14 Mar 2016 18:24:16 +0100 Subject: Order LPE list (bzr r14706) --- src/live_effects/effect.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 47fd02554..38d59a43a 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -133,25 +133,24 @@ const Util::EnumData LPETypeData[] = { /* 0.91 */ {POWERSTROKE, N_("Power stroke"), "powerstroke"}, {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, -/* EXPERIMENTAL */ +/* 0.92 */ + {SIMPLIFY, N_("Simplify"), "simplify"}, + {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, + {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"}, + {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"}, + {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, + {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"}, {SHOW_HANDLES, N_("Show handles"), "show_handles"}, {ROUGHEN, N_("Roughen"), "roughen"}, {BSPLINE, N_("BSpline"), "bspline"}, {JOIN_TYPE, N_("Join type"), "join_type"}, {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"}, -/* Ponyscape */ +/* Ponyscape -> Inkscape 0.92*/ {ATTACH_PATH, N_("Attach path"), "attach_path"}, {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"}, {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"}, {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"}, {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"}, -/* 0.91 */ - {SIMPLIFY, N_("Simplify"), "simplify"}, - {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, - {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"}, - {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"}, - {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, - {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"}, }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); -- cgit v1.2.3