diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 38127a421d1f597e54338bccc248345506193aab..1e684b1ca386bfdca5e3fca4658997e75584d378 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -1474,7 +1474,7 @@ void Effect::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) { } -void Effect::adjustForNewPath() +void Effect::adjustForNewPath(bool removed) { _adjust_path = true; } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index e6501b7b99ba04cb2a2bc19aec0db513ca503c41..7c310ffd7d71362cddef1b8b86d80f0ed388e104 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -103,7 +103,7 @@ public: void update_satellites(); virtual void doOnException(SPLPEItem const *lpeitem); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); - virtual void adjustForNewPath(); + virtual void adjustForNewPath(bool removed = false); void writeParamsToSVG(); std::vector effect_get_satellites(bool force = true); virtual void acceptParamPath (SPPath const* param_path); @@ -162,6 +162,7 @@ public: bool keep_paths; // set this to false allow retain extra generated objects, see measure line LPE bool is_load; bool is_applied; + bool is_current = false; bool on_remove_all; bool refresh_widgets; bool finishiddle = false; diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 2d1e0d0a0490ddda0ec92e0a28c8e5ea3c820117..cf1498bf4d872c29207cf776ee5f1cb5c64c9638 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -29,7 +29,7 @@ #include namespace Inkscape::LivePathEffect { - +static std::vector > removedsatellites = {}; static const Util::EnumData FilletmethodData[] = { { FM_AUTO, N_("Auto"), "auto" }, { FM_ARC, N_("Force arc"), "arc" }, @@ -301,12 +301,27 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) nodesatellites_param.setCurrentZoom(current_zoom); //mandatory call nodesatellites_param.setEffectType(effectType()); - Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(pathvector_before_effect); NodeSatellites nodesatellites = nodesatellites_param.data(); - if (nodesatellites.empty()) { + if (lpeItem && nodesatellites.empty()) { doOnApply(lpeItem); // dont want _impl to not update versioning nodesatellites = nodesatellites_param.data(); } + bool updated = false; + if (!removedsatellites.empty()) { + Geom::PathVector base = pathvector_before_effect; + for (auto ns : removedsatellites) { + for (size_t i = 0; i < ns.second.size(); ++i) { + nodesatellites.push_back(ns.second[i]); + base.push_back(ns.first[i]); + } + } + _pathvector_nodesatellites->setPathVector(base); + _pathvector_nodesatellites->setNodeSatellites(nodesatellites); + removedsatellites.clear(); + _adjust_path = true; + updated = true; + } + Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(pathvector_before_effect); for (size_t i = 0; i < nodesatellites.size(); ++i) { for (size_t j = 0; j < nodesatellites[i].size(); ++j) { if (pathv.size() <= i || j >= count_path_curves(pathv[i])) { @@ -341,7 +356,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) if (!_pathvector_nodesatellites) { _pathvector_nodesatellites = new PathVectorNodeSatellites(); } - if (is_load || _adjust_path) { + if (_adjust_path) { double power = radius; if (!flexible) { power = Inkscape::Util::Quantity::convert(power, unit.get_abbreviation(), "px") / getSPDoc()->getDocumentScale()[Geom::X]; @@ -376,8 +391,11 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) } void -LPEFilletChamfer::adjustForNewPath() { - _adjust_path = true; +LPEFilletChamfer::adjustForNewPath(bool removed) { + _adjust_path = !removed; + if(removed) { + removedsatellites.emplace_back(pathvector_before_effect, nodesatellites_param.data()); + } } void diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h index 957713693e317b0dd88c2ae9756187f58e1241ac..0c9d303abdf6568668aa876d1927b6b39d335d25 100644 --- a/src/live_effects/lpe-fillet-chamfer.h +++ b/src/live_effects/lpe-fillet-chamfer.h @@ -38,7 +38,7 @@ public: Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override; void doOnApply(SPLPEItem const *lpeItem) override; Gtk::Widget *newWidget() override; - void adjustForNewPath() override; + void adjustForNewPath(bool removed = false) override; Geom::Ray getRay(Geom::Point start, Geom::Point end, Geom::Curve *curve, bool reverse); void addChamferSteps(Geom::Path &tmp_path, Geom::Path path_chamfer, Geom::Point end_arc_point, size_t steps); void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec) override; diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index a41583c7f470677d58caa447a1dee0bf201a676b..cebbe8e79e8d8b55118cda23c4199585da0241d1 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -270,7 +270,7 @@ void LPEPowerStroke::doOnRemove(SPLPEItem const* lpeitem) } void -LPEPowerStroke::adjustForNewPath() +LPEPowerStroke::adjustForNewPath(bool removed) { _adjust_path = true; } diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h index 95c9ec79fe39bf308693a4a6057104d65f5d4dc5..979b0556e1beaa3ef1849507a6c2e33fe2da69fc 100644 --- a/src/live_effects/lpe-powerstroke.h +++ b/src/live_effects/lpe-powerstroke.h @@ -47,8 +47,7 @@ public: void doAfterEffect(SPLPEItem const *lpeitem, SPCurve *curve) override; void transform_multiply(Geom::Affine const &postmul, bool set) override; void applyStyle(SPLPEItem *lpeitem); - // methods called by path-manipulator upon edits - void adjustForNewPath() override; + void adjustForNewPath(bool removed = false) override; PowerStrokePointArrayParam offset_points; BoolParam not_jump; diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 20f7b9756be9dd2407721f762bc39b897d364289..6082e62c13bf947dc1943a3ad16517b1d36d2ff1 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -14,6 +14,7 @@ #include <2geom/bezier-utils.h> #include <2geom/path-sink.h> #include <2geom/point.h> +#include #include #include @@ -25,7 +26,6 @@ #include "helper/geom.h" #include "live_effects/lpeobject.h" -#include "live_effects/lpe-powerstroke.h" #include "live_effects/lpe-bspline.h" #include "live_effects/parameter/path.h" @@ -1465,7 +1465,13 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) ++i; } } + auto path = cast(_path); if (pathv.empty()) { + if (alert_LPE && path) { + for (auto lpe : path->getPathEffects()) { // first notify erased elements to on writeXML update remaining + lpe->adjustForNewPath(true); + } + } return; } @@ -1473,16 +1479,9 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) return; } _spcurve = SPCurve(pathv); - if (alert_LPE) { - /// \todo note that _path can be an Inkscape::LivePathEffect::Effect* too, kind of confusing, rework member naming? - auto path = cast(_path); - if (path && path->hasPathEffect()) { - Inkscape::LivePathEffect::Effect *this_effect = - path->getFirstPathEffectOfType(Inkscape::LivePathEffect::POWERSTROKE); - LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast(this_effect); - if (lpe_pwr) { - lpe_pwr->adjustForNewPath(); - } + if (alert_LPE && path) { + for (auto lpe : path->getPathEffects()) { // notify created elements outside multipath manipulator + lpe->adjustForNewPath(false); } } if (_live_outline) {