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 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-16 09:17:01 +03:00
1 parent 218150c76a
commit e4d04ef132
87 files changed
+380 -269

No files matched your search

+1 -1
View File
@@ -322,7 +322,7 @@ pub fn supports_annotation_context(entity: &EntityType) -> bool {
| EntityType::Tolerance(_)
| EntityType::Hatch(_) => true,
EntityType::Dimension(dimension) => {
!matches!(dimension, codec::entities::Dimension::Arc(_))
!matches!(&**dimension, codec::entities::Dimension::Arc(_))
}
_ => false,
}
+2 -2
View File
@@ -788,7 +788,7 @@ mod tests {
dimension.base.block_name = "SVC_TARGET".to_string();
scene
.document
.add_entity(EntityType::Dimension(Dimension::Aligned(dimension)))
.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(dimension))))
.unwrap();
// A table's picture block and a block-valued cell, by handle.
@@ -894,7 +894,7 @@ mod tests {
dimension.base.block_name = "SVC_RENAMED".to_string();
scene
.document
.add_entity(EntityType::Dimension(Dimension::Aligned(dimension)))
.add_entity(EntityType::Dimension(Box::new(Dimension::Aligned(dimension))))
.unwrap();
let mut style = DimStyle::new("SVC_STYLE");
style.dimblk = target;
+2 -2
View File
@@ -479,7 +479,7 @@ impl Scene {
self.previous_view = Some(ViewSnapshot::Floating {
layout,
handle,
viewport: Box::new(viewport.clone()),
viewport: viewport.clone(),
});
return;
}
@@ -538,7 +538,7 @@ impl Scene {
});
return false;
}
let current = Box::new(current.clone());
let current = current.clone();
if let Some(EntityType::Viewport(destination)) =
self.document.get_entity_mut(handle)
{
+26 -22
View File
@@ -869,7 +869,7 @@ pub(crate) fn constraint_from_associative_dimension(
Some(ParametricRef::whole(*reference.xrefs.first()?))
};
let measurement = DrivingValue::Literal(dimension.measurement());
match dimension {
match &**dimension {
Dimension::Aligned(_) => Some((
ConstraintKind::Distance,
vec![point(0)?, point(1)?],
@@ -921,7 +921,7 @@ pub(crate) fn radial_extension_points(
let EntityType::Dimension(dimension_entity) = document.get_entity(dimension)? else {
return None;
};
let target_point = match dimension_entity {
let target_point = match &**dimension_entity {
Dimension::Radius(radius) => radius.definition_point,
Dimension::Diameter(diameter) => diameter.angle_vertex,
Dimension::LargeRadial(radial) => radial.chord_point,
@@ -1009,7 +1009,7 @@ impl Scene {
else {
return;
};
let radial_data = match dimension_entity {
let radial_data = match &**dimension_entity {
Dimension::Radius(radius) => Some((
radius.angle_vertex,
radius.measurement(),
@@ -1223,7 +1223,7 @@ impl Scene {
};
// Radial references identify a circle/arc and angle, rather than a vertex.
let radial_dimension = matches!(
dimension_entity,
&**dimension_entity,
Dimension::Radius(_) | Dimension::Diameter(_) | Dimension::LargeRadial(_)
);
if radial_dimension {
@@ -1383,7 +1383,7 @@ impl Scene {
let Some(EntityType::Dimension(entity)) = self.document.get_entity(dimension) else {
return Vec::new();
};
match entity {
match &**entity {
// A radial dimension's single reference describes the point where
// the leader meets the circle.
Dimension::Radius(radius) => vec![radius.definition_point],
@@ -1458,17 +1458,15 @@ impl Scene {
let measurement_supported = !association.trans_space
|| self.document.get_entity(dimension).is_some_and(|entity| {
matches!(
entity,
EntityType::Dimension(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
crate::entities::dimension::as_dimension(entity),
Some(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
) || persisted_measurement_scale(&self.document, entity).is_some()
});
let measurement_supported = measurement_supported
&& self.document.get_entity(dimension).is_some_and(|entity| {
if !matches!(
entity,
EntityType::Dimension(
Dimension::Radius(_) | Dimension::Diameter(_) | Dimension::LargeRadial(_)
)
crate::entities::dimension::as_dimension(entity),
Some(Dimension::Radius(_) | Dimension::Diameter(_) | Dimension::LargeRadial(_))
) {
return true;
}
@@ -1652,7 +1650,7 @@ impl Scene {
let Some(EntityType::Dimension(entity)) = self.document.get_entity(dimension) else {
return Vec::new();
};
let radial_data = match entity {
let radial_data = match &**entity {
Dimension::Radius(radius) => Some((
radius.angle_vertex,
radius.measurement(),
@@ -1850,8 +1848,8 @@ impl Scene {
continue;
};
let angular = matches!(
&before,
EntityType::Dimension(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
crate::entities::dimension::as_dimension(&before),
Some(Dimension::Angular2Ln(_) | Dimension::Angular3Pt(_))
);
let measurement_scale = if let Some(frame) = map.frame.filter(|_| !angular) {
let Some(mut scale) = persisted_measurement_scale(&self.document, &before) else {
@@ -1874,7 +1872,7 @@ impl Scene {
else {
continue;
};
match dimension {
match &mut **dimension {
Dimension::Linear(linear) => {
// The sheet annotation the user placed — the dimension
// line's standoff and, when they dragged it, the text — is
@@ -2104,7 +2102,7 @@ impl Scene {
arc.base.actual_measurement = arc.measurement();
}
}
let measurement = match &*dimension {
let measurement = match &**dimension {
Dimension::Linear(linear) => linear_measurement(linear),
_ => dimension.measurement(),
};
@@ -2155,8 +2153,12 @@ impl Scene {
refreshed
}
pub(crate) fn sync_diameter_association_angle(&mut self, dimension: Handle) {
let chord = match self.document.get_entity(dimension) {
Some(EntityType::Dimension(Dimension::Diameter(diameter))) => diameter.angle_vertex,
let chord = match self
.document
.get_entity(dimension)
.and_then(crate::entities::dimension::as_dimension)
{
Some(Dimension::Diameter(diameter)) => diameter.angle_vertex,
_ => return,
};
@@ -2247,9 +2249,9 @@ mod tests {
Vector3::ZERO,
5.0,
)));
let dimension = scene.add_entity(EntityType::Dimension(Dimension::Diameter(
let dimension = scene.add_entity(EntityType::Dimension(Box::new(Dimension::Diameter(
DimensionDiameter::new(Vector3::new(5.0, 0.0, 0.0), Vector3::new(-5.0, 0.0, 0.0)),
)));
))));
scene.attach_dimension_association(dimension, vec![Some(circle)]);
let association = scene
.document
@@ -2270,8 +2272,10 @@ mod tests {
.expect("diameter association");
scene.begin_undo_recording();
let Some(EntityType::Dimension(Dimension::Diameter(diameter))) =
scene.document.get_entity_mut(dimension)
let Some(Dimension::Diameter(diameter)) = scene
.document
.get_entity_mut(dimension)
.and_then(crate::entities::dimension::as_dimension_mut)
else {
panic!("diameter dimension");
};
+1 -1
View File
@@ -3206,7 +3206,7 @@ impl Scene {
if let Some(origin) = model.pattern_origin {
dxf.record_pattern_origin(Vector2::new(origin[0], origin[1]));
}
let mut entity = EntityType::Hatch(dxf);
let mut entity = EntityType::Hatch(Box::new(dxf));
if let Some(layer) = layer {
entity.as_entity_mut().set_layer(layer.to_string());
+3 -3
View File
@@ -64,10 +64,10 @@ impl Scene {
if let Some(EntityType::Viewport(sheet)) = self.document.get_entity(from.viewport).cloned()
{
if let Some(EntityType::Viewport(target)) = self.document.get_entity_mut(to.viewport) {
*target = codec::entities::Viewport {
*target = Box::new(codec::entities::Viewport {
common: target.common.clone(),
..sheet
};
..*sheet
});
}
}
self.unopened_layouts.remove(name);
+5 -5
View File
@@ -4956,7 +4956,7 @@ impl Scene {
fit_sheet_viewport(&mut vp, min_lim, max_lim);
if let Ok(handle) = self
.document
.add_entity_to_layout(EntityType::Viewport(vp), layout_name)
.add_entity_to_layout(EntityType::Viewport(Box::new(vp)), layout_name)
{
if let Some(ObjectType::Layout(l)) = self.document.objects.get_mut(&layout_handle) {
l.viewports.retain(|candidate| *candidate != handle);
@@ -5027,7 +5027,7 @@ impl Scene {
viewport.status = codec::entities::ViewportStatusFlags::default_on();
if let Ok(handle) = self
.document
.add_entity_to_layout(EntityType::Viewport(viewport), layout_name)
.add_entity_to_layout(EntityType::Viewport(Box::new(viewport)), layout_name)
{
// The reference zooms the new viewport to the model's extents
// with a margin of under one percent.
@@ -13802,7 +13802,7 @@ mod journal_tests {
let mut annotative = MText::new();
annotative.value = "annotative".to_string();
annotative.is_annotative = true;
let annotative = s.add_entity(EntityType::MText(annotative));
let annotative = s.add_entity(EntityType::MText(Box::new(annotative)));
let before_points = s.geometry_epoch;
s.invalidate_point_dependencies();
@@ -14117,7 +14117,7 @@ mod journal_tests {
scene.document.layers.add_or_replace(Layer::new("Shadows"));
let mut hatch = Hatch::new();
hatch.common.layer = "Shadows".to_string();
let handle = scene.add_entity(EntityType::Hatch(hatch));
let handle = scene.add_entity(EntityType::Hatch(Box::new(hatch)));
let model = scene.model_space_block_handle();
assert_eq!(
scene
@@ -15447,7 +15447,7 @@ mod layout_cache_tests {
vp.height = 100.0;
let handle = scene
.document
.add_entity_to_layout(codec::EntityType::Viewport(vp), "P1")
.add_entity_to_layout(codec::EntityType::Viewport(Box::new(vp)), "P1")
.unwrap();
assert!(scene.set_viewport_scale_named_for(handle, "1:50").is_some());
assert!(scene.active_viewport.is_none());
+2 -2
View File
@@ -285,7 +285,7 @@ mod viewport_zoom_tests {
viewport.width = 100.0;
viewport.height = 100.0;
viewport.view_height = 200.0;
let handle = scene.add_entity(EntityType::Viewport(viewport));
let handle = scene.add_entity(EntityType::Viewport(Box::new(viewport)));
scene.active_viewport = Some(handle);
let view_height = |scene: &Scene| match scene.document.get_entity(handle) {
@@ -337,7 +337,7 @@ mod clip_tests {
viewport.height = 20.0;
viewport.clip_boundary_handle = clip;
viewport.status.non_rectangular_clipping = true;
let viewport = scene.add_entity(EntityType::Viewport(viewport));
let viewport = scene.add_entity(EntityType::Viewport(Box::new(viewport)));
for (x, y, inside) in [
(2.0, 2.0, true),
(8.0, 2.0, true),
+15 -11
View File
@@ -696,7 +696,7 @@ fn dynamic_dimension_follow_points(
target.attachment_point = base.attachment_point;
target.line_spacing_style = base.line_spacing_style;
target.line_spacing_factor = base.line_spacing_factor;
*dimension = rebuilt;
*dimension = *rebuilt;
true
}
@@ -794,7 +794,7 @@ fn dynamic_dimension_follow_radial(
let Some(codec::EntityType::Dimension(mut rebuilt)) = rebuilt else {
return false;
};
let unchanged = match (&*dimension, &rebuilt) {
let unchanged = match (&*dimension, &*rebuilt) {
(Dimension::Radius(old), Dimension::Radius(new)) => {
same(old.angle_vertex, new.angle_vertex)
&& same(old.definition_point, new.definition_point)
@@ -808,7 +808,7 @@ fn dynamic_dimension_follow_radial(
if unchanged {
return false;
}
match &mut rebuilt {
match &mut *rebuilt {
Dimension::Radius(new) => new.leader_length = leader,
Dimension::Diameter(new) => new.leader_length = leader,
_ => {}
@@ -821,7 +821,7 @@ fn dynamic_dimension_follow_radial(
target.attachment_point = base.attachment_point;
target.line_spacing_style = base.line_spacing_style;
target.line_spacing_factor = base.line_spacing_factor;
*dimension = rebuilt;
*dimension = *rebuilt;
true
}
@@ -881,7 +881,7 @@ fn dynamic_dimension_follow_angle(
target.attachment_point = base.attachment_point;
target.line_spacing_style = base.line_spacing_style;
target.line_spacing_factor = base.line_spacing_factor;
*dimension = rebuilt;
*dimension = *rebuilt;
true
}
@@ -2264,10 +2264,14 @@ impl super::Scene {
});
let measured = points.filter(|_| !angular).map(|(first, second)| {
let delta = second - first;
let axis = match self.document.get_entity(*dimension) {
Some(codec::EntityType::Dimension(codec::entities::Dimension::Linear(
linear,
))) => Some((linear.rotation.cos(), linear.rotation.sin())),
let axis = match self
.document
.get_entity(*dimension)
.and_then(crate::entities::dimension::as_dimension)
{
Some(codec::entities::Dimension::Linear(linear)) => {
Some((linear.rotation.cos(), linear.rotation.sin()))
}
_ => None,
};
match (constraint.kind, axis) {
@@ -2605,7 +2609,7 @@ impl super::Scene {
// line, which breaks around the text, so the text is centred on
// it rather than lifted above it.
let radial = matches!(
dimension,
&**dimension,
codec::entities::Dimension::Radius(_) | codec::entities::Dimension::Diameter(_)
);
let centred = !radial || ov::int(xdata, ov::DIMTAD) == Some(0);
@@ -2615,7 +2619,7 @@ impl super::Scene {
// The reference draws dynamic distance text horizontally; an
// angle's text keeps its style's alignment.
let angular = matches!(
dimension,
&**dimension,
codec::entities::Dimension::Angular2Ln(_)
| codec::entities::Dimension::Angular3Pt(_)
);
+2 -2
View File
@@ -16,7 +16,7 @@ impl Scene {
let viewports: Vec<&Viewport> = viewport_handles
.iter()
.filter_map(|handle| match self.document.get_entity(*handle) {
Some(EntityType::Viewport(vp)) => Some(vp),
Some(EntityType::Viewport(vp)) => Some(&**vp),
_ => None,
})
.filter(|vp| {
@@ -446,7 +446,7 @@ impl Scene {
Some(EntityType::Viewport(viewport))
if viewport.common.owner_handle == paper_block && viewport.is_on() =>
{
Some(viewport)
Some(&**viewport)
}
_ => None,
})