fix: keep dimension text grips aligned during stretch

This commit is contained in:
gianlucafiore 2026-08-13 09:46:56 -03:00
commit 2da520de80
2 changed files with 268 additions and 2 deletions

View file

@ -1618,6 +1618,49 @@ impl OpenCADStudio {
annotation_scale_handle,
);
let mut entity_grips = dispatch::grips(contextual.as_ref());
// Dimension::grips() cannot see the document, so an automatic dimension
// text grip cannot resolve its real DIMSTYLE/annotation-scaled position
// there. Correct it here, where both the document and displayed annotation
// scale are available.
if let acadrust::EntityType::Dimension(dim) = contextual.as_ref() {
if matches!(
dim,
acadrust::entities::Dimension::Linear(_)
| acadrust::entities::Dimension::Aligned(_)
) && !dim.base().text_user_positioned
{
let anno_scale = annotation_scale_handle
.and_then(|handle| {
match self.tabs[i].scene.document.objects.get(&handle) {
Some(acadrust::objects::ObjectType::Scale(scale)) => Some(
scale.inverse_factor()
/ self.tabs[i].scene.annotation_scale_unit_factor(),
),
_ => None,
}
})
.unwrap_or(self.tabs[i].scene.annotation_scale as f64);
if let Some(position) =
crate::entities::dimension::dimension_text_grip_position(
dim,
&self.tabs[i].scene.document,
anno_scale,
)
{
// The text grip is the final native grip of Linear/Aligned dims.
// While the text is still automatic, make this a point/stretch grip
// rather than a midpoint-translate grip. That makes the first drag use
// the displayed automatic position as its absolute starting point instead
// of translating the stale DWG text_middle_point.
if let Some(text_grip) = entity_grips.last_mut() {
text_grip.world =
glam::DVec3::new(position.x, position.y, position.z);
text_grip.is_midpoint = false;
}
}
}
}
entity_grips.extend(crate::scene::model::solid_history::primitive_grips(
&self.tabs[i].scene.document,
handle,