forked from 1b-agent/opencadstudio-upstream
feat(props): uniform-scale checkbox for block references
A selected INSERT's Geometry section gains a "Uniform scale" box (#427): while the three factors are equal it is checked and the panel shows a single Scale row that writes all three axes; unchecking expands the familiar Scale X/Y/Z rows without touching the values (remembered per entity), and re-checking collapses Y/Z onto X as an undoable CHPROP step. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d154a01cb4
commit
8821bb7131
4 files changed
+82
No files matched your search
@@ -139,6 +139,51 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
|
||||
// Uniform-scale checkbox for block references (#427):
|
||||
// while the three scale factors are equal (and the user
|
||||
// hasn't opted into per-axis editing) the panel shows one
|
||||
// Scale row plus a checked "Uniform scale" box; unchecking
|
||||
// expands the familiar Scale X/Y/Z rows.
|
||||
if let acadrust::EntityType::Insert(ins) = entity {
|
||||
let eq = (ins.x_scale() - ins.y_scale()).abs() < 1e-12
|
||||
&& (ins.x_scale() - ins.z_scale()).abs() < 1e-12;
|
||||
let uniform =
|
||||
eq && !self.props_asym_scale.contains(&handle.value());
|
||||
for section in sections.iter_mut() {
|
||||
let Some(xi) =
|
||||
section.props.iter().position(|p| p.field == "x_scale")
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let toggle = crate::scene::model::object::Property {
|
||||
label: "Uniform scale".into(),
|
||||
field: "ins_uniform",
|
||||
value: crate::scene::model::object::PropValue::BoolToggle {
|
||||
field: "ins_uniform",
|
||||
value: uniform,
|
||||
},
|
||||
};
|
||||
if uniform {
|
||||
section
|
||||
.props
|
||||
.retain(|p| p.field != "y_scale" && p.field != "z_scale");
|
||||
let xi = section
|
||||
.props
|
||||
.iter()
|
||||
.position(|p| p.field == "x_scale")
|
||||
.unwrap_or(xi.min(section.props.len()));
|
||||
section.props[xi] = crate::entities::common::edit_prop(
|
||||
"Scale",
|
||||
"u_scale",
|
||||
ins.x_scale(),
|
||||
);
|
||||
section.props.insert(xi, toggle);
|
||||
} else {
|
||||
section.props.insert(xi, toggle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In named plot-style mode (PSTYLEMODE=1) the Plot style row
|
||||
// picks a named style from the drawing's plot style table. In
|
||||
// the color-dependent mode it stays read-only (the object's
|
||||
|
||||
Reference in new issue
Block a user