Honor design units in sketch dimensions and measurements (#241)
* Honor design units in sketch dimensions and measurements
* fix: apply document units to specialized length controls
* Accept explicit units in length fields; document design-unit dimension values
Length fields in a design-unit control now evaluate what is typed as a
length expression: a bare number stays in the design's units, while an
explicit unit ("10 mm", "0.5 in", "1 in + 5 mm") is converted.
Document that a bare numeric sketch.dimension value from scripts, the
control channel or MCP is read in the design's units.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RjGw4gA5ZvKrU8MQP6sBgT
---------
Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
23 files changed
+285
-71
No files matched your search
@@ -202,3 +202,31 @@ fn occurrence_nested_shared_child_has_distinct_rows_and_scope() {
|
||||
context_menu::run_item(&mut h.app, delete, egui::Pos2::ZERO);
|
||||
assert!(h.app.menu.confirm.is_some(), "shared child deletion must communicate scope before removing both renderings");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn occurrence_distance_editor_reads_inches_and_keeps_four_digits_in_model_space() {
|
||||
let (mut h, _, first, _) = fixture();
|
||||
h.app.run("document.units", json!({"units":"in"})).unwrap();
|
||||
let target = Target::Occurrence { path: vec![first] };
|
||||
let items = context_menu::items(&h.app, &target);
|
||||
let movement = items.iter().find(|i| i.id == "ui.moveOccurrence").unwrap();
|
||||
context_menu::run_item(&mut h.app, movement, egui::Pos2::ZERO);
|
||||
h.settle();
|
||||
let original = h.app.session.doc.to_json();
|
||||
let point = h.call("ui.at", json!({"handle":"occurrence-move:distance:0"}));
|
||||
let at = &point["result"];
|
||||
h.call("ui.click", json!({"x":at[0],"y":at[1],"double":true}));
|
||||
h.settle();
|
||||
h.step(&json!({"key":"A","cmd":true})).unwrap();
|
||||
h.step(&json!({"text":"1.2345"})).unwrap();
|
||||
h.step(&json!({"key":"Enter"})).unwrap();
|
||||
let m = h.app.tree.occurrence_move.as_ref().unwrap();
|
||||
assert!((m.translate[0] - 31.3563).abs() < 1e-8, "{:?}", m.translate);
|
||||
assert_eq!(h.app.session.doc.to_json(), original, "pending movement does not alter the stored design");
|
||||
h.app.session.selection = vec![Sel::Occurrence { path: vec![first] }];
|
||||
let bounds = crate::viewport::selection_bounds(&h.app).unwrap();
|
||||
assert!((bounds.min.x - 31.3563).abs() < 1e-6);
|
||||
let movement = h.app.tree.occurrence_move.clone().unwrap();
|
||||
crate::browser::revert_occurrence_dialog(&mut h.app, &movement);
|
||||
assert!(h.app.session.pending_moves.is_empty());
|
||||
}
|
||||
Reference in new issue
Block a user