mirror of https://codeberg.org/topola/topola.git
dsn: flip pads of components placed on the back side
This commit is contained in:
parent
14f3234b7b
commit
cc7b3ac875
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
use super::{
|
use super::{
|
||||||
de,
|
de,
|
||||||
rules::DsnRules,
|
rules::DsnRules,
|
||||||
structure::{self, DsnFile, Pcb, Shape},
|
structure::{self, DsnFile, Layer, Pcb, Shape},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
|
@ -85,17 +85,32 @@ impl DsnDesign {
|
||||||
.find(|padstack| padstack.name == pin.name)
|
.find(|padstack| padstack.name == pin.name)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
for (layer, shape) in padstack.shape_vec.iter().enumerate() {
|
for shape in padstack.shape_vec.iter() {
|
||||||
match shape {
|
match shape {
|
||||||
Shape::Circle(circle) => Self::add_circle(
|
Shape::Circle(circle) => {
|
||||||
|
let layer = Self::layer(
|
||||||
|
&mut layout,
|
||||||
|
&self.pcb.structure.layer_vec,
|
||||||
|
&circle.layer,
|
||||||
|
place.side == "front",
|
||||||
|
);
|
||||||
|
Self::add_circle(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
(place.x + pin.x) as f64,
|
(place.x + pin.x) as f64,
|
||||||
-(place.y + pin.y) as f64,
|
-(place.y + pin.y) as f64,
|
||||||
circle.diameter as f64 / 2.0,
|
circle.diameter as f64 / 2.0,
|
||||||
layer as u64,
|
layer as u64,
|
||||||
*net_id as i64,
|
*net_id as i64,
|
||||||
),
|
)
|
||||||
Shape::Rect(rect) => Self::add_rect(
|
}
|
||||||
|
Shape::Rect(rect) => {
|
||||||
|
let layer = Self::layer(
|
||||||
|
&mut layout,
|
||||||
|
&self.pcb.structure.layer_vec,
|
||||||
|
&rect.layer,
|
||||||
|
place.side == "front",
|
||||||
|
);
|
||||||
|
Self::add_rect(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
(place.x - pin.x + rect.x1) as f64,
|
(place.x - pin.x + rect.x1) as f64,
|
||||||
-(place.y - pin.y + rect.y1) as f64,
|
-(place.y - pin.y + rect.y1) as f64,
|
||||||
|
|
@ -103,8 +118,16 @@ impl DsnDesign {
|
||||||
-(place.y - pin.y + rect.y2) as f64,
|
-(place.y - pin.y + rect.y2) as f64,
|
||||||
layer as u64,
|
layer as u64,
|
||||||
*net_id as i64,
|
*net_id as i64,
|
||||||
),
|
)
|
||||||
Shape::Path(path) => Self::add_path(
|
}
|
||||||
|
Shape::Path(path) => {
|
||||||
|
let layer = Self::layer(
|
||||||
|
&mut layout,
|
||||||
|
&self.pcb.structure.layer_vec,
|
||||||
|
&path.layer,
|
||||||
|
place.side == "front",
|
||||||
|
);
|
||||||
|
Self::add_path(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
(place.x - pin.x) as f64,
|
(place.x - pin.x) as f64,
|
||||||
-(place.y - pin.y) as f64,
|
-(place.y - pin.y) as f64,
|
||||||
|
|
@ -112,8 +135,16 @@ impl DsnDesign {
|
||||||
path.width as f64,
|
path.width as f64,
|
||||||
layer as u64,
|
layer as u64,
|
||||||
*net_id as i64,
|
*net_id as i64,
|
||||||
),
|
)
|
||||||
Shape::Polygon(polygon) => Self::add_path(
|
}
|
||||||
|
Shape::Polygon(polygon) => {
|
||||||
|
let layer = Self::layer(
|
||||||
|
&mut layout,
|
||||||
|
&self.pcb.structure.layer_vec,
|
||||||
|
&polygon.layer,
|
||||||
|
place.side == "front",
|
||||||
|
);
|
||||||
|
Self::add_path(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
(place.x - pin.x) as f64,
|
(place.x - pin.x) as f64,
|
||||||
-(place.y - pin.y) as f64,
|
-(place.y - pin.y) as f64,
|
||||||
|
|
@ -121,7 +152,8 @@ impl DsnDesign {
|
||||||
polygon.width as f64,
|
polygon.width as f64,
|
||||||
layer as u64,
|
layer as u64,
|
||||||
*net_id as i64,
|
*net_id as i64,
|
||||||
),
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -143,8 +175,12 @@ impl DsnDesign {
|
||||||
for shape in &padstack.shape_vec {
|
for shape in &padstack.shape_vec {
|
||||||
match shape {
|
match shape {
|
||||||
Shape::Circle(circle) => {
|
Shape::Circle(circle) => {
|
||||||
let layer = *layout.rules().layer_ids.get(&circle.layer).unwrap();
|
let layer = Self::layer(
|
||||||
|
&mut layout,
|
||||||
|
&self.pcb.structure.layer_vec,
|
||||||
|
&circle.layer,
|
||||||
|
true,
|
||||||
|
);
|
||||||
Self::add_circle(
|
Self::add_circle(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
via.x as f64,
|
via.x as f64,
|
||||||
|
|
@ -155,7 +191,12 @@ impl DsnDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Rect(rect) => {
|
Shape::Rect(rect) => {
|
||||||
let layer = *layout.rules().layer_ids.get(&rect.layer).unwrap();
|
let layer = Self::layer(
|
||||||
|
&mut layout,
|
||||||
|
&self.pcb.structure.layer_vec,
|
||||||
|
&rect.layer,
|
||||||
|
true,
|
||||||
|
);
|
||||||
Self::add_rect(
|
Self::add_rect(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
rect.x1 as f64,
|
rect.x1 as f64,
|
||||||
|
|
@ -167,7 +208,12 @@ impl DsnDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Path(path) => {
|
Shape::Path(path) => {
|
||||||
let layer = *layout.rules().layer_ids.get(&path.layer).unwrap();
|
let layer = Self::layer(
|
||||||
|
&mut layout,
|
||||||
|
&self.pcb.structure.layer_vec,
|
||||||
|
&path.layer,
|
||||||
|
true,
|
||||||
|
);
|
||||||
Self::add_path(
|
Self::add_path(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
0.0,
|
0.0,
|
||||||
|
|
@ -179,7 +225,12 @@ impl DsnDesign {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Polygon(polygon) => {
|
Shape::Polygon(polygon) => {
|
||||||
let layer = *layout.rules().layer_ids.get(&polygon.layer).unwrap();
|
let layer = Self::layer(
|
||||||
|
&mut layout,
|
||||||
|
&self.pcb.structure.layer_vec,
|
||||||
|
&polygon.layer,
|
||||||
|
true,
|
||||||
|
);
|
||||||
Self::add_path(
|
Self::add_path(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
0.0,
|
0.0,
|
||||||
|
|
@ -212,6 +263,21 @@ impl DsnDesign {
|
||||||
layout
|
layout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn layer(
|
||||||
|
layout: &Layout<DsnRules>,
|
||||||
|
layer_vec: &Vec<Layer>,
|
||||||
|
layer_name: &str,
|
||||||
|
front: bool,
|
||||||
|
) -> usize {
|
||||||
|
let image_layer = *layout.rules().layer_ids.get(layer_name).unwrap();
|
||||||
|
|
||||||
|
if front {
|
||||||
|
image_layer as usize
|
||||||
|
} else {
|
||||||
|
layer_vec.len() - image_layer as usize - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn add_circle(layout: &mut Layout<DsnRules>, x: f64, y: f64, r: f64, layer: u64, net: i64) {
|
fn add_circle(layout: &mut Layout<DsnRules>, x: f64, y: f64, r: f64, layer: u64, net: i64) {
|
||||||
let circle = Circle {
|
let circle = Circle {
|
||||||
pos: (x, y).into(),
|
pos: (x, y).into(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue