mirror of https://codeberg.org/topola/topola.git
Create layer groups, assign each layer to one of it
This commit is contained in:
parent
58be28cc8b
commit
ca517f62bd
|
|
@ -9,12 +9,13 @@ mod transforms;
|
|||
|
||||
use bidimap::BiBTreeMap;
|
||||
use derive_getters::Getters;
|
||||
use derive_more::{Constructor, From};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use undoredo::{Delta, Recorder};
|
||||
|
||||
use crate::{
|
||||
layout::LayerId,
|
||||
layout::{
|
||||
Layout, LayoutHalfDelta,
|
||||
LayerId, Layout, LayoutHalfDelta,
|
||||
compounds::{ComponentId, NetId, PinId},
|
||||
primitives::{
|
||||
JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId,
|
||||
|
|
@ -24,10 +25,35 @@ use crate::{
|
|||
math::Vector2,
|
||||
};
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
Constructor,
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Deserialize,
|
||||
Eq,
|
||||
From,
|
||||
Ord,
|
||||
PartialEq,
|
||||
PartialOrd,
|
||||
Serialize,
|
||||
)]
|
||||
pub struct LayerGroupId(usize);
|
||||
|
||||
impl LayerGroupId {
|
||||
#[inline]
|
||||
pub fn index(self) -> usize {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Getters, Delta)]
|
||||
pub struct Board {
|
||||
layout: Layout,
|
||||
#[getter(skip)]
|
||||
layer_groups: Recorder<Vec<LayerGroupId>>,
|
||||
#[getter(skip)]
|
||||
component_names: Recorder<BiBTreeMap<ComponentId, String>>,
|
||||
#[getter(skip)]
|
||||
pin_names: Recorder<BiBTreeMap<PinId, String>>,
|
||||
|
|
@ -38,7 +64,7 @@ pub struct Board {
|
|||
}
|
||||
|
||||
impl Board {
|
||||
pub fn new(boundary: Vec<Vector2<i64>>, layer_count: usize) -> Self {
|
||||
/*pub fn new(boundary: Vec<Vector2<i64>>, layer_count: usize) -> Self {
|
||||
Self {
|
||||
layout: Layout::new(boundary.into_iter().map(Into::into).collect(), layer_count),
|
||||
component_names: Recorder::new(BiBTreeMap::new()),
|
||||
|
|
@ -46,16 +72,21 @@ impl Board {
|
|||
layer_names: Recorder::new(BiBTreeMap::new()),
|
||||
net_names: Recorder::new(BiBTreeMap::new()),
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
pub fn with_names(
|
||||
boundary: Vec<Vector2<i64>>,
|
||||
layer_count: usize,
|
||||
layer_groups: impl Into<Vec<LayerGroupId>>,
|
||||
layer_names: BiBTreeMap<LayerId, String>,
|
||||
net_names: BiBTreeMap<NetId, String>,
|
||||
) -> Self {
|
||||
let layer_groups = layer_groups.into();
|
||||
Self {
|
||||
layout: Layout::new(boundary.into_iter().map(Into::into).collect(), layer_count),
|
||||
layout: Layout::new(
|
||||
boundary.into_iter().map(Into::into).collect(),
|
||||
layer_groups.len(),
|
||||
),
|
||||
layer_groups: Recorder::new(layer_groups),
|
||||
component_names: Recorder::new(BiBTreeMap::new()),
|
||||
pin_names: Recorder::new(BiBTreeMap::new()),
|
||||
layer_names: Recorder::new(layer_names),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ impl Board {
|
|||
.rev()
|
||||
.map(|p| Vector2::new(p.x as i64, p.y as i64))
|
||||
.collect(),
|
||||
dsn.pcb.structure.layers.len(),
|
||||
vec![crate::board::LayerGroupId::new(0); dsn.pcb.structure.layers.len()],
|
||||
layer_names,
|
||||
net_names,
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue