* Sketch Ellipse: Major radius and Minor radius boxes while drawing (#10279) The Ellipse tool showed no value boxes. After the centre it now shows Major radius, after the end of the major axis Minor radius; a typed value places the point at that size and becomes the ellipse's dimension, as for a circle's Diameter. sketch.draw.dimensioned takes major_radius and minor_radius for sketch.ellipse, so Dimension new shapes covers it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Sketch Ellipse: test the typed radii in the tool and in sketch.draw.dimensioned, and say so in the guide (#10279) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Sketch Ellipse: rustfmt the new engine test (#10279) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ pub fn dimension_roles(creator: &str) -> Option<&'static [&'static str]> {
|
||||
// A circle is dimensioned by its diameter unless a radius is given.
|
||||
"sketch.circle.center" | "sketch.circle.two_point" | "sketch.circle.three_point" => &["diameter", "radius"],
|
||||
"sketch.arc.center_point" => &["radius", "sweep"],
|
||||
"sketch.ellipse" => &["major_radius", "minor_radius"],
|
||||
"sketch.slot.center_to_center" | "sketch.slot.overall" | "sketch.slot.center_point" => &["length", "width"],
|
||||
"sketch.slot.arc_center" => &["radius", "sweep", "width"],
|
||||
"sketch.slot.arc_three_point" => &["width"],
|
||||
@@ -152,6 +153,9 @@ pub(super) fn draw(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
(c, "width" | "height") if c.starts_with("sketch.rectangle.") => (vec![curve(usize::from(role == "height"))?], "length"),
|
||||
(c, "radius" | "diameter") if c.starts_with("sketch.circle.") => (vec![curve(0)?], role),
|
||||
("sketch.arc.center_point", "radius" | "sweep") => (vec![curve(0)?], role),
|
||||
// `sketch.dimension` gives an ellipse its major radius as `major`, else its minor one.
|
||||
("sketch.ellipse", "major_radius") => (vec![curve(0)?], "major"),
|
||||
("sketch.ellipse", "minor_radius") => (vec![curve(0)?], "radius"),
|
||||
("sketch.slot.center_to_center" | "sketch.slot.center_point", "length") => (vec![curve(0)?], "length"),
|
||||
("sketch.slot.overall", "length") => (vec![curve(1)?, curve(3)?], "overall_length"),
|
||||
(c, "width") if c.starts_with("sketch.slot.") => (vec![curve(1)?], "diameter"),
|
||||
|
||||
@@ -355,6 +355,7 @@ fn sample(creator: &str) -> Option<Value> {
|
||||
"sketch.circle.two_point" => json!({"p0":[0,0],"p1":[10,0]}),
|
||||
"sketch.circle.three_point" => json!({"p0":[0,0],"p1":[10,0],"p2":[5,5]}),
|
||||
"sketch.arc.center_point" => json!({"center":[0,0],"start":[10,0],"end":[0,10]}),
|
||||
"sketch.ellipse" => json!({"center":[0,0],"major":[10,6],"minor_radius":4}),
|
||||
"sketch.slot.center_to_center" | "sketch.slot.overall" => json!({"p0":[2,3],"p1":[22,3],"width":4}),
|
||||
"sketch.slot.center_point" => json!({"center":[12,3],"end":[22,3],"width":4}),
|
||||
"sketch.slot.arc_center" => json!({"center":[0,0],"start":[20,0],"end":[0,20],"width":6}),
|
||||
@@ -450,6 +451,19 @@ fn as_drawn_keeps_typed_values_alternatives_and_leaves_out_determined_sizes() {
|
||||
assert_eq!(out["dimensions"].as_object().unwrap().keys().collect::<Vec<_>>(), ["width"]);
|
||||
}
|
||||
|
||||
/// An ellipse takes its major and minor radius (#10279): typed values drive it.
|
||||
#[test]
|
||||
fn an_ellipse_takes_a_typed_major_and_minor_radius() {
|
||||
let mut s = session();
|
||||
let out =
|
||||
draw(&mut s, "sketch.ellipse", json!({"center":[0,0],"major":[10,0],"minor_radius":4}), json!({"major_radius":"12 mm","minor_radius":5}));
|
||||
let mut placed: Vec<&String> = out["dimensions"].as_object().unwrap().keys().collect();
|
||||
placed.sort();
|
||||
assert_eq!(placed, ["major_radius", "minor_radius"]);
|
||||
close(measure(&s, |k| matches!(k, ConstraintKind::Distance { .. })), 12.0);
|
||||
close(measure(&s, |k| matches!(k, ConstraintKind::Radius { .. })), 5.0);
|
||||
}
|
||||
|
||||
/// Every `[x, y]` point of a sample moved by `(dx, dy)`; sizes and counts stay.
|
||||
fn shifted(v: &Value, dx: f64, dy: f64) -> Value {
|
||||
match v {
|
||||
|
||||
Reference in New Issue
Block a user