refactor(drawing,geometry): separate RecordingDrawing, RecordingWithRtree as mutable borrowing wrappers

This commit is contained in:
Alain Emilia Anna Zscheile 2025-01-03 03:15:43 +01:00
parent 9c007a8ccb
commit 3b47c4a30e
4 changed files with 945 additions and 979 deletions

File diff suppressed because it is too large Load Diff

View File

@ -23,8 +23,9 @@ use super::{
}; };
#[derive(Debug)] #[derive(Debug)]
pub struct RecordingGeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI> { pub struct RecordingGeometryWithRtree<'a, PW, DW, SW, BW, CW, PI, DI, SI, BI> {
geometry_with_rtree: GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>, pub geometry_with_rtree: &'a mut GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
pub recorder: &'a mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
} }
impl< impl<
@ -37,26 +38,14 @@ impl<
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy, DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy, SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy, BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
> RecordingGeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI> > RecordingGeometryWithRtree<'_, PW, DW, SW, BW, CW, PI, DI, SI, BI>
{ {
pub fn new(layer_count: usize) -> Self { pub fn add_dot<W: AccessDotWeight<PW> + GetLayer>(&mut self, weight: W) -> GenericIndex<W>
Self {
geometry_with_rtree: GeometryWithRtree::<PW, DW, SW, BW, CW, PI, DI, SI, BI>::new(
layer_count,
),
}
}
pub fn add_dot<W: AccessDotWeight<PW> + GetLayer>(
&mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
weight: W,
) -> GenericIndex<W>
where where
GenericIndex<W>: Into<PI>, GenericIndex<W>: Into<PI>,
{ {
let dot = self.geometry_with_rtree.add_dot(weight); let dot = self.geometry_with_rtree.add_dot(weight);
recorder.dots.insert( self.recorder.dots.insert(
Into::<PI>::into(dot) Into::<PI>::into(dot)
.try_into() .try_into()
.unwrap_or_else(|_| unreachable!()), .unwrap_or_else(|_| unreachable!()),
@ -70,7 +59,6 @@ impl<
pub fn add_seg<W: AccessSegWeight<PW> + GetLayer>( pub fn add_seg<W: AccessSegWeight<PW> + GetLayer>(
&mut self, &mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
from: DI, from: DI,
to: DI, to: DI,
weight: W, weight: W,
@ -79,7 +67,7 @@ impl<
GenericIndex<W>: Into<PI>, GenericIndex<W>: Into<PI>,
{ {
let seg = self.geometry_with_rtree.add_seg(from, to, weight); let seg = self.geometry_with_rtree.add_seg(from, to, weight);
recorder.segs.insert( self.recorder.segs.insert(
Into::<PI>::into(seg) Into::<PI>::into(seg)
.try_into() .try_into()
.unwrap_or_else(|_| unreachable!()), .unwrap_or_else(|_| unreachable!()),
@ -96,7 +84,6 @@ impl<
pub fn add_bend<W: AccessBendWeight<PW> + GetLayer>( pub fn add_bend<W: AccessBendWeight<PW> + GetLayer>(
&mut self, &mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
from: DI, from: DI,
to: DI, to: DI,
core: DI, core: DI,
@ -106,7 +93,7 @@ impl<
GenericIndex<W>: Into<PI>, GenericIndex<W>: Into<PI>,
{ {
let bend = self.geometry_with_rtree.add_bend(from, to, core, weight); let bend = self.geometry_with_rtree.add_bend(from, to, core, weight);
recorder.bends.insert( self.recorder.bends.insert(
Into::<PI>::into(bend) Into::<PI>::into(bend)
.try_into() .try_into()
.unwrap_or_else(|_| unreachable!()), .unwrap_or_else(|_| unreachable!()),
@ -121,24 +108,15 @@ impl<
bend bend
} }
pub fn add_compound( pub fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> {
&mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
weight: CW,
) -> GenericIndex<CW> {
let compound = self.geometry_with_rtree.add_compound(weight); let compound = self.geometry_with_rtree.add_compound(weight);
recorder self.recorder
.compounds .compounds
.insert(compound, (None, Some((vec![], weight)))); .insert(compound, (None, Some((vec![], weight))));
compound compound
} }
pub fn add_to_compound<W>( pub fn add_to_compound<W>(&mut self, primitive: GenericIndex<W>, compound: GenericIndex<CW>) {
&mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
primitive: GenericIndex<W>,
compound: GenericIndex<CW>,
) {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
let old_members = geometry.compound_members(compound).collect(); let old_members = geometry.compound_members(compound).collect();
let old_weight = geometry.compound_weight(compound); let old_weight = geometry.compound_weight(compound);
@ -150,88 +128,63 @@ impl<
let new_members = geometry.compound_members(compound).collect(); let new_members = geometry.compound_members(compound).collect();
let new_weight = geometry.compound_weight(compound); let new_weight = geometry.compound_weight(compound);
recorder self.recorder
.compounds .compounds
.entry(compound) .entry(compound)
.or_insert((Some((old_members, old_weight)), None)) .or_insert((Some((old_members, old_weight)), None))
.1 = Some((new_members, new_weight)); .1 = Some((new_members, new_weight));
} }
pub fn remove_dot( pub fn remove_dot(&mut self, dot: DI) -> Result<(), ()> {
&mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
dot: DI,
) -> Result<(), ()> {
let weight = self.geometry_with_rtree.geometry().dot_weight(dot); let weight = self.geometry_with_rtree.geometry().dot_weight(dot);
self.geometry_with_rtree.remove_dot(dot)?; self.geometry_with_rtree.remove_dot(dot)?;
edit_remove_from_map(&mut recorder.dots, dot, weight); edit_remove_from_map(&mut self.recorder.dots, dot, weight);
Ok(()) Ok(())
} }
pub fn remove_seg( pub fn remove_seg(&mut self, seg: SI) {
&mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
seg: SI,
) {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
let weight = geometry.seg_weight(seg); let weight = geometry.seg_weight(seg);
let joints = geometry.seg_joints(seg); let joints = geometry.seg_joints(seg);
self.geometry_with_rtree.remove_seg(seg); self.geometry_with_rtree.remove_seg(seg);
edit_remove_from_map(&mut recorder.segs, seg, (joints, weight)); edit_remove_from_map(&mut self.recorder.segs, seg, (joints, weight));
} }
pub fn remove_bend( pub fn remove_bend(&mut self, bend: BI) {
&mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
bend: BI,
) {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
let weight = geometry.bend_weight(bend); let weight = geometry.bend_weight(bend);
let joints = geometry.bend_joints(bend); let joints = geometry.bend_joints(bend);
let core = geometry.core(bend); let core = geometry.core(bend);
self.geometry_with_rtree.remove_bend(bend); self.geometry_with_rtree.remove_bend(bend);
edit_remove_from_map( edit_remove_from_map(
&mut recorder.bends, &mut self.recorder.bends,
bend, bend,
((joints.0, joints.1, core), weight), ((joints.0, joints.1, core), weight),
); );
} }
pub fn remove_compound( pub fn remove_compound(&mut self, compound: GenericIndex<CW>) {
&mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
compound: GenericIndex<CW>,
) {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
let weight = geometry.compound_weight(compound); let weight = geometry.compound_weight(compound);
let members = geometry.compound_members(compound).collect(); let members = geometry.compound_members(compound).collect();
self.geometry_with_rtree.remove_compound(compound); self.geometry_with_rtree.remove_compound(compound);
edit_remove_from_map(&mut recorder.compounds, compound, (members, weight)); edit_remove_from_map(&mut self.recorder.compounds, compound, (members, weight));
} }
pub fn move_dot( pub fn move_dot(&mut self, dot: DI, to: Point) {
&mut self,
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
dot: DI,
to: Point,
) {
let old_weight = self.geometry_with_rtree.geometry().dot_weight(dot); let old_weight = self.geometry_with_rtree.geometry().dot_weight(dot);
self.geometry_with_rtree.move_dot(dot, to); self.geometry_with_rtree.move_dot(dot, to);
let new_weight = self.geometry_with_rtree.geometry().dot_weight(dot); let new_weight = self.geometry_with_rtree.geometry().dot_weight(dot);
recorder self.recorder
.dots .dots
.entry(dot) .entry(dot)
.or_insert((Some(old_weight), None)) .or_insert((Some(old_weight), None))
.1 = Some(new_weight); .1 = Some(new_weight);
} }
fn modify_bend<F>( fn modify_bend<F>(&mut self, bend: BI, f: F)
&mut self, where
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
bend: BI,
f: F,
) where
F: FnOnce(&mut GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>, BI), F: FnOnce(&mut GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>, BI),
{ {
let geometry = self.geometry_with_rtree.geometry(); let geometry = self.geometry_with_rtree.geometry();
@ -246,7 +199,7 @@ impl<
let new_core = geometry.core(bend); let new_core = geometry.core(bend);
let new_weight = geometry.bend_weight(bend); let new_weight = geometry.bend_weight(bend);
recorder self.recorder
.bends .bends
.entry(bend) .entry(bend)
.or_insert(( .or_insert((
@ -256,34 +209,20 @@ impl<
.1 = Some(((new_joints.0, new_joints.1, new_core), new_weight)); .1 = Some(((new_joints.0, new_joints.1, new_core), new_weight));
} }
pub fn shift_bend( pub fn shift_bend(&mut self, bend: BI, offset: f64) {
&mut self, self.modify_bend(bend, |geometry_with_rtree, bend| {
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
bend: BI,
offset: f64,
) {
self.modify_bend(recorder, bend, |geometry_with_rtree, bend| {
geometry_with_rtree.shift_bend(bend, offset) geometry_with_rtree.shift_bend(bend, offset)
}); });
} }
pub fn flip_bend( pub fn flip_bend(&mut self, bend: BI) {
&mut self, self.modify_bend(bend, |geometry_with_rtree, bend| {
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
bend: BI,
) {
self.modify_bend(recorder, bend, |geometry_with_rtree, bend| {
geometry_with_rtree.flip_bend(bend) geometry_with_rtree.flip_bend(bend)
}); });
} }
pub fn reattach_bend( pub fn reattach_bend(&mut self, bend: BI, maybe_new_inner: Option<BI>) {
&mut self, self.modify_bend(bend, |geometry_with_rtree, bend| {
recorder: &mut GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
bend: BI,
maybe_new_inner: Option<BI>,
) {
self.modify_bend(recorder, bend, |geometry_with_rtree, bend| {
geometry_with_rtree.reattach_bend(bend, maybe_new_inner) geometry_with_rtree.reattach_bend(bend, maybe_new_inner)
}); });
} }
@ -299,6 +238,10 @@ impl<
self.geometry_with_rtree.compounds(node) self.geometry_with_rtree.compounds(node)
} }
pub fn recorder(&self) -> &GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
&*self.recorder
}
pub fn geometry(&self) -> &Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI> { pub fn geometry(&self) -> &Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
self.geometry_with_rtree.geometry() self.geometry_with_rtree.geometry()
} }
@ -349,65 +292,10 @@ impl<
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy, SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy, BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
> ApplyGeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI> > ApplyGeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>
for RecordingGeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI> for RecordingGeometryWithRtree<'_, PW, DW, SW, BW, CW, PI, DI, SI, BI>
{ {
#[inline(always)]
fn apply(&mut self, edit: &GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>) { fn apply(&mut self, edit: &GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>) {
for (compound, (maybe_old_data, ..)) in &edit.compounds { self.geometry_with_rtree.apply(edit)
if maybe_old_data.is_some() {
self.geometry_with_rtree.remove_compound(*compound);
}
}
for (bend, (maybe_old_data, ..)) in &edit.bends {
if maybe_old_data.is_some() {
self.geometry_with_rtree.remove_bend(*bend);
}
}
for (seg, (maybe_old_data, ..)) in &edit.segs {
if maybe_old_data.is_some() {
self.geometry_with_rtree.remove_seg(*seg);
}
}
for (dot, (maybe_old_data, ..)) in &edit.dots {
if maybe_old_data.is_some() {
self.geometry_with_rtree.remove_dot(*dot);
}
}
for (dot, (.., maybe_new_data)) in &edit.dots {
if let Some(weight) = maybe_new_data {
self.geometry_with_rtree.add_dot_at_index(*dot, *weight);
}
}
for (seg, (.., maybe_new_data)) in &edit.segs {
if let Some(((from, to), weight)) = maybe_new_data {
self.geometry_with_rtree
.add_seg_at_index(*seg, *from, *to, *weight);
}
}
for (bend, (.., maybe_new_data)) in &edit.bends {
if let Some(((from, to, core), weight)) = maybe_new_data {
self.geometry_with_rtree
.add_bend_at_index(*bend, *from, *to, *core, *weight);
}
}
for (compound, (.., maybe_new_data)) in &edit.compounds {
if let Some((members, weight)) = maybe_new_data {
self.geometry_with_rtree
.add_compound_at_index(*compound, *weight);
for member in members {
self.geometry_with_rtree.add_to_compound(
GenericIndex::<PW>::new(member.petgraph_index()),
*compound,
);
}
}
}
} }
} }

View File

@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
use contracts_try::debug_invariant; use contracts_try::debug_invariant;
use core::hash::Hash;
use derive_getters::Getters; use derive_getters::Getters;
use geo::Point; use geo::Point;
use petgraph::stable_graph::StableDiGraph; use petgraph::stable_graph::StableDiGraph;
@ -12,6 +13,7 @@ use crate::{
drawing::graph::{GetLayer, Retag}, drawing::graph::{GetLayer, Retag},
geometry::{ geometry::{
compound::ManageCompounds, compound::ManageCompounds,
edit::{ApplyGeometryEdit, GeometryEdit},
primitive::{AccessPrimitiveShape, PrimitiveShape}, primitive::{AccessPrimitiveShape, PrimitiveShape},
AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel, AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel,
GetWidth, GetWidth,
@ -68,6 +70,28 @@ impl<
} }
} }
#[inline(always)]
pub fn recording<'a>(
&'a mut self,
recorder: &'a mut super::edit::GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
) -> super::recording_with_rtree::RecordingGeometryWithRtree<
'a,
PW,
DW,
SW,
BW,
CW,
PI,
DI,
SI,
BI,
> {
super::recording_with_rtree::RecordingGeometryWithRtree {
geometry_with_rtree: self,
recorder,
}
}
pub fn add_dot<W: AccessDotWeight<PW> + GetLayer>(&mut self, weight: W) -> GenericIndex<W> pub fn add_dot<W: AccessDotWeight<PW> + GetLayer>(&mut self, weight: W) -> GenericIndex<W>
where where
GenericIndex<W>: Into<PI>, GenericIndex<W>: Into<PI>,
@ -424,3 +448,74 @@ impl<
self.geometry.compounds(node) self.geometry.compounds(node)
} }
} }
impl<
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: AccessDotWeight<PW> + GetLayer,
SW: AccessSegWeight<PW> + GetLayer,
BW: AccessBendWeight<PW> + GetLayer,
CW: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
> ApplyGeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>
for GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>
{
fn apply(&mut self, edit: &GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI>) {
for (compound, (maybe_old_data, ..)) in &edit.compounds {
if maybe_old_data.is_some() {
self.remove_compound(*compound);
}
}
for (bend, (maybe_old_data, ..)) in &edit.bends {
if maybe_old_data.is_some() {
self.remove_bend(*bend);
}
}
for (seg, (maybe_old_data, ..)) in &edit.segs {
if maybe_old_data.is_some() {
self.remove_seg(*seg);
}
}
for (dot, (maybe_old_data, ..)) in &edit.dots {
if maybe_old_data.is_some() {
self.remove_dot(*dot);
}
}
for (dot, (.., maybe_new_data)) in &edit.dots {
if let Some(weight) = maybe_new_data {
self.add_dot_at_index(*dot, *weight);
}
}
for (seg, (.., maybe_new_data)) in &edit.segs {
if let Some(((from, to), weight)) = maybe_new_data {
self.add_seg_at_index(*seg, *from, *to, *weight);
}
}
for (bend, (.., maybe_new_data)) in &edit.bends {
if let Some(((from, to, core), weight)) = maybe_new_data {
self.add_bend_at_index(*bend, *from, *to, *core, *weight);
}
}
for (compound, (.., maybe_new_data)) in &edit.compounds {
if let Some((members, weight)) = maybe_new_data {
self.add_compound_at_index(*compound, *weight);
for member in members {
self.add_to_compound(
GenericIndex::<PW>::new(member.petgraph_index()),
*compound,
);
}
}
}
}
}

View File

@ -70,8 +70,7 @@ impl<R: AccessRules> Layout<R> {
bend_weight: LooseBendWeight, bend_weight: LooseBendWeight,
cw: bool, cw: bool,
) -> Result<Cane, DrawingException> { ) -> Result<Cane, DrawingException> {
self.drawing.insert_cane( self.drawing.recording(recorder).insert_cane(
recorder,
from, from,
around, around,
dot_weight, dot_weight,
@ -83,7 +82,7 @@ impl<R: AccessRules> Layout<R> {
/// Remove [`Cane`] object from the [`Layout`] /// Remove [`Cane`] object from the [`Layout`]
pub fn remove_cane(&mut self, recorder: &mut LayoutEdit, cane: &Cane, face: LooseDotIndex) { pub fn remove_cane(&mut self, recorder: &mut LayoutEdit, cane: &Cane, face: LooseDotIndex) {
self.drawing.remove_cane(recorder, cane, face) self.drawing.recording(recorder).remove_cane(cane, face)
} }
#[debug_ensures(ret.is_ok() -> self.drawing.node_count() == old(self.drawing.node_count()) + weight.to_layer - weight.from_layer + 2)] #[debug_ensures(ret.is_ok() -> self.drawing.node_count() == old(self.drawing.node_count()) + weight.to_layer - weight.from_layer + 2)]
@ -94,29 +93,31 @@ impl<R: AccessRules> Layout<R> {
recorder: &mut LayoutEdit, recorder: &mut LayoutEdit,
weight: ViaWeight, weight: ViaWeight,
) -> Result<GenericIndex<ViaWeight>, Infringement> { ) -> Result<GenericIndex<ViaWeight>, Infringement> {
let compound = self.drawing.add_compound(recorder, weight.into()); let compound = self.drawing.recording(recorder).add_compound(weight.into());
let mut dots = vec![]; let mut dots = vec![];
for layer in weight.from_layer..=weight.to_layer { for layer in weight.from_layer..=weight.to_layer {
match self.drawing.add_fixed_dot( match self
recorder, .drawing
FixedDotWeight { .recording(recorder)
.add_fixed_dot(FixedDotWeight {
circle: weight.circle, circle: weight.circle,
layer, layer,
maybe_net: weight.maybe_net, maybe_net: weight.maybe_net,
}, }) {
) {
Ok(dot) => { Ok(dot) => {
self.drawing.add_to_compound(recorder, dot, compound); self.drawing
.recording(recorder)
.add_to_compound(dot, compound);
dots.push(dot); dots.push(dot);
} }
Err(err) => { Err(err) => {
// Remove inserted dots. // Remove inserted dots.
self.drawing.remove_compound(recorder, compound); self.drawing.recording(recorder).remove_compound(compound);
for dot in dots.iter().rev() { for dot in dots.iter().rev() {
self.drawing.remove_fixed_dot(recorder, *dot); self.drawing.recording(recorder).remove_fixed_dot(*dot);
} }
return Err(err); return Err(err);
@ -132,7 +133,7 @@ impl<R: AccessRules> Layout<R> {
recorder: &mut LayoutEdit, recorder: &mut LayoutEdit,
weight: FixedDotWeight, weight: FixedDotWeight,
) -> Result<FixedDotIndex, Infringement> { ) -> Result<FixedDotIndex, Infringement> {
self.drawing.add_fixed_dot(recorder, weight) self.drawing.recording(recorder).add_fixed_dot(weight)
} }
pub fn add_fixed_dot_infringably( pub fn add_fixed_dot_infringably(
@ -140,7 +141,9 @@ impl<R: AccessRules> Layout<R> {
recorder: &mut LayoutEdit, recorder: &mut LayoutEdit,
weight: FixedDotWeight, weight: FixedDotWeight,
) -> FixedDotIndex { ) -> FixedDotIndex {
self.drawing.add_fixed_dot_infringably(recorder, weight) self.drawing
.recording(recorder)
.add_fixed_dot_infringably(weight)
} }
pub fn add_poly_fixed_dot( pub fn add_poly_fixed_dot(
@ -149,10 +152,12 @@ impl<R: AccessRules> Layout<R> {
weight: FixedDotWeight, weight: FixedDotWeight,
poly: GenericIndex<PolyWeight>, poly: GenericIndex<PolyWeight>,
) -> Result<FixedDotIndex, Infringement> { ) -> Result<FixedDotIndex, Infringement> {
let maybe_dot = self.drawing.add_fixed_dot(recorder, weight); let maybe_dot = self.drawing.recording(recorder).add_fixed_dot(weight);
if let Ok(dot) = maybe_dot { if let Ok(dot) = maybe_dot {
self.drawing.add_to_compound(recorder, dot, poly.into()); self.drawing
.recording(recorder)
.add_to_compound(dot, poly.into());
} }
maybe_dot maybe_dot
@ -164,8 +169,13 @@ impl<R: AccessRules> Layout<R> {
weight: FixedDotWeight, weight: FixedDotWeight,
poly: GenericIndex<PolyWeight>, poly: GenericIndex<PolyWeight>,
) -> FixedDotIndex { ) -> FixedDotIndex {
let dot = self.drawing.add_fixed_dot_infringably(recorder, weight); let dot = self
self.drawing.add_to_compound(recorder, dot, poly.into()); .drawing
.recording(recorder)
.add_fixed_dot_infringably(weight);
self.drawing
.recording(recorder)
.add_to_compound(dot, poly.into());
dot dot
} }
@ -176,7 +186,9 @@ impl<R: AccessRules> Layout<R> {
to: FixedDotIndex, to: FixedDotIndex,
weight: FixedSegWeight, weight: FixedSegWeight,
) -> Result<FixedSegIndex, Infringement> { ) -> Result<FixedSegIndex, Infringement> {
self.drawing.add_fixed_seg(recorder, from, to, weight) self.drawing
.recording(recorder)
.add_fixed_seg(from, to, weight)
} }
pub fn add_fixed_seg_infringably( pub fn add_fixed_seg_infringably(
@ -187,7 +199,8 @@ impl<R: AccessRules> Layout<R> {
weight: FixedSegWeight, weight: FixedSegWeight,
) -> FixedSegIndex { ) -> FixedSegIndex {
self.drawing self.drawing
.add_fixed_seg_infringably(recorder, from, to, weight) .recording(recorder)
.add_fixed_seg_infringably(from, to, weight)
} }
pub fn add_poly_fixed_seg( pub fn add_poly_fixed_seg(
@ -201,7 +214,9 @@ impl<R: AccessRules> Layout<R> {
let maybe_seg = self.add_fixed_seg(recorder, from, to, weight); let maybe_seg = self.add_fixed_seg(recorder, from, to, weight);
if let Ok(seg) = maybe_seg { if let Ok(seg) = maybe_seg {
self.drawing.add_to_compound(recorder, seg, poly.into()); self.drawing
.recording(recorder)
.add_to_compound(seg, poly.into());
} }
maybe_seg maybe_seg
@ -216,7 +231,9 @@ impl<R: AccessRules> Layout<R> {
poly: GenericIndex<PolyWeight>, poly: GenericIndex<PolyWeight>,
) -> FixedSegIndex { ) -> FixedSegIndex {
let seg = self.add_fixed_seg_infringably(recorder, from, to, weight); let seg = self.add_fixed_seg_infringably(recorder, from, to, weight);
self.drawing.add_to_compound(recorder, seg, poly.into()); self.drawing
.recording(recorder)
.add_to_compound(seg, poly.into());
seg seg
} }
@ -227,7 +244,9 @@ impl<R: AccessRules> Layout<R> {
to: FixedDotIndex, to: FixedDotIndex,
weight: LoneLooseSegWeight, weight: LoneLooseSegWeight,
) -> Result<LoneLooseSegIndex, Infringement> { ) -> Result<LoneLooseSegIndex, Infringement> {
self.drawing.add_lone_loose_seg(recorder, from, to, weight) self.drawing
.recording(recorder)
.add_lone_loose_seg(from, to, weight)
} }
pub fn add_seq_loose_seg( pub fn add_seq_loose_seg(
@ -237,7 +256,9 @@ impl<R: AccessRules> Layout<R> {
to: LooseDotIndex, to: LooseDotIndex,
weight: SeqLooseSegWeight, weight: SeqLooseSegWeight,
) -> Result<SeqLooseSegIndex, Infringement> { ) -> Result<SeqLooseSegIndex, Infringement> {
self.drawing.add_seq_loose_seg(recorder, from, to, weight) self.drawing
.recording(recorder)
.add_seq_loose_seg(from, to, weight)
} }
pub fn move_dot( pub fn move_dot(
@ -246,7 +267,7 @@ impl<R: AccessRules> Layout<R> {
dot: DotIndex, dot: DotIndex,
to: Point, to: Point,
) -> Result<(), Infringement> { ) -> Result<(), Infringement> {
self.drawing.move_dot(recorder, dot, to) self.drawing.recording(recorder).move_dot(dot, to)
} }
pub fn add_poly( pub fn add_poly(
@ -256,7 +277,8 @@ impl<R: AccessRules> Layout<R> {
) -> GenericIndex<PolyWeight> { ) -> GenericIndex<PolyWeight> {
GenericIndex::<PolyWeight>::new( GenericIndex::<PolyWeight>::new(
self.drawing self.drawing
.add_compound(recorder, CompoundWeight::Poly(weight)) .recording(recorder)
.add_compound(CompoundWeight::Poly(weight))
.petgraph_index(), .petgraph_index(),
) )
} }
@ -266,7 +288,7 @@ impl<R: AccessRules> Layout<R> {
recorder: &mut LayoutEdit, recorder: &mut LayoutEdit,
band: BandTermsegIndex, band: BandTermsegIndex,
) -> Result<(), DrawingException> { ) -> Result<(), DrawingException> {
self.drawing.remove_band(recorder, band) self.drawing.recording(recorder).remove_band(band)
} }
pub fn polys<W: 'static>( pub fn polys<W: 'static>(