Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Hem: the direction arrow points the way the hem builds (#4794) (#4836)

raykholo4c8ae5d07858
diff --git a/crates/ui-egui/src/dialogs_sheet.rs b/crates/ui-egui/src/dialogs_sheet.rs
index c32e9fb51a..635cfb6588 100644
--- a/crates/ui-egui/src/dialogs_sheet.rs
+++ b/crates/ui-egui/src/dialogs_sheet.rs
@@ -716,11 +716,12 @@ pub fn for_feature(app: &SolveApp, kind: &FeatureKind) -> Option<(Kind, Vec<SelI
// ---- view ----
/// The direction an edge flange or hem grows from its first edge: out of the sheet's larger
-/// neighbouring face (flipped with Flip).
+/// neighbouring face for a flange, toward it for a hem (flipped with Flip).
pub fn arrow(app: &SolveApp, d: &Dialog) -> Option<Vec3> {
let Kind::Sheet(k) = &d.kind else { return None };
let flip = match k {
- Sm::Flange { ty: 1, flip, .. } | Sm::Hem { flip, .. } => *flip,
+ Sm::Flange { ty: 1, flip, .. } => *flip,
+ Sm::Hem { flip, .. } => !flip,
_ => return None,
};
let Sel::Edge { body, index, point } = d.inputs.first()?.items.first()? else { return None };
diff --git a/crates/ui-egui/src/dialogs_sheet_tests.rs b/crates/ui-egui/src/dialogs_sheet_tests.rs
index 2f6bdd8982..94f1ed43f1 100644
--- a/crates/ui-egui/src/dialogs_sheet_tests.rs
+++ b/crates/ui-egui/src/dialogs_sheet_tests.rs
@@ -69,6 +69,33 @@ fn flange_follows_the_picks() {
}
}
+#[test]
+fn hem_arrow_points_to_the_side_the_hem_builds_on() {
+ for mode in [crate::shell::LayoutMode::Floating, crate::shell::LayoutMode::Docked] {
+ for z in [0.0, 2.5] {
+ for flipped in [false, true] {
+ let mut app = plate(mode);
+ app.run("sheet.flange", json!({"sketch": "Base"})).unwrap();
+ let body = app.session.model.state().sheets[0].body.clone();
+ let before = app.session.world_state().body(&body).unwrap().mesh().bounds();
+ app.session.selection = vec![edge_sel(&app.session, Vec3::new(50.0, 0.0, z)).unwrap()];
+ app.start("sheet.hem");
+ let mut d = app.dialog.clone().unwrap();
+ let Kind::Sheet(Sm::Hem { flip, .. }) = &mut d.kind else { panic!("hem dialog") };
+ *flip = flipped;
+ let direction = arrow(&app, &d).unwrap();
+ let commands = apply_commands(&app, &d).unwrap();
+ run_all(&mut app, commands);
+ let after = app.session.world_state().body(&body).unwrap().mesh().bounds();
+ assert!(
+ direction.dot(after.center() - before.center()) > 1e-6,
+ "the arrow must point toward the added hem: z={z}, flip={flipped}, arrow={direction:?}, before={before:?}, after={after:?}"
+ );
+ }
+ }
+ }
+}
+
/// Hem takes edges and an optional gap; rules make and pick a rule with its expressions.
#[test]
fn hem_and_rules() {