From 9b1b135715f2adc0585c805818583f0cdb60d8a6 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 28 Nov 2024 06:17:29 +0100 Subject: [PATCH] feat(board,layout,drawing): implement edit applying interface --- src/board/board.rs | 31 +++++++++++++++++++++++++------ src/drawing/drawing.rs | 20 +++++++++++++++++++- src/layout/layout.rs | 30 ++++++++++++++++++++++++------ 3 files changed, 68 insertions(+), 13 deletions(-) diff --git a/src/board/board.rs b/src/board/board.rs index ecad7d0..cabb736 100644 --- a/src/board/board.rs +++ b/src/board/board.rs @@ -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 Board { 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 Board { &mut self.layout } } + +impl + ApplyGeometryEdit< + PrimitiveWeight, + DotWeight, + SegWeight, + BendWeight, + CompoundWeight, + PrimitiveIndex, + DotIndex, + SegIndex, + BendIndex, + > for Board +{ + fn apply(&mut self, edit: LayoutEdit) { + self.layout.apply(edit); + } +} diff --git a/src/drawing/drawing.rs b/src/drawing/drawing.rs index 434100d..05df6e6 100644 --- a/src/drawing/drawing.rs +++ b/src/drawing/drawing.rs @@ -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 Drawing { }) } } + +impl + ApplyGeometryEdit< + PrimitiveWeight, + DotWeight, + SegWeight, + BendWeight, + CW, + PrimitiveIndex, + DotIndex, + SegIndex, + BendIndex, + > for Drawing +{ + fn apply(&mut self, edit: DrawingEdit) { + self.recording_geometry_with_rtree.apply(edit); + } +} diff --git a/src/layout/layout.rs b/src/layout/layout.rs index b7cc30e..4ad667c 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -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 Layout { Via::new(index, self) } } + +impl + ApplyGeometryEdit< + PrimitiveWeight, + DotWeight, + SegWeight, + BendWeight, + CompoundWeight, + PrimitiveIndex, + DotIndex, + SegIndex, + BendIndex, + > for Layout +{ + fn apply(&mut self, edit: LayoutEdit) { + self.drawing.apply(edit); + } +}