Extrude Two Sides: fix the side and missing value box of Distance 2 (#11203)
* Extrude: Two Sides keeps each distance on the side Direction gives it Distance 2 stays on the side Direction gives it, whatever the sign of Distance 1, and its value box shows on the canvas. Rebased onto main as one change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Two Sides extrude: keep older designs' sides by a marker, and the full profile search - A saved two-sided extrude is marked `second_follows_first` instead of having a literal negative distance rewritten: expressions such as `-width` keep the old sides when their parameters change, `-0 mm` keeps its span, and a feature's named inputs keep their values. - Live sketch drags and the restored model cache use the full profile search evaluation uses, so a sketch whose only closed boundary is projected keeps its profiles. - The canvas Distance 2 box stays while its text does not evaluate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Tests: give the extrude added on main the second_follows_first field Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
90d9c6488a
commit
9cdee588f2
13 files changed
+192
-23
No files matched your search
@@ -321,6 +321,12 @@ pub struct Extent {
|
||||
/// Through all bodies in the direction(s) instead of `distance`.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub through_all: bool,
|
||||
/// Two Sides as older builds read it: `distance2` goes the other way from wherever the
|
||||
/// first side went, so a negative entered distance sends it back along the normal. Saved
|
||||
/// designs from before entered distances kept their sides carry it, so they rebuild as
|
||||
/// they did whatever their expressions evaluate to; new and edited extrudes leave it off.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub second_follows_first: bool,
|
||||
/// Taper angle (expression; positive grows the profile).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[walk(angle = "Taper angle")]
|
||||
|
||||
+18
-5
@@ -6083,15 +6083,28 @@ fn from_profile_on_closed_path(segs: Vec<solidcore_record::Seg2>, path: &Plane,
|
||||
/// Where an extrude of distance `d` starts and ends along the sketch normal, before any start
|
||||
/// offset: one side, the other, both (symmetric), or a second distance on the other side.
|
||||
///
|
||||
/// A second distance (`distance2`) goes the other way from the first side, wherever that went:
|
||||
/// against the normal for `direction: negative` (#2700), and back along it when a negative
|
||||
/// distance or a To Object below the sketch sends the first side down.
|
||||
/// A second distance (`distance2`) goes the other way from the first side: against the normal,
|
||||
/// or along it for `direction: negative` (#2700). Entered distances keep those sides whatever
|
||||
/// their signs; a To Object below the sketch or a Through All that reaches down sends the first
|
||||
/// side down and the second back along the normal.
|
||||
pub(crate) fn extent_sides(vals: &BTreeMap<String, Value>, extent: &crate::Extent, d: f64, direction: crate::Direction) -> Result<(f64, f64)> {
|
||||
Ok(match (&extent.distance2, direction) {
|
||||
(Some(d2), _) => {
|
||||
let first = if direction == crate::Direction::Negative { -d } else { d };
|
||||
let negative = direction == crate::Direction::Negative;
|
||||
let first = if negative { -d } else { d };
|
||||
let d2 = val(vals, d2, Kind::Length)?;
|
||||
(if first < 0.0 { d2 } else { -d2 }, first)
|
||||
// An entered distance keeps its side whatever its sign: Direction fixes the sides,
|
||||
// and a sign only turns its own side over. A reach computed from the model (To
|
||||
// Object, Through All) has the sign of where the object is, so the other side
|
||||
// follows it.
|
||||
let second = if extent.second_follows_first || extent.to.is_some() || extent.through_all {
|
||||
if first < 0.0 { d2 } else { -d2 }
|
||||
} else if negative {
|
||||
d2
|
||||
} else {
|
||||
-d2
|
||||
};
|
||||
(second, first)
|
||||
}
|
||||
(None, crate::Direction::Positive) => (0.0, d),
|
||||
(None, crate::Direction::Negative) => (-d, 0.0),
|
||||
|
||||
@@ -1914,6 +1914,7 @@ mod tests {
|
||||
distance2: None,
|
||||
start_offset: None,
|
||||
through_all: false,
|
||||
second_follows_first: false,
|
||||
taper: Some("0 deg".into()),
|
||||
corner: Default::default(),
|
||||
to: Some(crate::FacePick(solidcore_record::Vec3::new(0.0, 0.0, 10.0))),
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
//! In a two-sided extrude (`distance2`) with entered distances, Direction fixes the sides and the
|
||||
//! sign of a distance only turns its own side over; `distance2` no longer follows the first
|
||||
//! side across the sketch plane. Older builds sent `distance2` to the other side of a negative
|
||||
//! first distance, so this step marks every saved two-sided extrude with entered distances
|
||||
//! `second_follows_first`, which keeps that reading. The distances themselves are left as they
|
||||
//! were, so an expression keeps the old sides whatever it evaluates to and a feature's named
|
||||
//! inputs keep their values for the expressions that use them. An extent that reaches to an
|
||||
//! object or through all already lets the second side follow the first, and a symmetric one has
|
||||
//! no second side. The last release asks for an update instead of opening a design that carries
|
||||
//! this change.
|
||||
use serde_json::Value;
|
||||
|
||||
pub fn step(v: &mut Value) -> crate::Result<()> {
|
||||
let Some(Value::Array(features)) = v.get_mut("features") else {
|
||||
return Ok(());
|
||||
};
|
||||
for feature in features {
|
||||
if !matches!(feature.get("type").and_then(Value::as_str), Some("extrude" | "surface_extrude")) {
|
||||
continue;
|
||||
}
|
||||
let Some(extent) = feature.get_mut("extent").and_then(Value::as_object_mut) else { continue };
|
||||
let plain = extent.get("distance2").is_some_and(|d| !d.is_null())
|
||||
&& extent.get("to").is_none_or(Value::is_null)
|
||||
&& !extent.get("through_all").and_then(Value::as_bool).unwrap_or(false)
|
||||
&& extent.get("direction").and_then(Value::as_str) != Some("symmetric");
|
||||
if plain {
|
||||
extent.insert("second_follows_first".into(), Value::Bool(true));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn saved_two_sided_extrudes_keep_their_sides_and_distances() {
|
||||
let mut v = json!({"features": [
|
||||
{"type": "extrude", "extent": {"distance": "-10 mm", "distance2": "5 mm"}},
|
||||
{"type": "extrude", "extent": {"distance": "-10 mm", "direction": "negative", "distance2": "5 mm"}},
|
||||
{"type": "extrude", "extent": {"distance": "-0 mm", "distance2": "5 mm"}},
|
||||
{"type": "extrude", "extent": {"distance": "-width", "distance2": "10 mm"}},
|
||||
{"type": "extrude", "extent": {"distance": "-10 mm"}},
|
||||
{"type": "extrude", "extent": {"distance": "-10 mm", "through_all": true, "distance2": "5 mm"}},
|
||||
{"type": "extrude", "extent": {"distance": "-10 mm", "to": [0.0, 0.0, 1.0], "distance2": "5 mm"}},
|
||||
{"type": "sketch"}
|
||||
]});
|
||||
let before = v.clone();
|
||||
super::step(&mut v).unwrap();
|
||||
let features = v["features"].as_array().unwrap();
|
||||
let marked: Vec<bool> = features.iter().map(|f| f["extent"]["second_follows_first"] == json!(true)).collect();
|
||||
assert_eq!(marked, [true, true, true, true, false, false, false, false]);
|
||||
for (f, b) in features.iter().zip(before["features"].as_array().unwrap()) {
|
||||
assert_eq!((&f["extent"]["distance"], &f["extent"]["direction"]), (&b["extent"]["distance"], &b["extent"]["direction"]));
|
||||
}
|
||||
let mut empty = json!({"name": "Untitled"});
|
||||
super::step(&mut empty).unwrap();
|
||||
assert_eq!(empty, json!({"name": "Untitled"}));
|
||||
}
|
||||
}
|
||||
@@ -463,6 +463,7 @@ mod tests {
|
||||
distance2: None,
|
||||
start_offset: None,
|
||||
through_all: false,
|
||||
second_follows_first: false,
|
||||
taper: None,
|
||||
corner: Default::default(),
|
||||
to: None,
|
||||
|
||||
@@ -106,6 +106,7 @@ pub(super) fn local_geometry(f: &Feature, components: &std::collections::HashMap
|
||||
distance2: _,
|
||||
start_offset: _,
|
||||
through_all,
|
||||
second_follows_first: _,
|
||||
taper: _,
|
||||
to,
|
||||
to_offset: _,
|
||||
|
||||
@@ -453,6 +453,7 @@ mod tests {
|
||||
distance2: None,
|
||||
start_offset: None,
|
||||
through_all: false,
|
||||
second_follows_first: false,
|
||||
taper: None,
|
||||
corner: Default::default(),
|
||||
to: None,
|
||||
@@ -637,6 +638,7 @@ mod tests {
|
||||
distance2: None,
|
||||
start_offset: None,
|
||||
through_all: false,
|
||||
second_follows_first: false,
|
||||
taper: None,
|
||||
corner: Default::default(),
|
||||
to: None,
|
||||
|
||||
@@ -39,6 +39,7 @@ fn plate_doc() -> (Document, u64) {
|
||||
distance2: None,
|
||||
start_offset: None,
|
||||
through_all: false,
|
||||
second_follows_first: false,
|
||||
taper: None,
|
||||
corner: Default::default(),
|
||||
to: None,
|
||||
@@ -345,6 +346,7 @@ fn box_fillet_cut_timeline() {
|
||||
distance2: None,
|
||||
start_offset: None,
|
||||
through_all: false,
|
||||
second_follows_first: false,
|
||||
taper: None,
|
||||
corner: Default::default(),
|
||||
to: None,
|
||||
@@ -1130,6 +1132,7 @@ fn an_extruded_ellipse_or_spline_is_one_wall_named_by_its_curve() {
|
||||
distance2: None,
|
||||
start_offset: None,
|
||||
through_all: false,
|
||||
second_follows_first: false,
|
||||
taper: None,
|
||||
corner: Default::default(),
|
||||
to: None,
|
||||
|
||||
@@ -200,7 +200,10 @@ fn a_second_distance_goes_the_other_way_from_the_first_side() {
|
||||
for (settings, lo, hi) in [
|
||||
(json!({"direction":"positive","distance":"10 mm","distance2":"4 mm"}), -4.0, 10.0),
|
||||
(json!({"direction":"negative","distance":"10 mm","distance2":"4 mm"}), -10.0, 4.0),
|
||||
(json!({"direction":"positive","distance":"-10 mm","distance2":"4 mm"}), -10.0, 4.0),
|
||||
// A sign only turns its own side over: Distance 2 stays where Direction puts it, so a
|
||||
// negative Distance 1 leaves the span between the two ends.
|
||||
(json!({"direction":"positive","distance":"-10 mm","distance2":"4 mm"}), -10.0, -4.0),
|
||||
(json!({"direction":"negative","distance":"-10 mm","distance2":"4 mm"}), 4.0, 10.0),
|
||||
] {
|
||||
let s = fixture(settings.clone());
|
||||
check(&s, lo, hi);
|
||||
@@ -249,3 +252,34 @@ fn an_older_reversed_two_sided_extrude_keeps_its_shape() {
|
||||
let FeatureKind::Extrude { extent, .. } = &s.doc.find_feature("Depth").unwrap().kind else { panic!("extrude") };
|
||||
assert_eq!(extent.direction, solidcraft_doc::Direction::Positive);
|
||||
}
|
||||
|
||||
/// Designs saved before entered distances kept their sides sent Distance 2 to the other side of
|
||||
/// a negative first distance. Opening one keeps that, for an expression too and after its
|
||||
/// parameter changes, and leaves the distance and its named input as they were.
|
||||
#[test]
|
||||
fn an_older_two_sided_extrude_with_a_negative_distance_keeps_its_sides() {
|
||||
let mut base = fixture(json!({"direction":"positive","distance":"10 mm","distance2":"10 mm"}));
|
||||
run(&mut base, "parameters.add", json!({"name":"width","expression":"20 mm"}));
|
||||
let mut saved: Value = serde_json::from_str(&base.doc.to_json()).unwrap();
|
||||
// As the last release saved it: the format before this build's pending changes.
|
||||
let version: u32 = saved["format"].as_str().unwrap().trim_start_matches("solidcraft/").parse().unwrap();
|
||||
saved["format"] = json!(format!("solidcraft/{}", version - 1));
|
||||
saved.as_object_mut().unwrap().remove("format_pending");
|
||||
for (distance, lo, hi) in [("-width", -20.0, 10.0), ("-0 mm", -10.0, 0.0), ("-10 mm", -10.0, 10.0)] {
|
||||
let mut file = saved.clone();
|
||||
for f in file["features"].as_array_mut().unwrap() {
|
||||
if f["type"] == "extrude" {
|
||||
f["extent"]["distance"] = json!(distance);
|
||||
}
|
||||
}
|
||||
let mut opened = Session::new(Document::from_json(&file.to_string()).unwrap());
|
||||
check(&opened, lo, hi);
|
||||
let FeatureKind::Extrude { extent, .. } = &opened.doc.find_feature("Depth").unwrap().kind else { panic!("extrude") };
|
||||
assert_eq!(extent.distance, distance);
|
||||
if distance == "-width" {
|
||||
run(&mut opened, "parameters.change", json!({"name":"width","expression":"15 mm"}));
|
||||
check(&opened, -15.0, 10.0);
|
||||
}
|
||||
check(&Session::new(Document::from_json(&opened.doc.to_json()).unwrap()), if distance == "-width" { -15.0 } else { lo }, hi);
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.key("E")
|
||||
.contract(&EXTRUDE_CONTRACT)
|
||||
.output(output_schema_for::<FeatureResult>)
|
||||
.params("distance: expr (or through_all: true); taper?: angle expr (positive: outward, so the far end is larger along the extrusion direction; negative: inward, so the far end is smaller); corner?: preserve_curvature|tangent|round (how a taper closes a sharp corner its offset opens: each wall continues as itself, a line's plane or an arc's cone, until it meets its neighbour; each continues straight along its end tangent; or an arc about the corner. Without it, each profile preserves curvature where every curve is a line or an arc and takes tangent where another curve has a corner, and the feature's warning says so; a corner rule given is kept, and refused where the kernel cannot build it); sketch?: id|name (default: active or last sketch); profiles?: all | [index] | [{curves: [ids]}] (the profile whose outer loop is made of exactly these curves, or pieces of them; found again on every recompute, so it follows parameter changes; islands inside are its holes; an error when no profile or several match) | [{point:[x,y]}] (index and point picks are stored by their curves when that finds the same profile; a pick on a drawn profile that reference geometry, such as the projected outline of the face the sketch is on, cuts into regions takes the whole drawn profile); exact_regions?: bool (each index or point pick is exactly the region it names, as the dialogs send); default: every drawn profile, except that a loop inside another is its hole and a loop inside that hole is material again; face?: [x,y,z] (extrude a planar body face instead of a sketch profile); faces?: [[x,y,z],…] (coplanar faces of one body); face_body?: name (whose face, where faces of several bodies meet at the point); direction?: positive|negative|symmetric (distance is total thickness, split evenly around the start plane); convention?: total_distance|legacy_per_side (how a symmetric distance is read; default total_distance, split evenly around the start plane; legacy_per_side: the distance on each side, as older symmetric extrudes keep); distance2?: expr (Two Sides: a second distance the other way from the first side, which may be through_all or to; with direction: negative the first side goes against the normal and distance2 along it); start_offset?: expr (along the sketch normal, also with direction: negative); to?: [x,y,z] (To Object: a face, vertex or point; to_offset?: expr past it); from?: [x,y,z] (From Object: start at that face or point); operation?: new|join|cut|intersect|auto (cut into a body, otherwise join existing solids; new in an empty component); touching?: separate|one_body (what a join makes of pieces that share no face: separate, the default, makes each piece that touches another only along an edge or at a point a body of its own and keeps pieces that touch nothing in one body; one_body keeps every piece in one body); targets?: [body] (Join from a face, or from a sketch on a body's face, defaults to that face's body; explicit targets or participants override); name?; body_name?; thin?: true (Thin: a wall along sketch curves instead of the profiles) with curves?: [curve ids] (open chains and closed loops, joined where they meet end to end; default: every drawn curve of the sketch), thickness: expr, side?: center|inside|outside|two_sides (a closed loop's inside is the area it encloses, an open chain's the side it bends toward, a straight line's the left of its first curve as drawn; default center), thickness2?: expr (two_sides: the thickness outside); corners are mitred, crossing walls are one"),
|
||||
.params("distance: expr (or through_all: true); taper?: angle expr (positive: outward, so the far end is larger along the extrusion direction; negative: inward, so the far end is smaller); corner?: preserve_curvature|tangent|round (how a taper closes a sharp corner its offset opens: each wall continues as itself, a line's plane or an arc's cone, until it meets its neighbour; each continues straight along its end tangent; or an arc about the corner. Without it, each profile preserves curvature where every curve is a line or an arc and takes tangent where another curve has a corner, and the feature's warning says so; a corner rule given is kept, and refused where the kernel cannot build it); sketch?: id|name (default: active or last sketch); profiles?: all | [index] | [{curves: [ids]}] (the profile whose outer loop is made of exactly these curves, or pieces of them; found again on every recompute, so it follows parameter changes; islands inside are its holes; an error when no profile or several match) | [{point:[x,y]}] (index and point picks are stored by their curves when that finds the same profile; a pick on a drawn profile that reference geometry, such as the projected outline of the face the sketch is on, cuts into regions takes the whole drawn profile); exact_regions?: bool (each index or point pick is exactly the region it names, as the dialogs send); default: every drawn profile, except that a loop inside another is its hole and a loop inside that hole is material again; face?: [x,y,z] (extrude a planar body face instead of a sketch profile); faces?: [[x,y,z],…] (coplanar faces of one body); face_body?: name (whose face, where faces of several bodies meet at the point); direction?: positive|negative|symmetric (distance is total thickness, split evenly around the start plane); convention?: total_distance|legacy_per_side (how a symmetric distance is read; default total_distance, split evenly around the start plane; legacy_per_side: the distance on each side, as older symmetric extrudes keep); distance2?: expr (Two Sides: a second distance on the side direction leaves free, the first side may be through_all or to; with direction: negative the first side goes against the normal and distance2 along it; a negative distance only turns its own side over); start_offset?: expr (along the sketch normal, also with direction: negative); to?: [x,y,z] (To Object: a face, vertex or point; to_offset?: expr past it); from?: [x,y,z] (From Object: start at that face or point); operation?: new|join|cut|intersect|auto (cut into a body, otherwise join existing solids; new in an empty component); touching?: separate|one_body (what a join makes of pieces that share no face: separate, the default, makes each piece that touches another only along an edge or at a point a body of its own and keeps pieces that touch nothing in one body; one_body keeps every piece in one body); targets?: [body] (Join from a face, or from a sketch on a body's face, defaults to that face's body; explicit targets or participants override); name?; body_name?; thin?: true (Thin: a wall along sketch curves instead of the profiles) with curves?: [curve ids] (open chains and closed loops, joined where they meet end to end; default: every drawn curve of the sketch), thickness: expr, side?: center|inside|outside|two_sides (a closed loop's inside is the area it encloses, an open chain's the side it bends toward, a straight line's the left of its first curve as drawn; default center), thickness2?: expr (two_sides: the thickness outside); corners are mitred, crossing walls are one"),
|
||||
CommandSpec::new("solid.revolve", "Revolve", revolve)
|
||||
.at("SOLID", "CREATE")
|
||||
.icon("revolve")
|
||||
@@ -1269,6 +1269,7 @@ pub(super) fn extent_param(s: &Session, p: &Value, cmd: &str) -> Result<Extent>
|
||||
distance2,
|
||||
start_offset,
|
||||
through_all,
|
||||
second_follows_first: false,
|
||||
taper,
|
||||
corner,
|
||||
to: p.get("to").and_then(vec3).map(FacePick),
|
||||
|
||||
@@ -113,9 +113,9 @@ pub struct ExtrudeParams {
|
||||
/// Which way to extrude. Default: positive.
|
||||
#[serde(default)]
|
||||
pub direction: Option<DirectionParam>,
|
||||
/// Two Sides: a second distance the other way from the first side, which may be
|
||||
/// `through_all` or `to`; with `direction: negative` the first side goes against the normal
|
||||
/// and `distance2` along it.
|
||||
/// Two Sides: a second distance on the side `direction` leaves free; the first side may be
|
||||
/// `through_all` or `to`. With `direction: negative` the first side goes against the normal
|
||||
/// and `distance2` along it. A negative distance only turns its own side over.
|
||||
#[serde(default)]
|
||||
pub distance2: Option<LengthExpr>,
|
||||
/// Start this far from the sketch plane, along its normal.
|
||||
|
||||
@@ -608,22 +608,25 @@ fn draw(app: &SolveApp, ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj,
|
||||
}
|
||||
// Two sides: the second distance gets its own arrow, the other way from the first side.
|
||||
if let (Kind::Extrude { direction: crate::dialogs::TWO_SIDES | crate::dialogs::TWO_SIDES_REVERSED, distance2, .. }, Some(n)) = (&mut d.kind, dir)
|
||||
&& let Some(l2) = crate::length_input::eval(&app.session.doc, distance2, ValueKind::Length).ok().filter(|v| v.is_finite())
|
||||
{
|
||||
drag_arrow(
|
||||
&app.session.doc,
|
||||
// Distance 2 stays on the side Direction gives it, whatever the sign of Distance 1. Only
|
||||
// a reach computed from the model (To Object, Through All) sends it the other way.
|
||||
let n2 = if sign < 0.0 { n } else { -n };
|
||||
let before = distance2.clone();
|
||||
// While its text does not evaluate (cleared, or a `-` typed first) there is no arrow,
|
||||
// but the box stays below the base so the typing can be finished there.
|
||||
let ts = crate::length_input::eval(&app.session.doc, distance2, ValueKind::Length).ok().filter(|v| v.is_finite()).and_then(|l2| {
|
||||
drag_arrow(&app.session.doc, ui, painter, proj, base, bs, n2, l2, true, egui::Id::unique("sc_manipulator2"), half_height, 0.0, distance2)
|
||||
});
|
||||
value_box_in(
|
||||
ui,
|
||||
painter,
|
||||
proj,
|
||||
base,
|
||||
bs,
|
||||
-(n * sign),
|
||||
l2,
|
||||
true,
|
||||
egui::Id::unique("sc_manipulator2"),
|
||||
half_height,
|
||||
0.0,
|
||||
(egui::Id::unique("sc_canvas_area2"), egui::Id::unique("sc_canvas_value2")),
|
||||
"Distance 2",
|
||||
distance2,
|
||||
(ts.unwrap_or(bs + vec2(16.0, 14.0)) + vec2(14.0, 8.0), egui::Align2::LEFT_TOP),
|
||||
*distance2 != before,
|
||||
false,
|
||||
box_place(app, proj),
|
||||
);
|
||||
}
|
||||
// A chamfer of two distances: Distance 2 gets its own arrow along the other face.
|
||||
|
||||
@@ -597,6 +597,49 @@ fn two_sides_with_all_shows_distance_2_and_reverse_swaps_the_sides() {
|
||||
assert_eq!(extent(&h), e);
|
||||
}
|
||||
|
||||
/// Two Sides with a negative Distance 1: its side turns over, but Distance 2 stays where Direction
|
||||
/// puts it, and has its own value box like Distance 1.
|
||||
#[test]
|
||||
fn two_sides_second_arrow_stays_put_when_the_first_distance_turns_negative() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.run("sketch.create", json!({"plane":"XY","name":"Disc"})).unwrap();
|
||||
h.app.run("sketch.circle.center", json!({"center":[10,10],"radius":2})).unwrap();
|
||||
h.app.run("sketch.finish", json!({})).unwrap();
|
||||
h.app.run("solid.extrude", json!({"sketch":"Disc","distance":"-5 mm","distance2":"3 mm","name":"Depth"})).unwrap();
|
||||
h.frames(4);
|
||||
open(&mut h);
|
||||
assert!(h.widget("Distance 2").is_some(), "Two Sides shows the second side's distance");
|
||||
let centre = h.at(&json!({"world":[10,10,0]})).unwrap()[1] as f32;
|
||||
let tips = || (crate::scenario::handle_at("arrow").unwrap().y - centre, crate::scenario::handle_at("arrow2").unwrap().y - centre);
|
||||
let (first, second) = tips();
|
||||
assert!(first > 0.0 && second > 0.0, "the first arrow turned below the sketch, the second stayed below it: {first} {second}");
|
||||
}
|
||||
|
||||
/// Distance 2's box in the view stays while its text does not evaluate, so a cleared box or a
|
||||
/// `-` typed first can be finished there.
|
||||
#[test]
|
||||
fn two_sides_second_value_box_stays_while_its_text_is_incomplete() {
|
||||
let mut h = Harness::new();
|
||||
h.app.home.open = false;
|
||||
h.app.run("sketch.create", json!({"plane":"XY","name":"Disc"})).unwrap();
|
||||
h.app.run("sketch.circle.center", json!({"center":[10,10],"radius":2})).unwrap();
|
||||
h.app.run("sketch.finish", json!({})).unwrap();
|
||||
h.app.run("solid.extrude", json!({"sketch":"Disc","distance":"5 mm","distance2":"3 mm","name":"Depth"})).unwrap();
|
||||
h.frames(4);
|
||||
open(&mut h);
|
||||
let area = || egui::Id::unique("sc_canvas_area2");
|
||||
assert!(h.ctx.memory(|m| m.area_rect(area())).is_some(), "Distance 2's box in the view");
|
||||
for text in ["-", ""] {
|
||||
let Some(crate::dialogs::Dialog { kind: crate::dialogs::Kind::Extrude { distance2, .. }, .. }) = &mut h.app.dialog else {
|
||||
panic!("extrude dialog")
|
||||
};
|
||||
*distance2 = text.into();
|
||||
h.frames(3);
|
||||
assert!(h.ctx.read_response(egui::Id::unique("sc_canvas_value2")).is_some(), "Distance 2's box went away at {text:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Without value boxes in the view (Preferences, #9479), nothing covers the model: the command
|
||||
/// window's Distance takes the keyboard instead, its text selected, and the arrow still drags it.
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user