SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Flat Pattern: show the whole flat size (#7495) (#7496)
Ahmad Khan6af571eb4031
diff --git a/assets/locales/pending/flat-pattern-size-rows.json b/assets/locales/pending/flat-pattern-size-rows.jsonnew file mode 100644index 0000000000..b4054be225--- /dev/null+++ b/assets/locales/pending/flat-pattern-size-rows.json@@ -0,0 +1,26 @@+{+ "ar": {+ "Flat size X": "الحجم المسطّح X",+ "Flat size Y": "الحجم المسطّح Y"+ },+ "en": {+ "Flat size X": "Flat size X",+ "Flat size Y": "Flat size Y"+ },+ "he": {+ "Flat size X": "מידות הפריסה X",+ "Flat size Y": "מידות הפריסה Y"+ },+ "ja": {+ "Flat size X": "展開サイズ X",+ "Flat size Y": "展開サイズ Y"+ },+ "vi": {+ "Flat size X": "Kích thước phôi phẳng X",+ "Flat size Y": "Kích thước phôi phẳng Y"+ },+ "zh": {+ "Flat size X": "平板尺寸 X",+ "Flat size Y": "平板尺寸 Y"+ }+}diff --git a/crates/ui-egui/src/dialogs_sheet.rs b/crates/ui-egui/src/dialogs_sheet.rsindex 48231024bd..2d4998443a 100644--- a/crates/ui-egui/src/dialogs_sheet.rs+++ b/crates/ui-egui/src/dialogs_sheet.rs@@ -432,14 +432,13 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Sm, inputs: &mut [Selform_row(ui, "Body", |ui| {ui.label(v["body"].as_str().unwrap_or(""));});- form_row(ui, "Flat size", |ui| {- ui.label(format!(- "{} × {} × {}",- crate::prefs::show_mm(app, size[0].as_f64().unwrap_or(0.0), 1),- crate::prefs::show_mm(app, size[1].as_f64().unwrap_or(0.0), 1),- crate::prefs::show_mm(app, size[2].as_f64().unwrap_or(0.0), 1)- ));- });+ // One number per row, X and Y as in the DXF: on one row the panel's width cut the+ // flat size off after its first side, and the second is the one people read most.+ for (label, i) in [("Flat size X", 0), ("Flat size Y", 1), ("Thickness", 2)] {+ form_row(ui, label, |ui| {+ ui.label(crate::prefs::show_mm(app, size[i].as_f64().unwrap_or(0.0), 1));+ });+ }let bends = v["bends"].as_array().cloned().unwrap_or_default();form_row(ui, "Bends", |ui| {ui.label(format!("{}", bends.len()));diff --git a/crates/ui-egui/src/dialogs_sheet_tests.rs b/crates/ui-egui/src/dialogs_sheet_tests.rsindex a6e992586a..a217d022f7 100644--- a/crates/ui-egui/src/dialogs_sheet_tests.rs+++ b/crates/ui-egui/src/dialogs_sheet_tests.rs@@ -194,6 +194,35 @@ fn shallow_pocket_overlay_labels_depth_without_drawing_a_through_void() {}}+/// The Flat Pattern panel shows each side of the flat size, and the thickness, whole: on one row+/// ("1250.00 mm × 1000.00 mm × 2.50 mm") the panel cut it off after the first side.+#[test]+fn flat_pattern_shows_each_side_of_the_flat_size_whole() {+ for layout in ["docked", "floating"] {+ let mut h = crate::scenario::Harness::new();+ h.app.home.open = false;+ h.call("ui.resize", json!({"width": 1600, "height": 1200}));+ h.call("ui.set", json!({"layout": layout}));+ h.app.run("sketch.create", json!({"plane": "XY", "name": "Base"})).unwrap();+ h.app.run("sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [1250, 1000]})).unwrap();+ h.app.run("sketch.finish", json!({})).unwrap();+ h.app.run("sheet.flange", json!({"sketch": "Base"})).unwrap();+ h.app.start("sheet.flat_pattern");+ h.frames(4);+ let output = h.ctx.run_ui(egui::RawInput { screen_rect: Some(h.ctx.content_rect()), focused: true, ..Default::default() }, |ui| {+ h.app.logic(ui.ctx());+ h.app.ui(ui);+ });+ let texts: Vec<_> = crate::test_support::text_shapes(&output).collect();+ for (label, value) in [("Flat size X", "1250.00 mm"), ("Flat size Y", "1000.00 mm"), ("Thickness", "2.50 mm")] {+ assert!(texts.iter().any(|t| t.galley.text() == label), "{layout}: no {label} row");+ let shown = texts.iter().find(|t| t.galley.job.text == value).unwrap_or_else(|| panic!("{layout}: {label} {value} not painted"));+ assert!(!shown.galley.elided, "{layout}: {label} is cut off");+ }+ assert!(!texts.iter().any(|t| t.galley.text().contains('×')), "{layout}: the sides are no longer run together");+ }+}+#[test]fn flat_pattern_islands_fit_before_the_actual_command_panel() {for mode in [crate::shell::LayoutMode::Floating, crate::shell::LayoutMode::Docked] {