=== modified file 'src/sp-lpe-item.cpp' --- src/sp-lpe-item.cpp 2015-12-07 20:19:14 +0000 +++ src/sp-lpe-item.cpp 2016-02-01 23:17:20 +0000 @@ -209,7 +209,7 @@ /** * returns true when LPE was successful. */ -bool SPLPEItem::performPathEffect(SPCurve *curve) { +bool SPLPEItem::performPathEffect(SPCurve *curve, bool onlyfirst) { if (!this) { return false; } @@ -265,6 +265,9 @@ lpe->doAfterEffect(this); } } + if (onlyfirst) { + break; + } } } @@ -822,6 +825,61 @@ return NULL; } +void +SPLPEItem::flattenFirstLpe(SPItem *item) +{ + flattenFirstLpeData(item); + removeFirstLpeFromList(item); +} + +void +SPLPEItem::removeFirstLpeFromList(SPItem *item) +{ + PathEffectList lpelist = this->getEffectList(); + std::list::iterator i; + for (i = lpelist.begin(); i != lpelist.end(); ++i) { + LivePathEffectObject *lpeobj = (*i)->lpeobject; + if (lpeobj) { + this->setCurrentPathEffect(*i); + this->removeCurrentPathEffect(true); + break; + } + } +} + + +void +SPLPEItem::flattenFirstLpeData(SPItem *item) +{ + if (SP_IS_GROUP(item)) { + std::vector 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); + flattenFirstLpe(subitem); + } + } else if (SP_IS_SHAPE(item)) { + SPCurve * c = NULL; + + if (SP_IS_PATH(item)) { + c = SP_PATH(item)->get_original_curve(); + } else { + c = SP_SHAPE(item)->getCurve(); + } + if (c) { + PathEffectList lpelist = this->getEffectList(); + std::list::iterator i; + for (i = lpelist.begin(); i != lpelist.end(); ++i) { + LivePathEffectObject *lpeobj = (*i)->lpeobject; + if (lpeobj) { + this->performPathEffect(c, true); + SP_SHAPE(item)->setCurveBeforeLPE(c); + break; + } + } + } + } +} + void SPLPEItem::editNextParamOncanvas(SPDesktop *dt) { Inkscape::LivePathEffect::LPEObjectReference *lperef = this->getCurrentLPEReference(); === modified file 'src/sp-lpe-item.h' --- src/sp-lpe-item.h 2015-08-21 20:25:37 +0000 +++ src/sp-lpe-item.h 2016-02-01 19:50:50 +0000 @@ -69,7 +69,7 @@ virtual void update_patheffect(bool write); - bool performPathEffect(SPCurve *curve); + bool performPathEffect(SPCurve *curve, bool onlyfirst = false); bool pathEffectsEnabled() const; bool hasPathEffect() const; @@ -95,6 +95,9 @@ void apply_to_clippath(SPItem * item); void apply_to_clip_or_mask_group(SPItem * group, SPItem * item); bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1); + void flattenFirstLpe(SPItem *item); + void flattenFirstLpeData(SPItem *item); + void removeFirstLpeFromList(SPItem *item); void editNextParamOncanvas(SPDesktop *dt); }; === modified file 'src/ui/dialog/livepatheffect-editor.cpp' --- src/ui/dialog/livepatheffect-editor.cpp 2015-02-22 03:47:34 +0000 +++ src/ui/dialog/livepatheffect-editor.cpp 2016-02-01 23:40:02 +0000 @@ -42,6 +42,7 @@ #include "sp-use.h" #include "sp-text.h" #include "sp-shape.h" +#include "sp-lpe-item.h" #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" #include "verbs.h" @@ -95,6 +96,7 @@ effectcontrol_frame(""), button_add(), button_remove(), + button_flatten(), button_up(), button_down(), current_desktop(NULL), @@ -123,6 +125,10 @@ button_remove.set_tooltip_text(_("Delete current path effect")); lpe_style_button(button_remove, INKSCAPE_ICON("list-remove")); button_remove.set_relief(Gtk::RELIEF_NONE); + + button_flatten.set_tooltip_text(_("Flatten from current path effect")); + lpe_style_button(button_flatten, INKSCAPE_ICON("flatten-basic")); + button_flatten.set_relief(Gtk::RELIEF_NONE); button_up.set_tooltip_text(_("Raise the current path effect")); lpe_style_button(button_up, INKSCAPE_ICON("go-up")); @@ -145,6 +151,8 @@ toolbar_hbox.set_child_secondary( button_add , true); toolbar_hbox.add( button_remove ); toolbar_hbox.set_child_secondary( button_remove , true); + toolbar_hbox.add( button_flatten ); + toolbar_hbox.set_child_secondary( button_flatten , true); toolbar_hbox.add( button_up ); toolbar_hbox.add( button_down ); @@ -180,6 +188,7 @@ // connect callback functions to buttons button_add.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onAdd)); button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove)); + button_flatten.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onFlatten)); button_up.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onUp)); button_down.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onDown)); @@ -219,6 +228,7 @@ effectcontrol_vbox.pack_start(*effectwidget, true, true); } button_remove.show(); + button_flatten.show(); status_label.hide(); effectcontrol_frame.show(); @@ -260,6 +270,7 @@ //combo_effecttype.set_sensitive(sensitive); button_add.set_sensitive(sensitive); button_remove.set_sensitive(sensitive); + button_flatten.set_sensitive(sensitive); effectlist_view.set_sensitive(sensitive); button_up.set_sensitive(sensitive); button_down.set_sensitive(sensitive); @@ -300,6 +311,7 @@ } else { showText(_("Click button to add an effect")); button_remove.set_sensitive(false); + button_flatten.set_sensitive(false); button_up.set_sensitive(false); button_down.set_sensitive(false); } @@ -315,6 +327,7 @@ set_sensitize_all(true); showText(_("Click add button to convert clone")); button_remove.set_sensitive(false); + button_flatten.set_sensitive(false); button_up.set_sensitive(false); button_down.set_sensitive(false); } else { @@ -351,7 +364,6 @@ if ( !(*it)->lpeobject ) { continue; } - if ((*it)->lpeobject->get_lpe()) { Gtk::TreeModel::Row row = *(effectlist_store->append()); row[columns.col_name] = (*it)->lpeobject->get_lpe()->getName(); @@ -505,6 +517,30 @@ } +void LivePathEffectEditor::onFlatten() +{ + Inkscape::Selection *sel = _getSelection(); + if ( sel && !sel->isEmpty() ) { + SPItem *item = sel->singleItem(); + SPLPEItem *lpeitem = dynamic_cast(item); + Inkscape::LivePathEffect::LPEObjectReference *lperef = lpeitem->getCurrentLPEReference(); + if (lpeitem && lpeitem->hasPathEffect()){ + PathEffectList lpelist = lpeitem->getEffectList(); + std::list::iterator i; + for (i = lpelist.begin(); i != lpelist.end(); ++i) { + Inkscape::LivePathEffect::LPEObjectReference * lperefitemlist = (*i); + lpeitem->flattenFirstLpe(item); + if (lperef == lperefitemlist){ + break; + } + } + sel->clear(); + sel->add((SPObject *)item); + effect_list_reload(lpeitem); + } + } +} + void LivePathEffectEditor::onUp() { Inkscape::Selection *sel = _getSelection(); === modified file 'src/ui/dialog/livepatheffect-editor.h' --- src/ui/dialog/livepatheffect-editor.h 2014-03-27 01:33:44 +0000 +++ src/ui/dialog/livepatheffect-editor.h 2016-02-01 20:16:16 +0000 @@ -75,6 +75,7 @@ // callback methods for buttons on grids page. void onAdd(); void onRemove(); + void onFlatten(); void onUp(); void onDown(); @@ -88,7 +89,6 @@ add(col_visible); } virtual ~ModelColumns() {} - Gtk::TreeModelColumn col_name; Gtk::TreeModelColumn lperef; Gtk::TreeModelColumn col_visible; @@ -119,6 +119,7 @@ #endif Gtk::Button button_add; Gtk::Button button_remove; + Gtk::Button button_flatten; Gtk::Button button_up; Gtk::Button button_down;