fix: restore workspace verification

This commit is contained in:
Hakan Seven 2026-08-15 23:11:26 +03:00
commit 1dded7f881
19 changed files with 91 additions and 71 deletions

View file

@ -23,7 +23,7 @@ fn empty_annotation_scales_is_not_annotative() {
let ent = doc.add_entity(EntityType::MText(m)).unwrap();
// Build xdict -> "AcDbContextDataManager" -> "ACDB_ANNOTATIONSCALES" (empty).
let mut mk = |doc: &mut CadDocument, owner: Handle| -> Handle {
let mk = |doc: &mut CadDocument, owner: Handle| -> Handle {
let h = doc.allocate_handle();
let mut d = Dictionary::new();
d.handle = h;

View file

@ -76,8 +76,9 @@ fn block_internal_hatch_reaches_export() {
// A blue hatch, wrapped into a block and inserted in model space — the
// minimal shape of "coloured fill nested in a block".
let h = scene.add_entity(EntityType::Hatch(square_hatch(5)));
let identity = acadrust::types::Transform::identity();
scene
.create_block_from_entities(&[h], "LOGO", glam::DVec3::ZERO)
.create_block_from_entities(&[h], "LOGO", &identity, &identity)
.expect("wrap hatch into a block + insert");
scene.populate_hatches_from_document();
@ -239,17 +240,22 @@ fn app_created_hatch_roundtrips_catalog_spacing() {
let mut scene = Scene::new();
let boundary: Vec<[f32; 2]> = vec![[0.0, 0.0], [10.0, 0.0], [10.0, 10.0], [0.0, 10.0]];
let model = HatchModel {
render_instance: None,
world_origin: [0.0, 0.0],
boundary: Arc::new(boundary),
boundary_wcs: None,
boundary_exterior: None,
boundary_sources: None,
pattern: entry.gpu.clone(),
name: "ANSI31".into(),
color: [0.75, 0.75, 0.75, 0.85],
aci: 0,
line_weight_px: 1.0,
angle_offset: 0.0,
scale: 1.0,
draw_depth: 0.0,
};
scene.add_hatch(model);
scene.add_hatch(model, None, None);
scene.populate_hatches_from_document();
let hatches = scene.paper_canvas_hatches();
@ -288,19 +294,24 @@ fn nested_hatch_serializes_only_outer_as_external() {
let boundary_f32: Vec<[f32; 2]> = wcs.iter().map(|&[x, y]| [x as f32, y as f32]).collect();
let model = HatchModel {
render_instance: None,
world_origin: [0.0, 0.0],
boundary: Arc::new(boundary_f32),
boundary_wcs: Some(Arc::new(wcs)),
boundary_exterior: None,
boundary_sources: None,
pattern: HatchPattern::Solid,
name: "SOLID".into(),
color: [0.45, 0.45, 0.45, 0.60],
aci: 0,
line_weight_px: 1.0,
angle_offset: 0.0,
scale: 1.0,
draw_depth: 0.0,
};
let mut scene = Scene::new();
scene.add_hatch(model);
scene.add_hatch(model, None, None);
let dxf = scene
.document

View file

@ -2,7 +2,7 @@
// dictionary pointer unresolvable — it names a handle that never loaded (or a
// non-dictionary), while the real named-object sub-dictionaries are owned by an
// unrelated handle. Navigating that root then silently no-ops, so registering a
// new named-object entry (a page setup, the CTAB current-tab variable, an
// new named-object entry (a page setup, the variable dictionary, an
// annotation scale) would vanish instead of persisting.
//
// `annotative::root_named_dict_handle` resolves the root robustly and, when it
@ -121,8 +121,19 @@ fn ctab_is_created_against_a_repaired_root() {
else {
panic!("root must be a dictionary");
};
let variable_dictionary = root
.entries
.iter()
.find(|(key, _)| key == "AcDbVariableDictionary")
.map(|(_, handle)| *handle)
.expect("variable dictionary must be registered in the repaired root NOD");
let Some(ObjectType::Dictionary(variable_dictionary)) =
scene.document.objects.get(&variable_dictionary)
else {
panic!("variable dictionary must resolve");
};
assert!(
root.entries.iter().any(|(k, _)| k == "CTAB"),
"CTAB must be registered in the repaired root NOD"
variable_dictionary.entries.iter().any(|(key, _)| key == "CTAB"),
"CTAB must be registered in the variable dictionary"
);
}

View file

@ -11,7 +11,7 @@
use acadrust::entities::{Dimension, DimensionLinear, Text};
use acadrust::types::Vector3;
use acadrust::EntityType;
use OpenCADStudio::io::pdf_export::export_pdf;
use OpenCADStudio::io::pdf_export::{export_pdf, PdfPlotOptions};
use OpenCADStudio::scene::Scene;
#[test]
@ -69,6 +69,7 @@ fn text_and_dim_reach_pdf_export() {
None,
&p_text,
None,
PdfPlotOptions::default(),
)
.expect("export with text");
let with_text = std::fs::read(&p_text).expect("read pdf");
@ -96,6 +97,7 @@ fn text_and_dim_reach_pdf_export() {
None,
&p_bare,
None,
PdfPlotOptions::default(),
)
.expect("export without text");
let no_text = std::fs::read(&p_bare).expect("read pdf");

View file

@ -49,12 +49,21 @@ fn expand_block_mtext(
let ins = Insert::new("LABEL_BLOCK", insert_at);
doc.add_entity(EntityType::Insert(ins.clone())).unwrap();
let cache = BlockCache::build(&doc, 1.0, [0.0, 0.0, 0.0, 1.0], &Default::default());
let cache = BlockCache::build(
&doc,
1.0,
None,
true,
[0.0, 0.0, 0.0, 1.0],
None,
&Default::default(),
);
expand_insert(
&cache,
&ins,
Handle::new(999),
[1.0, 1.0, 1.0, 1.0],
0,
0.0,
[0.0; 8],
1.0,
@ -66,6 +75,7 @@ fn expand_block_mtext(
pat: [0.0; 8],
lw_px: 1.0,
},
0,
false,
1.0,
None,