While a section is on, Section Analysis opened with no plane picked now
says "No plane picked: OK turns the section off." and OK runs
inspect.section {"clear": true}. With no section on, OK with no plane
still asks for a plane.
Fixes #2410.
This commit is contained in:
@@ -1392,6 +1392,7 @@
|
||||
"search.suggest": "Did you mean {label}?",
|
||||
"search.try": "Type a command name, a feature in this design, or a parameter. To run a command with values, type its id and a JSON object: {example}",
|
||||
"search.valid": "Valid",
|
||||
"section.off_hint": "No plane picked: OK turns the section off.",
|
||||
"settings.display_quality_note": "Only the display. Designs and exports are not affected.",
|
||||
"settings.frame_rate_note": "Shows frames per second in the view's bottom-right corner.",
|
||||
"settings.measure_axis_distances": "Show X/Y/Z distances",
|
||||
|
||||
@@ -1392,6 +1392,7 @@
|
||||
"search.suggest": "{label} ですか?",
|
||||
"search.try": "コマンド名、このデザインのフィーチャー、またはパラメーターを入力します。値を指定して実行するには、IDとJSONオブジェクトを入力します:{example}",
|
||||
"search.valid": "有効",
|
||||
"section.off_hint": "平面が選択されていません。OK を押すとセクションを解除します。",
|
||||
"settings.display_quality_note": "表示だけに影響します。設計や書き出しは変わりません。",
|
||||
"settings.frame_rate_note": "ビューの右下に 1 秒あたりのフレーム数を表示します。",
|
||||
"settings.measure_axis_distances": "計測のX・Y・Z距離を表示",
|
||||
|
||||
@@ -1392,6 +1392,7 @@
|
||||
"search.suggest": "您是否想找 {label}?",
|
||||
"search.try": "输入命令名称、此设计中的特征或参数。要带值运行命令,请输入其ID和JSON对象:{example}",
|
||||
"search.valid": "有效",
|
||||
"section.off_hint": "未选择平面:按“确定”将移除剖面。",
|
||||
"settings.display_quality_note": "仅影响显示,不影响设计和导出。",
|
||||
"settings.frame_rate_note": "在视图右下角显示每秒帧数。",
|
||||
"settings.measure_axis_distances": "显示 X/Y/Z 距离",
|
||||
|
||||
@@ -3079,6 +3079,11 @@ fn sels(d: &Dialog, i: usize) -> &[Sel] {
|
||||
selection::items(&d.inputs, i)
|
||||
}
|
||||
|
||||
/// Section Analysis with a section on and no plane picked: OK turns the section off.
|
||||
fn section_turns_off(s: &Session, inputs: &[selection::SelInput]) -> bool {
|
||||
s.section.is_some() && selection::items(inputs, 0).is_empty()
|
||||
}
|
||||
|
||||
pub(crate) fn run_dialog(app: &mut SolveApp, d: &Dialog) -> Result<(), String> {
|
||||
if let Kind::ViewDxf { dashed, tolerance } = &d.kind {
|
||||
return crate::dialogs_view_dxf::run(app, *dashed, *tolerance);
|
||||
@@ -3731,6 +3736,9 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result<Vec<(String, Value)>, S
|
||||
("material.assign", json!({"bodies": sels(d, 0).body_names(), "material": name}))
|
||||
}
|
||||
Kind::Section { offset, flip, hatch } => {
|
||||
if section_turns_off(s, &d.inputs) {
|
||||
return Ok(vec![("inspect.section".into(), json!({"clear": true}))]);
|
||||
}
|
||||
need(0, "a plane or planar face")?;
|
||||
let plane = match sels(d, 0).first() {
|
||||
Some(Sel::Plane { name }) if matches!(name.as_str(), "XY" | "XZ" | "YZ") => json!(name),
|
||||
|
||||
@@ -791,6 +791,9 @@ fn additional_rows(app: &mut SolveApp, d: &mut Dialog, ui: &mut egui::Ui) -> boo
|
||||
Kind::Section { offset, flip, hatch } => {
|
||||
enter |= expr_row(ui, "Distance", offset);
|
||||
ui_kit::options(ui, "feature_options", &mut [("Flip", flip), ("Hatch", hatch)]);
|
||||
if section_turns_off(&app.session, &d.inputs) {
|
||||
ui_kit::text(ui, tr("section.off_hint"), ui_kit::Text::Hint("section_off"));
|
||||
}
|
||||
}
|
||||
Kind::Rename { name, .. } => {
|
||||
form_row(ui, "Name", |ui| {
|
||||
|
||||
@@ -173,3 +173,32 @@ fn the_hatch_option_carries_through_the_section() {
|
||||
let d = h.app.dialog.as_ref().map(|d| &d.kind);
|
||||
assert!(matches!(d, Some(crate::dialogs::Kind::Section { hatch: false, .. })), "{d:?}");
|
||||
}
|
||||
|
||||
/// With a section on and no plane picked, the dialog says OK turns the section off: Cancel keeps
|
||||
/// it and OK removes it. With no section on, OK still asks for a plane (#2410).
|
||||
#[test]
|
||||
fn ok_with_no_plane_picked_turns_the_section_off() {
|
||||
let mut h = harness();
|
||||
h.app.run("solid.box", json!({"length":40,"width":30,"height":20})).unwrap();
|
||||
h.app.run("inspect.section", json!({"plane": "XZ", "offset": 10})).unwrap();
|
||||
h.app.session.selection.clear();
|
||||
h.app.start("inspect.section");
|
||||
h.frames(3);
|
||||
assert!(section_dialog(&h).2.is_empty(), "no plane picked");
|
||||
assert!(crate::scenario::handle_at("dialog:hint:section_off").is_some(), "the dialog says OK turns the section off");
|
||||
h.step(&json!({"widget":"Cancel"})).unwrap();
|
||||
h.frames(3);
|
||||
assert!(h.app.dialog.is_none() && h.app.session.section.is_some(), "Cancel keeps the section");
|
||||
|
||||
h.app.start("inspect.section");
|
||||
ok(&mut h);
|
||||
assert_eq!(h.app.session.section, None, "OK with no plane picked turns the section off");
|
||||
assert!(crate::scenario::handle_at("row:Section Analysis").is_none(), "the browser no longer lists it");
|
||||
|
||||
h.app.start("inspect.section");
|
||||
h.frames(3);
|
||||
assert!(crate::scenario::handle_at("dialog:hint:section_off").is_none(), "no section to turn off");
|
||||
h.step(&json!({"widget":"OK"})).unwrap();
|
||||
h.frames(3);
|
||||
assert_eq!(h.app.dialog.as_ref().and_then(|d| d.error.as_deref()), Some("select a plane or planar face first"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user