mirror of https://codeberg.org/topola/topola.git
specctra/design: refactor Self::layer calls to avoid repetition
This commit is contained in:
parent
dc4ce2fbc7
commit
cd12775f46
|
|
@ -230,6 +230,14 @@ impl SpecctraDesign {
|
||||||
.find(|image| image.name == component.name)
|
.find(|image| image.name == component.name)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let place_side_is_front = place.side == "front";
|
||||||
|
let get_layer = |board: &Board<SpecctraMesadata>, name: &str| Self::layer(
|
||||||
|
board,
|
||||||
|
&self.pcb.structure.layers,
|
||||||
|
name,
|
||||||
|
place_side_is_front,
|
||||||
|
);
|
||||||
|
|
||||||
for pin in &image.pins {
|
for pin in &image.pins {
|
||||||
let pinname = format!("{}-{}", place.name, pin.id);
|
let pinname = format!("{}-{}", place.name, pin.id);
|
||||||
let net = pin_nets.get(&pinname).unwrap();
|
let net = pin_nets.get(&pinname).unwrap();
|
||||||
|
|
@ -245,12 +253,7 @@ impl SpecctraDesign {
|
||||||
for shape in padstack.shapes.iter() {
|
for shape in padstack.shapes.iter() {
|
||||||
match shape {
|
match shape {
|
||||||
Shape::Circle(circle) => {
|
Shape::Circle(circle) => {
|
||||||
let layer = Self::layer(
|
let layer = get_layer(&board, &circle.layer);
|
||||||
&mut board,
|
|
||||||
&self.pcb.structure.layers,
|
|
||||||
&circle.layer,
|
|
||||||
place.side == "front",
|
|
||||||
);
|
|
||||||
Self::add_circle(
|
Self::add_circle(
|
||||||
&mut board,
|
&mut board,
|
||||||
place.point_with_rotation(),
|
place.point_with_rotation(),
|
||||||
|
|
@ -262,12 +265,7 @@ impl SpecctraDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Rect(rect) => {
|
Shape::Rect(rect) => {
|
||||||
let layer = Self::layer(
|
let layer = get_layer(&board, &rect.layer);
|
||||||
&mut board,
|
|
||||||
&self.pcb.structure.layers,
|
|
||||||
&rect.layer,
|
|
||||||
place.side == "front",
|
|
||||||
);
|
|
||||||
Self::add_rect(
|
Self::add_rect(
|
||||||
&mut board,
|
&mut board,
|
||||||
place.point_with_rotation(),
|
place.point_with_rotation(),
|
||||||
|
|
@ -282,12 +280,7 @@ impl SpecctraDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Path(path) => {
|
Shape::Path(path) => {
|
||||||
let layer = Self::layer(
|
let layer = get_layer(&board, &path.layer);
|
||||||
&mut board,
|
|
||||||
&self.pcb.structure.layers,
|
|
||||||
&path.layer,
|
|
||||||
place.side == "front",
|
|
||||||
);
|
|
||||||
Self::add_path(
|
Self::add_path(
|
||||||
&mut board,
|
&mut board,
|
||||||
place.point_with_rotation(),
|
place.point_with_rotation(),
|
||||||
|
|
@ -300,12 +293,7 @@ impl SpecctraDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Polygon(polygon) => {
|
Shape::Polygon(polygon) => {
|
||||||
let layer = Self::layer(
|
let layer = get_layer(&board, &polygon.layer);
|
||||||
&mut board,
|
|
||||||
&self.pcb.structure.layers,
|
|
||||||
&polygon.layer,
|
|
||||||
place.side == "front",
|
|
||||||
);
|
|
||||||
Self::add_polygon(
|
Self::add_polygon(
|
||||||
&mut board,
|
&mut board,
|
||||||
place.point_with_rotation(),
|
place.point_with_rotation(),
|
||||||
|
|
@ -340,15 +328,13 @@ impl SpecctraDesign {
|
||||||
.find(|padstack| padstack.name == via.name)
|
.find(|padstack| padstack.name == via.name)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let get_layer = |board: &Board<SpecctraMesadata>, name: &str|
|
||||||
|
Self::layer(board, &self.pcb.structure.layers, name, true);
|
||||||
|
|
||||||
for shape in &padstack.shapes {
|
for shape in &padstack.shapes {
|
||||||
match shape {
|
match shape {
|
||||||
Shape::Circle(circle) => {
|
Shape::Circle(circle) => {
|
||||||
let layer = Self::layer(
|
let layer = get_layer(&board, &circle.layer);
|
||||||
&mut board,
|
|
||||||
&self.pcb.structure.layers,
|
|
||||||
&circle.layer,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
Self::add_circle(
|
Self::add_circle(
|
||||||
&mut board,
|
&mut board,
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
|
|
@ -360,8 +346,7 @@ impl SpecctraDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Rect(rect) => {
|
Shape::Rect(rect) => {
|
||||||
let layer =
|
let layer = get_layer(&board, &rect.layer);
|
||||||
Self::layer(&mut board, &self.pcb.structure.layers, &rect.layer, true);
|
|
||||||
Self::add_rect(
|
Self::add_rect(
|
||||||
&mut board,
|
&mut board,
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
|
|
@ -376,8 +361,7 @@ impl SpecctraDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Path(path) => {
|
Shape::Path(path) => {
|
||||||
let layer =
|
let layer = get_layer(&board, &path.layer);
|
||||||
Self::layer(&mut board, &self.pcb.structure.layers, &path.layer, true);
|
|
||||||
Self::add_path(
|
Self::add_path(
|
||||||
&mut board,
|
&mut board,
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
|
|
@ -390,12 +374,7 @@ impl SpecctraDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Polygon(polygon) => {
|
Shape::Polygon(polygon) => {
|
||||||
let layer = Self::layer(
|
let layer = get_layer(&board, &polygon.layer);
|
||||||
&mut board,
|
|
||||||
&self.pcb.structure.layers,
|
|
||||||
&polygon.layer,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
Self::add_polygon(
|
Self::add_polygon(
|
||||||
&mut board,
|
&mut board,
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue