* claim: #3278 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * 2-point circle takes a typed diameter (#3278) After its first point the 2-point circle tool showed no value box, so the circle could only be sized with the cursor. It now shows a Diameter box, like the centre circle: the typed value puts the second point that far along the cursor's direction, and Enter draws the circle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Phanoob <phanoob@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,8 @@ pub fn boxes_for(cmd: &str, n: usize) -> Vec<DimBox> {
|
||||
("sketch.rectangle.two_point" | "sketch.rectangle.center", 1) => vec![b("Width", Length), b("Height", Length)],
|
||||
("sketch.rectangle.rounded", 1) => vec![b("Width", Length), b("Height", Length), b("Radius", Length)],
|
||||
("sketch.circle.center", 1) => vec![b("Diameter", Length)],
|
||||
// The two points are a diameter's ends (#3278).
|
||||
("sketch.circle.two_point", 1) => vec![b("Diameter", Length)],
|
||||
("sketch.arc.center_point", 1) => vec![b("Radius", Length)],
|
||||
("sketch.arc.center_point", 2) => vec![b("Sweep", Angle)],
|
||||
("sketch.polygon.inscribed" | "sketch.polygon.circumscribed", 1) => vec![b("Radius", Length), b("Sides", Unitless)],
|
||||
@@ -85,6 +87,7 @@ pub fn effective(app: &SolveApp, t: &Tool, h: Vec2) -> Vec2 {
|
||||
Vec2::new(a.x + lk("Width").map_or(d.x, |w| w * 0.5 * sign(d.x)), a.y + lk("Height").map_or(d.y, |hh| hh * 0.5 * sign(d.y)))
|
||||
}
|
||||
("sketch.circle.center", 1) => a + dir_or_x(h - a) * lk("Diameter").map_or((h - a).len(), |d| d * 0.5),
|
||||
("sketch.circle.two_point", 1) => a + dir_or_x(h - a) * lk("Diameter").unwrap_or((h - a).len()),
|
||||
("sketch.arc.center_point", 1) => a + dir_or_x(h - a) * lk("Radius").unwrap_or((h - a).len()),
|
||||
("sketch.arc.center_point", 2) => {
|
||||
let c = t.pts.first().map(|p| p.0).unwrap_or(a);
|
||||
@@ -216,6 +219,7 @@ fn live(app: &SolveApp, t: &Tool, e: Vec2, px: f64) -> Vec<(f64, Vec2)> {
|
||||
vec![(2.0 * d.x.abs(), Vec2::new(a.x, a.y - d.y - sy * off)), (2.0 * d.y.abs(), Vec2::new(a.x + d.x + sx * 2.0 * off, a.y))]
|
||||
}
|
||||
("sketch.circle.center", 1) => vec![(2.0 * (e - a).len(), (a + e) * 0.5 + dir_or_x(e - a).perp() * off)],
|
||||
("sketch.circle.two_point", 1) => vec![((e - a).len(), (a + e) * 0.5 + dir_or_x(e - a).perp() * off)],
|
||||
("sketch.arc.center_point", 1) | ("sketch.polygon.inscribed" | "sketch.polygon.circumscribed", 1) => {
|
||||
vec![((e - a).len(), (a + e) * 0.5), (6.0, a + (e - a) * 0.5 + (e - a).perp() * 0.3)]
|
||||
}
|
||||
|
||||
@@ -154,6 +154,24 @@ fn clicking_a_parameter_suggestion_fills_the_length_box() {
|
||||
assert!(length.is_some_and(|l| (l - 24.0).abs() < 1e-6), "{length:?}");
|
||||
}
|
||||
|
||||
/// #3278: after the 2-point circle's first point, a Diameter box takes the keyboard; the typed
|
||||
/// diameter sets the second point along the cursor's direction, and Enter draws that circle.
|
||||
#[test]
|
||||
fn two_point_circle_takes_a_typed_diameter() {
|
||||
let mut h = drawing("sketch.circle.two_point");
|
||||
assert_eq!(h.app.tool.as_ref().unwrap().dims.iter().map(|b| b.label).collect::<Vec<_>>(), ["Diameter"]);
|
||||
type_value(&mut h, "30");
|
||||
h.step(&json!({"key": "Enter"})).unwrap();
|
||||
let state = h.app.session.world_state();
|
||||
let sk = &state.sketch(h.app.session.active_sketch.unwrap()).unwrap().sketch;
|
||||
assert_eq!(sk.curves.len(), 1, "{:?}", h.app.status);
|
||||
assert!(sk.radius(0).is_some_and(|r| (r - 15.0).abs() < 1e-6), "{:?}", sk.radius(0));
|
||||
let c = sk.center(0).unwrap();
|
||||
// From the first point (the origin) toward the cursor at (20, 10).
|
||||
let dir = solidcraft_engine::geom::Vec2::new(20.0, 10.0).normalized().unwrap();
|
||||
assert!((c - dir * 15.0).len() < 1e-6, "{c:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inch_live_lengths_use_design_units_and_typed_four_digits_commit_in_inches() {
|
||||
let mut h = Harness::new();
|
||||
|
||||
Reference in New Issue
Block a user