Block Definition dialog: preview references, amber band

A selected block reference is previewed from its definition placed by
the reference's transform; the no-objects band is amber.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-15 10:49:59 +03:00
1 parent d69a5f0ac4
commit 367c89a2c8
2 files changed
+36 -8

No files matched your search

+33 -6
View File
@@ -143,12 +143,39 @@ impl OpenCADStudio {
.unwrap_or_default()
} else {
state.empty_prompt = false;
let entities: Vec<_> = state
.selected_handles
.iter()
.filter_map(|handle| scene.document.get_entity(*handle).cloned())
.collect();
scene.wires_for_entities(&entities)
let mut wires = Vec::new();
for handle in &state.selected_handles {
match scene.document.get_entity(*handle) {
// A reference is drawn from its definition, placed by the
// reference's transform.
Some(codec::EntityType::Insert(insert)) => {
let base = crate::scene::render_graph::block_base_point(
&scene.document,
&insert.block_name,
);
let xform =
crate::scene::render_graph::insert_transform_with_base(insert, base);
for mut wire in scene.block_preview_wires(&insert.block_name) {
for p in &mut wire.points {
if p.iter().all(|v| v.is_finite()) {
let q = xform.apply(codec::types::Vector3::new(
f64::from(p[0]),
f64::from(p[1]),
f64::from(p[2]),
));
*p = [q.x as f32, q.y as f32, q.z as f32];
}
}
wires.push(wire);
}
}
Some(entity) => {
wires.extend(scene.wires_for_entities(std::slice::from_ref(entity)))
}
None => {}
}
}
wires
};
}
+3 -2
View File
@@ -257,8 +257,9 @@ fn empty_band<'a>() -> Element<'a, Message> {
)
.padding([7, 10])
.width(Fill)
.style(|theme: &Theme| {
let warn = theme.palette().warning.base.color;
.style(|_: &Theme| {
// Amber: the theme's warning colour is not a caution tone in every theme.
let warn = iced::Color::from_rgb8(0xD9, 0xA4, 0x00);
container::Style {
background: Some(Background::Color(warn.scale_alpha(0.16))),
border: Border {