From 6fd1a081d166d88200a22a89928bdca9192b1491 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 27 Jul 2015 02:04:29 +0200 Subject: add flattern button to interactive simplify (bzr r14261) --- share/icons/icons.svg | 35 ++++++++++++++++----------- share/icons/symbolic_icons.svg | 16 ++++++++----- share/icons/tango_icons.svg | 46 +++++++++++++++++++---------------- src/live_effects/lpe-simplify.cpp | 1 + src/widgets/pencil-toolbar.cpp | 50 ++++++++++++++++++++++++++++++++++++++- src/widgets/toolbox.cpp | 1 + 6 files changed, 107 insertions(+), 42 deletions(-) diff --git a/share/icons/icons.svg b/share/icons/icons.svg index 044fb753c..c20164f44 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -1,6 +1,9 @@ + + + @@ -867,7 +870,7 @@ - + @@ -890,7 +893,7 @@ http://www.inkscape.org/ Inkscape Developers - + @@ -2812,11 +2815,11 @@ http://www.inkscape.org/ - + - + @@ -2928,7 +2931,7 @@ http://www.inkscape.org/ - + @@ -3422,8 +3425,8 @@ http://www.inkscape.org/ - - + + @@ -3541,7 +3544,7 @@ http://www.inkscape.org/ - + @@ -3815,8 +3818,8 @@ http://www.inkscape.org/ - - + + @@ -3856,7 +3859,7 @@ http://www.inkscape.org/ - + @@ -3954,8 +3957,12 @@ http://www.inkscape.org/ - - - + + + + + + + diff --git a/share/icons/symbolic_icons.svg b/share/icons/symbolic_icons.svg index afe5a8167..1f301f85c 100644 --- a/share/icons/symbolic_icons.svg +++ b/share/icons/symbolic_icons.svg @@ -1,7 +1,7 @@ - + Inkscape Icon Theme @@ -9,7 +9,7 @@ - + @@ -3464,10 +3464,6 @@ - - - - @@ -3617,5 +3613,13 @@ + + + + + + + + diff --git a/share/icons/tango_icons.svg b/share/icons/tango_icons.svg index 9728120e7..9a96e1f8f 100644 --- a/share/icons/tango_icons.svg +++ b/share/icons/tango_icons.svg @@ -2306,7 +2306,7 @@ - + @@ -3755,11 +3755,11 @@ http://www.inkscape.org/ - + - + @@ -3770,8 +3770,8 @@ http://www.inkscape.org/ - - + + @@ -5277,10 +5277,6 @@ http://www.inkscape.org/ - - - - @@ -5288,6 +5284,14 @@ http://www.inkscape.org/ + + + + + + + + @@ -6637,8 +6641,8 @@ http://www.inkscape.org/ - - + + @@ -6953,9 +6957,9 @@ http://www.inkscape.org/ - - - + + + @@ -6964,9 +6968,9 @@ http://www.inkscape.org/ - - - + + + @@ -6975,9 +6979,9 @@ http://www.inkscape.org/ - - - + + + @@ -7856,7 +7860,7 @@ http://www.inkscape.org/ - + diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 265192a17..f6842a030 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -82,6 +82,7 @@ LPESimplify::newWidget() { // use manage here, because after deletion of Effect object, others might still be pointing to this widget. Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); + vbox->set_border_width(5); vbox->set_homogeneous(false); vbox->set_spacing(2); diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 4b177d3ad..c889436b9 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "pencil-toolbar.h" #include "desktop.h" @@ -45,9 +46,11 @@ #include "ui/uxmanager.h" #include "widgets/spinbutton-events.h" #include +#include "live_effects/effect.h" #include "live_effects/lpe-simplify.h" #include "live_effects/effect-enum.h" #include "live_effects/lpeobject.h" +#include "live_effects/lpeobject-reference.h" #include "sp-lpe-item.h" #include "util/glib-list-iterators.h" @@ -233,6 +236,41 @@ static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GObject *obj) spinbutton_defocus(tbl); } +static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj) +{ + SPDesktop *desktop = static_cast(g_object_get_data(obj, "desktop")); + std::vector selected = desktop->getSelection()->itemList(); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it){ + SPLPEItem* lpeitem = dynamic_cast(*it); + if (lpeitem && lpeitem->hasPathEffect()){ + PathEffectList lpelist = lpeitem->getEffectList(); + std::list::iterator i; + for (i = lpelist.begin(); i != lpelist.end(); ++i) { + LivePathEffectObject *lpeobj = (*i)->lpeobject; + if (lpeobj) { + Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe(); + if (dynamic_cast(lpe)) { + SPShape * shape = dynamic_cast(lpeitem); + if(shape){ + SPCurve * c = shape->getCurveBeforeLPE(); + lpe->doEffect(c); + lpeitem->setCurrentPathEffect(*i); + if (lpelist.size() > 1){ + lpeitem->removeCurrentPathEffect(true); + shape->setCurveBeforeLPE(c); + } else { + lpeitem->removeCurrentPathEffect(false); + shape->setCurve(c,0); + } + break; + } + } + } + } + } + } +} + static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tbl) { // quit if run by the attr_changed listener @@ -255,7 +293,7 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); if (lpe) { double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); - tol = tol/(100.0*(101.0-tol)); + tol = tol/(100.0*(102.0-tol)); std::ostringstream ss; ss << tol; lpe->getRepr()->setAttribute("threshold", ss.str()); @@ -346,6 +384,16 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(freehand_simplify_lpe), holder) ; gtk_action_group_add_action( mainActions, GTK_ACTION(itact) ); } + /* LPE simplify flatten */ + { + InkAction* inky = ink_action_new( "PencilLpeSimplifyFlatten", + _("LPE simplify flatten"), + _("LPE simplify flatten"), + INKSCAPE_ICON("flatten_simplify"), + Inkscape::ICON_SIZE_SMALL_TOOLBAR ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_simplify_flatten), holder ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 62e4bcb8b..cdf39e9ef 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -399,6 +399,7 @@ static gchar const * ui_descr = " " " " " " + " " " " " " " " -- cgit v1.2.3