From 2c160c193b9767df8448ec3d018c3d6225a4ec63 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 27 May 2017 12:23:25 +0200 Subject: Change bad named vars (bzr r15703.1.1) --- src/live_effects/effect.cpp | 2 +- src/live_effects/effect.h | 2 +- src/live_effects/lpe-copy_rotate.cpp | 4 ++-- src/live_effects/lpe-fillet-chamfer.cpp | 2 +- src/live_effects/lpe-measure-line.cpp | 4 ++-- src/live_effects/lpe-mirror_symmetry.cpp | 4 ++-- src/live_effects/parameter/bool.cpp | 6 +++--- src/live_effects/parameter/bool.h | 4 ++-- src/live_effects/parameter/hidden.cpp | 6 ++++-- src/live_effects/parameter/hidden.h | 5 +++-- src/live_effects/parameter/parameter.cpp | 6 +++--- src/live_effects/parameter/parameter.h | 4 ++-- src/sp-lpe-item.cpp | 2 +- 13 files changed, 27 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index a4b44b1a9..23a4c9f3d 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -355,7 +355,7 @@ Effect::Effect(LivePathEffectObject *lpeobject) 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), - erase_extra_objects(true), + keep_paths(false), lpeobj(lpeobject), concatenate_before_pwd2(false), sp_lpe_item(NULL), diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 60ee8d98f..cc0d53f12 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -132,7 +132,7 @@ public: void editNextParamOncanvas(SPItem * item, SPDesktop * desktop); bool apply_to_clippath_and_mask; - bool erase_extra_objects; // set this to false allow retain extra generated objects, see measure line LPE + bool keep_paths; // set this to false allow retain extra generated objects, see measure line LPE bool upd_params; BoolParam is_visible; SPCurve * sp_curve; diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index ff24b46da..2364f4f66 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -722,8 +722,8 @@ LPECopyRotate::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) void LPECopyRotate::doOnRemove (SPLPEItem const* /*lpeitem*/) { - //unset "erase_extra_objects" hook on sp-lpe-item.cpp - if (!erase_extra_objects) { + //set "keep paths" hook on sp-lpe-item.cpp + if (keep_paths) { processObjects(LPE_TO_OBJECTS); return; } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 08ceab3c3..a2f0b829d 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -38,7 +38,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) method(_("Method:"), _("Methods to calculate the fillet or chamfer"), "method", FMConverter, &wr, this, FM_AUTO), mode(_("Mode:"), _("Mode, fillet or chamfer"), - "mode", &wr, this, "F"), + "mode", &wr, this, "F", true), radius(_("Radius (unit or %):"), _("Radius, in unit or %"), "radius", &wr, this, 0.0), chamfer_steps(_("Chamfer steps:"), _("Chamfer steps"), "chamfer_steps", diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index f7892cbe7..f18ba2dcd 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -674,8 +674,8 @@ LPEMeasureLine::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) void LPEMeasureLine::doOnRemove (SPLPEItem const* /*lpeitem*/) { - //unset "erase_extra_objects" hook on sp-lpe-item.cpp - if (!erase_extra_objects) { + //set "keep paths" hook on sp-lpe-item.cpp + if (keep_paths) { processObjects(LPE_TO_OBJECTS); items.clear(); return; diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index bd3dedc86..9c2b876db 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -350,8 +350,8 @@ LPEMirrorSymmetry::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) void LPEMirrorSymmetry::doOnRemove (SPLPEItem const* /*lpeitem*/) { - //unset "erase_extra_objects" hook on sp-lpe-item.cpp - if (!erase_extra_objects) { + //set "keep paths" hook on sp-lpe-item.cpp + if (keep_paths) { processObjects(LPE_TO_OBJECTS); return; } diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index 3184bfa80..d9e8ecc90 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 , bool no_widget) - : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value), hide_widget(no_widget) + Effect* effect, bool default_value , bool is_visible) + : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value), widget_is_visible(is_visible) { } @@ -65,7 +65,7 @@ BoolParam::param_getSVGValue() const Gtk::Widget * BoolParam::param_newWidget() { - if(!hide_widget){ + if(widget_is_visible){ Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( new Inkscape::UI::Widget::RegisteredCheckButton( param_label, param_tooltip, diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index 39f328eaa..86681e764 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -26,7 +26,7 @@ public: Inkscape::UI::Widget::Registry* wr, Effect* effect, bool default_value = false, - bool no_widget = false); + bool widget_is_visible = true); virtual ~BoolParam(); virtual Gtk::Widget * param_newWidget(); @@ -40,6 +40,7 @@ public: virtual void param_update_default(const gchar * default_value); bool get_value() const { return value; }; inline operator bool() const { return value; }; + bool widget_is_visible; private: BoolParam(const BoolParam&); @@ -47,7 +48,6 @@ private: bool value; bool defvalue; - bool hide_widget; }; diff --git a/src/live_effects/parameter/hidden.cpp b/src/live_effects/parameter/hidden.cpp index 2f218847a..95735d50f 100644 --- a/src/live_effects/parameter/hidden.cpp +++ b/src/live_effects/parameter/hidden.cpp @@ -22,10 +22,12 @@ namespace LivePathEffect { HiddenParam::HiddenParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const Glib::ustring default_value ) + Effect* effect, const Glib::ustring default_value, bool is_visible) : Parameter(label, tip, key, wr, effect), value(default_value), - defvalue(default_value) + defvalue(default_value), + //This last is to allow set or unset default parameters on hidden ones + widget_is_visible(is_visible) { } diff --git a/src/live_effects/parameter/hidden.h b/src/live_effects/parameter/hidden.h index d565272b6..f07dd9edc 100644 --- a/src/live_effects/parameter/hidden.h +++ b/src/live_effects/parameter/hidden.h @@ -29,7 +29,8 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const Glib::ustring default_value = ""); + const Glib::ustring default_value = "", + bool widget_is_visible = false); virtual ~HiddenParam() {} virtual Gtk::Widget * param_newWidget(); @@ -42,7 +43,7 @@ public: virtual void param_update_default(const gchar * default_value); const Glib::ustring get_value() const { return value; }; - + bool widget_is_visible; private: HiddenParam(const HiddenParam&); HiddenParam& operator=(const HiddenParam&); diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 45f46a0a7..cc7b476d7 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -55,7 +55,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, bool no_widget) + Effect* effect, gdouble default_value, bool is_visible) : Parameter(label, tip, key, wr, effect), value(default_value), min(-SCALARPARAM_G_MAXDOUBLE), @@ -67,7 +67,7 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, inc_page(1), add_slider(false), overwrite_widget(false), - hide_widget(no_widget) + widget_is_visible(is_visible) { } @@ -172,7 +172,7 @@ ScalarParam::param_overwrite_widget(bool overwrite_widget) Gtk::Widget * ScalarParam::param_newWidget() { - if(!hide_widget){ + if(widget_is_visible){ 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() ) ); diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index ee1d2d547..bdba9f860 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -104,7 +104,7 @@ public: Inkscape::UI::Widget::Registry* wr, Effect* effect, gdouble default_value = 1.0, - bool no_widget = false); + bool widget_is_visible = true); virtual ~ScalarParam(); virtual bool param_readSVGValue(const gchar * strvalue); @@ -125,6 +125,7 @@ public: virtual Gtk::Widget * param_newWidget(); inline operator gdouble() const { return value; }; + bool widget_is_visible; protected: gdouble value; @@ -137,7 +138,6 @@ protected: double inc_page; bool add_slider; bool overwrite_widget; - bool hide_widget; private: ScalarParam(const ScalarParam&); diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index efb1f4353..b08772826 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -519,7 +519,7 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths) LivePathEffectObject *lpeobj = (*it)->lpeobject; if (lpeobj) { Inkscape::LivePathEffect::Effect * lpe = lpeobj->get_lpe(); - lpe->erase_extra_objects = false; + lpe->keep_paths = true; } } } -- cgit v1.2.3 From 9867bcf966bf0a52333fd3c129d94d3afa4baa55 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 27 May 2017 14:00:01 +0200 Subject: More fixes to LPE (bzr r15703.1.2) --- src/live_effects/lpe-bspline.cpp | 4 +-- src/live_effects/lpe-copy_rotate.cpp | 15 +++++----- src/live_effects/lpe-fillet-chamfer.cpp | 2 +- src/live_effects/lpe-measure-line.cpp | 35 ++++++++++++------------ src/live_effects/lpe-mirror_symmetry.cpp | 38 ++------------------------ src/live_effects/lpe-mirror_symmetry.h | 1 - src/live_effects/lpe-transform_2pts.cpp | 4 +-- src/live_effects/parameter/bool.cpp | 4 +-- src/live_effects/parameter/bool.h | 4 +-- src/live_effects/parameter/hidden.cpp | 5 ++-- src/live_effects/parameter/hidden.h | 2 +- src/live_effects/parameter/parameter.cpp | 11 ++++---- src/live_effects/parameter/parameter.h | 9 +++--- src/live_effects/parameter/satellitesarray.cpp | 1 + 14 files changed, 47 insertions(+), 88 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index dbd67beda..721a4ecab 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -44,12 +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); + weight.param_set_undo(false); steps.param_set_range(1, 10); steps.param_set_increments(1, 1); steps.param_set_digits(0); - steps.param_overwrite_widget(true); + steps.param_set_undo(false); helper_size.param_set_range(0.0, 999.0); helper_size.param_set_increments(1, 1); diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 2364f4f66..551cf1bf9 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -96,6 +96,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : previous_num_copies = num_copies; previous_origin = Geom::Point(0,0); previous_start_point = Geom::Point(0,0); + starting_point.param_widget_is_visible(false); reset = false; } @@ -319,14 +320,12 @@ Gtk::Widget * LPECopyRotate::newWidget() Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); Glib::ustring *tip = param->param_getTooltip(); if (widg) { - if (param->param_key != "starting_point") { - vbox->pack_start(*widg, true, true, 2); - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); } } } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index a2f0b829d..11298bcbe 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -80,7 +80,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) radius.param_set_range(0.0, Geom::infinity()); radius.param_set_increments(1, 1); radius.param_set_digits(4); - radius.param_overwrite_widget(true); + radius.param_set_undo(false); chamfer_steps.param_set_range(1, 999); chamfer_steps.param_set_increments(1, 1); chamfer_steps.param_set_digits(0); diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index f18ba2dcd..99828aef8 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -141,6 +141,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : helpline_overlap.param_set_digits(2); start_stored = Geom::Point(0,0); end_stored = Geom::Point(0,0); + id_origin.param_widget_is_visible(false); } LPEMeasureLine::~LPEMeasureLine() {} @@ -700,24 +701,22 @@ Gtk::Widget *LPEMeasureLine::newWidget() while (it != param_vector.end()) { if ((*it)->widget_is_visible) { Parameter *param = *it; - if (param->param_key != "id_origin") { - Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); - Glib::ustring *tip = param->param_getTooltip(); - if (widg) { - if (param->param_key != "dimline_format" && - param->param_key != "helperlines_format" && - param->param_key != "arrows_format" && - param->param_key != "anotation_format") { - vbox->pack_start(*widg, true, true, 2); - } else { - vbox_expander->pack_start(*widg, true, true, 2); - } - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } + Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + Glib::ustring *tip = param->param_getTooltip(); + if (widg) { + if (param->param_key != "dimline_format" && + param->param_key != "helperlines_format" && + param->param_key != "arrows_format" && + param->param_key != "anotation_format") { + vbox->pack_start(*widg, true, true, 2); + } else { + vbox_expander->pack_start(*widg, true, true, 2); + } + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); } } } diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 9c2b876db..8e68c483c 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -78,6 +78,8 @@ LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) : split_gap.param_set_digits(5); apply_to_clippath_and_mask = true; previous_center = Geom::Point(0,0); + id_origin.param_widget_is_visible(false); + center_point.param_widget_is_visible(false); } LPEMirrorSymmetry::~LPEMirrorSymmetry() @@ -304,42 +306,6 @@ LPEMirrorSymmetry::toMirror(Geom::Affine transform) } } -Gtk::Widget * -LPEMirrorSymmetry::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); - - std::vector::iterator it = param_vector.begin(); - while (it != param_vector.end()) { - if ((*it)->widget_is_visible) { - Parameter * param = *it; - if (param->param_key == "id_origin" || param->param_key == "center_point") { - ++it; - continue; - } - Gtk::Widget * widg = param->param_newWidget(); - Glib::ustring * tip = param->param_getTooltip(); - if (widg) { - vbox->pack_start(*widg, true, true, 2); - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } - } - } - - ++it; - } - return dynamic_cast(vbox); -} - //TODO: Migrate the tree next function to effect.cpp/h to avoid duplication void LPEMirrorSymmetry::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) diff --git a/src/live_effects/lpe-mirror_symmetry.h b/src/live_effects/lpe-mirror_symmetry.h index 07bb3d4fc..e98c83f2b 100644 --- a/src/live_effects/lpe-mirror_symmetry.h +++ b/src/live_effects/lpe-mirror_symmetry.h @@ -46,7 +46,6 @@ public: virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/); - virtual Gtk::Widget * newWidget(); void toMirror(Geom::Affine transform); // void cloneAttrbutes(Inkscape::XML::Node * origin, Inkscape::XML::Node * dest, const char * first_attribute, ...); void cloneD(SPObject *orig, SPObject *dest, bool live, bool root); diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index f4d233d56..ab05b880c 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -64,9 +64,9 @@ LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : registerParameter(&lock_angle); first_knot.param_make_integer(true); - first_knot.param_overwrite_widget(true); + first_knot.param_set_undo(false); last_knot.param_make_integer(true); - last_knot.param_overwrite_widget(true); + last_knot.param_set_undo(false); helper_size.param_set_range(0, 999); helper_size.param_set_increments(1, 1); helper_size.param_set_digits(0); diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index d9e8ecc90..954947cf4 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 , bool is_visible) - : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value), widget_is_visible(is_visible) + Effect* effect, bool default_value) + : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value) { } diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index 86681e764..417752050 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -25,8 +25,7 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - bool default_value = false, - bool widget_is_visible = true); + bool default_value = false); virtual ~BoolParam(); virtual Gtk::Widget * param_newWidget(); @@ -40,7 +39,6 @@ public: virtual void param_update_default(const gchar * default_value); bool get_value() const { return value; }; inline operator bool() const { return value; }; - bool widget_is_visible; private: BoolParam(const BoolParam&); diff --git a/src/live_effects/parameter/hidden.cpp b/src/live_effects/parameter/hidden.cpp index 95735d50f..6d0e7f58f 100644 --- a/src/live_effects/parameter/hidden.cpp +++ b/src/live_effects/parameter/hidden.cpp @@ -25,10 +25,9 @@ HiddenParam::HiddenParam( const Glib::ustring& label, const Glib::ustring& tip, Effect* effect, const Glib::ustring default_value, bool is_visible) : Parameter(label, tip, key, wr, effect), value(default_value), - defvalue(default_value), - //This last is to allow set or unset default parameters on hidden ones - widget_is_visible(is_visible) + defvalue(default_value) { + param_widget_is_visible(is_visible); } void diff --git a/src/live_effects/parameter/hidden.h b/src/live_effects/parameter/hidden.h index f07dd9edc..387071e53 100644 --- a/src/live_effects/parameter/hidden.h +++ b/src/live_effects/parameter/hidden.h @@ -43,7 +43,7 @@ public: virtual void param_update_default(const gchar * default_value); const Glib::ustring get_value() const { return value; }; - bool widget_is_visible; + private: HiddenParam(const HiddenParam&); HiddenParam& operator=(const HiddenParam&); diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index cc7b476d7..2f73488aa 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -55,7 +55,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, bool is_visible) + Effect* effect, gdouble default_value) : Parameter(label, tip, key, wr, effect), value(default_value), min(-SCALARPARAM_G_MAXDOUBLE), @@ -66,8 +66,7 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, inc_step(0.1), inc_page(1), add_slider(false), - overwrite_widget(false), - widget_is_visible(is_visible) + _set_undo(true) { } @@ -164,9 +163,9 @@ ScalarParam::param_make_integer(bool yes) } void -ScalarParam::param_overwrite_widget(bool overwrite_widget) +ScalarParam::param_set_undo(bool set_undo) { - this->overwrite_widget = overwrite_widget; + _set_undo = set_undo; } Gtk::Widget * @@ -184,7 +183,7 @@ ScalarParam::param_newWidget() if (add_slider) { rsu->addSlider(); } - if(!overwrite_widget){ + if(_set_undo){ 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 bdba9f860..7ab7e30dd 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -57,6 +57,7 @@ public: virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted. virtual gchar * param_getSVGValue() const = 0; + virtual void param_widget_is_visible(bool is_visible) {widget_is_visible = is_visible;} void write_to_SVG(); virtual void param_set_default() = 0; @@ -103,8 +104,7 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - gdouble default_value = 1.0, - bool widget_is_visible = true); + gdouble default_value = 1.0); virtual ~ScalarParam(); virtual bool param_readSVGValue(const gchar * strvalue); @@ -121,11 +121,10 @@ public: void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; double param_get_max() { return max; }; double param_get_min() { return min; }; - void param_overwrite_widget(bool overwrite_widget); + void param_set_undo(bool set_undo); virtual Gtk::Widget * param_newWidget(); inline operator gdouble() const { return value; }; - bool widget_is_visible; protected: gdouble value; @@ -137,7 +136,7 @@ protected: double inc_step; double inc_page; bool add_slider; - bool overwrite_widget; + bool _set_undo; private: ScalarParam(const ScalarParam&); diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 7626317a1..ce4da243e 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -37,6 +37,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, _current_zoom = 0; _effectType = FILLET_CHAMFER; _last_pathvector_satellites = NULL; + param_widget_is_visible(false); } -- cgit v1.2.3 From dc565882efdb6da2d813390cddee69818d2dac5e Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 27 May 2017 22:26:45 +0200 Subject: Allow LPE clip or mask hasent effect applied (bzr r15703.1.3) --- src/sp-lpe-item.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index b08772826..68f9843d5 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -220,6 +220,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip if (!curve) { return false; } + bool has_lpe_clipmask = false; if (this->hasPathEffect() && this->pathEffectsEnabled()) { for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) { @@ -245,6 +246,9 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip // yet, we don't alter the path return false; } + if (lpe->apply_to_clippath_and_mask) { + has_lpe_clipmask = true; + } if (!is_clip_or_mask || (is_clip_or_mask && lpe->apply_to_clippath_and_mask)) { // Groups have their doBeforeEffect called elsewhere if (current) { @@ -272,7 +276,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip } } } - if(!SP_IS_GROUP(this) && !is_clip_or_mask){ + if(!SP_IS_GROUP(this) && !is_clip_or_mask && has_lpe_clipmask){ this->apply_to_clippath(this); this->apply_to_mask(this); } -- cgit v1.2.3 From 07dc06a89868df632ea08117add317ac123f6ced Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sun, 28 May 2017 07:40:43 +0200 Subject: Force not original-d if the clip-path or mask has not a LPE allowed to change it (bzr r15703.1.4) --- src/live_effects/parameter/path.cpp | 104 +++++++++++++++++++++--------------- src/live_effects/parameter/path.h | 6 ++- src/sp-lpe-item.cpp | 92 +++++++++++++++++++++++-------- src/sp-lpe-item.h | 2 + 4 files changed, 140 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 6e90c9279..54f5d93e8 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -69,7 +69,10 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip, defvalue = g_strdup(default_value); param_readSVGValue(defvalue); oncanvas_editable = true; - + _edit_button = true; + _copy_button = true; + _paste_button = true; + _link_button = true; ref_changed_connection = ref.changedSignal().connect(sigc::mem_fun(*this, &PathParam::ref_changed)); } @@ -167,6 +170,15 @@ PathParam::param_getSVGValue() const } } +void +PathParam::set_buttons(bool edit_button, bool copy_button, bool paste_button, bool link_button) +{ + _edit_button = edit_button; + _copy_button = copy_button; + _paste_button = paste_button; + _link_button = link_button; +} + Gtk::Widget * PathParam::param_newWidget() { @@ -175,47 +187,55 @@ PathParam::param_newWidget() Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); - - Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) ); - Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click)); - static_cast(_widget)->pack_start(*pButton, true, true); - pButton->set_tooltip_text(_("Edit on-canvas")); - - pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) ); - pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_copy_button_click)); - static_cast(_widget)->pack_start(*pButton, true, true); - pButton->set_tooltip_text(_("Copy path")); - - pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) ); - pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click)); - static_cast(_widget)->pack_start(*pButton, true, true); - pButton->set_tooltip_text(_("Paste path")); - - pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) ); - pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_link_button_click)); - static_cast(_widget)->pack_start(*pButton, true, true); - pButton->set_tooltip_text(_("Link to path on clipboard")); - + Gtk::Widget * pIcon = NULL; + Gtk::Button * pButton = NULL; + if (_edit_button) { + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) ); + pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click)); + static_cast(_widget)->pack_start(*pButton, true, true); + pButton->set_tooltip_text(_("Edit on-canvas")); + } + + if (_copy_button) { + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) ); + pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_copy_button_click)); + static_cast(_widget)->pack_start(*pButton, true, true); + pButton->set_tooltip_text(_("Copy path")); + } + + if (_paste_button) { + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) ); + pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click)); + static_cast(_widget)->pack_start(*pButton, true, true); + pButton->set_tooltip_text(_("Paste path")); + } + if (_link_button) { + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) ); + pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_link_button_click)); + static_cast(_widget)->pack_start(*pButton, true, true); + pButton->set_tooltip_text(_("Link to path on clipboard")); + } + static_cast(_widget)->show_all_children(); return dynamic_cast (_widget); diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index 5381a6b36..ff5e4f1b8 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -44,7 +44,7 @@ public: void param_set_and_write_default(); void set_new_value (Geom::PathVector const &newpath, bool write_to_svg); void set_new_value (Geom::Piecewise > const &newpath, bool write_to_svg); - + void set_buttons(bool edit_button, bool copy_button, bool paste_button, bool link_button); virtual void param_editOncanvas(SPItem * item, SPDesktop * dt); virtual void param_setup_nodepath(Inkscape::NodePath::Path *np); virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &hp_vec); @@ -91,6 +91,10 @@ protected: gchar * defvalue; private: + bool _edit_button; + bool _copy_button; + bool _paste_button; + bool _link_button; PathParam(const PathParam&); PathParam& operator=(const PathParam&); }; diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 68f9843d5..d1f1697a8 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -212,6 +212,47 @@ Inkscape::XML::Node* SPLPEItem::write(Inkscape::XML::Document *xml_doc, Inkscape return repr; } +/** + * returns true when LPE was successful. + */ +bool SPLPEItem::hasPathEffectOnClipOrMask() const +{ + bool has_clipormask_lpe = false; + if (this->hasPathEffect() && this->pathEffectsEnabled()) { + for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) + { + LivePathEffectObject *lpeobj = (*it)->lpeobject; + if (!lpeobj) { + return false; + } + Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe(); + if (!lpe) { + return false; + } + if (lpe->isVisible()) { + if (lpe->acceptsNumClicks() > 0 && !lpe->isReady()) { + return false; + } + if (lpe->apply_to_clippath_and_mask) { + has_clipormask_lpe = true; + } + } + } + } + std::cout << has_clipormask_lpe << "has_clipormask_lpe\n"; + return has_clipormask_lpe; +} + +bool SPLPEItem::hasPathEffectOnClipOrMaskRecursive() const +{ + if (parent && SP_IS_LPE_ITEM(parent)) { + return hasPathEffectOnClipOrMask() || SP_LPE_ITEM(parent)->hasPathEffectOnClipOrMaskRecursive(); + } + else { + return hasPathEffectOnClipOrMask(); + } +} + /** * returns true when LPE was successful. */ @@ -220,7 +261,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip if (!curve) { return false; } - bool has_lpe_clipmask = false; + bool has_clipormask_lpe = false; if (this->hasPathEffect() && this->pathEffectsEnabled()) { for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) { @@ -247,7 +288,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip return false; } if (lpe->apply_to_clippath_and_mask) { - has_lpe_clipmask = true; + has_clipormask_lpe = true; } if (!is_clip_or_mask || (is_clip_or_mask && lpe->apply_to_clippath_and_mask)) { // Groups have their doBeforeEffect called elsewhere @@ -276,7 +317,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip } } } - if(!SP_IS_GROUP(this) && !is_clip_or_mask && has_lpe_clipmask){ + if(!SP_IS_GROUP(this) && !is_clip_or_mask && has_clipormask_lpe){ this->apply_to_clippath(this); this->apply_to_mask(this); } @@ -370,9 +411,8 @@ static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) { g_return_if_fail(lpeitem != NULL); - if (SP_IS_GROUP(lpeitem)) { - if (!lpeitem->hasPathEffectRecursive()) { + if (!lpeitem->hasPathEffectOnClipOrMaskRecursive()) { SPMask * mask = lpeitem->mask_ref->getObject(); if(mask) { @@ -391,24 +431,24 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); } } - } - else if (SP_IS_PATH(lpeitem)) { + } else if (SP_IS_PATH(lpeitem)) { Inkscape::XML::Node *repr = lpeitem->getRepr(); - if (!lpeitem->hasPathEffectRecursive() && repr->attribute("inkscape:original-d")) { - SPMask * mask = lpeitem->mask_ref->getObject(); - if(mask) - { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); - } - SPClipPath * clip_path = lpeitem->clip_ref->getObject(); - if(clip_path) - { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); - } + SPMask * mask = lpeitem->mask_ref->getObject(); + if(mask) { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clip_path = lpeitem->clip_ref->getObject(); + if(clip_path) { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); + } + mask = dynamic_cast(lpeitem->parent); + clip_path = dynamic_cast(lpeitem->parent); + if ((!lpeitem->hasPathEffectRecursive() && repr->attribute("inkscape:original-d")) || + ((mask || clip_path) && !lpeitem->hasPathEffectOnClipOrMask() && repr->attribute("inkscape:original-d"))) + { repr->setAttribute("d", repr->attribute("inkscape:original-d")); repr->setAttribute("inkscape:original-d", NULL); - } - else { + } else { sp_lpe_item_update_patheffect(lpeitem, true, true); } } @@ -462,7 +502,16 @@ void SPLPEItem::addPathEffect(std::string value, bool reset) // Apply the path effect sp_lpe_item_update_patheffect(this, true, true); - + SPMask * mask = mask_ref->getObject(); + if(mask && !hasPathEffectOnClipOrMask()) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clip_path = clip_ref->getObject(); + if(clip_path && !hasPathEffectOnClipOrMask()) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); + } //fix bug 1219324 if (SP_ACTIVE_DESKTOP ) { Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context; @@ -649,6 +698,7 @@ bool SPLPEItem::hasPathEffectRecursive() const return hasPathEffect(); } } + void SPLPEItem::apply_to_clippath(SPItem *item) { diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index 0f198c49c..d5d4e118b 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -70,6 +70,8 @@ public: virtual void update_patheffect(bool write); + bool hasPathEffectOnClipOrMask() const; + bool hasPathEffectOnClipOrMaskRecursive() const; bool performPathEffect(SPCurve *curve, SPShape *current = NULL, bool is_clip_or_mask = false); bool pathEffectsEnabled() const; -- cgit v1.2.3 From 0e48d3acb1c3ae038cf4ecda45cf482bb3177a0a Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sun, 28 May 2017 08:10:29 +0200 Subject: Remove original-d from clip and mask LPE if keep paths (bzr r15703.1.5) --- src/sp-lpe-item.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index d1f1697a8..7dcbc4311 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -50,7 +50,7 @@ static void sp_lpe_item_enable_path_effects(SPLPEItem *lpeitem, bool enable); static void lpeobject_ref_modified(SPObject *href, guint flags, SPLPEItem *lpeitem); static void sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem); -static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem); +static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths); typedef std::list HRefList; static std::string patheffectlist_svg_string(PathEffectList const & list); @@ -408,7 +408,7 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) } static void -sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) +sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths) { g_return_if_fail(lpeitem != NULL); if (SP_IS_GROUP(lpeitem)) { @@ -416,37 +416,39 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) SPMask * mask = lpeitem->mask_ref->getObject(); if(mask) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild()), keep_paths); } SPClipPath * clip_path = lpeitem->clip_ref->getObject(); if(clip_path) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild()), keep_paths); } } 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) { SPObject *subitem = *iter; if (SP_IS_LPE_ITEM(subitem)) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem), keep_paths); } } } else if (SP_IS_PATH(lpeitem)) { Inkscape::XML::Node *repr = lpeitem->getRepr(); SPMask * mask = lpeitem->mask_ref->getObject(); if(mask) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild()), keep_paths); } SPClipPath * clip_path = lpeitem->clip_ref->getObject(); if(clip_path) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild()), keep_paths); } mask = dynamic_cast(lpeitem->parent); clip_path = dynamic_cast(lpeitem->parent); if ((!lpeitem->hasPathEffectRecursive() && repr->attribute("inkscape:original-d")) || - ((mask || clip_path) && !lpeitem->hasPathEffectOnClipOrMask() && repr->attribute("inkscape:original-d"))) + ((mask || clip_path) && !lpeitem->hasPathEffectOnClipOrMaskRecursive() && repr->attribute("inkscape:original-d"))) { - repr->setAttribute("d", repr->attribute("inkscape:original-d")); + if (!keep_paths) { + repr->setAttribute("d", repr->attribute("inkscape:original-d")); + } repr->setAttribute("inkscape:original-d", NULL); } else { sp_lpe_item_update_patheffect(lpeitem, true, true); @@ -503,14 +505,14 @@ void SPLPEItem::addPathEffect(std::string value, bool reset) // Apply the path effect sp_lpe_item_update_patheffect(this, true, true); SPMask * mask = mask_ref->getObject(); - if(mask && !hasPathEffectOnClipOrMask()) + if(mask && !hasPathEffectOnClipOrMaskRecursive()) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild()), false); } SPClipPath * clip_path = clip_ref->getObject(); - if(clip_path && !hasPathEffectOnClipOrMask()) + if(clip_path && !hasPathEffectOnClipOrMaskRecursive()) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild()), false); } //fix bug 1219324 if (SP_ACTIVE_DESKTOP ) { @@ -552,9 +554,8 @@ void SPLPEItem::removeCurrentPathEffect(bool keep_paths) if( SP_IS_GENERICELLIPSE(this)) { SP_GENERICELLIPSE(this)->write( this->getRepr()->document(), this->getRepr(), SP_OBJECT_WRITE_EXT ); } - - sp_lpe_item_cleanup_original_path_recursive(this); } + sp_lpe_item_cleanup_original_path_recursive(this, keep_paths); } /** @@ -584,9 +585,8 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths) if (SP_IS_GENERICELLIPSE(this)) { SP_GENERICELLIPSE(this)->write(this->getRepr()->document(), this->getRepr(), SP_OBJECT_WRITE_EXT); } - - sp_lpe_item_cleanup_original_path_recursive(this); } + sp_lpe_item_cleanup_original_path_recursive(this, keep_paths); } void SPLPEItem::downCurrentPathEffect() @@ -607,7 +607,7 @@ void SPLPEItem::downCurrentPathEffect() this->getRepr()->setAttribute("inkscape:path-effect", patheffectlist_svg_string(new_list)); - sp_lpe_item_cleanup_original_path_recursive(this); + sp_lpe_item_cleanup_original_path_recursive(this, false); } void SPLPEItem::upCurrentPathEffect() @@ -626,7 +626,7 @@ void SPLPEItem::upCurrentPathEffect() this->getRepr()->setAttribute("inkscape:path-effect", patheffectlist_svg_string(new_list)); - sp_lpe_item_cleanup_original_path_recursive(this); + sp_lpe_item_cleanup_original_path_recursive(this, false); } /** used for shapes so they can see if they should also disable shape calculation and read from d= */ @@ -854,7 +854,7 @@ void SPLPEItem::remove_child(Inkscape::XML::Node * child) { SPObject *ochild = this->get_child_by_repr(child); if ( ochild && SP_IS_LPE_ITEM(ochild) ) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(ochild)); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(ochild), false); } } -- cgit v1.2.3 From 117bfe6d616a1b34d4afeb976b708363206aef71 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sun, 28 May 2017 08:59:50 +0200 Subject: Remove dabug line (bzr r15703.1.6) --- src/sp-lpe-item.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 7dcbc4311..d920909f9 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -239,7 +239,6 @@ bool SPLPEItem::hasPathEffectOnClipOrMask() const } } } - std::cout << has_clipormask_lpe << "has_clipormask_lpe\n"; return has_clipormask_lpe; } -- cgit v1.2.3 From b7b7cec5f8828c5d949b9eb2bea6d9f16ce77a7c Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sun, 28 May 2017 09:15:03 +0200 Subject: Allow doOnRemove in all LPE (bzr r15703.1.7) --- src/sp-lpe-item.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src') diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index d920909f9..83cf408a4 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -129,12 +129,7 @@ void SPLPEItem::set(unsigned int key, gchar const* value) { if (!value) { LivePathEffectObject *lpeobj = (*it)->lpeobject; Inkscape::LivePathEffect::Effect * lpe = lpeobj->get_lpe(); - if (dynamic_cast(lpe) || - dynamic_cast(lpe) || - dynamic_cast(lpe) ) - { - lpe->doOnRemove(this); - } + lpe->doOnRemove(this); } (*it)->unlink(); delete *it; -- cgit v1.2.3 From 723a528815298cdf6989c03fcdbaa8ad20914571 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sun, 28 May 2017 12:46:10 +0200 Subject: Add a new value to LPE 'is_load' to know the lpe is just load, no previous values set yet to not LPE stored values when loading a previous file (bzr r15703.1.8) --- src/live_effects/effect.cpp | 2 ++ src/live_effects/effect.h | 1 + src/live_effects/lpe-copy_rotate.cpp | 1 + src/live_effects/lpe-mirror_symmetry.cpp | 1 + 4 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 23a4c9f3d..3a628b243 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -356,6 +356,7 @@ Effect::Effect(LivePathEffectObject *lpeobject) 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), keep_paths(false), + is_load(true), lpeobj(lpeobject), concatenate_before_pwd2(false), sp_lpe_item(NULL), @@ -511,6 +512,7 @@ Effect::doBeforeEffect (SPLPEItem const*/*lpeitem*/) void Effect::doAfterEffect (SPLPEItem const* /*lpeitem*/) { + is_load = false; } void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/) diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index cc0d53f12..e353eba23 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -133,6 +133,7 @@ public: void editNextParamOncanvas(SPItem * item, SPDesktop * desktop); bool apply_to_clippath_and_mask; bool keep_paths; // set this to false allow retain extra generated objects, see measure line LPE + bool is_load; bool upd_params; BoolParam is_visible; SPCurve * sp_curve; diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 551cf1bf9..b29b5e493 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -109,6 +109,7 @@ void LPECopyRotate::doAfterEffect (SPLPEItem const* lpeitem) { if (split_items) { + is_load = false; SPDocument * document = SP_ACTIVE_DOCUMENT; if (!document) { return; diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 8e68c483c..3fcc4ae3d 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -89,6 +89,7 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry() void LPEMirrorSymmetry::doAfterEffect (SPLPEItem const* lpeitem) { + is_load = false; SPDocument * document = SP_ACTIVE_DOCUMENT; if (!document) { return; -- cgit v1.2.3 From 63925693eb0141d1f589f86f967536918e7b17f6 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sun, 28 May 2017 12:57:28 +0200 Subject: Fix bug on crash if undefined LPE load (bzr r15703.1.9) --- src/sp-lpe-item.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 83cf408a4..35e7dfa3e 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -129,7 +129,9 @@ void SPLPEItem::set(unsigned int key, gchar const* value) { if (!value) { LivePathEffectObject *lpeobj = (*it)->lpeobject; Inkscape::LivePathEffect::Effect * lpe = lpeobj->get_lpe(); - lpe->doOnRemove(this); + if (lpe) { + lpe->doOnRemove(this); + } } (*it)->unlink(); delete *it; -- cgit v1.2.3 From 822154dfcb9fe3777f32aa27b9bae4480a1417c2 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Mon, 29 May 2017 02:09:29 +0200 Subject: Fix bug #1694111 also fixes noumerous bugfixes on LPE undo. And shapes are improved to only perform path effet one time each Fixed bugs: - https://launchpad.net/bugs/1694111 (bzr r15703.1.10) --- src/live_effects/effect.cpp | 11 ++++++++--- src/live_effects/lpe-copy_rotate.cpp | 9 ++++----- src/live_effects/lpe-mirror_symmetry.cpp | 1 + src/live_effects/lpeobject.cpp | 1 + src/sp-ellipse.cpp | 10 ++++++++-- src/sp-ellipse.h | 2 +- src/sp-lpe-item.cpp | 34 +++++++++++++------------------- src/sp-spiral.cpp | 10 ++++++++-- src/sp-spiral.h | 2 +- src/sp-star.cpp | 10 ++++++++-- src/sp-star.h | 2 +- 11 files changed, 55 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 3a628b243..21136353c 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -452,10 +452,13 @@ Effect::processObjects(LpeAction lpe_action) std::vector item_selected; SPCSSAttr *css; Glib::ustring css_str; + SPItem *item = SP_ITEM(elemref); switch (lpe_action){ case LPE_TO_OBJECTS: - if (SP_ITEM(elemref)->isHidden()) { - elemref->deleteObject(); + if (item->isHidden()) { + sp_object_ref(item, 0 ); + item->deleteObject(true); + sp_object_unref(item); } else { if (elemnode->attribute("inkscape:path-effect")) { sp_item_list_to_curves(item_list, item_selected, item_to_select); @@ -465,7 +468,9 @@ Effect::processObjects(LpeAction lpe_action) break; case LPE_ERASE: - elemref->deleteObject(); + sp_object_ref(item, 0 ); + item->deleteObject(true); + sp_object_unref(item); break; case LPE_VISIBILITY: diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index b29b5e493..3abcbf217 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -199,15 +199,13 @@ LPECopyRotate::cloneD(SPObject *orig, SPObject *dest, Geom::Affine transform, bo } } SPShape * shape = SP_SHAPE(orig); - SPPath * path = SP_PATH(dest); - if (shape && !path) { + if (shape && !SP_IS_PATH(dest)) { const char * id = dest->getId(); Inkscape::XML::Node *dest_node = sp_selected_item_to_curved_repr(SP_ITEM(dest), 0); dest->updateRepr(xml_doc, dest_node, SP_OBJECT_WRITE_ALL); dest->getRepr()->setAttribute("d", id); - path = SP_PATH(dest); } - if (path && shape) { + if (SP_IS_PATH(dest) && shape) { SPCurve *c = NULL; if (root) { c = new SPCurve(); @@ -216,7 +214,7 @@ LPECopyRotate::cloneD(SPObject *orig, SPObject *dest, Geom::Affine transform, bo c = shape->getCurve(); } if (c) { - path->setCurve(c, TRUE); + SP_PATH(dest)->setCurve(c, TRUE); c->unref(); } else { dest->getRepr()->setAttribute("d", NULL); @@ -725,6 +723,7 @@ LPECopyRotate::doOnRemove (SPLPEItem const* /*lpeitem*/) //set "keep paths" hook on sp-lpe-item.cpp if (keep_paths) { processObjects(LPE_TO_OBJECTS); + items.clear(); return; } processObjects(LPE_ERASE); diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 3fcc4ae3d..5d80d65fe 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -320,6 +320,7 @@ LPEMirrorSymmetry::doOnRemove (SPLPEItem const* /*lpeitem*/) //set "keep paths" hook on sp-lpe-item.cpp if (keep_paths) { processObjects(LPE_TO_OBJECTS); + items.clear(); return; } processObjects(LPE_ERASE); diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index b5b27c984..ca3ae46e0 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -112,6 +112,7 @@ void LivePathEffectObject::set(unsigned key, gchar const *value) { this->effecttype_set = true; } else { this->effecttype = Inkscape::LivePathEffect::INVALID_LPE; + this->lpe = NULL; this->effecttype_set = false; } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 5dfc60f1a..30c1096ca 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -408,7 +408,7 @@ const char *SPGenericEllipse::displayName() const } // Create path for rendering shape on screen -void SPGenericEllipse::set_shape() +void SPGenericEllipse::set_shape(bool force) { // std::cout << "SPGenericEllipse::set_shape: Entrance" << std::endl; if (hasBrokenPathEffect()) { @@ -475,6 +475,12 @@ void SPGenericEllipse::set_shape() /* Reset the shape's curve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ + if(this->getCurveBeforeLPE()) { + if(!force && this->getCurveBeforeLPE()->get_pathvector() == curve->get_pathvector()) { + curve->unref(); + return; + } + } this->setCurveInsync(curve, TRUE); this->setCurveBeforeLPE(curve); @@ -617,7 +623,7 @@ void SPGenericEllipse::modified(guint flags) void SPGenericEllipse::update_patheffect(bool write) { - this->set_shape(); + this->set_shape(true); if (write) { Inkscape::XML::Node *repr = this->getRepr(); diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index dafece625..a879c596d 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -64,7 +64,7 @@ public: virtual Inkscape::XML::Node *write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char *displayName() const; - virtual void set_shape(); + virtual void set_shape(bool force = false); virtual Geom::Affine set_transform(Geom::Affine const &xform); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 35e7dfa3e..be886bdd2 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -122,17 +122,8 @@ void SPLPEItem::set(unsigned int key, gchar const* value) { this->lpe_modified_connection_list->clear(); // Clear the path effect list - PathEffectList::iterator it = this->path_effect_list->begin(); - - while ( it != this->path_effect_list->end() ) - { - if (!value) { - LivePathEffectObject *lpeobj = (*it)->lpeobject; - Inkscape::LivePathEffect::Effect * lpe = lpeobj->get_lpe(); - if (lpe) { - lpe->doOnRemove(this); - } - } + PathEffectList::iterator it = this->path_effect_list->begin(); + while ( it != this->path_effect_list->end()) { (*it)->unlink(); delete *it; it = this->path_effect_list->erase(it); @@ -539,11 +530,11 @@ void SPLPEItem::removeCurrentPathEffect(bool keep_paths) return; if (Inkscape::LivePathEffect::Effect* effect_ = this->getCurrentLPE()) { + effect_->keep_paths = keep_paths; effect_->doOnRemove(this); } PathEffectList new_list = *this->path_effect_list; new_list.remove(lperef); //current lpe ref is always our 'own' pointer from the path_effect_list - *this->path_effect_list = new_list; this->getRepr()->setAttribute("inkscape:path-effect", patheffectlist_svg_string(new_list)); if (!keep_paths) { // Make sure that ellipse is stored as or if possible. @@ -563,15 +554,18 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths) if (path_effect_list->empty()) { return; } - - for (PathEffectList::const_iterator it = path_effect_list->begin(); it != path_effect_list->end(); ++it) - { - LivePathEffectObject *lpeobj = (*it)->lpeobject; - if (lpeobj) { - Inkscape::LivePathEffect::Effect * lpe = lpeobj->get_lpe(); - lpe->keep_paths = true; - } + } + for (PathEffectList::const_iterator it = path_effect_list->begin(); it != path_effect_list->end(); ++it) + { + LivePathEffectObject *lpeobj = (*it)->lpeobject; + if (lpeobj) { + Inkscape::LivePathEffect::Effect * lpe = lpeobj->get_lpe(); + lpe->keep_paths = keep_paths; + lpe->doOnRemove(this); } + (*it)->unlink(); + delete *it; + it = this->path_effect_list->erase(it); } this->getRepr()->setAttribute("inkscape:path-effect", NULL); diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 57eb918fe..d75db3daa 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -197,7 +197,7 @@ void SPSpiral::update(SPCtx *ctx, guint flags) { } void SPSpiral::update_patheffect(bool write) { - this->set_shape(); + this->set_shape(true); if (write) { Inkscape::XML::Node *repr = this->getRepr(); @@ -310,7 +310,7 @@ void SPSpiral::fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom:: g_assert (is_unit_vector (hat2)); } -void SPSpiral::set_shape() { +void SPSpiral::set_shape(bool force) { if (hasBrokenPathEffect()) { g_warning ("The spiral shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as spiral will remove the bad LPE"); @@ -365,6 +365,12 @@ void SPSpiral::set_shape() { /* Reset the shape'scurve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ + if(this->getCurveBeforeLPE()) { + if(!force && this->getCurveBeforeLPE()->get_pathvector() == c->get_pathvector()) { + c->unref(); + return; + } + } setCurveInsync( c, TRUE); setCurveBeforeLPE( c ); diff --git a/src/sp-spiral.h b/src/sp-spiral.h index 94724685c..ebf4c9e28 100644 --- a/src/sp-spiral.h +++ b/src/sp-spiral.h @@ -70,7 +70,7 @@ public: virtual const char* displayName() const; virtual char* description() const; - virtual void set_shape(); + virtual void set_shape(bool force = false); virtual void update_patheffect(bool write); private: diff --git a/src/sp-star.cpp b/src/sp-star.cpp index d112962a2..d7ee352c7 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -223,7 +223,7 @@ void SPStar::update(SPCtx *ctx, guint flags) { } void SPStar::update_patheffect(bool write) { - this->set_shape(); + this->set_shape(true); if (write) { Inkscape::XML::Node *repr = this->getRepr(); @@ -363,7 +363,7 @@ sp_star_get_curvepoint (SPStar *star, SPStarPoint point, gint index, bool previ) #define NEXT false #define PREV true -void SPStar::set_shape() { +void SPStar::set_shape(bool force) { // perhaps we should convert all our shapes into LPEs without source path // and with knotholders for parameters, then this situation will be handled automatically // by disabling the entire stack (including the shape LPE) @@ -446,6 +446,12 @@ void SPStar::set_shape() { /* Reset the shape'scurve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ + if(this->getCurveBeforeLPE()) { + if(!force && this->getCurveBeforeLPE()->get_pathvector() == c->get_pathvector()) { + c->unref(); + return; + } + } this->setCurveInsync( c, TRUE); this->setCurveBeforeLPE( c ); diff --git a/src/sp-star.h b/src/sp-star.h index 1ebe3298a..4519de869 100644 --- a/src/sp-star.h +++ b/src/sp-star.h @@ -55,7 +55,7 @@ public: virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; virtual void update_patheffect(bool write); - virtual void set_shape(); + virtual void set_shape(bool force = false); virtual Geom::Affine set_transform(Geom::Affine const& xform); }; -- cgit v1.2.3