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, board::mesadata::AccessMesadata,
drawing::{ drawing::{
band::BandUid, band::BandUid,
dot::{FixedDotIndex, FixedDotWeight}, bend::{BendIndex, BendWeight},
graph::{GetLayer, GetMaybeNet}, dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight},
seg::{FixedSegIndex, FixedSegWeight}, graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight},
seg::{FixedSegIndex, FixedSegWeight, SegIndex, SegWeight},
}, },
geometry::{shape::AccessShape, GenericNode}, geometry::{edit::ApplyGeometryEdit, shape::AccessShape, GenericNode},
graph::GenericIndex, graph::GenericIndex,
layout::{ layout::{
poly::{GetMaybeApex, MakePolyShape, PolyWeight}, poly::{GetMaybeApex, MakePolyShape, PolyWeight},
Layout, LayoutEdit, NodeIndex, CompoundWeight, Layout, LayoutEdit, NodeIndex,
}, },
math::Circle, math::Circle,
}; };
@ -167,7 +168,7 @@ impl<M: AccessMesadata> Board<M> {
poly 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. /// If the polygon already has an apex, returns it. Otherwise, creates and returns a new fixed dot as the apex.
pub fn poly_apex( pub fn poly_apex(
@ -254,3 +255,21 @@ impl<M: AccessMesadata> Board<M> {
&mut self.layout &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 thiserror::Error;
use crate::geometry::{ use crate::geometry::{
edit::GeometryEdit, edit::{ApplyGeometryEdit, GeometryEdit},
primitive::{AccessPrimitiveShape, PrimitiveShape}, primitive::{AccessPrimitiveShape, PrimitiveShape},
recording_with_rtree::RecordingGeometryWithRtree, recording_with_rtree::RecordingGeometryWithRtree,
with_rtree::BboxedIndex, 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::{ use crate::{
drawing::{ drawing::{
band::BandTermsegIndex, band::BandTermsegIndex,
bend::LooseBendWeight, bend::{BendIndex, BendWeight, LooseBendWeight},
cane::Cane, cane::Cane,
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight}, dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
gear::GearIndex, gear::GearIndex,
graph::{GetMaybeNet, PrimitiveIndex}, graph::{GetMaybeNet, PrimitiveIndex, PrimitiveWeight},
rules::AccessRules, rules::AccessRules,
seg::{ seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex, FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
SeqLooseSegWeight, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
}, },
Drawing, DrawingEdit, DrawingException, Infringement, Drawing, DrawingEdit, DrawingException, Infringement,
}, },
geometry::GenericNode, geometry::{edit::ApplyGeometryEdit, GenericNode},
graph::{GenericIndex, GetPetgraphIndex}, graph::{GenericIndex, GetPetgraphIndex},
layout::{ layout::{
poly::{Poly, PolyWeight}, poly::{Poly, PolyWeight},
@ -327,3 +327,21 @@ impl<R: AccessRules> Layout<R> {
Via::new(index, self) 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);
}
}