feat(board,layout,drawing): implement edit applying interface

This commit is contained in:
Mikolaj Wielgus 2024-11-28 06:17:29 +01:00
parent 847654b5c3
commit 9b1b135715
3 changed files with 68 additions and 13 deletions

View File

@ -8,15 +8,16 @@ use crate::{
board::mesadata::AccessMesadata,
drawing::{
band::BandUid,
dot::{FixedDotIndex, FixedDotWeight},
graph::{GetLayer, GetMaybeNet},
seg::{FixedSegIndex, FixedSegWeight},
bend::{BendIndex, BendWeight},
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight},
graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight},
seg::{FixedSegIndex, FixedSegWeight, SegIndex, SegWeight},
},
geometry::{shape::AccessShape, GenericNode},
geometry::{edit::ApplyGeometryEdit, shape::AccessShape, GenericNode},
graph::GenericIndex,
layout::{
poly::{GetMaybeApex, MakePolyShape, PolyWeight},
Layout, LayoutEdit, NodeIndex,
CompoundWeight, Layout, LayoutEdit, NodeIndex,
},
math::Circle,
};
@ -167,7 +168,7 @@ impl<M: AccessMesadata> Board<M> {
poly
}
/// Retrieves or creates the apex (top point) of a polygon in the layout.
/// Retrieves or creates the apex (center point) of a polygon in the layout.
///
/// If the polygon already has an apex, returns it. Otherwise, creates and returns a new fixed dot as the apex.
pub fn poly_apex(
@ -254,3 +255,21 @@ impl<M: AccessMesadata> Board<M> {
&mut self.layout
}
}
impl<M: AccessMesadata>
ApplyGeometryEdit<
PrimitiveWeight,
DotWeight,
SegWeight,
BendWeight,
CompoundWeight,
PrimitiveIndex,
DotIndex,
SegIndex,
BendIndex,
> for Board<M>
{
fn apply(&mut self, edit: LayoutEdit) {
self.layout.apply(edit);
}
}

View File

@ -7,7 +7,7 @@ use rstar::{RTree, AABB};
use thiserror::Error;
use crate::geometry::{
edit::GeometryEdit,
edit::{ApplyGeometryEdit, GeometryEdit},
primitive::{AccessPrimitiveShape, PrimitiveShape},
recording_with_rtree::RecordingGeometryWithRtree,
with_rtree::BboxedIndex,
@ -1120,3 +1120,21 @@ impl<CW: Copy, R: AccessRules> Drawing<CW, R> {
})
}
}
impl<CW: Copy, R: AccessRules>
ApplyGeometryEdit<
PrimitiveWeight,
DotWeight,
SegWeight,
BendWeight,
CW,
PrimitiveIndex,
DotIndex,
SegIndex,
BendIndex,
> for Drawing<CW, R>
{
fn apply(&mut self, edit: DrawingEdit<CW>) {
self.recording_geometry_with_rtree.apply(edit);
}
}

View File

@ -7,19 +7,19 @@ use rstar::AABB;
use crate::{
drawing::{
band::BandTermsegIndex,
bend::LooseBendWeight,
bend::{BendIndex, BendWeight, LooseBendWeight},
cane::Cane,
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
gear::GearIndex,
graph::{GetMaybeNet, PrimitiveIndex},
graph::{GetMaybeNet, PrimitiveIndex, PrimitiveWeight},
rules::AccessRules,
seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
SeqLooseSegWeight,
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
SegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
},
Drawing, DrawingEdit, DrawingException, Infringement,
},
geometry::GenericNode,
geometry::{edit::ApplyGeometryEdit, GenericNode},
graph::{GenericIndex, GetPetgraphIndex},
layout::{
poly::{Poly, PolyWeight},
@ -327,3 +327,21 @@ impl<R: AccessRules> Layout<R> {
Via::new(index, self)
}
}
impl<R: AccessRules>
ApplyGeometryEdit<
PrimitiveWeight,
DotWeight,
SegWeight,
BendWeight,
CompoundWeight,
PrimitiveIndex,
DotIndex,
SegIndex,
BendIndex,
> for Layout<R>
{
fn apply(&mut self, edit: LayoutEdit) {
self.drawing.apply(edit);
}
}