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 <noreply@anthropic.com>
This commit is contained in:
1 parent
218150c76a
commit
e4d04ef132
87 files changed
+380
-269
No files matched your search
@@ -3248,7 +3248,7 @@ pub(crate) fn materialize_large_radial_text_position(
|
||||
let Some(EntityType::Dimension(dimension)) = document.get_entity(handle) else {
|
||||
return;
|
||||
};
|
||||
if !matches!(dimension, Dimension::LargeRadial(_)) || dimension.base().text_user_positioned {
|
||||
if !matches!(&**dimension, Dimension::LargeRadial(_)) || dimension.base().text_user_positioned {
|
||||
return;
|
||||
}
|
||||
let source = document.dim_styles.iter().find(|style| {
|
||||
@@ -3262,8 +3262,8 @@ pub(crate) fn materialize_large_radial_text_position(
|
||||
.map(|style| resolved_dimension_style(style, dimension, document))
|
||||
.map(|style| styled_dimension_text_position(dimension, &style, 1.0))
|
||||
.unwrap_or_else(|| dimension_text_pos_f64(dimension, None, 2.5, 1.0));
|
||||
if let Some(EntityType::Dimension(Dimension::LargeRadial(radial))) =
|
||||
document.get_entity_mut(handle)
|
||||
if let Some(Dimension::LargeRadial(radial)) =
|
||||
document.get_entity_mut(handle).and_then(as_dimension_mut)
|
||||
{
|
||||
radial.base.text_middle_point = position;
|
||||
}
|
||||
@@ -6491,7 +6491,7 @@ fn dimension_text_entity(
|
||||
}
|
||||
mtext.normal = base.normal;
|
||||
mtext.common = base.common.clone();
|
||||
return Some(EntityType::MText(mtext));
|
||||
return Some(EntityType::MText(Box::new(mtext)));
|
||||
}
|
||||
|
||||
let value = if style.is_some_and(|style| style.dimtxtdirection) {
|
||||
@@ -7150,7 +7150,7 @@ fn dimension_tolerance_entity(
|
||||
mtext.style = primary_style;
|
||||
mtext.attachment_point = codec::entities::AttachmentPoint::MiddleCenter;
|
||||
mtext.common = primary_common;
|
||||
return Some(EntityType::MText(mtext));
|
||||
return Some(EntityType::MText(Box::new(mtext)));
|
||||
}
|
||||
|
||||
let mut t = Text::with_value(tol, pos)
|
||||
@@ -9559,3 +9559,22 @@ mod layout_parity_tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The dimension an entity is, if it is one. The variant holds it boxed, so
|
||||
/// a pattern cannot reach into it; match on this instead.
|
||||
pub(crate) fn as_dimension(entity: &codec::EntityType) -> Option<&codec::entities::Dimension> {
|
||||
match entity {
|
||||
codec::EntityType::Dimension(dimension) => Some(dimension),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// [`as_dimension`], mutably.
|
||||
pub(crate) fn as_dimension_mut(
|
||||
entity: &mut codec::EntityType,
|
||||
) -> Option<&mut codec::entities::Dimension> {
|
||||
match entity {
|
||||
codec::EntityType::Dimension(dimension) => Some(dimension),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -620,7 +620,7 @@ fn dynamic_data_text(data: &DynamicBlockData) -> String {
|
||||
"{}; dependencies {}; parameters {}; distance multiplier {:.6}; angle {:.6}",
|
||||
value.action.element.name,
|
||||
value.action.dependencies.len(),
|
||||
value.action.parameter_ids.len(),
|
||||
value.action.action_ids.len(),
|
||||
value.offsets.distance_multiplier,
|
||||
value.offsets.angle_offset
|
||||
),
|
||||
@@ -628,14 +628,14 @@ fn dynamic_data_text(data: &DynamicBlockData) -> String {
|
||||
"{}; dependencies {}; parameters {}; connections {}",
|
||||
value.action.element.name,
|
||||
value.action.dependencies.len(),
|
||||
value.action.parameter_ids.len(),
|
||||
value.action.action_ids.len(),
|
||||
value.connections.len()
|
||||
),
|
||||
DynamicBlockData::RotateAction(value) | DynamicBlockData::ScaleAction(value) => format!(
|
||||
"{}; dependencies {}; parameters {}; base {:.6},{:.6},{:.6}; dependent {}",
|
||||
value.action.action.element.name,
|
||||
value.action.action.dependencies.len(),
|
||||
value.action.action.parameter_ids.len(),
|
||||
value.action.action.action_ids.len(),
|
||||
value.action.base_point.x,
|
||||
value.action.base_point.y,
|
||||
value.action.base_point.z,
|
||||
|
||||
@@ -676,7 +676,9 @@ pub fn adapt_mtext_paragraphs(
|
||||
ATab::Left(_) => TabKind::Left,
|
||||
ATab::Center(_) => TabKind::Center,
|
||||
ATab::Right(_) => TabKind::Right,
|
||||
ATab::Decimal(..) => TabKind::Decimal,
|
||||
ATab::Decimal(..) | ATab::DecimalWithCharacter { .. } => {
|
||||
TabKind::Decimal
|
||||
}
|
||||
};
|
||||
TabStop {
|
||||
position: ts.position() as f32 * entity_height,
|
||||
|
||||
@@ -158,6 +158,16 @@ pub trait TextContent {
|
||||
fn replace_text(&mut self, search: &str, rep: &str);
|
||||
}
|
||||
|
||||
/// Entity variants holding their entity boxed (MTEXT) dispatch through here.
|
||||
impl<T: TextContent + ?Sized> TextContent for Box<T> {
|
||||
fn text_content(&self) -> Option<String> {
|
||||
(**self).text_content()
|
||||
}
|
||||
fn replace_text(&mut self, search: &str, rep: &str) {
|
||||
(**self).replace_text(search, rep)
|
||||
}
|
||||
}
|
||||
|
||||
/// Human-readable variant name used by Quick Select / Select Similar
|
||||
/// filtering. Stable across releases — the strings here are the canonical
|
||||
/// type identifiers throughout the UI.
|
||||
|
||||
Reference in new issue
Block a user