From 28b657ca12294e9683edc7c6b627df6ab4865041 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 30 Mar 2024 09:59:05 +0100 Subject: [PATCH] [Corners LPE 5] Retain on joins --- src/path-chemistry.cpp | 4 +++ src/ui/dialog/inkscape-preferences.cpp | 4 +++ src/ui/dialog/inkscape-preferences.h | 1 + src/ui/tool/multi-path-manipulator.cpp | 44 +++++++++++++++++++++++--- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 0da6d5c434..cba72702ab 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -28,6 +28,7 @@ #include "text-editing.h" #include "display/curve.h" +#include "live_effects/effect.h" #include "object/box3d.h" #include "object/object-set.h" @@ -152,6 +153,9 @@ void ObjectSet::combine(bool skip_undo, bool silent) if (item->getRepr()->parent() == parent) { position--; } + for (auto lpe : path->getPathEffects()) { // notify deleted elements + lpe->adjustForNewPath(); + } // delete the object for real, so that its clones can take appropriate action item->deleteObject(); } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index f9f276dd29..555de02290 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -2891,6 +2891,10 @@ void InkscapePreferences::initPageBehavior() _lpe_copy_mirroricons.init ( _("Add advanced tiling options"), "/live_effects/copy/mirroricons", true); // text label _page_lpe.add_line( true, "", _lpe_copy_mirroricons, "", _("Enables using 16 advanced mirror options between the copies (so there can be copies that are mirrored differently between the rows and the columns) for Tiling LPE")); // tooltip + _page_lpe.add_group_header( _("Corners")); + _lpe_keep_corners_join.init ( _("Keep on joins"), "/tools/nodes/keepcornersjoin", true); // text label + _page_lpe.add_line( true, "", _lpe_keep_corners_join, "", + _("Allow corners live path effect preserve always on join with diferent items")); // tooltip this->AddPage(_page_lpe, _("Live Path Effects (LPE)"), iter_behavior, PREFS_PAGE_BEHAVIOR_LPE); } diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index f16b2a294d..ff61a639a8 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -411,6 +411,7 @@ protected: UI::Widget::PrefCheckButton _cleanup_swatches; UI::Widget::PrefCheckButton _lpe_copy_mirroricons; + UI::Widget::PrefCheckButton _lpe_keep_corners_join; UI::Widget::PrefCheckButton _lpe_show_experimental; UI::Widget::PrefSpinButton _importexport_export_res; diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index c4d7938f09..aac6073450 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -84,6 +84,32 @@ void find_join_iterators(ControlPointSelection &sel, IterPairList &pairs) } } + +// force corners LPE keep when join with non corners path +// anyway not fix bsplie or spiro, mainy for this reason both require a tool based specialiced original-d +// but power stroke or others can benefit also (but in a moment we need to define a rule +// of preferences if both paths have different LPE +// for the moment I keep simple just for corners LPE +bool fix_corners(IterPair &join, std::map> mmap, bool keep_corners_join) +{ + if (keep_corners_join) { + keep_corners_join = false; + for (auto & i : mmap) { + if (join.second == (i.second.get())->extremeNode(join.second, true, true, true)) { + if (auto path = cast((i.second.get())->item())) { + if(path->hasPathEffectOfType(Inkscape::LivePathEffect::FILLET_CHAMFER)){ + std::swap(join.first, join.second); + return true; + } + } + } + + } + } + return false; +} + + /** After this function, first should be at the end of path and second at the beginning. * @returns True if the nodes are in the same subpath */ bool prepare_join(IterPair &join_iters) @@ -375,9 +401,11 @@ void MultiPathManipulator::joinNodes() preserve_pos = NodeList::get_iterator(mouseover_node); } find_join_iterators(_selection, joins); - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool keep_corners_join = prefs->getBool("/tools/nodes/keepcornersjoin", true); for (auto & join : joins) { - bool same_path = prepare_join(join); + bool same_path = prepare_join(join, _mmap, keep_corners_join); + bool corners_fix = same_path ? false : fix_corners(join, _mmap, keep_corners_join); NodeList &sp_first = NodeList::get(join.first); NodeList &sp_second = NodeList::get(join.second); join.first->setType(NODE_CUSP, false); @@ -413,6 +441,9 @@ void MultiPathManipulator::joinNodes() } else { sp_first.splice(sp_first.end(), sp_second); sp_second.kill(); + if (corners_fix) { + sp_first.reverse(); + } } _selection.insert(join.first.ptr()); } @@ -449,9 +480,11 @@ void MultiPathManipulator::joinSegments() if (_selection.empty()) return; IterPairList joins; find_join_iterators(_selection, joins); - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool keep_corners_join = prefs->getBool("/tools/nodes/keepcornersjoin", true); for (auto & join : joins) { - bool same_path = prepare_join(join); + bool same_path = prepare_join(join, _mmap, keep_corners_join); + bool corners_fix = same_path ? false : fix_corners(join, _mmap, keep_corners_join); NodeList &sp_first = NodeList::get(join.first); NodeList &sp_second = NodeList::get(join.second); join.first->setType(NODE_CUSP, false); @@ -461,6 +494,9 @@ void MultiPathManipulator::joinSegments() } else { sp_first.splice(sp_first.end(), sp_second); sp_second.kill(); + if (corners_fix) { + sp_first.reverse(); + } } } -- GitLab