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 ++-- 12 files changed, 26 insertions(+), 23 deletions(-) (limited to 'src/live_effects') 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&); -- 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/live_effects') 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 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 ++- 2 files changed, 67 insertions(+), 43 deletions(-) (limited to 'src/live_effects') 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&); }; -- 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/live_effects') 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 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 + 4 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/live_effects') 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; } -- cgit v1.2.3 From 802385842d5a2fbe8def45b72ce433260720c954 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Mon, 29 May 2017 02:11:53 +0200 Subject: Initial release (bzr r15704) --- src/live_effects/CMakeLists.txt | 2 + src/live_effects/effect-enum.h | 1 + src/live_effects/effect.cpp | 9 +- src/live_effects/effect.h | 3 +- src/live_effects/lpe-bspline.cpp | 4 +- src/live_effects/lpe-copy_rotate.cpp | 20 +- src/live_effects/lpe-fillet-chamfer.cpp | 4 +- src/live_effects/lpe-measure-line.cpp | 39 ++-- src/live_effects/lpe-mirror_symmetry.cpp | 43 +--- src/live_effects/lpe-mirror_symmetry.h | 1 - src/live_effects/lpe-powerclip.cpp | 297 +++++++++++++++++++++++++ src/live_effects/lpe-powerclip.h | 47 ++++ src/live_effects/lpe-transform_2pts.cpp | 4 +- src/live_effects/parameter/bool.cpp | 6 +- src/live_effects/parameter/bool.h | 4 +- src/live_effects/parameter/hidden.cpp | 8 +- src/live_effects/parameter/hidden.h | 5 +- src/live_effects/parameter/parameter.cpp | 13 +- src/live_effects/parameter/parameter.h | 9 +- src/live_effects/parameter/path.cpp | 104 +++++---- src/live_effects/parameter/path.h | 6 +- src/live_effects/parameter/satellitesarray.cpp | 1 + src/live_effects/parameter/satellitesarray.h | 1 + 23 files changed, 489 insertions(+), 142 deletions(-) create mode 100644 src/live_effects/lpe-powerclip.cpp create mode 100644 src/live_effects/lpe-powerclip.h (limited to 'src/live_effects') diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index c2f434f50..e1e5cab4c 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -36,6 +36,7 @@ set(live_effects_SRC lpe-perp_bisector.cpp lpe-perspective-envelope.cpp lpe-perspective_path.cpp + lpe-powerclip.cpp lpe-powerstroke.cpp lpe-recursiveskeleton.cpp lpe-rough-hatches.cpp @@ -121,6 +122,7 @@ set(live_effects_SRC lpe-perspective-envelope.h lpe-perspective_path.h lpe-powerstroke-interpolators.h + lpe-powerclip.h lpe-powerstroke.h lpe-recursiveskeleton.h lpe-rough-hatches.h diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index a6920c1fb..700564334 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -49,6 +49,7 @@ enum EffectType { BOUNDING_BOX, MEASURE_LINE, FILLET_CHAMFER, + POWERCLIP, DOEFFECTSTACK_TEST, ANGLE_BISECTOR, CIRCLE_WITH_RADIUS, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index a4b44b1a9..50976188a 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -47,6 +47,7 @@ #include "live_effects/lpe-perp_bisector.h" #include "live_effects/lpe-perspective-envelope.h" #include "live_effects/lpe-perspective_path.h" +#include "live_effects/lpe-powerclip.h" #include "live_effects/lpe-powerstroke.h" #include "live_effects/lpe-recursiveskeleton.h" #include "live_effects/lpe-roughen.h" @@ -124,6 +125,7 @@ const Util::EnumData LPETypeData[] = { /* 9.93 */ {MEASURE_LINE, N_("Measure Line"), "measure_line"}, {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, + {POWERCLIP, N_("Power clip"), "powerclip"}, #ifdef LPE_ENABLE_TEST_EFFECTS {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"}, @@ -302,6 +304,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case FILLET_CHAMFER: neweffect = static_cast ( new LPEFilletChamfer(lpeobj) ); break; + case POWERCLIP: + neweffect = static_cast ( new LPEPowerClip(lpeobj) ); + break; case ROUGHEN: neweffect = static_cast ( new LPERoughen(lpeobj) ); break; @@ -355,7 +360,8 @@ 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), + is_load(true), lpeobj(lpeobject), concatenate_before_pwd2(false), sp_lpe_item(NULL), @@ -511,6 +517,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 60ee8d98f..e353eba23 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -132,7 +132,8 @@ 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 is_load; bool upd_params; BoolParam is_visible; SPCurve * sp_curve; 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 ff24b46da..b29b5e493 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; } @@ -108,6 +109,7 @@ void LPECopyRotate::doAfterEffect (SPLPEItem const* lpeitem) { if (split_items) { + is_load = false; SPDocument * document = SP_ACTIVE_DOCUMENT; if (!document) { return; @@ -319,14 +321,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); } } } @@ -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..11298bcbe 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", @@ -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 f7892cbe7..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() {} @@ -674,8 +675,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; @@ -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 bd3dedc86..3fcc4ae3d 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() @@ -87,6 +89,7 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry() void LPEMirrorSymmetry::doAfterEffect (SPLPEItem const* lpeitem) { + is_load = false; SPDocument * document = SP_ACTIVE_DOCUMENT; if (!document) { return; @@ -304,42 +307,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*/) @@ -350,8 +317,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/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-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp new file mode 100644 index 000000000..a3a827ec4 --- /dev/null +++ b/src/live_effects/lpe-powerclip.cpp @@ -0,0 +1,297 @@ +/* + * Released under GNU GPL, read the file 'COPYING' for more information + */ +#include "live_effects/lpe-powerclip.h" +#include <2geom/path-intersection.h> +#include <2geom/intersection-graph.h> +#include "display/drawing-item.h" +#include "display/curve.h" +#include "helper/geom.h" +#include "sp-clippath.h" +#include "sp-path.h" +#include "sp-shape.h" +#include "sp-item-group.h" +#include "ui/tools-switch.h" +#include "path-chemistry.h" + +// TODO due to internal breakage in glibmm headers, this must be last: +#include + +namespace Inkscape { +namespace LivePathEffect { + +LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) + : Effect(lpeobject), + hide_clip(_("Hide clip"), _("Hide clip"), "hide_clip", &wr, this, false), + inverse(_("Inverse clip"), _("Inverse clip"), "inverse", &wr, this, false), + flatten(_("Flatten clip"), _("Flatten clip"), "flatten", &wr, this, false), + fillrule(_("Set/unset evenodd fill rule"), _("Set/unset evenodd fill rule (this is overwriting your current value)."), "fillrule", &wr, this, false), + convert_shapes(_("Convert clip shapes to paths"), _("Convert clip shapes to paths (this is overwriting your current value)."), "convert_shapes", &wr, this, false), + //tooltip empty to no show in default param set + is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false) +{ + registerParameter(&hide_clip); + registerParameter(&inverse); + registerParameter(&flatten); + registerParameter(&fillrule); + registerParameter(&convert_shapes); + registerParameter(&is_inverse); + is_clip = false; + previous_fillrule = fillrule; +} + +LPEPowerClip::~LPEPowerClip() {} + +void +LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ + original_bbox(lpeitem); + const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path"); + SPClipPath *clip_path = SP_ITEM(lpeitem)->clip_ref->getObject(); + SPItem * item = SP_ITEM(lpeitem); + if(hide_clip) { + SPItemView *v; + for (v = item->display; v != NULL; v = v->next) { + clip_path->hide(v->arenaitem->key()); + } + Geom::OptRect bbox = item->geometricBounds(); + clip_path->setBBox(v->arenaitem->key(), bbox); + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } else if (!hide_clip) { + Geom::OptRect bbox = item->geometricBounds(); + for (SPItemView *v = item->display; v != NULL; v = v->next) { + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); + } + Inkscape::DrawingItem *ai = clip_path->show( + v->arenaitem->drawing(), + v->arenaitem->key()); + v->arenaitem->setClip(ai); + clip_path->setBBox(v->arenaitem->key(), bbox); + clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } + Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); + Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); + Geom::Point bottomright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.min() - 5); + Geom::Point bottomleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.min() - 5); + clip_box.clear(); + clip_box.start(topleft); + clip_box.appendNew(topright); + clip_box.appendNew(bottomright); + clip_box.appendNew(bottomleft); + clip_box.close(); + //clip_path *= sp_lpe_item->i2dt_affine(); + if(clip_path) { + is_clip = true; + std::vector clip_path_list = clip_path->childList(true); + for ( std::vector::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) { + SPObject * clip_data = *iter; + if (SP_IS_SHAPE(clip_data) && !SP_IS_PATH(clip_data) && convert_shapes) { + SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } + Inkscape::XML::Document *xml_doc = document->getReprDoc(); + const char * id = clip_data->getId(); + Inkscape::XML::Node *clip_path_node = sp_selected_item_to_curved_repr(SP_ITEM(clip_data), 0); + clip_data->updateRepr(xml_doc, clip_path_node, SP_OBJECT_WRITE_ALL); + clip_data->getRepr()->setAttribute("id", id); + clip_path->emitModified(SP_OBJECT_MODIFIED_CASCADE); + std::cout << "toshapes\n"; + } + if( inverse && isVisible()) { + addInverse(SP_ITEM(clip_data)); + } else if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + removeInverse(SP_ITEM(clip_data)); + } + } + } else { + is_clip = false; + } +} + +void +LPEPowerClip::addInverse (SPItem * clip_data){ + if (SP_IS_GROUP(clip_data)) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(clip_data)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + SPItem *subitem = *iter; + addInverse(subitem); + } + } else if (SP_IS_PATH(clip_data)) { + setFillRule(clip_data); + SPCurve * c = NULL; + c = SP_SHAPE(clip_data)->getCurve(); + if (c) { + Geom::PathVector c_pv = c->get_pathvector(); + if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + c_pv.pop_back(); + } + //TODO: this can be not correct but no better way + bool dir_a = Geom::path_direction(c_pv[0]); + bool dir_b = Geom::path_direction(clip_box); + if (dir_a == dir_b) { + clip_box = clip_box.reversed(); + } + c_pv.push_back(clip_box); + c->set_pathvector(c_pv); + SP_SHAPE(clip_data)->setCurve(c, TRUE); + c->unref(); + is_inverse.param_setValue((Glib::ustring)"true", true); +// SPDesktop *desktop = SP_ACTIVE_DESKTOP; +// if (desktop) { +// if (tools_isactive(desktop, TOOLS_NODES)) { +// Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); +// SPItem * item = sel->singleItem(); +// if (item != NULL) { +// sel->remove(item); +// sel->add(item); +// } +// } +// } + } + } +} + +void +LPEPowerClip::removeInverse (SPItem * clip_data){ + if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + if (SP_IS_GROUP(clip_data)) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(clip_data)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + SPItem *subitem = *iter; + removeInverse(subitem); + } + } else if (SP_IS_PATH(clip_data)) { + setFillRule(clip_data); + SPCurve * c = NULL; + c = SP_SHAPE(clip_data)->getCurve(); + if (c) { + Geom::PathVector c_pv = c->get_pathvector(); + c_pv.pop_back(); + c->set_pathvector(c_pv); + SP_SHAPE(clip_data)->setCurve(c, TRUE); + c->unref(); + is_inverse.param_setValue((Glib::ustring)"false", true); +// SPDesktop *desktop = SP_ACTIVE_DESKTOP; +// if (desktop) { +// if (tools_isactive(desktop, TOOLS_NODES)) { +// Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); +// SPItem * item = sel->singleItem(); +// if (item != NULL) { +// sel->remove(item); +// sel->add(item); +// } +// } +// } + } + } + } +} + +void +LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/) +{ + SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject(); + if(!keep_paths) { + if(clip_path) { + is_clip = true; + std::vector clip_path_list = clip_path->childList(true); + for ( std::vector::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) { + SPObject * clip_data = *iter; + if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + removeInverse(SP_ITEM(clip_data)); + is_inverse.param_setValue((Glib::ustring)"false"); + } + } + } + } else { + if (flatten && clip_path) { + clip_path->deleteObject(); + sp_lpe_item->getRepr()->setAttribute("clip-path", NULL); + } + } +} + +Geom::PathVector +LPEPowerClip::doEffect_path(Geom::PathVector const & path_in){ + Geom::PathVector path_out = pathv_to_linear_and_cubic_beziers(path_in); + if (flatten && is_clip && isVisible()) { + SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject(); + if(clip_path) { + std::vector clip_path_list = clip_path->childList(true); + for ( std::vector::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) { + SPObject * clip_data = *iter; + flattenClip(SP_ITEM(clip_data), path_out); + } + } + } + return path_out; +} + +void +LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in) +{ + if (SP_IS_GROUP(clip_data)) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(clip_data)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + SPItem *subitem = *iter; + flattenClip(subitem, path_in); + } + } else if (SP_IS_PATH(clip_data)) { + if (!SP_IS_PATH(clip_data) && convert_shapes) { + SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } + Inkscape::XML::Document *xml_doc = document->getReprDoc(); + const char * id = clip_data->getId(); + Inkscape::XML::Node *clip_path_node = sp_selected_item_to_curved_repr(clip_data, 0); + clip_data->updateRepr(xml_doc, clip_path_node, SP_OBJECT_WRITE_ALL); + clip_data->getRepr()->setAttribute("id", id); + } + SPCurve * c = NULL; + c = SP_SHAPE(clip_data)->getCurve(); + if (c) { + Geom::PathVector c_pv = c->get_pathvector(); + Geom::PathIntersectionGraph *pig = new Geom::PathIntersectionGraph(c_pv, path_in); + if (pig && !c_pv.empty() && !path_in.empty()) { + path_in = pig->getIntersection(); + } + c->unref(); + } + } +} + +void +LPEPowerClip::setFillRule(SPItem * clip_data) +{ + if (previous_fillrule != fillrule) { + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string(css, clip_data->getRepr()->attribute("style")); + if (fillrule) { + sp_repr_css_set_property (css, "fill-rule", "evenodd"); + } else { + sp_repr_css_set_property (css, "fill-rule", "nonzero"); + } + Glib::ustring css_str; + sp_repr_css_write_string(css,css_str); + clip_data->getRepr()->setAttribute("style", css_str.c_str()); + previous_fillrule = fillrule; + } +} + +}; //namespace LivePathEffect +}; /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h new file mode 100644 index 000000000..8ff8111e8 --- /dev/null +++ b/src/live_effects/lpe-powerclip.h @@ -0,0 +1,47 @@ +#ifndef INKSCAPE_LPE_POWERCLIP_H +#define INKSCAPE_LPE_POWERCLIP_H + +/* + * Inkscape::LPEPowerClip + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/parameter/hidden.h" +#include "live_effects/parameter/path.h" +#include "live_effects/lpegroupbbox.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEPowerClip : public Effect, GroupBBoxEffect { +public: + LPEPowerClip(LivePathEffectObject *lpeobject); + virtual ~LPEPowerClip(); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); + //virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); + virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); + void addInverse (SPItem * clip_data); + void removeInverse (SPItem * clip_data); + void flattenClip(SPItem * clip_data, Geom::PathVector &path_in); + void setFillRule(SPItem * clip_data); +protected: + //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); + +private: + BoolParam hide_clip; + BoolParam inverse; + BoolParam flatten; + BoolParam fillrule; + BoolParam convert_shapes; + HiddenParam is_inverse; + Geom::Path clip_box; + bool is_clip; + bool previous_fillrule; +}; + +} //namespace LivePathEffect +} //namespace Inkscape +#endif 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 3184bfa80..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 no_widget) - : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value), hide_widget(no_widget) + Effect* effect, bool default_value) + : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value) { } @@ -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..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 no_widget = false); + bool default_value = false); virtual ~BoolParam(); virtual Gtk::Widget * param_newWidget(); @@ -47,7 +46,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..e8c55ebd3 100644 --- a/src/live_effects/parameter/hidden.cpp +++ b/src/live_effects/parameter/hidden.cpp @@ -22,11 +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) { + param_widget_is_visible(is_visible); } void @@ -65,9 +66,12 @@ HiddenParam::param_newWidget() } void -HiddenParam::param_setValue(const Glib::ustring newvalue) +HiddenParam::param_setValue(const Glib::ustring newvalue, bool write) { value = newvalue; + if (write) { + param_write_to_repr(value.c_str()); + } } } /* namespace LivePathEffect */ diff --git a/src/live_effects/parameter/hidden.h b/src/live_effects/parameter/hidden.h index d565272b6..c3fba5575 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(); @@ -37,7 +38,7 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - void param_setValue(Glib::ustring newvalue); + void param_setValue(Glib::ustring newvalue, bool write = false); virtual void param_set_default(); virtual void param_update_default(const gchar * default_value); diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 45f46a0a7..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 no_widget) + 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), - hide_widget(no_widget) + _set_undo(true) { } @@ -164,15 +163,15 @@ 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 * 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() ) ); @@ -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 ee1d2d547..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 no_widget = false); + gdouble default_value = 1.0); virtual ~ScalarParam(); virtual bool param_readSVGValue(const gchar * strvalue); @@ -121,7 +121,7 @@ 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; }; @@ -136,8 +136,7 @@ protected: double inc_step; double inc_page; bool add_slider; - bool overwrite_widget; - bool hide_widget; + bool _set_undo; private: ScalarParam(const ScalarParam&); 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/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); } diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h index 5ae372ac2..300a7a9dd 100644 --- a/src/live_effects/parameter/satellitesarray.h +++ b/src/live_effects/parameter/satellitesarray.h @@ -57,6 +57,7 @@ public: void setEffectType(EffectType et); void setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write = true); void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); + bool widget_is_visible; friend class FilletChamferKnotHolderEntity; friend class LPEFilletChamfer; -- cgit v1.2.3 From 18619e3328e070c5d59f12c4d19fa09713fc4700 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Mon, 29 May 2017 04:23:48 +0200 Subject: Handling hide (bzr r15706) --- src/live_effects/lpe-powerclip.cpp | 46 +++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index a3a827ec4..275acef1e 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -17,6 +17,14 @@ // TODO due to internal breakage in glibmm headers, this must be last: #include +// FIXME: expose these from sp-clippath/mask.cpp +struct SPClipPathView { + SPClipPathView *next; + unsigned int key; + Inkscape::DrawingItem *arenaitem; + Geom::OptRect bbox; +}; + namespace Inkscape { namespace LivePathEffect { @@ -48,28 +56,34 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path"); SPClipPath *clip_path = SP_ITEM(lpeitem)->clip_ref->getObject(); SPItem * item = SP_ITEM(lpeitem); - if(hide_clip) { + bool update_lpe = false; + if(clip_path && hide_clip) { SPItemView *v; for (v = item->display; v != NULL; v = v->next) { - clip_path->hide(v->arenaitem->key()); + if (clip_path->display->arenaitem && clip_path->display->arenaitem->visible()) { + clip_path->hide(v->arenaitem->key()); + update_lpe = true; + } } - Geom::OptRect bbox = item->geometricBounds(); - clip_path->setBBox(v->arenaitem->key(), bbox); - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - } else if (!hide_clip) { + } else if (clip_path && !hide_clip) { Geom::OptRect bbox = item->geometricBounds(); for (SPItemView *v = item->display; v != NULL; v = v->next) { - if (!v->arenaitem->key()) { - v->arenaitem->setKey(SPItem::display_key_new(3)); - } - Inkscape::DrawingItem *ai = clip_path->show( - v->arenaitem->drawing(), - v->arenaitem->key()); - v->arenaitem->setClip(ai); - clip_path->setBBox(v->arenaitem->key(), bbox); - clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + if (!clip_path->display->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); + } + if (clip_path->display->arenaitem && !clip_path->display->arenaitem->visible()) { + Inkscape::DrawingItem *ai = clip_path->show( + v->arenaitem->drawing(), + v->arenaitem->key()); + v->arenaitem->setClip(ai); + clip_path->setBBox(v->arenaitem->key(), bbox); + update_lpe = true; + } } - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } + if (update_lpe) { + clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + sp_lpe_item_update_patheffect(sp_lpe_item, true, true); } Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); -- cgit v1.2.3 From 38d796905f3b0e467d9e653c51f2993870f033cf Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 29 May 2017 17:33:21 +0200 Subject: Allow temp hide clip (bzr r15707) --- src/live_effects/lpe-powerclip.cpp | 39 +++++++++++++++++++------------------- src/live_effects/lpe-powerclip.h | 1 + 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index 275acef1e..7ab662bbc 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -30,7 +30,7 @@ namespace LivePathEffect { LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) : Effect(lpeobject), - hide_clip(_("Hide clip"), _("Hide clip"), "hide_clip", &wr, this, false), + hide_clip(_("Temporary hide"), _("Hide clip, not storeable, reset on doc load"), "hide_clip", &wr, this, false), inverse(_("Inverse clip"), _("Inverse clip"), "inverse", &wr, this, false), flatten(_("Flatten clip"), _("Flatten clip"), "flatten", &wr, this, false), fillrule(_("Set/unset evenodd fill rule"), _("Set/unset evenodd fill rule (this is overwriting your current value)."), "fillrule", &wr, this, false), @@ -38,53 +38,52 @@ LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) //tooltip empty to no show in default param set is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false) { - registerParameter(&hide_clip); registerParameter(&inverse); registerParameter(&flatten); registerParameter(&fillrule); registerParameter(&convert_shapes); registerParameter(&is_inverse); + registerParameter(&hide_clip); is_clip = false; previous_fillrule = fillrule; + previous_hide_clip = false; } LPEPowerClip::~LPEPowerClip() {} void LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ - original_bbox(lpeitem); + if (is_load) { + hide_clip.param_setValue(false); + } const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path"); SPClipPath *clip_path = SP_ITEM(lpeitem)->clip_ref->getObject(); SPItem * item = SP_ITEM(lpeitem); - bool update_lpe = false; - if(clip_path && hide_clip) { - SPItemView *v; - for (v = item->display; v != NULL; v = v->next) { - if (clip_path->display->arenaitem && clip_path->display->arenaitem->visible()) { + if (!is_load) { + if(clip_path && hide_clip && previous_hide_clip != hide_clip) { + SPItemView *v; + for (v = item->display; v != NULL; v = v->next) { clip_path->hide(v->arenaitem->key()); - update_lpe = true; - } - } - } else if (clip_path && !hide_clip) { - Geom::OptRect bbox = item->geometricBounds(); - for (SPItemView *v = item->display; v != NULL; v = v->next) { - if (!clip_path->display->arenaitem->key()) { - v->arenaitem->setKey(SPItem::display_key_new(3)); } - if (clip_path->display->arenaitem && !clip_path->display->arenaitem->visible()) { + } else if (clip_path && !hide_clip && previous_hide_clip != hide_clip) { + Geom::OptRect bbox = item->geometricBounds(); + for (SPItemView *v = item->display; v != NULL; v = v->next) { + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); + } Inkscape::DrawingItem *ai = clip_path->show( v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setClip(ai); clip_path->setBBox(v->arenaitem->key(), bbox); - update_lpe = true; } } } - if (update_lpe) { + if(!is_load && previous_hide_clip != hide_clip) { clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - sp_lpe_item_update_patheffect(sp_lpe_item, true, true); } + previous_hide_clip = hide_clip; + original_bbox(lpeitem); Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); Geom::Point bottomright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.min() - 5); diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index 8ff8111e8..bf3eeac0d 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -40,6 +40,7 @@ private: Geom::Path clip_box; bool is_clip; bool previous_fillrule; + bool previous_hide_clip; }; } //namespace LivePathEffect -- cgit v1.2.3 From eb70ace04dd450317b08d1c3e48ff087f9cfe775 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 29 May 2017 17:41:44 +0200 Subject: Alow write to repr on hidden LPE parameters (bzr r15703.1.13) --- src/live_effects/parameter/hidden.cpp | 5 ++++- src/live_effects/parameter/hidden.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/parameter/hidden.cpp b/src/live_effects/parameter/hidden.cpp index 6d0e7f58f..e8c55ebd3 100644 --- a/src/live_effects/parameter/hidden.cpp +++ b/src/live_effects/parameter/hidden.cpp @@ -66,9 +66,12 @@ HiddenParam::param_newWidget() } void -HiddenParam::param_setValue(const Glib::ustring newvalue) +HiddenParam::param_setValue(const Glib::ustring newvalue, bool write) { value = newvalue; + if (write) { + param_write_to_repr(value.c_str()); + } } } /* namespace LivePathEffect */ diff --git a/src/live_effects/parameter/hidden.h b/src/live_effects/parameter/hidden.h index 387071e53..c3fba5575 100644 --- a/src/live_effects/parameter/hidden.h +++ b/src/live_effects/parameter/hidden.h @@ -38,7 +38,7 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - void param_setValue(Glib::ustring newvalue); + void param_setValue(Glib::ustring newvalue, bool write = false); virtual void param_set_default(); virtual void param_update_default(const gchar * default_value); -- cgit v1.2.3 From 15adf7b6003d6956e38ccf42a65d0e883bac2731 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 29 May 2017 19:26:57 +0200 Subject: Add toggle clip bisibility button (bzr r15709) --- src/live_effects/lpe-powerclip.cpp | 148 +++++++++++++++++---------- src/live_effects/lpe-powerclip.h | 4 +- src/live_effects/parameter/satellitesarray.h | 1 - 3 files changed, 97 insertions(+), 56 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index 7ab662bbc..bbbe733fe 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -30,7 +30,6 @@ namespace LivePathEffect { LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) : Effect(lpeobject), - hide_clip(_("Temporary hide"), _("Hide clip, not storeable, reset on doc load"), "hide_clip", &wr, this, false), inverse(_("Inverse clip"), _("Inverse clip"), "inverse", &wr, this, false), flatten(_("Flatten clip"), _("Flatten clip"), "flatten", &wr, this, false), fillrule(_("Set/unset evenodd fill rule"), _("Set/unset evenodd fill rule (this is overwriting your current value)."), "fillrule", &wr, this, false), @@ -43,47 +42,18 @@ LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) registerParameter(&fillrule); registerParameter(&convert_shapes); registerParameter(&is_inverse); - registerParameter(&hide_clip); is_clip = false; previous_fillrule = fillrule; - previous_hide_clip = false; + hide_clip = false; } LPEPowerClip::~LPEPowerClip() {} void LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ - if (is_load) { - hide_clip.param_setValue(false); - } + original_bbox(lpeitem); const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path"); SPClipPath *clip_path = SP_ITEM(lpeitem)->clip_ref->getObject(); - SPItem * item = SP_ITEM(lpeitem); - if (!is_load) { - if(clip_path && hide_clip && previous_hide_clip != hide_clip) { - SPItemView *v; - for (v = item->display; v != NULL; v = v->next) { - clip_path->hide(v->arenaitem->key()); - } - } else if (clip_path && !hide_clip && previous_hide_clip != hide_clip) { - Geom::OptRect bbox = item->geometricBounds(); - for (SPItemView *v = item->display; v != NULL; v = v->next) { - if (!v->arenaitem->key()) { - v->arenaitem->setKey(SPItem::display_key_new(3)); - } - Inkscape::DrawingItem *ai = clip_path->show( - v->arenaitem->drawing(), - v->arenaitem->key()); - v->arenaitem->setClip(ai); - clip_path->setBBox(v->arenaitem->key(), bbox); - } - } - } - if(!is_load && previous_hide_clip != hide_clip) { - clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - } - previous_hide_clip = hide_clip; - original_bbox(lpeitem); Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); Geom::Point bottomright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.min() - 5); @@ -152,17 +122,17 @@ LPEPowerClip::addInverse (SPItem * clip_data){ SP_SHAPE(clip_data)->setCurve(c, TRUE); c->unref(); is_inverse.param_setValue((Glib::ustring)"true", true); -// SPDesktop *desktop = SP_ACTIVE_DESKTOP; -// if (desktop) { -// if (tools_isactive(desktop, TOOLS_NODES)) { -// Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); -// SPItem * item = sel->singleItem(); -// if (item != NULL) { -// sel->remove(item); -// sel->add(item); -// } -// } -// } + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item != NULL) { + sel->remove(item); + sel->add(item); + } + } + } } } } @@ -187,22 +157,92 @@ LPEPowerClip::removeInverse (SPItem * clip_data){ SP_SHAPE(clip_data)->setCurve(c, TRUE); c->unref(); is_inverse.param_setValue((Glib::ustring)"false", true); -// SPDesktop *desktop = SP_ACTIVE_DESKTOP; -// if (desktop) { -// if (tools_isactive(desktop, TOOLS_NODES)) { -// Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); -// SPItem * item = sel->singleItem(); -// if (item != NULL) { -// sel->remove(item); -// sel->add(item); -// } -// } -// } + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item != NULL) { + sel->remove(item); + sel->add(item); + } + } + } + } + } + } +} + +void +LPEPowerClip::toggleClip() { + SPItem * item = SP_ITEM(sp_lpe_item); + if (item) { + SPClipPath *clip_path = item->clip_ref->getObject(); + if (clip_path) { + hide_clip = !hide_clip; + if(hide_clip) { + SPItemView *v; + for (v = item->display; v != NULL; v = v->next) { + clip_path->hide(v->arenaitem->key()); + } + } else { + Geom::OptRect bbox = item->geometricBounds(); + for (SPItemView *v = item->display; v != NULL; v = v->next) { + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); + } + Inkscape::DrawingItem *ai = clip_path->show( + v->arenaitem->drawing(), + v->arenaitem->key()); + v->arenaitem->setClip(ai); + clip_path->setBBox(v->arenaitem->key(), bbox); + } } + clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } } +Gtk::Widget * +LPEPowerClip::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(6); + Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); + Gtk::Button * toggle_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Toggle clip visibiliy")))); + toggle_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::toggleClip)); + toggle_button->set_size_request(140,30); + vbox->pack_start(*hbox, true,true,2); + hbox->pack_start(*toggle_button, false, false,2); + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Gtk::Widget * widg = dynamic_cast(param->param_newWidget()); + if(param->param_key == "grid") { + widg = NULL; + } + 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); +} + void LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/) { diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index bf3eeac0d..63594cfd8 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -23,6 +23,8 @@ public: virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); //virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); + virtual Gtk::Widget * newWidget(); + void toggleClip(); void addInverse (SPItem * clip_data); void removeInverse (SPItem * clip_data); void flattenClip(SPItem * clip_data, Geom::PathVector &path_in); @@ -31,7 +33,6 @@ protected: //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); private: - BoolParam hide_clip; BoolParam inverse; BoolParam flatten; BoolParam fillrule; @@ -39,6 +40,7 @@ private: HiddenParam is_inverse; Geom::Path clip_box; bool is_clip; + bool hide_clip; bool previous_fillrule; bool previous_hide_clip; }; diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h index 300a7a9dd..5ae372ac2 100644 --- a/src/live_effects/parameter/satellitesarray.h +++ b/src/live_effects/parameter/satellitesarray.h @@ -57,7 +57,6 @@ public: void setEffectType(EffectType et); void setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write = true); void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); - bool widget_is_visible; friend class FilletChamferKnotHolderEntity; friend class LPEFilletChamfer; -- cgit v1.2.3 From cfb1e23e906e35f0d4e7bbd9fcbb047c3a3788bf Mon Sep 17 00:00:00 2001 From: Michael Soegtrop Date: Mon, 5 Jun 2017 20:59:36 +0200 Subject: fixed enum order + added cpp files to POFILES.in (bzr r14862.2.4) --- src/live_effects/effect-enum.h | 4 ++-- src/live_effects/effect.cpp | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 0ad9c5230..5cc4d58e5 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -42,8 +42,6 @@ enum EffectType { TAPER_STROKE, MIRROR_SYMMETRY, COPY_ROTATE, - EMBRODERY_STITCH, - BOOL_OP, ATTACH_PATH, FILL_BETWEEN_STROKES, FILL_BETWEEN_MANY, @@ -51,6 +49,8 @@ enum EffectType { BOUNDING_BOX, MEASURE_LINE, FILLET_CHAMFER, + BOOL_OP, + EMBRODERY_STITCH, DOEFFECTSTACK_TEST, ANGLE_BISECTOR, CIRCLE_WITH_RADIUS, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 44580b9b2..e5a879241 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -118,8 +118,6 @@ const Util::EnumData LPETypeData[] = { {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, /* Ponyscape -> Inkscape 0.92*/ - {EMBRODERY_STITCH, N_("Embrodery stitch"), "embrodery_stitch"}, - {BOOL_OP, N_("Boolean operation"), "bool_op"}, {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"}, @@ -128,6 +126,8 @@ const Util::EnumData LPETypeData[] = { /* 9.93 */ {MEASURE_LINE, N_("Measure Line"), "measure_line"}, {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, + {BOOL_OP, N_("Boolean operation"), "bool_op"}, + {EMBRODERY_STITCH, N_("Embrodery stitch"), "embrodery_stitch"}, #ifdef LPE_ENABLE_TEST_EFFECTS {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"}, @@ -171,11 +171,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case EMBRODERY_STITCH: neweffect = static_cast ( new LPEEmbroderyStitch(lpeobj) ); break; - case BOOL_OP: neweffect = static_cast ( new LPEBool(lpeobj) ); break; - case PATTERN_ALONG_PATH: neweffect = static_cast ( new LPEPatternAlongPath(lpeobj) ); break; -- cgit v1.2.3 From 5adc02881af091a146faceaa8187cd567d5c4412 Mon Sep 17 00:00:00 2001 From: Michael Soegtrop Date: Mon, 5 Jun 2017 21:00:41 +0200 Subject: fixed enum order + added cpp files to POFILES.in (bzr r14876.2.5) --- src/live_effects/effect-enum.h | 2 +- src/live_effects/effect.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 71d669bf6..ed9fb2c9d 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -42,7 +42,6 @@ enum EffectType { TAPER_STROKE, MIRROR_SYMMETRY, COPY_ROTATE, - BOOL_OP, ATTACH_PATH, FILL_BETWEEN_STROKES, FILL_BETWEEN_MANY, @@ -50,6 +49,7 @@ enum EffectType { BOUNDING_BOX, MEASURE_LINE, FILLET_CHAMFER, + BOOL_OP, DOEFFECTSTACK_TEST, ANGLE_BISECTOR, CIRCLE_WITH_RADIUS, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index fe40920e3..9e1555c26 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -117,7 +117,6 @@ const Util::EnumData LPETypeData[] = { {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, /* Ponyscape -> Inkscape 0.92*/ - {BOOL_OP, N_("Boolean operation"), "bool_op"}, {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"}, @@ -126,6 +125,7 @@ const Util::EnumData LPETypeData[] = { /* 9.93 */ {MEASURE_LINE, N_("Measure Line"), "measure_line"}, {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, + {BOOL_OP, N_("Boolean operation"), "bool_op"}, #ifdef LPE_ENABLE_TEST_EFFECTS {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"}, @@ -169,7 +169,6 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case BOOL_OP: neweffect = static_cast ( new LPEBool(lpeobj) ); break; - case PATTERN_ALONG_PATH: neweffect = static_cast ( new LPEPatternAlongPath(lpeobj) ); break; -- cgit v1.2.3 From 09d096d4d8afd236344bd34dc637e9a56ea1d731 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 6 Jun 2017 21:17:08 +0200 Subject: Fixing somethings changing from shapes to paths (bzr r15716) --- src/live_effects/lpe-powerclip.cpp | 91 ++++++++++++++++++++------------------ src/live_effects/lpe-powerclip.h | 4 +- 2 files changed, 48 insertions(+), 47 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index bbbe733fe..e4a6f9e60 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -31,19 +31,16 @@ namespace LivePathEffect { LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) : Effect(lpeobject), inverse(_("Inverse clip"), _("Inverse clip"), "inverse", &wr, this, false), - flatten(_("Flatten clip"), _("Flatten clip"), "flatten", &wr, this, false), - fillrule(_("Set/unset evenodd fill rule"), _("Set/unset evenodd fill rule (this is overwriting your current value)."), "fillrule", &wr, this, false), + flatten(_("Flatten clip"), _("Flatten clip, see fill rule once convert to paths"), "flatten", &wr, this, false), convert_shapes(_("Convert clip shapes to paths"), _("Convert clip shapes to paths (this is overwriting your current value)."), "convert_shapes", &wr, this, false), //tooltip empty to no show in default param set is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false) { registerParameter(&inverse); registerParameter(&flatten); - registerParameter(&fillrule); registerParameter(&convert_shapes); registerParameter(&is_inverse); is_clip = false; - previous_fillrule = fillrule; hide_clip = false; } @@ -70,23 +67,58 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ std::vector clip_path_list = clip_path->childList(true); for ( std::vector::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) { SPObject * clip_data = *iter; + SPObject * clip_to_path = NULL; if (SP_IS_SHAPE(clip_data) && !SP_IS_PATH(clip_data) && convert_shapes) { SPDocument * document = SP_ACTIVE_DOCUMENT; if (!document) { return; } Inkscape::XML::Document *xml_doc = document->getReprDoc(); - const char * id = clip_data->getId(); Inkscape::XML::Node *clip_path_node = sp_selected_item_to_curved_repr(SP_ITEM(clip_data), 0); - clip_data->updateRepr(xml_doc, clip_path_node, SP_OBJECT_WRITE_ALL); - clip_data->getRepr()->setAttribute("id", id); - clip_path->emitModified(SP_OBJECT_MODIFIED_CASCADE); - std::cout << "toshapes\n"; + // remember the position of the item + gint pos = clip_data->getRepr()->position(); + // remember parent + Inkscape::XML::Node *parent = clip_data->getRepr()->parent(); + // remember id + char const *id = clip_data->getRepr()->attribute("id"); + // remember title + gchar *title = clip_data->title(); + // remember description + gchar *desc = clip_data->desc(); + + // It's going to resurrect, so we delete without notifying listeners. + clip_data->deleteObject(false); + + // restore id + clip_path_node->setAttribute("id", id); + // add the new repr to the parent + parent->appendChild(clip_path_node); + clip_to_path = document->getObjectByRepr(clip_path_node); + if (title && clip_to_path) { + clip_to_path->setTitle(title); + g_free(title); + } + if (desc && clip_to_path) { + clip_to_path->setDesc(desc); + g_free(desc); + } + // move to the saved position + clip_path_node->setPosition(pos > 0 ? pos : 0); + Inkscape::GC::release(clip_path_node); + clip_to_path->emitModified(SP_OBJECT_MODIFIED_CASCADE); } if( inverse && isVisible()) { - addInverse(SP_ITEM(clip_data)); + if (clip_to_path) { + addInverse(SP_ITEM(clip_to_path)); + } else { + addInverse(SP_ITEM(clip_data)); + } } else if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { - removeInverse(SP_ITEM(clip_data)); + if (clip_to_path) { + removeInverse(SP_ITEM(clip_to_path)); + } else { + removeInverse(SP_ITEM(clip_data)); + } } } } else { @@ -103,12 +135,11 @@ LPEPowerClip::addInverse (SPItem * clip_data){ addInverse(subitem); } } else if (SP_IS_PATH(clip_data)) { - setFillRule(clip_data); SPCurve * c = NULL; c = SP_SHAPE(clip_data)->getCurve(); if (c) { Geom::PathVector c_pv = c->get_pathvector(); - if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + if(c_pv.size() > 1 && is_inverse.param_getSVGValue() == (Glib::ustring)"true") { c_pv.pop_back(); } //TODO: this can be not correct but no better way @@ -147,12 +178,13 @@ LPEPowerClip::removeInverse (SPItem * clip_data){ removeInverse(subitem); } } else if (SP_IS_PATH(clip_data)) { - setFillRule(clip_data); SPCurve * c = NULL; c = SP_SHAPE(clip_data)->getCurve(); if (c) { Geom::PathVector c_pv = c->get_pathvector(); - c_pv.pop_back(); + if(c_pv.size() > 1) { + c_pv.pop_back(); + } c->set_pathvector(c_pv); SP_SHAPE(clip_data)->setCurve(c, TRUE); c->unref(); @@ -293,17 +325,6 @@ LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in) flattenClip(subitem, path_in); } } else if (SP_IS_PATH(clip_data)) { - if (!SP_IS_PATH(clip_data) && convert_shapes) { - SPDocument * document = SP_ACTIVE_DOCUMENT; - if (!document) { - return; - } - Inkscape::XML::Document *xml_doc = document->getReprDoc(); - const char * id = clip_data->getId(); - Inkscape::XML::Node *clip_path_node = sp_selected_item_to_curved_repr(clip_data, 0); - clip_data->updateRepr(xml_doc, clip_path_node, SP_OBJECT_WRITE_ALL); - clip_data->getRepr()->setAttribute("id", id); - } SPCurve * c = NULL; c = SP_SHAPE(clip_data)->getCurve(); if (c) { @@ -317,24 +338,6 @@ LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in) } } -void -LPEPowerClip::setFillRule(SPItem * clip_data) -{ - if (previous_fillrule != fillrule) { - SPCSSAttr *css = sp_repr_css_attr_new(); - sp_repr_css_attr_add_from_string(css, clip_data->getRepr()->attribute("style")); - if (fillrule) { - sp_repr_css_set_property (css, "fill-rule", "evenodd"); - } else { - sp_repr_css_set_property (css, "fill-rule", "nonzero"); - } - Glib::ustring css_str; - sp_repr_css_write_string(css,css_str); - clip_data->getRepr()->setAttribute("style", css_str.c_str()); - previous_fillrule = fillrule; - } -} - }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index 63594cfd8..b9c68c652 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -28,20 +28,18 @@ public: void addInverse (SPItem * clip_data); void removeInverse (SPItem * clip_data); void flattenClip(SPItem * clip_data, Geom::PathVector &path_in); - void setFillRule(SPItem * clip_data); + void setClipRule(SPItem * clip_data); protected: //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); private: BoolParam inverse; BoolParam flatten; - BoolParam fillrule; BoolParam convert_shapes; HiddenParam is_inverse; Geom::Path clip_box; bool is_clip; bool hide_clip; - bool previous_fillrule; bool previous_hide_clip; }; -- cgit v1.2.3 From 0477b2e5da044c5d4c61198f3200467bbf619362 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 6 Jun 2017 21:37:40 +0200 Subject: Substitute a bool paramenter by a button (bzr r15717) --- src/live_effects/lpe-powerclip.cpp | 28 ++++++++++++++++++++-------- src/live_effects/lpe-powerclip.h | 7 ++----- 2 files changed, 22 insertions(+), 13 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index e4a6f9e60..d5666bdde 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -32,16 +32,15 @@ LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) : Effect(lpeobject), inverse(_("Inverse clip"), _("Inverse clip"), "inverse", &wr, this, false), flatten(_("Flatten clip"), _("Flatten clip, see fill rule once convert to paths"), "flatten", &wr, this, false), - convert_shapes(_("Convert clip shapes to paths"), _("Convert clip shapes to paths (this is overwriting your current value)."), "convert_shapes", &wr, this, false), //tooltip empty to no show in default param set is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false) { registerParameter(&inverse); registerParameter(&flatten); - registerParameter(&convert_shapes); registerParameter(&is_inverse); is_clip = false; hide_clip = false; + convert_shapes = false; } LPEPowerClip::~LPEPowerClip() {} @@ -235,6 +234,12 @@ LPEPowerClip::toggleClip() { } } +void +LPEPowerClip::convertShapes() { + convert_shapes = true; + sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); +} + Gtk::Widget * LPEPowerClip::newWidget() { @@ -244,12 +249,7 @@ LPEPowerClip::newWidget() vbox->set_border_width(5); vbox->set_homogeneous(false); vbox->set_spacing(6); - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); - Gtk::Button * toggle_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Toggle clip visibiliy")))); - toggle_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::toggleClip)); - toggle_button->set_size_request(140,30); - vbox->pack_start(*hbox, true,true,2); - hbox->pack_start(*toggle_button, false, false,2); + std::vector::iterator it = param_vector.begin(); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { @@ -272,6 +272,18 @@ LPEPowerClip::newWidget() ++it; } + Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); + Gtk::Button * toggle_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Toggle clip visibiliy")))); + toggle_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::toggleClip)); + toggle_button->set_size_request(140,30); + vbox->pack_start(*hbox, true,true,2); + hbox->pack_start(*toggle_button, false, false,2); + Gtk::HBox * hbox2 = Gtk::manage(new Gtk::HBox(false,0)); + Gtk::Button * topaths_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Convert clips to paths, undoable")))); + topaths_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::convertShapes)); + topaths_button->set_size_request(200,30); + vbox->pack_start(*hbox2, true,true,2); + hbox2->pack_start(*topaths_button, false, false,2); return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index b9c68c652..88d425f01 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -28,17 +28,14 @@ public: void addInverse (SPItem * clip_data); void removeInverse (SPItem * clip_data); void flattenClip(SPItem * clip_data, Geom::PathVector &path_in); - void setClipRule(SPItem * clip_data); -protected: - //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); - + void convertShapes(); private: BoolParam inverse; BoolParam flatten; - BoolParam convert_shapes; HiddenParam is_inverse; Geom::Path clip_box; bool is_clip; + bool convert_shapes; bool hide_clip; bool previous_hide_clip; }; -- cgit v1.2.3 From cc8dee1e385d81f4cb326f385ef282ea3b7d0370 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Tue, 6 Jun 2017 22:27:19 +0200 Subject: Starting with powermask (bzr r15718) --- src/live_effects/CMakeLists.txt | 2 + src/live_effects/effect-enum.h | 1 + src/live_effects/effect.cpp | 5 + src/live_effects/lpe-powerclip.cpp | 8 - src/live_effects/lpe-powermask.cpp | 357 +++++++++++++++++++++++++++++++++++++ src/live_effects/lpe-powermask.h | 45 +++++ 6 files changed, 410 insertions(+), 8 deletions(-) create mode 100644 src/live_effects/lpe-powermask.cpp create mode 100644 src/live_effects/lpe-powermask.h (limited to 'src/live_effects') diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index e1e5cab4c..75e3c2154 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -37,6 +37,7 @@ set(live_effects_SRC lpe-perspective-envelope.cpp lpe-perspective_path.cpp lpe-powerclip.cpp + lpe-powermask.cpp lpe-powerstroke.cpp lpe-recursiveskeleton.cpp lpe-rough-hatches.cpp @@ -123,6 +124,7 @@ set(live_effects_SRC lpe-perspective_path.h lpe-powerstroke-interpolators.h lpe-powerclip.h + lpe-powermask.h lpe-powerstroke.h lpe-recursiveskeleton.h lpe-rough-hatches.h diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 700564334..88e93b936 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -50,6 +50,7 @@ enum EffectType { MEASURE_LINE, FILLET_CHAMFER, POWERCLIP, + POWERMASK, DOEFFECTSTACK_TEST, ANGLE_BISECTOR, CIRCLE_WITH_RADIUS, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index ff481dd96..faf1d14ab 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -48,6 +48,7 @@ #include "live_effects/lpe-perspective-envelope.h" #include "live_effects/lpe-perspective_path.h" #include "live_effects/lpe-powerclip.h" +#include "live_effects/lpe-powermask.h" #include "live_effects/lpe-powerstroke.h" #include "live_effects/lpe-recursiveskeleton.h" #include "live_effects/lpe-roughen.h" @@ -126,6 +127,7 @@ const Util::EnumData LPETypeData[] = { {MEASURE_LINE, N_("Measure Line"), "measure_line"}, {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, {POWERCLIP, N_("Power clip"), "powerclip"}, + {POWERMASK, N_("Power mask"), "powermask"}, #ifdef LPE_ENABLE_TEST_EFFECTS {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"}, @@ -307,6 +309,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case POWERCLIP: neweffect = static_cast ( new LPEPowerClip(lpeobj) ); break; + case POWERMASK: + neweffect = static_cast ( new LPEPowerClip(lpeobj) ); + break; case ROUGHEN: neweffect = static_cast ( new LPERoughen(lpeobj) ); break; diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index d5666bdde..75e4c24de 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -17,14 +17,6 @@ // TODO due to internal breakage in glibmm headers, this must be last: #include -// FIXME: expose these from sp-clippath/mask.cpp -struct SPClipPathView { - SPClipPathView *next; - unsigned int key; - Inkscape::DrawingItem *arenaitem; - Geom::OptRect bbox; -}; - namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp new file mode 100644 index 000000000..a98d2655f --- /dev/null +++ b/src/live_effects/lpe-powermask.cpp @@ -0,0 +1,357 @@ +/* + * Released under GNU GPL, read the file 'COPYING' for more information + */ +#include "live_effects/lpe-powermask.h" +#include <2geom/path-intersection.h> +#include <2geom/intersection-graph.h> +#include "display/drawing-item.h" +#include "display/curve.h" +#include "helper/geom.h" +#include "sp-mask.h" +#include "sp-path.h" +#include "sp-shape.h" +#include "sp-item-group.h" +#include "ui/tools-switch.h" +#include "path-chemistry.h" + +// TODO due to internal breakage in glibmm headers, this must be last: +#include + +namespace Inkscape { +namespace LivePathEffect { + +LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) + : Effect(lpeobject), + inverse(_("Inverse mask"), _("Inverse mask"), "inverse", &wr, this, false), + flatten(_("Flatten mask"), _("Flatten mask, see fill rule once convert to paths"), "flatten", &wr, this, false), + //tooltip empty to no show in default param set + is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false) +{ + registerParameter(&inverse); + registerParameter(&flatten); + registerParameter(&is_inverse); + is_mask = false; + hide_mask = false; + convert_shapes = false; +} + +LPEPowerMask::~LPEPowerMask() {} + +void +LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ + original_bbox(lpeitem); + const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("mask-path"); + SPMaskPath *mask_path = SP_ITEM(lpeitem)->mask_ref->getObject(); + Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); + Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); + Geom::Point bottomright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.min() - 5); + Geom::Point bottomleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.min() - 5); + mask_box.clear(); + mask_box.start(topleft); + mask_box.appendNew(topright); + mask_box.appendNew(bottomright); + mask_box.appendNew(bottomleft); + mask_box.close(); + //mask_path *= sp_lpe_item->i2dt_affine(); + if(mask_path) { + is_mask = true; + std::vector mask_path_list = mask_path->childList(true); + for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { + SPObject * mask_data = *iter; + SPObject * mask_to_path = NULL; + if (SP_IS_SHAPE(mask_data) && !SP_IS_PATH(mask_data) && convert_shapes) { + SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } + Inkscape::XML::Document *xml_doc = document->getReprDoc(); + Inkscape::XML::Node *mask_path_node = sp_selected_item_to_curved_repr(SP_ITEM(mask_data), 0); + // remember the position of the item + gint pos = mask_data->getRepr()->position(); + // remember parent + Inkscape::XML::Node *parent = mask_data->getRepr()->parent(); + // remember id + char const *id = mask_data->getRepr()->attribute("id"); + // remember title + gchar *title = mask_data->title(); + // remember description + gchar *desc = mask_data->desc(); + + // It's going to resurrect, so we delete without notifying listeners. + mask_data->deleteObject(false); + + // restore id + mask_path_node->setAttribute("id", id); + // add the new repr to the parent + parent->appendChild(mask_path_node); + mask_to_path = document->getObjectByRepr(mask_path_node); + if (title && mask_to_path) { + mask_to_path->setTitle(title); + g_free(title); + } + if (desc && mask_to_path) { + mask_to_path->setDesc(desc); + g_free(desc); + } + // move to the saved position + mask_path_node->setPosition(pos > 0 ? pos : 0); + Inkscape::GC::release(mask_path_node); + mask_to_path->emitModified(SP_OBJECT_MODIFIED_CASCADE); + } + if( inverse && isVisible()) { + if (mask_to_path) { + addInverse(SP_ITEM(mask_to_path)); + } else { + addInverse(SP_ITEM(mask_data)); + } + } else if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + if (mask_to_path) { + removeInverse(SP_ITEM(mask_to_path)); + } else { + removeInverse(SP_ITEM(mask_data)); + } + } + } + } else { + is_mask = false; + } +} + +void +LPEPowerMask::addInverse (SPItem * mask_data){ + if (SP_IS_GROUP(mask_data)) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(mask_data)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + SPItem *subitem = *iter; + addInverse(subitem); + } + } else if (SP_IS_PATH(mask_data)) { + SPCurve * c = NULL; + c = SP_SHAPE(mask_data)->getCurve(); + if (c) { + Geom::PathVector c_pv = c->get_pathvector(); + if(c_pv.size() > 1 && is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + c_pv.pop_back(); + } + //TODO: this can be not correct but no better way + bool dir_a = Geom::path_direction(c_pv[0]); + bool dir_b = Geom::path_direction(mask_box); + if (dir_a == dir_b) { + mask_box = mask_box.reversed(); + } + c_pv.push_back(mask_box); + c->set_pathvector(c_pv); + SP_SHAPE(mask_data)->setCurve(c, TRUE); + c->unref(); + is_inverse.param_setValue((Glib::ustring)"true", true); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item != NULL) { + sel->remove(item); + sel->add(item); + } + } + } + } + } +} + +void +LPEPowerMask::removeInverse (SPItem * mask_data){ + if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + if (SP_IS_GROUP(mask_data)) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(mask_data)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + SPItem *subitem = *iter; + removeInverse(subitem); + } + } else if (SP_IS_PATH(mask_data)) { + SPCurve * c = NULL; + c = SP_SHAPE(mask_data)->getCurve(); + if (c) { + Geom::PathVector c_pv = c->get_pathvector(); + if(c_pv.size() > 1) { + c_pv.pop_back(); + } + c->set_pathvector(c_pv); + SP_SHAPE(mask_data)->setCurve(c, TRUE); + c->unref(); + is_inverse.param_setValue((Glib::ustring)"false", true); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item != NULL) { + sel->remove(item); + sel->add(item); + } + } + } + } + } + } +} + +void +LPEPowerMask::toggleMask() { + SPItem * item = SP_ITEM(sp_lpe_item); + if (item) { + SPMaskPath *mask_path = item->mask_ref->getObject(); + if (mask_path) { + hide_mask = !hide_mask; + if(hide_mask) { + SPItemView *v; + for (v = item->display; v != NULL; v = v->next) { + mask_path->hide(v->arenaitem->key()); + } + } else { + Geom::OptRect bbox = item->geometricBounds(); + for (SPItemView *v = item->display; v != NULL; v = v->next) { + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); + } + Inkscape::DrawingItem *ai = mask_path->show( + v->arenaitem->drawing(), + v->arenaitem->key()); + v->arenaitem->setMask(ai); + mask_path->setBBox(v->arenaitem->key(), bbox); + } + } + mask_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } + } +} + +void +LPEPowerMask::convertShapes() { + convert_shapes = true; + sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); +} + +Gtk::Widget * +LPEPowerMask::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(6); + + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Gtk::Widget * widg = dynamic_cast(param->param_newWidget()); + if(param->param_key == "grid") { + widg = NULL; + } + 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; + } + Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); + Gtk::Button * toggle_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Toggle mask visibiliy")))); + toggle_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerMask::toggleMask)); + toggle_button->set_size_request(140,30); + vbox->pack_start(*hbox, true,true,2); + hbox->pack_start(*toggle_button, false, false,2); + Gtk::HBox * hbox2 = Gtk::manage(new Gtk::HBox(false,0)); + Gtk::Button * topaths_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Convert masks to paths, undoable")))); + topaths_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerMask::convertShapes)); + topaths_button->set_size_request(200,30); + vbox->pack_start(*hbox2, true,true,2); + hbox2->pack_start(*topaths_button, false, false,2); + return dynamic_cast(vbox); +} + +void +LPEPowerMask::doOnRemove (SPLPEItem const* /*lpeitem*/) +{ + SPMaskPath *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); + if(!keep_paths) { + if(mask_path) { + is_mask = true; + std::vector mask_path_list = mask_path->childList(true); + for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { + SPObject * mask_data = *iter; + if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + removeInverse(SP_ITEM(mask_data)); + is_inverse.param_setValue((Glib::ustring)"false"); + } + } + } + } else { + if (flatten && mask_path) { + mask_path->deleteObject(); + sp_lpe_item->getRepr()->setAttribute("mask-path", NULL); + } + } +} + +Geom::PathVector +LPEPowerMask::doEffect_path(Geom::PathVector const & path_in){ + Geom::PathVector path_out = pathv_to_linear_and_cubic_beziers(path_in); + if (flatten && is_mask && isVisible()) { + SPMaskPath *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); + if(mask_path) { + std::vector mask_path_list = mask_path->childList(true); + for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { + SPObject * mask_data = *iter; + flattenMask(SP_ITEM(mask_data), path_out); + } + } + } + return path_out; +} + +void +LPEPowerMask::flattenMask(SPItem * mask_data, Geom::PathVector &path_in) +{ + if (SP_IS_GROUP(mask_data)) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(mask_data)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + SPItem *subitem = *iter; + flattenMask(subitem, path_in); + } + } else if (SP_IS_PATH(mask_data)) { + SPCurve * c = NULL; + c = SP_SHAPE(mask_data)->getCurve(); + if (c) { + Geom::PathVector c_pv = c->get_pathvector(); + Geom::PathIntersectionGraph *pig = new Geom::PathIntersectionGraph(c_pv, path_in); + if (pig && !c_pv.empty() && !path_in.empty()) { + path_in = pig->getIntersection(); + } + c->unref(); + } + } +} + +}; //namespace LivePathEffect +}; /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h new file mode 100644 index 000000000..933eeefb1 --- /dev/null +++ b/src/live_effects/lpe-powermask.h @@ -0,0 +1,45 @@ +#ifndef INKSCAPE_LPE_POWERMASK_H +#define INKSCAPE_LPE_POWERMASK_H + +/* + * Inkscape::LPEPowerMask + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/parameter/hidden.h" +#include "live_effects/parameter/path.h" +#include "live_effects/lpegroupbbox.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPEPowerMask : public Effect, GroupBBoxEffect { +public: + LPEPowerMask(LivePathEffectObject *lpeobject); + virtual ~LPEPowerMask(); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); + //virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); + virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); + virtual Gtk::Widget * newWidget(); + void toggleMask(); + void addInverse (SPItem * mask_data); + void removeInverse (SPItem * mask_data); + void flattenMask(SPItem * mask_data, Geom::PathVector &path_in); + void convertShapes(); +private: + BoolParam inverse; + BoolParam flatten; + HiddenParam is_inverse; + Geom::Path mask_box; + bool is_mask; + bool convert_shapes; + bool hide_mask; + bool previous_hide_mask; +}; + +} //namespace LivePathEffect +} //namespace Inkscape +#endif -- cgit v1.2.3 From bfdef68f1e252a7e185fced8f8f0c0fd20b66e20 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Wed, 7 Jun 2017 00:41:50 +0200 Subject: Working on powermask (bzr r15719) --- src/live_effects/lpe-powermask.cpp | 293 ++++++++++--------------------------- src/live_effects/lpe-powermask.h | 12 +- 2 files changed, 76 insertions(+), 229 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index a98d2655f..bbe0dff40 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -10,7 +10,9 @@ #include "sp-mask.h" #include "sp-path.h" #include "sp-shape.h" +#include "sp-defs.h" #include "sp-item-group.h" +#include "svg/svg.h" #include "ui/tools-switch.h" #include "path-chemistry.h" @@ -22,17 +24,10 @@ namespace LivePathEffect { LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), - inverse(_("Inverse mask"), _("Inverse mask"), "inverse", &wr, this, false), - flatten(_("Flatten mask"), _("Flatten mask, see fill rule once convert to paths"), "flatten", &wr, this, false), - //tooltip empty to no show in default param set - is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false) + inverse(_("Inverse mask"), _("Inverse mask"), "inverse", &wr, this, false) { registerParameter(&inverse); - registerParameter(&flatten); - registerParameter(&is_inverse); - is_mask = false; hide_mask = false; - convert_shapes = false; } LPEPowerMask::~LPEPowerMask() {} @@ -41,7 +36,7 @@ void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ original_bbox(lpeitem); const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("mask-path"); - SPMaskPath *mask_path = SP_ITEM(lpeitem)->mask_ref->getObject(); + SPMask *mask = SP_ITEM(lpeitem)->mask_ref->getObject(); Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); Geom::Point bottomright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.min() - 5); @@ -52,147 +47,72 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ mask_box.appendNew(bottomright); mask_box.appendNew(bottomleft); mask_box.close(); - //mask_path *= sp_lpe_item->i2dt_affine(); - if(mask_path) { - is_mask = true; - std::vector mask_path_list = mask_path->childList(true); - for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { - SPObject * mask_data = *iter; - SPObject * mask_to_path = NULL; - if (SP_IS_SHAPE(mask_data) && !SP_IS_PATH(mask_data) && convert_shapes) { - SPDocument * document = SP_ACTIVE_DOCUMENT; - if (!document) { - return; - } - Inkscape::XML::Document *xml_doc = document->getReprDoc(); - Inkscape::XML::Node *mask_path_node = sp_selected_item_to_curved_repr(SP_ITEM(mask_data), 0); - // remember the position of the item - gint pos = mask_data->getRepr()->position(); - // remember parent - Inkscape::XML::Node *parent = mask_data->getRepr()->parent(); - // remember id - char const *id = mask_data->getRepr()->attribute("id"); - // remember title - gchar *title = mask_data->title(); - // remember description - gchar *desc = mask_data->desc(); - - // It's going to resurrect, so we delete without notifying listeners. - mask_data->deleteObject(false); - - // restore id - mask_path_node->setAttribute("id", id); - // add the new repr to the parent - parent->appendChild(mask_path_node); - mask_to_path = document->getObjectByRepr(mask_path_node); - if (title && mask_to_path) { - mask_to_path->setTitle(title); - g_free(title); - } - if (desc && mask_to_path) { - mask_to_path->setDesc(desc); - g_free(desc); - } - // move to the saved position - mask_path_node->setPosition(pos > 0 ? pos : 0); - Inkscape::GC::release(mask_path_node); - mask_to_path->emitModified(SP_OBJECT_MODIFIED_CASCADE); - } - if( inverse && isVisible()) { - if (mask_to_path) { - addInverse(SP_ITEM(mask_to_path)); - } else { - addInverse(SP_ITEM(mask_data)); - } - } else if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { - if (mask_to_path) { - removeInverse(SP_ITEM(mask_to_path)); - } else { - removeInverse(SP_ITEM(mask_data)); - } - } - } - } else { - is_mask = false; + //mask *= sp_lpe_item->i2dt_affine(); + if(mask) { + setInverse(); } } void -LPEPowerMask::addInverse (SPItem * mask_data){ - if (SP_IS_GROUP(mask_data)) { - std::vector item_list = sp_item_group_item_list(SP_GROUP(mask_data)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPItem *subitem = *iter; - addInverse(subitem); - } - } else if (SP_IS_PATH(mask_data)) { - SPCurve * c = NULL; - c = SP_SHAPE(mask_data)->getCurve(); - if (c) { - Geom::PathVector c_pv = c->get_pathvector(); - if(c_pv.size() > 1 && is_inverse.param_getSVGValue() == (Glib::ustring)"true") { - c_pv.pop_back(); - } - //TODO: this can be not correct but no better way - bool dir_a = Geom::path_direction(c_pv[0]); - bool dir_b = Geom::path_direction(mask_box); - if (dir_a == dir_b) { - mask_box = mask_box.reversed(); - } - c_pv.push_back(mask_box); - c->set_pathvector(c_pv); - SP_SHAPE(mask_data)->setCurve(c, TRUE); - c->unref(); - is_inverse.param_setValue((Glib::ustring)"true", true); - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) { - if (tools_isactive(desktop, TOOLS_NODES)) { - Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); - SPItem * item = sel->singleItem(); - if (item != NULL) { - sel->remove(item); - sel->add(item); - } - } - } - } +LPEPowerMask::setInverse(){ + SPMask *mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); + SPObject *elemref = NULL; + SPDocument * document = SP_ACTIVE_DOCUMENT; + if(!document || !mask) { + return; } -} - -void -LPEPowerMask::removeInverse (SPItem * mask_data){ - if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { - if (SP_IS_GROUP(mask_data)) { - std::vector item_list = sp_item_group_item_list(SP_GROUP(mask_data)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPItem *subitem = *iter; - removeInverse(subitem); - } - } else if (SP_IS_PATH(mask_data)) { - SPCurve * c = NULL; - c = SP_SHAPE(mask_data)->getCurve(); - if (c) { - Geom::PathVector c_pv = c->get_pathvector(); - if(c_pv.size() > 1) { - c_pv.pop_back(); - } - c->set_pathvector(c_pv); - SP_SHAPE(mask_data)->setCurve(c, TRUE); - c->unref(); - is_inverse.param_setValue((Glib::ustring)"false", true); - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) { - if (tools_isactive(desktop, TOOLS_NODES)) { - Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); - SPItem * item = sel->singleItem(); - if (item != NULL) { - sel->remove(item); - sel->add(item); - } - } - } - } - } + Inkscape::XML::Document *xml_doc = document->getReprDoc(); + Inkscape::XML::Node *box = NULL; + Inkscape::XML::Node *filter = NULL; + SPDefs * defs = document->getDefs(); + if (inverse) { +// if (!(elemref = document->getObjectById((Glib::ustring)mask->getId() + (Glib::ustring)"_transparentbox"))) { +// std::vector mask_list = mask->childList(true); +// box = xml_doc->createElement("svg:path"); +// box->setAttribute("id", (Glib::ustring)mask->getId() + (Glib::ustring)"_transparentbox"); +// box->setAttribute("style", "fill:#000"); +// gchar * box_str = sp_svg_write_path( mask_box ); +// box->setAttribute("d" , box_str); +// g_free(box_str); +// elemref = mask->appendChildRepr(box); +// box->setPosition(mask_list.size()); +// Inkscape::GC::release(box); +// mask_list.clear(); +// } +// if (!(elemref = document->getObjectById((Glib::ustring)mask->getId() + (Glib::ustring)"_inverse"))) { +// filter = xml_doc->createElement("svg:filter"); +// filter->setAttribute("id", (Glib::ustring)mask->getId() + (Glib::ustring)"_inverse"); +// filter->setAttribute("color-interpolation-filters", "sRGB"); +// filter->setAttribute("height", "100"); +// filter->setAttribute("width", "100"); +// filter->setAttribute("x", "-50"); +// filter->setAttribute("y", "-50"); +// Inkscape::XML::Node *primitive1 = xml_doc->createElement("svg:feColorMatrix"); +// primitive1->setAttribute("id", (Glib::ustring)mask->getId() + (Glib::ustring)"_primitive1"); +// primitive1->setAttribute("values", "1"); +// primitive1->setAttribute("type", "saturate"); +// primitive1->setAttribute("result", "fbSourceGraphic"); +// Inkscape::XML::Node *primitive2 = xml_doc->createElement("svg:feColorMatrix"); +// primitive2->setAttribute("id", (Glib::ustring)mask->getId() + (Glib::ustring)"_primitive2"); +// primitive2->setAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 "); +// primitive2->setAttribute("in", "fbSourceGraphic"); +// elemref = defs->appendChildRepr(filter); +// filter->appendChild(primitive1); +// filter->appendChild(primitive2); +// Inkscape::GC::release(filter); +// Inkscape::GC::release(primitive1); +// Inkscape::GC::release(primitive2); +// } +// mask->getRepr()->setAttribute("css", (Glib::ustring)"filter:#" + (Glib::ustring)mask->getId() + (Glib::ustring)"_inverse"); + } else { +// if ((elemref = document->getObjectById((Glib::ustring)mask->getId() + (Glib::ustring)"_transparentbox"))) { +// elemref->deleteObject(true); +// } + +// if ((elemref = document->getObjectById((Glib::ustring)mask->getId() + (Glib::ustring)"_inverse"))) { +// elemref->deleteObject(true); +// } + //mask->getRepr()->setAttribute("css", NULL); } } @@ -200,13 +120,13 @@ void LPEPowerMask::toggleMask() { SPItem * item = SP_ITEM(sp_lpe_item); if (item) { - SPMaskPath *mask_path = item->mask_ref->getObject(); - if (mask_path) { + SPMask *mask = item->mask_ref->getObject(); + if (mask) { hide_mask = !hide_mask; if(hide_mask) { SPItemView *v; for (v = item->display; v != NULL; v = v->next) { - mask_path->hide(v->arenaitem->key()); + mask->sp_mask_hide(v->arenaitem->key()); } } else { Geom::OptRect bbox = item->geometricBounds(); @@ -214,24 +134,18 @@ LPEPowerMask::toggleMask() { if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new(3)); } - Inkscape::DrawingItem *ai = mask_path->show( + Inkscape::DrawingItem *ai = mask->sp_mask_show( v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setMask(ai); - mask_path->setBBox(v->arenaitem->key(), bbox); + mask->sp_mask_set_bbox(v->arenaitem->key(), bbox); } } - mask_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } } -void -LPEPowerMask::convertShapes() { - convert_shapes = true; - sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); -} - Gtk::Widget * LPEPowerMask::newWidget() { @@ -270,74 +184,17 @@ LPEPowerMask::newWidget() toggle_button->set_size_request(140,30); vbox->pack_start(*hbox, true,true,2); hbox->pack_start(*toggle_button, false, false,2); - Gtk::HBox * hbox2 = Gtk::manage(new Gtk::HBox(false,0)); - Gtk::Button * topaths_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Convert masks to paths, undoable")))); - topaths_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerMask::convertShapes)); - topaths_button->set_size_request(200,30); - vbox->pack_start(*hbox2, true,true,2); - hbox2->pack_start(*topaths_button, false, false,2); return dynamic_cast(vbox); } void LPEPowerMask::doOnRemove (SPLPEItem const* /*lpeitem*/) { - SPMaskPath *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); + SPMask *mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(!keep_paths) { - if(mask_path) { - is_mask = true; - std::vector mask_path_list = mask_path->childList(true); - for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { - SPObject * mask_data = *iter; - if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { - removeInverse(SP_ITEM(mask_data)); - is_inverse.param_setValue((Glib::ustring)"false"); - } - } - } - } else { - if (flatten && mask_path) { - mask_path->deleteObject(); - sp_lpe_item->getRepr()->setAttribute("mask-path", NULL); - } - } -} - -Geom::PathVector -LPEPowerMask::doEffect_path(Geom::PathVector const & path_in){ - Geom::PathVector path_out = pathv_to_linear_and_cubic_beziers(path_in); - if (flatten && is_mask && isVisible()) { - SPMaskPath *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); - if(mask_path) { - std::vector mask_path_list = mask_path->childList(true); - for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { - SPObject * mask_data = *iter; - flattenMask(SP_ITEM(mask_data), path_out); - } - } - } - return path_out; -} - -void -LPEPowerMask::flattenMask(SPItem * mask_data, Geom::PathVector &path_in) -{ - if (SP_IS_GROUP(mask_data)) { - std::vector item_list = sp_item_group_item_list(SP_GROUP(mask_data)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPItem *subitem = *iter; - flattenMask(subitem, path_in); - } - } else if (SP_IS_PATH(mask_data)) { - SPCurve * c = NULL; - c = SP_SHAPE(mask_data)->getCurve(); - if (c) { - Geom::PathVector c_pv = c->get_pathvector(); - Geom::PathIntersectionGraph *pig = new Geom::PathIntersectionGraph(c_pv, path_in); - if (pig && !c_pv.empty() && !path_in.empty()) { - path_in = pig->getIntersection(); - } - c->unref(); + if(mask) { + inverse.param_setValue(false); + setInverse(); } } } diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index 933eeefb1..4038f207e 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -20,24 +20,14 @@ public: LPEPowerMask(LivePathEffectObject *lpeobject); virtual ~LPEPowerMask(); virtual void doBeforeEffect (SPLPEItem const* lpeitem); - virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); - //virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual Gtk::Widget * newWidget(); void toggleMask(); - void addInverse (SPItem * mask_data); - void removeInverse (SPItem * mask_data); - void flattenMask(SPItem * mask_data, Geom::PathVector &path_in); - void convertShapes(); + void setInverse(); private: BoolParam inverse; - BoolParam flatten; - HiddenParam is_inverse; Geom::Path mask_box; - bool is_mask; - bool convert_shapes; bool hide_mask; - bool previous_hide_mask; }; } //namespace LivePathEffect -- cgit v1.2.3 From ef4db6f8483312a558b512e8a1ad11fc95872886 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 7 Jun 2017 21:34:53 +0200 Subject: Working on powermask LPE (bzr r15722) --- src/live_effects/effect-enum.h | 2 - src/live_effects/effect.cpp | 2 +- src/live_effects/lpe-powerclip.cpp | 3 - src/live_effects/lpe-powerclip.h | 1 - src/live_effects/lpe-powermask.cpp | 181 +++++++++++++++++++++++++------------ src/live_effects/lpe-powermask.h | 13 ++- 6 files changed, 134 insertions(+), 68 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 7c2965d14..7114004a0 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -49,8 +49,6 @@ enum EffectType { BOUNDING_BOX, MEASURE_LINE, FILLET_CHAMFER, - POWERCLIP, - POWERMASK, BOOL_OP, POWERCLIP, POWERMASK, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 256530a38..c4a437ff6 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -315,7 +315,7 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) neweffect = static_cast ( new LPEPowerClip(lpeobj) ); break; case POWERMASK: - neweffect = static_cast ( new LPEPowerClip(lpeobj) ); + neweffect = static_cast ( new LPEPowerMask(lpeobj) ); break; case ROUGHEN: neweffect = static_cast ( new LPERoughen(lpeobj) ); diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index 75e4c24de..ee1603855 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -247,9 +247,6 @@ LPEPowerClip::newWidget() if ((*it)->widget_is_visible) { Parameter * param = *it; Gtk::Widget * widg = dynamic_cast(param->param_newWidget()); - if(param->param_key == "grid") { - widg = NULL; - } Glib::ustring * tip = param->param_getTooltip(); if (widg) { vbox->pack_start(*widg, true, true, 2); diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index 88d425f01..e70ec2c9c 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -9,7 +9,6 @@ #include "live_effects/effect.h" #include "live_effects/parameter/hidden.h" -#include "live_effects/parameter/path.h" #include "live_effects/lpegroupbbox.h" namespace Inkscape { diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index bbe0dff40..a49d4c493 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -11,6 +11,7 @@ #include "sp-path.h" #include "sp-shape.h" #include "sp-defs.h" +#include "style.h" #include "sp-item-group.h" #include "svg/svg.h" #include "ui/tools-switch.h" @@ -24,10 +25,21 @@ namespace LivePathEffect { LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), - inverse(_("Inverse mask"), _("Inverse mask"), "inverse", &wr, this, false) + invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), + wrap(_("Wrap filtered clip data"), _("Wrap filtered clip data"), "wrap", &wr, this, false), + background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), + background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:0.7;") + { - registerParameter(&inverse); + registerParameter(&invert); + registerParameter(&wrap); + registerParameter(&background); + registerParameter(&background_style); + background_style.param_hide_canvas_text(); hide_mask = false; + previous_invert = !invert; + previous_wrap = !wrap; + previous_background_style = ""; } LPEPowerMask::~LPEPowerMask() {} @@ -35,7 +47,7 @@ LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ original_bbox(lpeitem); - const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("mask-path"); + const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("mask"); SPMask *mask = SP_ITEM(lpeitem)->mask_ref->getObject(); Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); @@ -49,12 +61,12 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ mask_box.close(); //mask *= sp_lpe_item->i2dt_affine(); if(mask) { - setInverse(); + setMask(); } } void -LPEPowerMask::setInverse(){ +LPEPowerMask::setMask(){ SPMask *mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); SPObject *elemref = NULL; SPDocument * document = SP_ACTIVE_DOCUMENT; @@ -65,55 +77,111 @@ LPEPowerMask::setInverse(){ Inkscape::XML::Node *box = NULL; Inkscape::XML::Node *filter = NULL; SPDefs * defs = document->getDefs(); - if (inverse) { -// if (!(elemref = document->getObjectById((Glib::ustring)mask->getId() + (Glib::ustring)"_transparentbox"))) { -// std::vector mask_list = mask->childList(true); -// box = xml_doc->createElement("svg:path"); -// box->setAttribute("id", (Glib::ustring)mask->getId() + (Glib::ustring)"_transparentbox"); -// box->setAttribute("style", "fill:#000"); -// gchar * box_str = sp_svg_write_path( mask_box ); -// box->setAttribute("d" , box_str); -// g_free(box_str); -// elemref = mask->appendChildRepr(box); -// box->setPosition(mask_list.size()); -// Inkscape::GC::release(box); -// mask_list.clear(); -// } -// if (!(elemref = document->getObjectById((Glib::ustring)mask->getId() + (Glib::ustring)"_inverse"))) { -// filter = xml_doc->createElement("svg:filter"); -// filter->setAttribute("id", (Glib::ustring)mask->getId() + (Glib::ustring)"_inverse"); -// filter->setAttribute("color-interpolation-filters", "sRGB"); -// filter->setAttribute("height", "100"); -// filter->setAttribute("width", "100"); -// filter->setAttribute("x", "-50"); -// filter->setAttribute("y", "-50"); -// Inkscape::XML::Node *primitive1 = xml_doc->createElement("svg:feColorMatrix"); -// primitive1->setAttribute("id", (Glib::ustring)mask->getId() + (Glib::ustring)"_primitive1"); -// primitive1->setAttribute("values", "1"); -// primitive1->setAttribute("type", "saturate"); -// primitive1->setAttribute("result", "fbSourceGraphic"); -// Inkscape::XML::Node *primitive2 = xml_doc->createElement("svg:feColorMatrix"); -// primitive2->setAttribute("id", (Glib::ustring)mask->getId() + (Glib::ustring)"_primitive2"); -// primitive2->setAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 "); -// primitive2->setAttribute("in", "fbSourceGraphic"); -// elemref = defs->appendChildRepr(filter); -// filter->appendChild(primitive1); -// filter->appendChild(primitive2); -// Inkscape::GC::release(filter); -// Inkscape::GC::release(primitive1); -// Inkscape::GC::release(primitive2); -// } -// mask->getRepr()->setAttribute("css", (Glib::ustring)"filter:#" + (Glib::ustring)mask->getId() + (Glib::ustring)"_inverse"); + Glib::ustring mask_id = (Glib::ustring)mask->getId(); + Glib::ustring box_id = mask_id + (Glib::ustring)"_transparentbox"; + Glib::ustring filter_id = mask_id + (Glib::ustring)"_inverse"; + Glib::ustring filter_uri = (Glib::ustring)"url(#" + mask_id + (Glib::ustring)"_inverse)"; + if (previous_invert != invert || previous_wrap != wrap) { + if (invert) { + if (!(elemref = document->getObjectById(filter_id))) { + filter = xml_doc->createElement("svg:filter"); + filter->setAttribute("id", filter_id.c_str()); + filter->setAttribute("color-interpolation-filters", "sRGB"); + filter->setAttribute("height", "100"); + filter->setAttribute("width", "100"); + filter->setAttribute("x", "-50"); + filter->setAttribute("y", "-50"); + Inkscape::XML::Node *primitive1 = xml_doc->createElement("svg:feColorMatrix"); + Glib::ustring primitive1_id = (mask_id + (Glib::ustring)"_primitive1").c_str(); + primitive1->setAttribute("id", primitive1_id.c_str()); + primitive1->setAttribute("values", "1"); + primitive1->setAttribute("type", "saturate"); + primitive1->setAttribute("result", "fbSourceGraphic"); + Inkscape::XML::Node *primitive2 = xml_doc->createElement("svg:feColorMatrix"); + Glib::ustring primitive2_id = (mask_id + (Glib::ustring)"_primitive2").c_str(); + primitive2->setAttribute("id", primitive2_id.c_str()); + primitive2->setAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 "); + primitive2->setAttribute("in", "fbSourceGraphic"); + elemref = defs->appendChildRepr(filter); + filter->appendChild(primitive1); + filter->appendChild(primitive2); + Inkscape::GC::release(filter); + Inkscape::GC::release(primitive1); + Inkscape::GC::release(primitive2); + } + } else { + if ((elemref = document->getObjectById(filter_id))) { + elemref->deleteObject(true); + } + filter_uri = ""; + } + std::vector mask_list = mask->childList(true); + for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { + SPItem * mask_data = SP_ITEM(*iter); + if (! strcmp(mask_data->getId(), box_id.c_str())){ + continue; + } + Glib::ustring mask_data_id = (Glib::ustring)mask_data->getId(); + SPCSSAttr *css = sp_repr_css_attr_new(); + if(mask_data->getRepr()->attribute("style")) { + sp_repr_css_attr_add_from_string(css, mask_data->getRepr()->attribute("style")); + } + char const* filter = sp_repr_css_property (css, "filter", ""); + if(!filter ||! strcmp(filter, filter_uri.c_str())) { + if (filter_uri.empty()) { + sp_repr_css_set_property (css, "filter", NULL); + } else { + sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + mask_data->getRepr()->setAttribute("style", css_str.c_str()); + } else if(wrap){ + Glib::ustring g_data_id = mask_data_id + (Glib::ustring)"_container"; + Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); + container->setAttribute("id", g_data_id.c_str()); + mask->appendChildRepr(container); + container->setPosition(mask_data->getPosition()); + container->appendChild(mask_data->getRepr()); + Inkscape::GC::release(container); + SPCSSAttr *css = sp_repr_css_attr_new(); + if (filter_uri.empty()) { + sp_repr_css_set_property (css, "filter", NULL); + } else { + sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + container->setAttribute("style", css_str.c_str()); + } + } + } + if (background) { + if ((elemref = document->getObjectById(box_id))) { + if (strcmp(previous_background_style, background_style.param_getSVGValue())) { + elemref->getRepr()->setAttribute("style", background_style.param_getSVGValue()); + } + } else { + std::vector mask_list = mask->childList(true); + box = xml_doc->createElement("svg:path"); + box->setAttribute("id", box_id.c_str()); + box->setAttribute("style", background_style.param_getSVGValue()); + gchar * box_str = sp_svg_write_path( mask_box ); + box->setAttribute("d" , box_str); + g_free(box_str); + elemref = mask->appendChildRepr(box); + box->setPosition(mask_list.size()); + Inkscape::GC::release(box); + mask_list.clear(); + } } else { -// if ((elemref = document->getObjectById((Glib::ustring)mask->getId() + (Glib::ustring)"_transparentbox"))) { -// elemref->deleteObject(true); -// } - -// if ((elemref = document->getObjectById((Glib::ustring)mask->getId() + (Glib::ustring)"_inverse"))) { -// elemref->deleteObject(true); -// } - //mask->getRepr()->setAttribute("css", NULL); + if ((elemref = document->getObjectById(box_id))) { + elemref->deleteObject(true); + } } + previous_invert = invert; + previous_wrap = wrap; + previous_background_style = background_style.param_getSVGValue(); } void @@ -161,9 +229,6 @@ LPEPowerMask::newWidget() if ((*it)->widget_is_visible) { Parameter * param = *it; Gtk::Widget * widg = dynamic_cast(param->param_newWidget()); - if(param->param_key == "grid") { - widg = NULL; - } Glib::ustring * tip = param->param_getTooltip(); if (widg) { vbox->pack_start(*widg, true, true, 2); @@ -193,8 +258,10 @@ LPEPowerMask::doOnRemove (SPLPEItem const* /*lpeitem*/) SPMask *mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(!keep_paths) { if(mask) { - inverse.param_setValue(false); - setInverse(); + invert.param_setValue(false); + wrap.param_setValue(false); + background.param_setValue(false); + setMask(); } } } diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index 4038f207e..4869fbc53 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -8,8 +8,7 @@ */ #include "live_effects/effect.h" -#include "live_effects/parameter/hidden.h" -#include "live_effects/parameter/path.h" +#include "live_effects/parameter/text.h" #include "live_effects/lpegroupbbox.h" namespace Inkscape { @@ -23,11 +22,17 @@ public: virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual Gtk::Widget * newWidget(); void toggleMask(); - void setInverse(); + void setMask(); private: - BoolParam inverse; + BoolParam invert; + BoolParam wrap; + BoolParam background; + TextParam background_style; Geom::Path mask_box; bool hide_mask; + bool previous_invert; + bool previous_wrap; + const gchar * previous_background_style; }; } //namespace LivePathEffect -- cgit v1.2.3 From 9a581994db67e6f788a24ea20fa150ed7837c489 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 10 Jun 2017 16:27:16 +0200 Subject: Working on powermask --- src/live_effects/lpe-powerclip.cpp | 2 +- src/live_effects/lpe-powermask.cpp | 212 ++++++++++++++++++++----------------- src/live_effects/lpe-powermask.h | 3 - 3 files changed, 118 insertions(+), 99 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index ee1603855..d33e05176 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -40,7 +40,6 @@ LPEPowerClip::~LPEPowerClip() {} void LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ original_bbox(lpeitem); - const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path"); SPClipPath *clip_path = SP_ITEM(lpeitem)->clip_ref->getObject(); Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); @@ -55,6 +54,7 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ //clip_path *= sp_lpe_item->i2dt_affine(); if(clip_path) { is_clip = true; + const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path"); std::vector clip_path_list = clip_path->childList(true); for ( std::vector::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) { SPObject * clip_data = *iter; diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index a49d4c493..8b9d981c4 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -26,9 +26,9 @@ namespace LivePathEffect { LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), - wrap(_("Wrap filtered clip data"), _("Wrap filtered clip data"), "wrap", &wr, this, false), + wrap(_("Wrap clip data"), _("Wrap clip data allowing previous filters"), "wrap", &wr, this, false), background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), - background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:0.7;") + background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") { registerParameter(&invert); @@ -37,9 +37,6 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) registerParameter(&background_style); background_style.param_hide_canvas_text(); hide_mask = false; - previous_invert = !invert; - previous_wrap = !wrap; - previous_background_style = ""; } LPEPowerMask::~LPEPowerMask() {} @@ -78,110 +75,128 @@ LPEPowerMask::setMask(){ Inkscape::XML::Node *filter = NULL; SPDefs * defs = document->getDefs(); Glib::ustring mask_id = (Glib::ustring)mask->getId(); - Glib::ustring box_id = mask_id + (Glib::ustring)"_transparentbox"; + Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; Glib::ustring filter_id = mask_id + (Glib::ustring)"_inverse"; - Glib::ustring filter_uri = (Glib::ustring)"url(#" + mask_id + (Glib::ustring)"_inverse)"; - if (previous_invert != invert || previous_wrap != wrap) { - if (invert) { - if (!(elemref = document->getObjectById(filter_id))) { - filter = xml_doc->createElement("svg:filter"); - filter->setAttribute("id", filter_id.c_str()); - filter->setAttribute("color-interpolation-filters", "sRGB"); - filter->setAttribute("height", "100"); - filter->setAttribute("width", "100"); - filter->setAttribute("x", "-50"); - filter->setAttribute("y", "-50"); - Inkscape::XML::Node *primitive1 = xml_doc->createElement("svg:feColorMatrix"); - Glib::ustring primitive1_id = (mask_id + (Glib::ustring)"_primitive1").c_str(); - primitive1->setAttribute("id", primitive1_id.c_str()); - primitive1->setAttribute("values", "1"); - primitive1->setAttribute("type", "saturate"); - primitive1->setAttribute("result", "fbSourceGraphic"); - Inkscape::XML::Node *primitive2 = xml_doc->createElement("svg:feColorMatrix"); - Glib::ustring primitive2_id = (mask_id + (Glib::ustring)"_primitive2").c_str(); - primitive2->setAttribute("id", primitive2_id.c_str()); - primitive2->setAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 "); - primitive2->setAttribute("in", "fbSourceGraphic"); - elemref = defs->appendChildRepr(filter); - filter->appendChild(primitive1); - filter->appendChild(primitive2); - Inkscape::GC::release(filter); - Inkscape::GC::release(primitive1); - Inkscape::GC::release(primitive2); - } - } else { - if ((elemref = document->getObjectById(filter_id))) { - elemref->deleteObject(true); - } - filter_uri = ""; + Glib::ustring filter_label = (Glib::ustring)"filter" + mask_id; + Glib::ustring filter_uri = (Glib::ustring)"url(#" + filter_id + (Glib::ustring)")"; + if (!(elemref = document->getObjectById(filter_id))) { + filter = xml_doc->createElement("svg:filter"); + filter->setAttribute("id", filter_id.c_str()); + filter->setAttribute("inkscape:label", filter_label.c_str()); + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, "color-interpolation-filters", "sRGB"); + sp_repr_css_change(filter, css, "style"); + sp_repr_css_attr_unref(css); + filter->setAttribute("height", "100"); + filter->setAttribute("width", "100"); + filter->setAttribute("x", "-50"); + filter->setAttribute("y", "-50"); + Inkscape::XML::Node *primitive1 = xml_doc->createElement("svg:feColorMatrix"); + Glib::ustring primitive1_id = (mask_id + (Glib::ustring)"_primitive1").c_str(); + primitive1->setAttribute("id", primitive1_id.c_str()); + primitive1->setAttribute("values", "1"); + primitive1->setAttribute("type", "saturate"); + primitive1->setAttribute("result", "fbSourceGraphic"); + Inkscape::XML::Node *primitive2 = xml_doc->createElement("svg:feColorMatrix"); + Glib::ustring primitive2_id = (mask_id + (Glib::ustring)"_primitive2").c_str(); + primitive2->setAttribute("id", primitive2_id.c_str()); + primitive2->setAttribute("values", "-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 "); + primitive2->setAttribute("in", "fbSourceGraphic"); + elemref = defs->appendChildRepr(filter); + Inkscape::GC::release(filter); + filter->appendChild(primitive1); + Inkscape::GC::release(primitive1); + filter->appendChild(primitive2); + Inkscape::GC::release(primitive2); + } + if (background) { + if ((elemref = document->getObjectById(box_id))) { + elemref->deleteObject(true); } - std::vector mask_list = mask->childList(true); - for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { - SPItem * mask_data = SP_ITEM(*iter); - if (! strcmp(mask_data->getId(), box_id.c_str())){ - continue; - } - Glib::ustring mask_data_id = (Glib::ustring)mask_data->getId(); - SPCSSAttr *css = sp_repr_css_attr_new(); - if(mask_data->getRepr()->attribute("style")) { - sp_repr_css_attr_add_from_string(css, mask_data->getRepr()->attribute("style")); - } - char const* filter = sp_repr_css_property (css, "filter", ""); - if(!filter ||! strcmp(filter, filter_uri.c_str())) { - if (filter_uri.empty()) { - sp_repr_css_set_property (css, "filter", NULL); - } else { - sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + box = xml_doc->createElement("svg:path"); + box->setAttribute("id", box_id.c_str()); + box->setAttribute("style", background_style.param_getSVGValue()); + gchar * box_str = sp_svg_write_path( mask_box ); + box->setAttribute("d" , box_str); + g_free(box_str); + elemref = mask->appendChildRepr(box); + box->setPosition(1); + Inkscape::GC::release(box); + } + if(wrap){ + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + elemref->getRepr()->setPosition(-1); + } else { + Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); + container->setAttribute("id", g_data_id.c_str()); + mask->appendChildRepr(container); + std::vector mask_list = mask->childList(true); + container->setPosition(-1); + Inkscape::GC::release(container); + for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { + SPItem * mask_data = SP_ITEM(*iter); + Inkscape::XML::Node *mask_node = mask_data->getRepr(); + if (! strcmp(mask_data->getId(), box_id.c_str()) || + ! strcmp(mask_data->getId(), g_data_id.c_str())) + { + continue; } - Glib::ustring css_str; - sp_repr_css_write_string(css, css_str); - mask_data->getRepr()->setAttribute("style", css_str.c_str()); - } else if(wrap){ - Glib::ustring g_data_id = mask_data_id + (Glib::ustring)"_container"; - Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); - container->setAttribute("id", g_data_id.c_str()); - mask->appendChildRepr(container); - container->setPosition(mask_data->getPosition()); - container->appendChild(mask_data->getRepr()); - Inkscape::GC::release(container); SPCSSAttr *css = sp_repr_css_attr_new(); - if (filter_uri.empty()) { + if(mask_node->attribute("style")) { + sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); + } + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { sp_repr_css_set_property (css, "filter", NULL); - } else { - sp_repr_css_set_property (css, "filter", filter_uri.c_str()); } Glib::ustring css_str; sp_repr_css_write_string(css, css_str); - container->setAttribute("style", css_str.c_str()); - } - } - } - if (background) { - if ((elemref = document->getObjectById(box_id))) { - if (strcmp(previous_background_style, background_style.param_getSVGValue())) { - elemref->getRepr()->setAttribute("style", background_style.param_getSVGValue()); + mask_node->setAttribute("style", css_str.c_str()); + mask->getRepr()->removeChild(mask_node); + container->appendChild(mask_node); + Inkscape::GC::release(mask_node); } - } else { - std::vector mask_list = mask->childList(true); - box = xml_doc->createElement("svg:path"); - box->setAttribute("id", box_id.c_str()); - box->setAttribute("style", background_style.param_getSVGValue()); - gchar * box_str = sp_svg_write_path( mask_box ); - box->setAttribute("d" , box_str); - g_free(box_str); - elemref = mask->appendChildRepr(box); - box->setPosition(mask_list.size()); - Inkscape::GC::release(box); - mask_list.clear(); } } else { - if ((elemref = document->getObjectById(box_id))) { + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + Inkscape::XML::Node *mask_node = (*iter)->getRepr(); + elemref->getRepr()->removeChild(mask_node); + mask->getRepr()->appendChild(mask_node); + Inkscape::GC::release(mask_node); + } + sp_object_ref(elemref, 0 ); elemref->deleteObject(true); + sp_object_unref(elemref); + } + } + std::vector mask_list = mask->childList(true); + for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { + SPItem * mask_data = SP_ITEM(*iter); + Inkscape::XML::Node *mask_node = mask_data->getRepr(); + if (! strcmp(mask_data->getId(), box_id.c_str())){ + continue; + } + Glib::ustring mask_data_id = (Glib::ustring)mask_data->getId(); + SPCSSAttr *css = sp_repr_css_attr_new(); + if(mask_node->attribute("style")) { + sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); + } + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { + if (invert) { + sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + } else { + sp_repr_css_set_property (css, "filter", NULL); + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + mask_node->setAttribute("style", css_str.c_str()); } } - previous_invert = invert; - previous_wrap = wrap; - previous_background_style = background_style.param_getSVGValue(); } void @@ -262,6 +277,13 @@ LPEPowerMask::doOnRemove (SPLPEItem const* /*lpeitem*/) wrap.param_setValue(false); background.param_setValue(false); setMask(); + SPObject *elemref = NULL; + SPDocument * document = SP_ACTIVE_DOCUMENT; + Glib::ustring mask_id = (Glib::ustring)mask->getId(); + Glib::ustring filter_id = mask_id + (Glib::ustring)"_inverse"; + if ((elemref = document->getObjectById(filter_id))) { + elemref->deleteObject(true); + } } } } diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index 4869fbc53..1bd06e914 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -30,9 +30,6 @@ private: TextParam background_style; Geom::Path mask_box; bool hide_mask; - bool previous_invert; - bool previous_wrap; - const gchar * previous_background_style; }; } //namespace LivePathEffect -- cgit v1.2.3 From 2218ecdfec042a7ee333e9091790e2d1e398350f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 11 Jun 2017 20:58:59 +0200 Subject: Working on powermask --- src/live_effects/lpe-powermask.cpp | 23 +++++++++++++++++++---- src/live_effects/lpe-powermask.h | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 8b9d981c4..cc276c870 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -67,7 +67,12 @@ LPEPowerMask::setMask(){ SPMask *mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); SPObject *elemref = NULL; SPDocument * document = SP_ACTIVE_DOCUMENT; - if(!document || !mask) { + if (!document || !mask) { + return; + } + Inkscape::XML::Node *root = sp_lpe_item->document->getReprRoot(); + Inkscape::XML::Node *root_origin = document->getReprRoot(); + if (root_origin != root) { return; } Inkscape::XML::Document *xml_doc = document->getReprDoc(); @@ -109,10 +114,10 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } + if ((elemref = document->getObjectById(box_id))) { + elemref->deleteObject(true); + } if (background) { - if ((elemref = document->getObjectById(box_id))) { - elemref->deleteObject(true); - } box = xml_doc->createElement("svg:path"); box->setAttribute("id", box_id.c_str()); box->setAttribute("style", background_style.param_getSVGValue()); @@ -187,9 +192,12 @@ LPEPowerMask::setMask(){ } char const* filter = sp_repr_css_property (css, "filter", NULL); if(!filter || !strcmp(filter, filter_uri.c_str())) { + if (invert) { + std::cout << "qqqqqqqqqqqqqqqqqqqqqqqqq\n"; sp_repr_css_set_property (css, "filter", filter_uri.c_str()); } else { + std::cout << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaqq\n"; sp_repr_css_set_property (css, "filter", NULL); } Glib::ustring css_str; @@ -197,6 +205,13 @@ LPEPowerMask::setMask(){ mask_node->setAttribute("style", css_str.c_str()); } } + mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +void +LPEPowerMask::doEffect (SPCurve * curve) +{ + } void diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index 1bd06e914..1cc7a888b 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -19,6 +19,7 @@ public: LPEPowerMask(LivePathEffectObject *lpeobject); virtual ~LPEPowerMask(); virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual Gtk::Widget * newWidget(); void toggleMask(); -- cgit v1.2.3 From c5f2e56e9564c601d3210b8570d9a736a01e390b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Mon, 12 Jun 2017 20:09:40 +0200 Subject: adding last changes --- src/live_effects/lpe-powermask.cpp | 50 +++++++++++++++++++------------------- src/live_effects/lpe-powermask.h | 1 + 2 files changed, 26 insertions(+), 25 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index cc276c870..decfa842d 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -44,7 +44,6 @@ LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ original_bbox(lpeitem); - const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("mask"); SPMask *mask = SP_ITEM(lpeitem)->mask_ref->getObject(); Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); @@ -56,7 +55,6 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ mask_box.appendNew(bottomright); mask_box.appendNew(bottomleft); mask_box.close(); - //mask *= sp_lpe_item->i2dt_affine(); if(mask) { setMask(); } @@ -114,21 +112,7 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } - if ((elemref = document->getObjectById(box_id))) { - elemref->deleteObject(true); - } - if (background) { - box = xml_doc->createElement("svg:path"); - box->setAttribute("id", box_id.c_str()); - box->setAttribute("style", background_style.param_getSVGValue()); - gchar * box_str = sp_svg_write_path( mask_box ); - box->setAttribute("d" , box_str); - g_free(box_str); - elemref = mask->appendChildRepr(box); - box->setPosition(1); - Inkscape::GC::release(box); - } - if(wrap){ + if(wrap && is_visible){ Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; if((elemref = document->getObjectById(g_data_id))){ elemref->getRepr()->setPosition(-1); @@ -192,12 +176,9 @@ LPEPowerMask::setMask(){ } char const* filter = sp_repr_css_property (css, "filter", NULL); if(!filter || !strcmp(filter, filter_uri.c_str())) { - - if (invert) { - std::cout << "qqqqqqqqqqqqqqqqqqqqqqqqq\n"; + if (invert && is_visible) { sp_repr_css_set_property (css, "filter", filter_uri.c_str()); } else { - std::cout << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaqq\n"; sp_repr_css_set_property (css, "filter", NULL); } Glib::ustring css_str; @@ -205,13 +186,32 @@ LPEPowerMask::setMask(){ mask_node->setAttribute("style", css_str.c_str()); } } + if ((elemref = document->getObjectById(box_id))) { + elemref->deleteObject(true); + } + if (background && is_visible) { + box = xml_doc->createElement("svg:path"); + box->setAttribute("id", box_id.c_str()); + box->setAttribute("style", background_style.param_getSVGValue()); + gchar * box_str = sp_svg_write_path( mask_box ); + box->setAttribute("d" , box_str); + g_free(box_str); + elemref = mask->appendChildRepr(box); + box->setPosition(1); + Inkscape::GC::release(box); + } mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +void +LPEPowerMask::doOnVisibilityToggled(SPLPEItem const* lpeitem) +{ + doBeforeEffect(lpeitem); +} + void LPEPowerMask::doEffect (SPCurve * curve) { - } void @@ -283,11 +283,11 @@ LPEPowerMask::newWidget() } void -LPEPowerMask::doOnRemove (SPLPEItem const* /*lpeitem*/) +LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) { - SPMask *mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(!keep_paths) { - if(mask) { + SPMask *mask = lpeitem->mask_ref->getObject(); + if (mask) { invert.param_setValue(false); wrap.param_setValue(false); background.param_setValue(false); diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index 1cc7a888b..ce6166a72 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -22,6 +22,7 @@ public: virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual Gtk::Widget * newWidget(); + virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); void toggleMask(); void setMask(); private: -- cgit v1.2.3 From e1b08bb2e05c407f3e524e5d9f7b63ae88e15f6c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 24 Jun 2017 19:45:12 +0200 Subject: Working with powerclip and powermask --- src/live_effects/effect.cpp | 1 + src/live_effects/lpe-powerclip.cpp | 127 +++++++++++++++++++++++++------------ src/live_effects/lpe-powerclip.h | 6 +- src/live_effects/lpe-powermask.cpp | 49 ++++++++++++-- src/live_effects/lpe-powermask.h | 2 + 5 files changed, 140 insertions(+), 45 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index d555c277b..c817f5caa 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -981,6 +981,7 @@ Effect::resetDefaults(SPItem const* /*item*/) } } +//Activate handle your transform filling your effect on SPPath.cpp void Effect::transform_multiply(Geom::Affine const& postmul, bool set) { diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index d33e05176..b83c50ea0 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -24,12 +24,15 @@ LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) : Effect(lpeobject), inverse(_("Inverse clip"), _("Inverse clip"), "inverse", &wr, this, false), flatten(_("Flatten clip"), _("Flatten clip, see fill rule once convert to paths"), "flatten", &wr, this, false), + //loock(_("Lock clip"), _("Lock clip"), "lock", &wr, this, false), //tooltip empty to no show in default param set is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false) { registerParameter(&inverse); registerParameter(&flatten); registerParameter(&is_inverse); + //registerParameter(&lock); + //lock.param_setValue(false); is_clip = false; hide_clip = false; convert_shapes = false; @@ -52,7 +55,7 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ clip_box.appendNew(bottomleft); clip_box.close(); //clip_path *= sp_lpe_item->i2dt_affine(); - if(clip_path) { + if (clip_path) { is_clip = true; const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path"); std::vector clip_path_list = clip_path->childList(true); @@ -98,13 +101,13 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ Inkscape::GC::release(clip_path_node); clip_to_path->emitModified(SP_OBJECT_MODIFIED_CASCADE); } - if( inverse && isVisible()) { + if( is_inverse.param_getSVGValue() == (Glib::ustring)"false" && inverse && isVisible()) { if (clip_to_path) { addInverse(SP_ITEM(clip_to_path)); } else { addInverse(SP_ITEM(clip_data)); } - } else if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { + } else if(is_inverse.param_getSVGValue() == (Glib::ustring)"true" && !inverse && isVisible()) { if (clip_to_path) { removeInverse(SP_ITEM(clip_to_path)); } else { @@ -119,39 +122,38 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ void LPEPowerClip::addInverse (SPItem * clip_data){ - if (SP_IS_GROUP(clip_data)) { - std::vector item_list = sp_item_group_item_list(SP_GROUP(clip_data)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - SPItem *subitem = *iter; - addInverse(subitem); - } - } else if (SP_IS_PATH(clip_data)) { - SPCurve * c = NULL; - c = SP_SHAPE(clip_data)->getCurve(); - if (c) { - Geom::PathVector c_pv = c->get_pathvector(); - if(c_pv.size() > 1 && is_inverse.param_getSVGValue() == (Glib::ustring)"true") { - c_pv.pop_back(); - } - //TODO: this can be not correct but no better way - bool dir_a = Geom::path_direction(c_pv[0]); - bool dir_b = Geom::path_direction(clip_box); - if (dir_a == dir_b) { - clip_box = clip_box.reversed(); + if(is_inverse.param_getSVGValue() == (Glib::ustring)"false") { + if (SP_IS_GROUP(clip_data)) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(clip_data)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + SPItem *subitem = *iter; + addInverse(subitem); } - c_pv.push_back(clip_box); - c->set_pathvector(c_pv); - SP_SHAPE(clip_data)->setCurve(c, TRUE); - c->unref(); - is_inverse.param_setValue((Glib::ustring)"true", true); - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) { - if (tools_isactive(desktop, TOOLS_NODES)) { - Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); - SPItem * item = sel->singleItem(); - if (item != NULL) { - sel->remove(item); - sel->add(item); + } else if (SP_IS_PATH(clip_data)) { + SPCurve * c = NULL; + c = SP_SHAPE(clip_data)->getCurve(); + if (c) { + Geom::PathVector c_pv = c->get_pathvector(); + //TODO: this can be not correct but no better way + bool dir_a = Geom::path_direction(c_pv[0]); + bool dir_b = Geom::path_direction(clip_box); + if (dir_a == dir_b) { + clip_box = clip_box.reversed(); + } + c_pv.push_back(clip_box); + c->set_pathvector(c_pv); + SP_SHAPE(clip_data)->setCurve(c, TRUE); + c->unref(); + is_inverse.param_setValue((Glib::ustring)"true", true); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item != NULL) { + sel->remove(item); + sel->add(item); + } } } } @@ -159,6 +161,11 @@ LPEPowerClip::addInverse (SPItem * clip_data){ } } +void +LPEPowerClip::doEffect (SPCurve * curve) +{ +} + void LPEPowerClip::removeInverse (SPItem * clip_data){ if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { @@ -258,19 +265,18 @@ LPEPowerClip::newWidget() } } } - ++it; } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); Gtk::Button * toggle_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Toggle clip visibiliy")))); toggle_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::toggleClip)); - toggle_button->set_size_request(140,30); + toggle_button->set_size_request(180,30); vbox->pack_start(*hbox, true,true,2); hbox->pack_start(*toggle_button, false, false,2); Gtk::HBox * hbox2 = Gtk::manage(new Gtk::HBox(false,0)); Gtk::Button * topaths_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Convert clips to paths, undoable")))); topaths_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::convertShapes)); - topaths_button->set_size_request(200,30); + topaths_button->set_size_request(220,30); vbox->pack_start(*hbox2, true,true,2); hbox2->pack_start(*topaths_button, false, false,2); return dynamic_cast(vbox); @@ -288,7 +294,6 @@ LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/) SPObject * clip_data = *iter; if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { removeInverse(SP_ITEM(clip_data)); - is_inverse.param_setValue((Glib::ustring)"false"); } } } @@ -316,6 +321,50 @@ LPEPowerClip::doEffect_path(Geom::PathVector const & path_in){ return path_out; } +//void +//LPEPowerClip::transform_multiply(Geom::Affine const& postmul, bool set) +//{ +// SPDocument * doc = SP_ACTIVE_DOCUMENT; +// SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject(); +// if (is_clip && lock) { +// std::vector clip_path_list = clip_path->childList(true); +// Glib::ustring clip_id = (Glib::ustring)clip_path->getId(); +// Glib::ustring box_id = clip_id + (Glib::ustring)"_box"; +// for ( std::vector::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) { +// SPItem * clip_data = SP_ITEM(*iter); +// if(inverse && is_clip && lock) { +// removeInverse(clip_data); +// } +// if (lock) { +// clip_data->transform *= postmul; +//// if (!inverse) { +//// SPDesktop *desktop = SP_ACTIVE_DESKTOP; +//// if (desktop) { +//// if (tools_isactive(desktop, TOOLS_NODES)) { +//// Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); +//// SPItem * item = sel->singleItem(); +//// if (item != NULL) { +//// sel->remove(item); +//// sel->add(item); +//// } +//// } +//// } +//// } +// } +// if(inverse && is_clip && lock) { +// doBeforeEffect(sp_lpe_item); +// } +// } +// } +// //cycle through all parameters. Most parameters will not need transformation, but path and point params +// for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { +// Parameter * param = *it; +// param->param_transform_multiply(postmul, set); +// } +// toggleClip(); +// toggleClip(); +//} + void LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in) { diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index e70ec2c9c..adaa8b7a1 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -20,9 +20,11 @@ public: virtual ~LPEPowerClip(); virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); - //virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); + virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual Gtk::Widget * newWidget(); + //virtual void transform_multiply(Geom::Affine const& postmul, bool set); + void toggleClip(); void addInverse (SPItem * clip_data); void removeInverse (SPItem * clip_data); @@ -31,8 +33,10 @@ public: private: BoolParam inverse; BoolParam flatten; + // BoolParam lock; HiddenParam is_inverse; Geom::Path clip_box; + Geom::Affine base; bool is_clip; bool convert_shapes; bool hide_clip; diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index decfa842d..434ad6dd4 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -26,15 +26,18 @@ namespace LivePathEffect { LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), - wrap(_("Wrap clip data"), _("Wrap clip data allowing previous filters"), "wrap", &wr, this, false), + wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), + //lock(_("Lock mask"), _("Lock mask"), "lock", &wr, this, false), background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") { registerParameter(&invert); registerParameter(&wrap); + //registerParameter(&lock); registerParameter(&background); registerParameter(&background_style); + //lock.param_setValue(false); background_style.param_hide_canvas_text(); hide_mask = false; } @@ -190,15 +193,23 @@ LPEPowerMask::setMask(){ elemref->deleteObject(true); } if (background && is_visible) { - box = xml_doc->createElement("svg:path"); - box->setAttribute("id", box_id.c_str()); + bool exist = true; + if (!(elemref = document->getObjectById(box_id))) { + box = xml_doc->createElement("svg:path"); + box->setAttribute("id", box_id.c_str()); + exist = false; + } box->setAttribute("style", background_style.param_getSVGValue()); gchar * box_str = sp_svg_write_path( mask_box ); box->setAttribute("d" , box_str); g_free(box_str); - elemref = mask->appendChildRepr(box); + if (!exist) { + elemref = mask->appendChildRepr(box); + Inkscape::GC::release(box); + } box->setPosition(1); - Inkscape::GC::release(box); + } else if ((elemref = document->getObjectById(box_id))) { + elemref->deleteObject(true); } mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } @@ -235,6 +246,7 @@ LPEPowerMask::toggleMask() { Inkscape::DrawingItem *ai = mask->sp_mask_show( v->arenaitem->drawing(), v->arenaitem->key()); + bbox.unionWith(ai->geometricBounds()); v->arenaitem->setMask(ai); mask->sp_mask_set_bbox(v->arenaitem->key(), bbox); } @@ -244,6 +256,33 @@ LPEPowerMask::toggleMask() { } } +//void +//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set) +//{ +// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); +// if (mask_path && lock) { +// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); +// std::vector mask_path_list = mask_path->childList(true); +// Glib::ustring mask_id = (Glib::ustring)mask_path->getId(); +// Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; +// for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { +// SPObject * mask_data = *iter; +// if (! strcmp(mask_data->getId(), box_id.c_str())){ +// continue; +// } +// SP_ITEM(mask_data)->transform *= postmul.inverse(); +// } +// } +// //cycle through all parameters. Most parameters will not need transformation, but path and point params +// for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { +// Parameter * param = *it; +// param->param_transform_multiply(postmul, set); +// } +// sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); +//} + + + Gtk::Widget * LPEPowerMask::newWidget() { diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index ce6166a72..cd36b3b37 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -23,12 +23,14 @@ public: virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual Gtk::Widget * newWidget(); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); + //virtual void transform_multiply(Geom::Affine const& postmul, bool set); void toggleMask(); void setMask(); private: BoolParam invert; BoolParam wrap; BoolParam background; + //BoolParam lock; TextParam background_style; Geom::Path mask_box; bool hide_mask; -- cgit v1.2.3 From d4eac71f31f34723469e332791df919e1c64d7d3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 24 Jun 2017 21:50:49 +0200 Subject: Bug fixes --- src/live_effects/lpe-powerclip.cpp | 14 +++++++++----- src/live_effects/lpe-powerclip.h | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index b83c50ea0..2d0d4bb12 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -113,6 +113,8 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ } else { removeInverse(SP_ITEM(clip_data)); } + } else if (inverse && !is_visible && is_inverse.param_getSVGValue() == (Glib::ustring)"true"){ + removeInverse(SP_ITEM(clip_data)); } } } else { @@ -161,11 +163,6 @@ LPEPowerClip::addInverse (SPItem * clip_data){ } } -void -LPEPowerClip::doEffect (SPCurve * curve) -{ -} - void LPEPowerClip::removeInverse (SPItem * clip_data){ if(is_inverse.param_getSVGValue() == (Glib::ustring)"true") { @@ -321,6 +318,13 @@ LPEPowerClip::doEffect_path(Geom::PathVector const & path_in){ return path_out; } +void +LPEPowerClip::doOnVisibilityToggled(SPLPEItem const* lpeitem) +{ + doBeforeEffect(lpeitem); +} + + //void //LPEPowerClip::transform_multiply(Geom::Affine const& postmul, bool set) //{ diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index adaa8b7a1..ce46b560a 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -20,11 +20,10 @@ public: virtual ~LPEPowerClip(); virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); - virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual Gtk::Widget * newWidget(); //virtual void transform_multiply(Geom::Affine const& postmul, bool set); - + virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); void toggleClip(); void addInverse (SPItem * clip_data); void removeInverse (SPItem * clip_data); -- cgit v1.2.3