mirror of
https://github.com/storytold/cadcraft.git
synced 2026-12-01 18:25:32 -06:00
Test: a layer-0 attribute of a nested reference follows the outer reference's layer
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -1046,6 +1046,36 @@ fn attribute_set_on_layer_zero_does_not_take_the_reference_layer() {
|
||||
assert!(own.iter().all(|t| *t < line), "{own:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn attribute_on_layer_zero_of_a_nested_reference_follows_the_outer_reference() {
|
||||
// A reference on the opaque layer A, with an attribute set on layer 0, sits inside block
|
||||
// Outer beside a layer-0 line; Outer is placed on a 40 % layer. In Outer the attribute is
|
||||
// layer-0 content like that line, so both take the outer reference's layer: not layer 0
|
||||
// itself, and not layer A, which only the inner block's own line takes.
|
||||
let mut d = Drawing::new_imperial();
|
||||
d.layers.push(cadcraft_doc::Layer { name: "A".into(), ..Default::default() });
|
||||
let mut inner = cadcraft_doc::Block::new("B");
|
||||
let (c, k) = line_common(Common::default());
|
||||
inner.entities.push(block_entity(1, c, k));
|
||||
inner.entities.push(block_entity(2, Common::default(), EntityKind::AttDef(attrib("TAG"))));
|
||||
d.blocks.insert("B".into(), std::sync::Arc::new(inner));
|
||||
let EntityKind::Insert(mut ins) = insert_of("B") else { panic!("an insert") };
|
||||
let props = cadcraft_doc::AttribProps { layer: Some("0".into()), ..Default::default() };
|
||||
ins.attribs.push(cadcraft_doc::Attrib { props, ..attrib("TAG") });
|
||||
let mut outer = cadcraft_doc::Block::new("Outer");
|
||||
let (c, k) = line_common(Common::default());
|
||||
outer.entities.push(block_entity(3, c, k));
|
||||
outer.entities.push(block_entity(4, Common { layer: "A".into(), ..Default::default() }, EntityKind::Insert(ins)));
|
||||
d.blocks.insert("Outer".into(), std::sync::Arc::new(outer));
|
||||
d.add(&Space::Model, Common { layer: "Glass".into(), ..Default::default() }, insert_of("Outer")).unwrap();
|
||||
d.layer_mut("Glass").unwrap().transparency = 40;
|
||||
let l = build(&d, &Space::Model, &with_transparency());
|
||||
let [outer_line, inner_line, text @ ..] = l.prims.as_slice() else { panic!("two lines and the attribute") };
|
||||
assert!(!text.is_empty(), "the attribute is drawn");
|
||||
assert!(inner_line.transparency < outer_line.transparency, "the inner block's line is on layer A");
|
||||
assert!(text.iter().all(|p| p.transparency == outer_line.transparency), "the attribute follows the outer reference's layer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mtext_exact_spacing_ignores_taller_lines() {
|
||||
// #711: a doubled middle line pushes the next baseline down with At least, not with Exactly.
|
||||
|
||||
Reference in New Issue
Block a user