From 3b585aa639d46417beb401847600e5918406e5c1 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 18 Oct 2014 17:03:29 +0200 Subject: LPE Powerstroke, editing behavior: implement scaling of strokepath width when the proportional-stroke-scaling toggle is on. Patch by Javier, tweaks by Johan. (bzr r13623) --- src/live_effects/parameter/powerstrokepointarray.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/live_effects/parameter/powerstrokepointarray.cpp') diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 647986da6..420195aa8 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -68,9 +68,23 @@ PowerStrokePointArrayParam::param_newWidget() } -void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/) +void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const &postmul, bool /*set*/) { -// param_set_and_write_new_value( (*this) * postmul ); + // Check if proportional stroke-width scaling is on + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true; + if (transform_stroke) { + std::vector result; + result.reserve(_vector.size()); // reserve space for the points that will be added in the for loop + for (std::vector::const_iterator point_it = _vector.begin(), e = _vector.end(); + point_it != e; ++point_it) + { + // scale each width knot with the average scaling in X and Y + Geom::Coord const A = (*point_it)[Geom::Y] * ((postmul.expansionX() + postmul.expansionY()) / 2); + result.push_back(Geom::Point((*point_it)[Geom::X], A)); + } + param_set_and_write_new_value(result); + } } -- cgit v1.2.3 From 96ae336eb61517078d4ab86629908724824806a4 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sat, 18 Oct 2014 17:10:19 +0200 Subject: noop: remove cruft from powerstrokepointarray.cpp (bzr r13624) --- .../parameter/powerstrokepointarray.cpp | 28 +--------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'src/live_effects/parameter/powerstrokepointarray.cpp') diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 420195aa8..964ab13b0 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -9,17 +9,13 @@ #include "live_effects/parameter/powerstrokepointarray.h" #include "live_effects/effect.h" -#include "svg/svg.h" -#include "svg/stringstream.h" #include "knotholder.h" #include "sp-lpe-item.h" #include <2geom/piecewise.h> #include <2geom/sbasis-geometric.h> -// needed for on-canvas editting: -#include "desktop.h" -#include "live_effects/lpeobject.h" +#include "preferences.h" // for proportional stroke/path scaling behavior namespace Inkscape { @@ -43,28 +39,6 @@ Gtk::Widget * PowerStrokePointArrayParam::param_newWidget() { return NULL; -/* - Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label, - param_tooltip, - param_key, - *param_wr, - param_effect->getRepr(), - param_effect->getSPDoc() ) ); - // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP) - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - Geom::Affine transf = desktop->doc2dt(); - pointwdg->setTransform(transf); - pointwdg->setValue( *this ); - pointwdg->clearProgrammatically(); - pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter")); - - Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() ); - static_cast(hbox)->pack_start(*pointwdg, true, true); - static_cast(hbox)->show_all_children(); - - return dynamic_cast (hbox); -*/ } -- cgit v1.2.3