The Scale dialog gets a Type row, Uniform or Per axis. Per axis shows X, Y and Z rows and sends factors, which solid.scale already takes. A Scale made with factors opens per axis with its three values; before, they rode along as an extra and the dialog's factor did nothing. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"en": {
|
||||
"scale.uniform": "Uniform",
|
||||
"scale.per_axis": "Per axis"
|
||||
},
|
||||
"ar": {
|
||||
"scale.uniform": "موحّد",
|
||||
"scale.per_axis": "لكل محور"
|
||||
},
|
||||
"cs": {
|
||||
"scale.uniform": "Rovnoměrně",
|
||||
"scale.per_axis": "Podle os"
|
||||
},
|
||||
"da": {
|
||||
"scale.uniform": "Ensartet",
|
||||
"scale.per_axis": "Per akse"
|
||||
},
|
||||
"de": {
|
||||
"scale.uniform": "Gleichmäßig",
|
||||
"scale.per_axis": "Je Achse"
|
||||
},
|
||||
"es": {
|
||||
"scale.uniform": "Uniforme",
|
||||
"scale.per_axis": "Por eje"
|
||||
},
|
||||
"fi": {
|
||||
"scale.uniform": "Tasainen",
|
||||
"scale.per_axis": "Akseleittain"
|
||||
},
|
||||
"fr": {
|
||||
"scale.uniform": "Uniforme",
|
||||
"scale.per_axis": "Par axe"
|
||||
},
|
||||
"gl": {
|
||||
"scale.uniform": "Uniforme",
|
||||
"scale.per_axis": "Por eixo"
|
||||
},
|
||||
"he": {
|
||||
"scale.uniform": "אחיד",
|
||||
"scale.per_axis": "לפי ציר"
|
||||
},
|
||||
"hu": {
|
||||
"scale.uniform": "Egyenletes",
|
||||
"scale.per_axis": "Tengelyenként"
|
||||
},
|
||||
"id": {
|
||||
"scale.uniform": "Seragam",
|
||||
"scale.per_axis": "Per sumbu"
|
||||
},
|
||||
"it": {
|
||||
"scale.uniform": "Uniforme",
|
||||
"scale.per_axis": "Per asse"
|
||||
},
|
||||
"ja": {
|
||||
"scale.uniform": "均等",
|
||||
"scale.per_axis": "軸ごと"
|
||||
},
|
||||
"ko": {
|
||||
"scale.uniform": "균일",
|
||||
"scale.per_axis": "축별"
|
||||
},
|
||||
"ms": {
|
||||
"scale.uniform": "Seragam",
|
||||
"scale.per_axis": "Mengikut paksi"
|
||||
},
|
||||
"nb": {
|
||||
"scale.uniform": "Jevn",
|
||||
"scale.per_axis": "Per akse"
|
||||
},
|
||||
"nl": {
|
||||
"scale.uniform": "Uniform",
|
||||
"scale.per_axis": "Per as"
|
||||
},
|
||||
"pt-BR": {
|
||||
"scale.uniform": "Uniforme",
|
||||
"scale.per_axis": "Por eixo"
|
||||
},
|
||||
"ro": {
|
||||
"scale.uniform": "Uniform",
|
||||
"scale.per_axis": "Pe axe"
|
||||
},
|
||||
"ru": {
|
||||
"scale.uniform": "Равномерно",
|
||||
"scale.per_axis": "По осям"
|
||||
},
|
||||
"sv": {
|
||||
"scale.uniform": "Likformig",
|
||||
"scale.per_axis": "Per axel"
|
||||
},
|
||||
"tr": {
|
||||
"scale.uniform": "Tekdüze",
|
||||
"scale.per_axis": "Eksen başına"
|
||||
},
|
||||
"uk": {
|
||||
"scale.uniform": "Рівномірно",
|
||||
"scale.per_axis": "По осях"
|
||||
},
|
||||
"vi": {
|
||||
"scale.uniform": "Đồng đều",
|
||||
"scale.per_axis": "Theo từng trục"
|
||||
},
|
||||
"zh": {
|
||||
"scale.uniform": "等比",
|
||||
"scale.per_axis": "按轴"
|
||||
},
|
||||
"zh-TW": {
|
||||
"scale.uniform": "等比",
|
||||
"scale.per_axis": "依軸"
|
||||
}
|
||||
}
|
||||
@@ -135,10 +135,14 @@ crate::dialog_descriptor::dialog_descriptors! {
|
||||
FeatureKind::ConstructionPlane { plane: PlaneRef::Tangent { angle, .. } }) {
|
||||
angle: String = "0 deg".into() => angle.as_ref().map_or_else(|| "0 deg".to_string(), ToString::to_string),
|
||||
} => json!({"angle": angle});
|
||||
// Uniform, or per axis (#10782): then `factor` is X's, beside Y's and Z's.
|
||||
Scale("solid.scale", "SCALE", [("Bodies", BODIES, true)],
|
||||
FeatureKind::Scale { factor, .. }) {
|
||||
factor: String = "2".into() => factor.to_string(),
|
||||
} => json!({"factor": factor});
|
||||
FeatureKind::Scale { factor, factors, .. }) {
|
||||
factor: String = "2".into() => factors.as_ref().map_or_else(|| factor.to_string(), |f| f[0].to_string()),
|
||||
per_axis: bool = false => factors.is_some(),
|
||||
factor_y: String = "2".into() => factors.as_ref().map_or_else(|| factor.to_string(), |f| f[1].to_string()),
|
||||
factor_z: String = "2".into() => factors.as_ref().map_or_else(|| factor.to_string(), |f| f[2].to_string()),
|
||||
} => if *per_axis { json!({"factors": [factor, factor_y, factor_z]}) } else { json!({"factor": factor}) };
|
||||
OffsetFaces("solid.offset_face", "OFFSET FACE", [("Faces", FACES, true)],
|
||||
FeatureKind::OffsetFace { distance, .. }) {
|
||||
distance: String = "2 mm".into() => shown_expr(distance, ValueKind::Length),
|
||||
@@ -1440,7 +1444,8 @@ impl Dialog {
|
||||
Kind::Pipe { diameter, .. } => ("Diameter", ValueKind::Length, diameter),
|
||||
Kind::Stock { margin } => ("Margin", ValueKind::Length, margin),
|
||||
Kind::AnglePlane { angle } => ("Angle", ValueKind::Angle, angle),
|
||||
Kind::Scale { factor } => ("Scale", ValueKind::Unitless, factor),
|
||||
Kind::Scale { per_axis: true, .. } => return None,
|
||||
Kind::Scale { factor, .. } => ("Scale", ValueKind::Unitless, factor),
|
||||
Kind::OffsetFaces { distance } => ("Distance", ValueKind::Length, distance),
|
||||
Kind::Sheet(k) => return k.primary(&self.inputs),
|
||||
Kind::Surface(k) => return k.primary(),
|
||||
@@ -7180,16 +7185,13 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option<usize>) -> Option<Dia
|
||||
}
|
||||
d
|
||||
}
|
||||
FeatureKind::Scale { bodies, origin, factors, .. } => {
|
||||
FeatureKind::Scale { bodies, origin, .. } => {
|
||||
let mut d = start("solid.scale")?;
|
||||
d.kind = Kind::simple_restore(&f.kind)?;
|
||||
if let Some(inp) = d.inputs.first_mut() {
|
||||
inp.items = bodies.iter().map(|n| Sel::Body { name: n.to_string() }).collect();
|
||||
}
|
||||
d.extra.insert("origin".into(), pt3(origin.0));
|
||||
if let Some(f) = factors {
|
||||
d.extra.insert("factors".into(), json!(f));
|
||||
}
|
||||
d
|
||||
}
|
||||
FeatureKind::OffsetFace { faces, body, .. } => {
|
||||
|
||||
@@ -282,7 +282,7 @@ fn check_form(command: &str, labels: &[&str]) {
|
||||
fn control_role(command: &str, label: &str) -> Option<egui::accesskit::Role> {
|
||||
use egui::accesskit::Role;
|
||||
Some(match label {
|
||||
"Type" if matches!(command, "sheet.flange" | "sheet.hem" | "solid.revolve" | "solid.emboss") => return None,
|
||||
"Type" if matches!(command, "sheet.flange" | "sheet.hem" | "solid.revolve" | "solid.emboss" | "solid.scale") => return None,
|
||||
"Direction" => return None, // segmented buttons, labelled by each choice
|
||||
"ui.fair_strength" | "ui.fair_iterations" => return None,
|
||||
"Continuity" | "Corners" | "Cells" | "Profile" => return None,
|
||||
@@ -440,7 +440,50 @@ form_case!(point_along_path, "construct.point.along_path", ["Position (0 to 1)"]
|
||||
form_case!(angle_plane, "construct.plane.at_angle", ["Angle"]);
|
||||
form_case!(path_plane, "construct.plane.along_path", ["Position (0 to 1)"]);
|
||||
form_case!(split, "solid.split_body", []);
|
||||
form_case!(scale, "solid.scale", ["Scale factor"]);
|
||||
form_case!(scale, "solid.scale", ["Type", "Scale factor"]);
|
||||
|
||||
/// Scale per axis (#10782): the dialog's X, Y and Z rows build `factors`; a Scale made with
|
||||
/// `factors` opens per axis with its three values and keeps them on OK, and switching it back to
|
||||
/// Uniform scales the same in every direction again.
|
||||
#[test]
|
||||
fn scale_takes_a_factor_per_axis() {
|
||||
let mut h = Harness::new();
|
||||
h.app.run("solid.box", json!({"length": 10, "width": 10, "height": 10, "corner": [0, 0, 0]})).unwrap();
|
||||
let body = h.app.session.model.state().bodies[0].name.clone();
|
||||
let mut d = Dialog::for_command(&h.app, "solid.scale").unwrap();
|
||||
d.inputs[0].items = vec![Sel::Body { name: body.clone() }];
|
||||
let Kind::Scale { factor, per_axis, factor_y, factor_z } = &mut d.kind else { panic!("not the Scale dialog") };
|
||||
assert!(!*per_axis, "Scale opens uniform");
|
||||
*per_axis = true;
|
||||
(*factor, *factor_y, *factor_z) = ("2".into(), "1".into(), "0.5".into());
|
||||
for (command, params) in apply_commands(&h.app, &d).unwrap() {
|
||||
assert!(params.get("factor").is_none(), "{params}");
|
||||
h.app.run(&command, params).unwrap();
|
||||
}
|
||||
let scale = h.app.session.doc.features.last().unwrap().id;
|
||||
let kind = |h: &Harness| serde_json::to_value(&h.app.session.doc.feature(scale).unwrap().kind).unwrap();
|
||||
assert_eq!(kind(&h)["factors"], json!(["2", "1", "0.5"]));
|
||||
let size = |h: &Harness| h.app.session.model.state().bodies[0].mesh().bounds().size();
|
||||
assert!((size(&h) - Vec3::new(20.0, 10.0, 5.0)).len() < 1e-6, "{:?}", size(&h));
|
||||
let mut d = crate::dialogs::for_feature(&h.app, scale, None).unwrap();
|
||||
assert!(
|
||||
matches!(&d.kind, Kind::Scale { factor, per_axis: true, factor_y, factor_z } if [factor, factor_y, factor_z] == ["2", "1", "0.5"]),
|
||||
"{:?}",
|
||||
d.kind
|
||||
);
|
||||
for (command, params) in apply_commands(&h.app, &d).unwrap() {
|
||||
h.app.run(&command, params).unwrap();
|
||||
}
|
||||
assert_eq!(kind(&h)["factors"], json!(["2", "1", "0.5"]), "OK keeps the three factors");
|
||||
if let Kind::Scale { per_axis, factor, .. } = &mut d.kind {
|
||||
(*per_axis, *factor) = (false, "3".into());
|
||||
}
|
||||
for (command, params) in apply_commands(&h.app, &d).unwrap() {
|
||||
h.app.run(&command, params).unwrap();
|
||||
}
|
||||
assert!(kind(&h).get("factors").is_none(), "{}", kind(&h));
|
||||
assert!((size(&h) - Vec3::new(30.0, 30.0, 30.0)).len() < 1e-6, "{:?}", size(&h));
|
||||
}
|
||||
form_case!(offset_faces, "solid.offset_face", ["Distance"]);
|
||||
form_case!(section, "inspect.section", ["Distance"]);
|
||||
form_case!(move_copy, "solid.move", ["Move Type", "X Distance", "Y Distance", "Z Distance", "X Angle", "Y Angle", "Z Angle"]);
|
||||
|
||||
@@ -989,8 +989,26 @@ fn additional_rows(app: &mut SolveApp, d: &mut Dialog, ui: &mut egui::Ui) -> boo
|
||||
Kind::Stock { margin } => {
|
||||
enter |= expr_row(ui, "Margin", margin);
|
||||
}
|
||||
Kind::Scale { factor } => {
|
||||
enter |= expr_row(ui, "Scale factor", factor);
|
||||
Kind::Scale { factor, per_axis, factor_y, factor_z } => {
|
||||
form_row(ui, "Type", |ui| {
|
||||
let mut i = usize::from(*per_axis);
|
||||
ui_kit::segmented(ui, &mut i, &["scale.uniform", "scale.per_axis"], Default::default());
|
||||
if (i == 1) != *per_axis {
|
||||
*per_axis = i == 1;
|
||||
// Y and Z start at the factor, so nothing changes until one of them does.
|
||||
if *per_axis {
|
||||
factor_y.clone_from(factor);
|
||||
factor_z.clone_from(factor);
|
||||
}
|
||||
}
|
||||
});
|
||||
if *per_axis {
|
||||
enter |= expr_row(ui, "X", factor);
|
||||
enter |= expr_row(ui, "Y", factor_y);
|
||||
enter |= expr_row(ui, "Z", factor_z);
|
||||
} else {
|
||||
enter |= expr_row(ui, "Scale factor", factor);
|
||||
}
|
||||
}
|
||||
Kind::OffsetFaces { distance } => {
|
||||
enter |= expr_row(ui, "Distance", distance);
|
||||
|
||||
Reference in New Issue
Block a user