mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-26 10:21:00 +00:00
Port the sketch layer work from snaporca: offset chains, right-click, MCP verbs
Carries snaporca 971320e129, 6b049f0dc6, 4aae782029, 444d59f212, 74cf3d7e54 and the build guards from 597557a6e4. Parity re-verified after every hunk: 17 files identical, 8 diverging by their expected counts — DesignPanel.cpp still 32, DesignCanvas.cpp still 16, which is the proof each hunk landed on the right side rather than being copied over a real divergence. OFFSET OFFSETS THE CHAIN. Per-entity offsetting returned a closed rectangle as four parallel segments that no longer touch, so entities_to_wires gave four OPEN wires and nothing could be extruded. offset_entities now chains by shared endpoints and repairs each seam by mitering the neighbours to their intersection. Second bug, invisible to any single-entity test: +d meant "left of travel" for a line but "radius + d" for an arc regardless of sweep, so a slot outline offset with its straights going one way and its caps the other. The convention is now written on the declaration and pinned by a test. tests/libslic3r/test_sketchprofile.cpp is new and asserts the LOOP rather than coordinates — the property that decides whether a profile can be built, and the one the existing single-entity [SketchEdit] cases cannot see. Its include is catch2/catch_all.hpp here: this fork ships Catch2 v3 while snaporca is on v2, which is why the test files are a tolerated divergence. RIGHT-CLICK PICKS WHAT YOU POINTED AT, so a line's own verbs are offered instead of the empty-selection vocabulary; sk_delete stops sharing btn:delete with the feature tree; and an element's defining number (length / radius / diameter / angle / distance) can be typed, from the menu or from V. TWELVE MCP SKETCH VERBS. The socket had ~40 verbs and none touched a sketch, so the 2D layer could only be exercised by driving a GUI with synthetic clicks. sketch_describe reports each closed loop, the loops it encloses as voids, exact areas, and where a chain is still open; sketch_validate/sketch_heal are FreeCAD's ValidateSketch — find vertices that overlap within a tolerance but carry no coincidence, then weld them AND record the constraint, so a loop closed by floating-point luck becomes one closed by construction. scripts/mcp-sketch-smoke.py is the loop that asserts all of it. Kernel suite on this fork: all tests passed, 2677 assertions in 230 test cases. The GUI target links against the rebuilt deps image (the wxInspector blockage is gone) and the binary carries the new verbs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
df45edb13d
commit
5d7fc8c545
@@ -473,6 +473,20 @@ void DesignCanvas::set_sketch_construction(bool c)
|
||||
m_sketch_tool.set_construction(c);
|
||||
}
|
||||
|
||||
bool DesignCanvas::edit_sketch_selection_value()
|
||||
{
|
||||
const bool ok = m_sketch_tool.open_selection_dimension_editor();
|
||||
if (ok) request_repaint();
|
||||
return ok;
|
||||
}
|
||||
|
||||
int DesignCanvas::toggle_sketch_construction_selection()
|
||||
{
|
||||
const int n = m_sketch_tool.toggle_selection_construction();
|
||||
if (n > 0) request_repaint();
|
||||
return n;
|
||||
}
|
||||
|
||||
bool DesignCanvas::add_sketch_regions(
|
||||
const std::vector<std::vector<std::vector<Vec2d>>>& regions)
|
||||
{
|
||||
@@ -970,6 +984,12 @@ void DesignCanvas::set_on_context_menu(std::function<void(const wxPoint&)> cb)
|
||||
const bool terminated = m_sketch_tool.take_right_consumed();
|
||||
if (m_on_context_menu && !terminated && !inline_busy()
|
||||
&& std::max(std::abs(d.x), std::abs(d.y)) <= 8) {
|
||||
// The menu belongs to what you POINTED AT. Pick first, so a right-click on a line
|
||||
// offers that line's verbs instead of the empty-selection vocabulary. Selecting an
|
||||
// entity that is already selected is a no-op, so a multi-entity pick survives a
|
||||
// right-click on one of its members.
|
||||
if (m_canvas && m_sketch_tool.select_at_screen(*m_canvas, e.GetX(), e.GetY()))
|
||||
request_repaint();
|
||||
m_on_context_menu(m_canvas_widget->ClientToScreen(e.GetPosition()));
|
||||
return; // consumed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user