Add (not yet used) private interface to modify joints without segment, via updates

This commit is contained in:
Mikolaj Wielgus 2026-05-18 21:09:47 +02:00
parent 618905f56d
commit 79f859f8cb
1 changed files with 16 additions and 8 deletions

View File

@ -147,15 +147,8 @@ impl Layout {
where where
F: FnOnce(&mut JointSpec), F: FnOnce(&mut JointSpec),
{ {
let old_joint = self.joints.get(&id.index()).unwrap(); self.modify_joint_raw(id, |joint| f(&mut joint.spec));
self.joints_rtree
.remove(&GeomWithData::new(old_joint.bbox(), id));
self.joints.modify(id.index(), |joint| f(&mut joint.spec));
let new_joint = self.joints.get(&id.index()).unwrap().clone(); let new_joint = self.joints.get(&id.index()).unwrap().clone();
self.joints_rtree
.insert(GeomWithData::new(new_joint.bbox(), id), ());
for &segment in &new_joint.segments { for &segment in &new_joint.segments {
self.update_segment(segment); self.update_segment(segment);
@ -166,6 +159,21 @@ impl Layout {
} }
} }
fn modify_joint_raw<F>(&mut self, id: JointId, f: F)
where
F: FnOnce(&mut Joint),
{
let old_joint = self.joints.get(&id.index()).unwrap();
self.joints_rtree
.remove(&GeomWithData::new(old_joint.bbox(), id));
self.joints.modify(id.index(), |joint| f(joint));
let new_joint = self.joints.get(&id.index()).unwrap().clone();
self.joints_rtree
.insert(GeomWithData::new(new_joint.bbox(), id), ());
}
pub fn add_segment(&mut self, spec: SegmentSpec) -> SegmentId { pub fn add_segment(&mut self, spec: SegmentSpec) -> SegmentId {
self.add_segment_raw(Segment { self.add_segment_raw(Segment {
spec, spec,