forked from 1b-agent/opencadstudio-upstream
Cargo: codec e023bc3 (acadrust sync), kernel abca4e8, graph c63556f
The codec now holds wide EntityType variants boxed (MText, Helix, Dimension, Hatch, Viewport, MultiLeader, Surface, Table, Ole2Frame, Light, Extended). Constructors box their entity; nested patterns reach a dimension through entities::dimension::as_dimension(_mut). Also follows BlockAction::action_ids, LineTypeComplexData::source_flags and the decimal tab stop with an explicit character. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
218150c76a
commit
e4d04ef132
87 files changed
+380
-269
No files matched your search
@@ -90,13 +90,13 @@ fn entered_viewport_survives_a_save_and_reload() {
|
||||
sheet.id = 1;
|
||||
sheet.width = 420.0;
|
||||
sheet.height = 297.0;
|
||||
let sheet = scene.add_entity(EntityType::Viewport(sheet));
|
||||
let sheet = scene.add_entity(EntityType::Viewport(Box::new(sheet)));
|
||||
let mut model = Viewport::new();
|
||||
model.id = 2;
|
||||
model.width = 100.0;
|
||||
model.height = 80.0;
|
||||
model.view_height = 80.0;
|
||||
let model = scene.add_entity(EntityType::Viewport(model));
|
||||
let model = scene.add_entity(EntityType::Viewport(Box::new(model)));
|
||||
assert_ne!(sheet, model);
|
||||
|
||||
for entered in [Some(model), None] {
|
||||
|
||||
@@ -20,7 +20,7 @@ fn empty_annotation_scales_is_not_annotative() {
|
||||
let mut doc = CadDocument::with_version(DxfVersion::AC1032);
|
||||
let mut m = MText::new();
|
||||
m.is_annotative = false; // no native flag, no annotative style
|
||||
let ent = doc.add_entity(EntityType::MText(m)).unwrap();
|
||||
let ent = doc.add_entity(EntityType::MText(Box::new(m))).unwrap();
|
||||
|
||||
// Build xdict -> "AcDbContextDataManager" -> "ACDB_ANNOTATIONSCALES" (empty).
|
||||
let mk = |doc: &mut CadDocument, owner: Handle| -> Handle {
|
||||
@@ -92,7 +92,7 @@ fn ocs_synthesized_mtext_context_survives_dwg_roundtrip() {
|
||||
m.insertion_point = Vector3::new(100.0, 200.0, 0.0);
|
||||
m.rectangle_width = 50.0;
|
||||
m.is_annotative = true;
|
||||
let ent = doc.add_entity(EntityType::MText(m)).expect("add mtext");
|
||||
let ent = doc.add_entity(EntityType::MText(Box::new(m))).expect("add mtext");
|
||||
|
||||
let sh = doc.allocate_handle();
|
||||
let mut scale = Scale::new("1:50", 1.0, 50.0);
|
||||
@@ -174,7 +174,7 @@ fn object_scale_membership_add_remove_roundtrips() {
|
||||
let mut doc = CadDocument::with_version(DxfVersion::AC1032);
|
||||
let mut m = MText::new();
|
||||
m.insertion_point = Vector3::new(1.0, 2.0, 0.0);
|
||||
let ent = doc.add_entity(EntityType::MText(m)).unwrap();
|
||||
let ent = doc.add_entity(EntityType::MText(Box::new(m))).unwrap();
|
||||
|
||||
let mk_scale = |doc: &mut CadDocument, name: &str, d: f64| {
|
||||
let h = doc.allocate_handle();
|
||||
|
||||
@@ -75,7 +75,7 @@ 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 h = scene.add_entity(EntityType::Hatch(Box::new(square_hatch(5))));
|
||||
let identity = codec::types::Transform::identity();
|
||||
scene
|
||||
.create_block_from_entities(&[h], "LOGO", &identity, &identity)
|
||||
@@ -100,7 +100,7 @@ fn block_internal_hatch_reaches_export() {
|
||||
fn pattern_hatch_uses_stored_line_spacing() {
|
||||
let mut scene = Scene::new();
|
||||
// Spacing 0.5; a big pattern_scale (10) that the catalog path would apply.
|
||||
scene.add_entity(EntityType::Hatch(ansi31_stored(0.5, 10.0)));
|
||||
scene.add_entity(EntityType::Hatch(Box::new(ansi31_stored(0.5, 10.0))));
|
||||
scene.populate_hatches_from_document();
|
||||
|
||||
let hatches = scene.paper_plot_hatches();
|
||||
@@ -143,7 +143,7 @@ fn far_from_origin_pattern_hatch_still_fills() {
|
||||
// the perpendicular index is |k| ≈ 4000·sin45°/0.3 ≈ 9400, well past the
|
||||
// 4096 clamp on both ends; the old absolute-index clamp inverts the range
|
||||
// (k_lo > k_hi) there and emits nothing.
|
||||
scene.add_entity(EntityType::Hatch(ansi31_stored_at(0.3, 1.0, 4000.0, 0.0)));
|
||||
scene.add_entity(EntityType::Hatch(Box::new(ansi31_stored_at(0.3, 1.0, 4000.0, 0.0))));
|
||||
scene.populate_hatches_from_document();
|
||||
|
||||
let hatches = scene.paper_plot_hatches();
|
||||
@@ -188,7 +188,7 @@ fn textbox_boundary_path_is_not_filled() {
|
||||
let mut tb = rect_path(0.0, 0.0, 200.0, 50.0);
|
||||
tb.flags = BoundaryPathFlags::from_bits(8 | 1); // TEXTBOX + EXTERNAL
|
||||
hatch.paths.push(tb);
|
||||
scene.add_entity(EntityType::Hatch(hatch));
|
||||
scene.add_entity(EntityType::Hatch(Box::new(hatch)));
|
||||
scene.populate_hatches_from_document();
|
||||
|
||||
let hatches = scene.paper_plot_hatches();
|
||||
|
||||
@@ -28,7 +28,7 @@ fn copy_dimension_duplicates_its_block() {
|
||||
// A linear dimension whose drawn geometry is that baked block.
|
||||
let mut dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||
dim.base.block_name = "*D0".to_string();
|
||||
let dim_h = scene.add_entity(EntityType::Dimension(Dimension::Linear(dim)));
|
||||
let dim_h = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dim))));
|
||||
|
||||
// Copy the dimension by (0, 50).
|
||||
let copies = scene.copy_entities(
|
||||
|
||||
@@ -38,7 +38,7 @@ fn dim_leader_extends_only_when_requested() {
|
||||
base.insertion_point = base.text_middle_point;
|
||||
base.text_user_positioned = true;
|
||||
base.style_name = "Standard".into();
|
||||
let handle = scene.add_entity(EntityType::Dimension(dim));
|
||||
let handle = scene.add_entity(EntityType::Dimension(Box::new(dim)));
|
||||
for (code, value) in [
|
||||
(ov::DIMTMOVE, XDataValue::Integer16(movement)),
|
||||
(ov::DIMTXT, XDataValue::Real(3.5)),
|
||||
|
||||
@@ -70,7 +70,7 @@ fn dimension_scene(aci: i16) -> Scene {
|
||||
|
||||
let mut dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||
dim.base.block_name = "*D0".to_string();
|
||||
let h = scene.add_entity(EntityType::Dimension(Dimension::Linear(dim)));
|
||||
let h = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dim))));
|
||||
dov::set(
|
||||
&mut scene.document,
|
||||
h,
|
||||
|
||||
@@ -130,7 +130,7 @@ fn explode_dimension_linear_golden_segments() {
|
||||
let mut d = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(10.0, 0.0, 0.0));
|
||||
d.definition_point = Vector3::new(5.0, 3.0, 0.0);
|
||||
d.base.text_middle_point = Vector3::new(5.0, 5.0, 0.0);
|
||||
let pieces = explode_entity(&EntityType::Dimension(Dimension::Linear(d)), &doc);
|
||||
let pieces = explode_entity(&EntityType::Dimension(Box::new(Dimension::Linear(d))), &doc);
|
||||
// A baked linear dimension explodes to exactly 2 extension lines + 1
|
||||
// dimension line. The arrowheads bake as SOLIDs (see the unit test
|
||||
// `linear_dim_bakes_filled_arrowheads`), which is why the Lines count is
|
||||
|
||||
@@ -331,7 +331,7 @@ fn viewport_projection_clips_images_and_respects_frozen_and_nonplot_layers() {
|
||||
viewport.view_center = Vector3::new(20.0, 10.0, 0.0);
|
||||
viewport.id = 2;
|
||||
viewport.status.is_on = true;
|
||||
let handle = scene.add_entity(EntityType::Viewport(viewport));
|
||||
let handle = scene.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||
let (_, _, _, images) = scene.viewport_plot_fills();
|
||||
assert_eq!(images.len(), 1);
|
||||
let raster = Raster::from_pdf(&export(&[page(images)]), 0);
|
||||
|
||||
@@ -26,7 +26,7 @@ fn text_and_dim_reach_pdf_export() {
|
||||
// A linear dimension — its measurement value is synthesized as SDF text too,
|
||||
// and dimension text is what #385 was actually filed about.
|
||||
let dim = DimensionLinear::new(Vector3::new(0.0, 0.0, 0.0), Vector3::new(40.0, 0.0, 0.0));
|
||||
let dim_h = scene.add_entity(EntityType::Dimension(Dimension::Linear(dim)));
|
||||
let dim_h = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Linear(dim))));
|
||||
|
||||
let wires = scene.entity_wires();
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ fn expand_block_mtext(
|
||||
mtext.style = "SHOP".to_string();
|
||||
mtext.height = 20.0;
|
||||
mtext.rectangle_width = 0.0;
|
||||
let mut sub = EntityType::MText(mtext);
|
||||
let mut sub = EntityType::MText(Box::new(mtext));
|
||||
sub.common_mut().owner_handle = br_h;
|
||||
doc.add_entity(sub).unwrap();
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ fn viewport_projection_scales_wide_polyline_band_width() {
|
||||
viewport.view_center = Vector3::new(50.0, 0.0, 0.0);
|
||||
viewport.id = 2;
|
||||
viewport.status.is_on = true;
|
||||
scene.add_entity(EntityType::Viewport(viewport));
|
||||
scene.add_entity(EntityType::Viewport(Box::new(viewport)));
|
||||
|
||||
let (_paper, model) = scene.plot_wire_groups(None);
|
||||
let band = model
|
||||
|
||||
@@ -75,7 +75,7 @@ fn fit_all_reaches_an_entity_parked_far_from_the_rest() {
|
||||
#[test]
|
||||
fn fit_all_frames_a_hatch_only_drawing() {
|
||||
let mut scene = Scene::new();
|
||||
scene.add_entity(EntityType::Hatch(square_hatch(100.0, 200.0, 40.0)));
|
||||
scene.add_entity(EntityType::Hatch(Box::new(square_hatch(100.0, 200.0, 40.0))));
|
||||
|
||||
scene.fit_all();
|
||||
|
||||
@@ -103,7 +103,7 @@ fn fit_all_keeps_a_hatch_outside_the_wires_in_view() {
|
||||
}
|
||||
// The fill is the outermost thing in the drawing; the wires alone would
|
||||
// frame a 12 x 10 strip and leave it off screen.
|
||||
scene.add_entity(EntityType::Hatch(square_hatch(500.0, 500.0, 50.0)));
|
||||
scene.add_entity(EntityType::Hatch(Box::new(square_hatch(500.0, 500.0, 50.0))));
|
||||
|
||||
scene.fit_all();
|
||||
|
||||
|
||||
Reference in new issue
Block a user