Feat: viewport UCS name picker from document UCS table
- properties.rs: inject 'UCS Name' Choice property for viewports when document.ucss is non-empty; resolves current handle to display name - update.rs: intercept PropGeomChoiceChanged for 'vp_ucs_name'; clones UCS origin/x_axis/y_axis into viewport and sets ucs_handle — no trait signature change required Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5ad2f4a8cb
commit
36bda2ac2b
2 changed files with 49 additions and 4 deletions
|
|
@ -56,7 +56,7 @@ impl H7CAD {
|
|||
let mut sections =
|
||||
dispatch::properties_sectioned(handle, entity, &text_style_names);
|
||||
|
||||
// Inject frozen-layer property for viewports (requires doc access).
|
||||
// Inject viewport-only properties that require doc access.
|
||||
if let acadrust::EntityType::Viewport(vp) = entity {
|
||||
let frozen_names: Vec<String> = vp
|
||||
.frozen_layers
|
||||
|
|
@ -67,6 +67,21 @@ impl H7CAD {
|
|||
.map(|l| l.name.clone())
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Collect available UCS names for the name picker.
|
||||
let ucs_names: Vec<String> = self.tabs[i].scene.document.ucss
|
||||
.iter()
|
||||
.map(|u| u.name.clone())
|
||||
.filter(|n| !n.is_empty())
|
||||
.collect();
|
||||
|
||||
// Current UCS name (resolved from vp.ucs_handle).
|
||||
let current_ucs = self.tabs[i].scene.document.ucss
|
||||
.iter()
|
||||
.find(|u| u.handle == vp.ucs_handle)
|
||||
.map(|u| u.name.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
if let Some(geom) = sections.last_mut() {
|
||||
geom.props.push(crate::scene::object::Property {
|
||||
label: "Frozen Layers".to_string(),
|
||||
|
|
@ -75,6 +90,16 @@ impl H7CAD {
|
|||
frozen_names.join(", "),
|
||||
),
|
||||
});
|
||||
if !ucs_names.is_empty() {
|
||||
geom.props.push(crate::scene::object::Property {
|
||||
label: "UCS Name".to_string(),
|
||||
field: "vp_ucs_name",
|
||||
value: crate::scene::object::PropValue::Choice {
|
||||
selected: current_ucs,
|
||||
options: ucs_names,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1484,9 +1484,29 @@ impl H7CAD {
|
|||
let handles = self.property_target_handles(i);
|
||||
if !handles.is_empty() {
|
||||
self.push_undo_snapshot(i, "CHPROP");
|
||||
for handle in handles {
|
||||
if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(handle) {
|
||||
crate::scene::dispatch::apply_geom_prop(entity, field, &value);
|
||||
if field == "vp_ucs_name" {
|
||||
// Resolve UCS name → cloned data, then mutate viewports.
|
||||
let ucs_data = self.tabs[i].scene.document.ucss
|
||||
.iter()
|
||||
.find(|u| u.name == value)
|
||||
.cloned();
|
||||
if let Some(ucs) = ucs_data {
|
||||
for handle in &handles {
|
||||
if let Some(acadrust::EntityType::Viewport(vp)) =
|
||||
self.tabs[i].scene.document.get_entity_mut(*handle)
|
||||
{
|
||||
vp.ucs_handle = ucs.handle;
|
||||
vp.ucs_origin = ucs.origin.clone();
|
||||
vp.ucs_x_axis = ucs.x_axis.clone();
|
||||
vp.ucs_y_axis = ucs.y_axis.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for handle in handles {
|
||||
if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(handle) {
|
||||
crate::scene::dispatch::apply_geom_prop(entity, field, &value);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.tabs[i].dirty = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue