A tool window for the rectangular sketch pattern (#799)

sketch.pattern.rectangular gets a tool window with both quantities and spacings and an optional direction, instead of a click flow with a fixed count.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
William DunnandClaude Opus 5 authored and GitHub committed 2026-10-13 14:54:48 -04:00
1 parent e540832626
commit 3ea8562c5e
9 files changed
+353 -30

No files matched your search

+9 -22
View File
@@ -361,7 +361,7 @@ fn mode(id: &str) -> Option<Mode> {
"sketch.circle.three_tangent" => Mode::Entities(3),
"sketch.constrainer" | "sketch.constraint.polygon" => Mode::Entities(0),
"sketch.centerline" => Mode::Entities(1),
"sketch.pattern.circular" | "sketch.pattern.rectangular" => Mode::EntitiesThen,
"sketch.pattern.circular" => Mode::EntitiesThen,
"sketch.project_to_surface" | "sketch.intersection_curve" | "sketch.spun_profile" => Mode::Steps,
_ => return None,
})
@@ -420,7 +420,6 @@ pub fn hint(id: &str) -> Option<String> {
"sketch.constraint.polygon" => "Polygon: click the lines of a closed chain; right-click to apply",
"sketch.centerline" => "Centerline: click lines",
"sketch.pattern.circular" => "Circular pattern: click entities, right-click, then click the centre",
"sketch.pattern.rectangular" => "Rectangular pattern: click entities, right-click, then click two points (direction and spacing)",
"sketch.project_to_surface" => "Project to surface: click curves of other sketches, right-click, then click the face",
"sketch.intersection_curve" => "Intersection curve: click two faces",
"sketch.spun_profile" => "Spun profile: click the body, then the axis line",
@@ -721,26 +720,14 @@ pub fn on_click(app: &mut SolveApp, tool: &mut Tool, proj: &Proj, pos: Pos2) {
// Stage 2 (after a right-click) is marked by a "|" pick.
if tool.picks.last().is_some_and(|x| x == "|") {
let ents: Vec<String> = tool.picks.iter().filter(|x| *x != "|").cloned().collect();
match cmd {
"sketch.pattern.circular" => {
if let Some(p) = at {
let _ = app.run(cmd, json!({"entities": ents, "center": arg(&p), "count": 6}));
tool.picks.clear();
}
}
_ => {
if let Some(p) = at {
tool.pts.push(p);
if tool.pts.len() >= 2 {
let d = tool.pts[1].0 - tool.pts[0].0;
if d.len() > 1e-9 {
let _ = app.run(cmd, json!({"entities": ents, "dir": xy(d), "count": 3, "spacing": d.len()}));
}
tool.picks.clear();
tool.pts.clear();
}
}
}
// `sketch.pattern.rectangular` left this flow for a tool window: its count was
// hard-coded to 3 here and the command's second count and spacing could not be
// reached at all. The circular pattern is the last command still on it.
if cmd == "sketch.pattern.circular"
&& let Some(p) = at
{
let _ = app.run(cmd, json!({"entities": ents, "center": arg(&p), "count": 6}));
tool.picks.clear();
}
return;
}