Repository navigation
feat: edit nodes of imported vector paths - #557
Conversation
1ba5a63 to
93d191a
Compare
|
Rebased onto current main, which conflicted again after #552 (only CHANGELOG.md; both entries kept). That replaced your 'Merge branch main into pr-557' commit with a linear history. Everything from it is in main, so nothing is lost. Sorry for the churn. |
|
I went over this again against the architecture and added three small commits on top (no force-push from here on):
Each has tests. The bounding box question in the description is still open. |
DocEditor.node_edit moves, deletes and inserts nodes, turns segments into curves or lines and moves Bezier handles on the boundaries of an imported workpiece, through raygeo's node editing operations. The result goes to the workpiece's edited boundaries like segment deletion, and every edit is its own undo step. Sketch workpieces are left alone. Refs barebaric#521
Selecting a segment in the vector edit mode now shows the nodes of its contour and the handles of selected Beziers. Nodes and handles can be dragged with a live preview and are committed on release as one undo step. Delete removes the selected node (or the selected segments, as before), I inserts a node where the pointer is on a segment, and C turns the selected segments into curves or lines. Hit testing uses a per-axis tolerance, so it works on non-square workpieces. Refs barebaric#521
The node edit command only refused to merge the next command into itself, so a node edit right after a segment deletion was still merged into that deletion. ChangePropertyCommand now takes a coalesce flag that is checked on both sides, replacing the private subclass. Refs barebaric#521
The canvas carried a list of the workpiece's node edit keys, and also sent Ctrl+C and Ctrl+I to the edit mode, so copy toggled a curve there. The canvas now offers every key without the primary modifier to the edit context and leaves shortcuts to the accelerators. Refs barebaric#521
Inserting or deleting a node shifts the command indices, so the kept segment selection pointed at other segments afterwards. Segment deletion now goes through the same re-snapshot as node edits instead of its own copy, and the key handler is split into small helpers. Refs barebaric#521
Add the node editing description of the vector edit mode to the Canvas Tools page in every translated docs directory. Refs barebaric#521
340618a to
b854ea2
Compare
edited_boundaries_command() in doceditor/boundaries.py replaces the four copies of the ChangePropertyCommand recipe in edit_cmd, path_cleanup_cmd and node_edit_cmd. It opts out of coalescing, so two quick segment or contour deletions no longer merge into one undo step, matching node edits. Bumps raygeo to 1.67.0 for Geometry.contour_info(): the seam of a closed contour is one node in the node operations, but the edit overlay drew it twice, once per command index, and hit testing always picked the later one. visible_nodes now shows the seam node once at its Move index, and visible_handles shows the handles of both segments meeting there. The node editing helpers also move from canvas2d/elements/ to canvas2d/, since they are not CanvasElements.
|
I pushed 9cf1b05 ("refactor(doceditor): one undoable boundaries command, single seam node") directly to this branch — it folds the review follow-ups into the PR:
Verification: |
|
Tested manually and everything seems to work. Thank you for the PR! |
All parts are in. It uses the new
Geometrynode operations from raygeo#58, released in raygeo 1.64.0, which main already pins; CI is green.Implements #521, option B as agreed: node editing in the existing vector edit mode, without the solver.
DocEditor.node_editcovers move / delete / insert node, line ↔ curve and moving Bézier handles. It runs on the workpiece's boundaries through raygeo#58 and writes_edited_boundarieslikedelete_segments, so traced bitmaps work too.Deleteremoves the selected node (or the selected segments, as today).Iinserts a node where the pointer is on a segment.Ctoggles the selected segments between line and curve.Checked in the running app (headless), driving the real
handle_edit_*methods on an imported 40×20 mm rectangle: select a segment (its contour's nodes appear), drag a node (live preview, one undo step),Iinserts a node at the pointer,Cmakes a curve, drag its handle, andDeleteremoves the node. Four undos bring back the original path exactly, and the edit mode stays active throughout. Hit testing now uses a per-axis tolerance, so it also works on non-square workpieces (the old segment hit test used the X scale only).One question: a node dragged outside the workpiece's original bounding box goes outside the 0..1 boundary frame. The toolpath is right, but the canvas may clip that part, because nothing re-fits the bounding box after an edit. That is the same as segment deletion today. Should node edits re-normalise the boundaries (and compensate the matrix, like split does), or do you prefer to keep the frame fixed?