forked from 1b-agent/opencadstudio-upstream
Fix diameter dimension grip and text alignment
This commit is contained in:
1 parent
ca0ee37d26
commit
1f71a70580
3 files changed
+177
-10
No files matched your search
@@ -2157,6 +2157,82 @@ 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
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
|
||||
let association_handle = self.document.objects.iter().find_map(|(handle, object)| {
|
||||
let ObjectType::Associative(object) = object else {
|
||||
return None;
|
||||
};
|
||||
|
||||
let AssociativeData::DimensionAssociation(association) = &object.data else {
|
||||
return None;
|
||||
};
|
||||
|
||||
(association.dimension == dimension).then_some(*handle)
|
||||
});
|
||||
|
||||
let Some(association_handle) = association_handle else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Resolve the radial source while the association is borrowed immutably.
|
||||
let angle = {
|
||||
let Some(ObjectType::Associative(object)) =
|
||||
self.document.objects.get(&association_handle)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let AssociativeData::DimensionAssociation(association) = &object.data else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(reference) = association.references[0].first() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(walked) = chain::walk_chain(&self.document, &reference.xrefs) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(entity) = self.document.get_entity(walked.entity) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(radial) = radial_source_for_marker(entity, reference.main_gs_marker) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(radial) = chain_map(self, &walked).map_radial(radial) else {
|
||||
return;
|
||||
};
|
||||
|
||||
radial.angle_at(dpoint(chord))
|
||||
};
|
||||
|
||||
let Some(ObjectType::Associative(object)) =
|
||||
self.document.objects.get_mut(&association_handle)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
let AssociativeData::DimensionAssociation(association) = &mut object.data else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Some(reference) = association.references[0].first_mut() else {
|
||||
return;
|
||||
};
|
||||
|
||||
reference.osnap_distance = angle;
|
||||
reference.osnap_point = chord;
|
||||
}
|
||||
}
|
||||
|
||||
/// Average displacement of the dimension's resolved definition points.
|
||||
|
||||
@@ -1399,6 +1399,7 @@ impl Scene {
|
||||
if let Some(entity) = self.document.get_entity_mut(handle) {
|
||||
view::dispatch::apply_grip(entity, grip_id, apply);
|
||||
}
|
||||
self.sync_diameter_association_angle(handle);
|
||||
if let Some((annotation_handle, old_landing)) = leader_landing_before {
|
||||
let new_landing = self.document.get_entity(handle).and_then(|entity| {
|
||||
let EntityType::Leader(leader) = entity else {
|
||||
|
||||
Reference in new issue
Block a user