diff --git a/src/bin/topola-egui/overlay.rs b/src/bin/topola-egui/overlay.rs index 9a0cee3..0e0e2fe 100644 --- a/src/bin/topola-egui/overlay.rs +++ b/src/bin/topola-egui/overlay.rs @@ -17,6 +17,7 @@ use topola::{ }, graph::{GenericIndex, GetNodeIndex}, layout::{ + via::ViaWeight, zone::{MakePolyShape, Zone, ZoneWeight}, CompoundWeight, Layout, NodeIndex, }, @@ -78,13 +79,22 @@ impl Overlay { } NodeIndex::Compound(compound) => { match board.layout().drawing().compound_weight(compound) { - CompoundWeight::Zone(zone) => Zone::new( + /*CompoundWeight::Zone(zone) => Zone::new( GenericIndex::::new(compound.node_index()), board.layout(), ) .shape() - .into(), - CompoundWeight::Via(via) => unreachable!(), + .into(),*/ + CompoundWeight::Zone(weight) => board + .layout() + .zone(GenericIndex::::new(compound.node_index())) + .shape() + .into(), + CompoundWeight::Via(weight) => board + .layout() + .via(GenericIndex::::new(compound.node_index())) + .shape() + .into(), } } }; diff --git a/src/layout/layout.rs b/src/layout/layout.rs index ad5f42d..462b39d 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -28,7 +28,7 @@ use crate::{ }, graph::{GenericIndex, GetNodeIndex}, layout::{ - via::ViaWeight, + via::{Via, ViaWeight}, zone::{GetMaybeApex, MakePolyShape, Zone, ZoneWeight}, }, math::Circle, @@ -256,33 +256,8 @@ impl Layout { pub fn zone(&self, index: GenericIndex) -> Zone { Zone::new(index, self) } + + pub fn via(&self, index: GenericIndex) -> Via { + Via::new(index, self) + } } - -/*impl CompoundManagerTrait> for Layout { - fn add_compound(&mut self, weight: ZoneWeight) -> GenericIndex { - self.drawing.add_compound(weight) - } - - fn remove_compound(&mut self, compound: GenericIndex) { - self.drawing.remove_compound(compound); - } - - fn add_to_compound( - &mut self, - primitive: GenericIndex, - compound: GenericIndex, - ) { - self.drawing.add_to_compound(primitive, compound); - } - - fn compound_weight(&self, compound: GenericIndex) -> ZoneWeight { - self.drawing.compound_weight(compound) - } - - fn compounds( - &self, - node: GenericIndex, - ) -> impl Iterator> { - self.drawing.compounds(node) - } -}*/ diff --git a/src/layout/via.rs b/src/layout/via.rs index 3dcb7a8..93267f9 100644 --- a/src/layout/via.rs +++ b/src/layout/via.rs @@ -1,6 +1,9 @@ use crate::{ - drawing::{graph::GetMaybeNet, rules::RulesTrait}, - geometry::compound::CompoundManagerTrait, + drawing::{graph::GetMaybeNet, primitive::MakePrimitiveShape, rules::RulesTrait}, + geometry::{ + compound::CompoundManagerTrait, + primitive::{DotShape, PrimitiveShape}, + }, graph::{GenericIndex, GetNodeIndex}, layout::{CompoundWeight, Layout}, math::Circle, @@ -27,6 +30,18 @@ impl<'a, R: RulesTrait> GetMaybeNet for Via<'a, R> { } } +impl<'a, R: RulesTrait> MakePrimitiveShape for Via<'a, R> { + fn shape(&self) -> PrimitiveShape { + if let CompoundWeight::Via(weight) = + self.layout.drawing().compound_weight(self.index.into()) + { + weight.shape() + } else { + unreachable!(); + } + } +} + #[derive(Debug, Clone, Copy)] pub struct ViaWeight { pub from_layer: u64, @@ -35,14 +50,20 @@ pub struct ViaWeight { pub maybe_net: Option, } +impl From> for GenericIndex { + fn from(via: GenericIndex) -> Self { + GenericIndex::::new(via.node_index()) + } +} + impl GetMaybeNet for ViaWeight { fn maybe_net(&self) -> Option { self.maybe_net } } -impl From> for GenericIndex { - fn from(via: GenericIndex) -> Self { - GenericIndex::::new(via.node_index()) +impl MakePrimitiveShape for ViaWeight { + fn shape(&self) -> PrimitiveShape { + DotShape { c: self.circle }.into() } }