mirror of https://codeberg.org/topola/topola.git
Merge branch 'develop' of https://codeberg.org/topola/topola into develop
This commit is contained in:
commit
479791ea02
|
|
@ -220,15 +220,3 @@ pub fn execute<F: Future<Output = ()> + Send + 'static>(f: F) {
|
||||||
pub fn execute<F: Future<Output = ()> + 'static>(f: F) {
|
pub fn execute<F: Future<Output = ()> + 'static>(f: F) {
|
||||||
wasm_bindgen_futures::spawn_local(f);
|
wasm_bindgen_futures::spawn_local(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub async fn channel_text(file_handle: rfd::FileHandle) -> String {
|
|
||||||
file_handle.path().to_str().unwrap().to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
pub async fn channel_text(file_handle: rfd::FileHandle) -> String {
|
|
||||||
std::str::from_utf8(&file_handle.read().await)
|
|
||||||
.unwrap()
|
|
||||||
.to_string()
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use topola::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
action::{Action, Switch, Trigger},
|
action::{Action, Switch, Trigger},
|
||||||
app::{channel_text, execute},
|
app::execute,
|
||||||
file_sender::FileSender,
|
file_sender::FileSender,
|
||||||
overlay::Overlay,
|
overlay::Overlay,
|
||||||
translator::Translator,
|
translator::Translator,
|
||||||
|
|
|
||||||
19
src/math.rs
19
src/math.rs
|
|
@ -20,14 +20,29 @@ pub struct Circle {
|
||||||
pub r: f64,
|
pub r: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
pub struct PointWithRotation {
|
||||||
|
pub pos: Point,
|
||||||
|
pub rot: f64,
|
||||||
|
}
|
||||||
|
|
||||||
impl Sub for Circle {
|
impl Sub for Circle {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn sub(self, other: Self) -> Self {
|
fn sub(self, other: Self) -> Self {
|
||||||
return Self {
|
Self {
|
||||||
pos: self.pos - other.pos,
|
pos: self.pos - other.pos,
|
||||||
r: self.r,
|
r: self.r,
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for PointWithRotation {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
pos: (0.0, 0.0).into(),
|
||||||
|
rot: 0.0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
geometry::{primitive::PrimitiveShape, GetWidth},
|
geometry::{primitive::PrimitiveShape, GetWidth},
|
||||||
layout::{poly::SolidPolyWeight, Layout},
|
layout::{poly::SolidPolyWeight, Layout},
|
||||||
math::Circle,
|
math::{Circle, PointWithRotation},
|
||||||
specctra::{
|
specctra::{
|
||||||
mesadata::SpecctraMesadata,
|
mesadata::SpecctraMesadata,
|
||||||
read::{self, ListTokenizer},
|
read::{self, ListTokenizer},
|
||||||
|
|
@ -231,33 +231,32 @@ 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();
|
||||||
|
|
||||||
let padstack = &self
|
let padstack = self
|
||||||
.pcb
|
.pcb
|
||||||
.library
|
.library
|
||||||
.padstacks
|
.find_padstack_by_name(&pin.name)
|
||||||
.iter()
|
|
||||||
.find(|padstack| padstack.name == pin.name)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
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.x, place.y).into(),
|
place.point_with_rotation(),
|
||||||
place.rotation,
|
pin.point_with_rotation(),
|
||||||
(pin.x, pin.y).into(),
|
|
||||||
pin.rotate.unwrap_or(0.0),
|
|
||||||
circle.diameter / 2.0,
|
circle.diameter / 2.0,
|
||||||
layer,
|
layer,
|
||||||
*net,
|
*net,
|
||||||
|
|
@ -265,18 +264,11 @@ 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.x, place.y).into(),
|
place.point_with_rotation(),
|
||||||
place.rotation,
|
pin.point_with_rotation(),
|
||||||
(pin.x, pin.y).into(),
|
|
||||||
pin.rotate.unwrap_or(0.0),
|
|
||||||
rect.x1,
|
rect.x1,
|
||||||
rect.y1,
|
rect.y1,
|
||||||
rect.x2,
|
rect.x2,
|
||||||
|
|
@ -287,18 +279,11 @@ 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.x, place.y).into(),
|
place.point_with_rotation(),
|
||||||
place.rotation,
|
pin.point_with_rotation(),
|
||||||
(pin.x, pin.y).into(),
|
|
||||||
pin.rotate.unwrap_or(0.0),
|
|
||||||
&path.coords,
|
&path.coords,
|
||||||
path.width,
|
path.width,
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -307,18 +292,11 @@ 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.x, place.y).into(),
|
place.point_with_rotation(),
|
||||||
place.rotation,
|
pin.point_with_rotation(),
|
||||||
(pin.x, pin.y).into(),
|
|
||||||
pin.rotate.unwrap_or(0.0),
|
|
||||||
&polygon.coords,
|
&polygon.coords,
|
||||||
polygon.width,
|
polygon.width,
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -340,30 +318,23 @@ impl SpecctraDesign {
|
||||||
.netname_net(&via.net)
|
.netname_net(&via.net)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// find the padstack referenced by this via placement
|
let padstack = self
|
||||||
let padstack = &self
|
|
||||||
.pcb
|
.pcb
|
||||||
.library
|
.library
|
||||||
.padstacks
|
.find_padstack_by_name(&via.name)
|
||||||
.iter()
|
|
||||||
.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,
|
||||||
(0.0, 0.0).into(),
|
PointWithRotation::default(),
|
||||||
0.0,
|
PointWithRotation::default(),
|
||||||
(0.0, 0.0).into(),
|
|
||||||
0.0,
|
|
||||||
circle.diameter / 2.0,
|
circle.diameter / 2.0,
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
|
|
@ -371,14 +342,11 @@ 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,
|
||||||
(0.0, 0.0).into(),
|
PointWithRotation::default(),
|
||||||
0.0,
|
PointWithRotation::default(),
|
||||||
(0.0, 0.0).into(),
|
|
||||||
0.0,
|
|
||||||
rect.x1,
|
rect.x1,
|
||||||
rect.y1,
|
rect.y1,
|
||||||
rect.x2,
|
rect.x2,
|
||||||
|
|
@ -389,14 +357,11 @@ 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,
|
||||||
(0.0, 0.0).into(),
|
PointWithRotation::default(),
|
||||||
0.0,
|
PointWithRotation::default(),
|
||||||
(0.0, 0.0).into(),
|
|
||||||
0.0,
|
|
||||||
&path.coords,
|
&path.coords,
|
||||||
path.width,
|
path.width,
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -405,18 +370,11 @@ 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,
|
||||||
(0.0, 0.0).into(),
|
PointWithRotation::default(),
|
||||||
0.0,
|
PointWithRotation::default(),
|
||||||
(0.0, 0.0).into(),
|
|
||||||
0.0,
|
|
||||||
&polygon.coords,
|
&polygon.coords,
|
||||||
polygon.width,
|
polygon.width,
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -444,10 +402,8 @@ impl SpecctraDesign {
|
||||||
|
|
||||||
Self::add_path(
|
Self::add_path(
|
||||||
&mut board,
|
&mut board,
|
||||||
(0.0, 0.0).into(),
|
PointWithRotation::default(),
|
||||||
0.0,
|
PointWithRotation::default(),
|
||||||
(0.0, 0.0).into(),
|
|
||||||
0.0,
|
|
||||||
&wire.path.coords,
|
&wire.path.coords,
|
||||||
wire.path.width,
|
wire.path.width,
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -456,26 +412,6 @@ impl SpecctraDesign {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The clones here are bad, we'll have something better later on.
|
|
||||||
|
|
||||||
let layername_to_layer = &board.layout().drawing().rules().layer_layername.clone();
|
|
||||||
|
|
||||||
for (layer, layername) in layername_to_layer.iter() {
|
|
||||||
board
|
|
||||||
.layout_mut()
|
|
||||||
.rules_mut()
|
|
||||||
.bename_layer(*layer, layername.to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
let netname_to_net = &board.layout().drawing().rules().net_netname.clone();
|
|
||||||
|
|
||||||
for (net, netname) in netname_to_net.iter() {
|
|
||||||
board
|
|
||||||
.layout_mut()
|
|
||||||
.rules_mut()
|
|
||||||
.bename_net(*net, netname.to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
board
|
board
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -501,17 +437,15 @@ impl SpecctraDesign {
|
||||||
|
|
||||||
fn add_circle(
|
fn add_circle(
|
||||||
board: &mut Board<SpecctraMesadata>,
|
board: &mut Board<SpecctraMesadata>,
|
||||||
place_pos: Point,
|
place: PointWithRotation,
|
||||||
place_rot: f64,
|
pin: PointWithRotation,
|
||||||
pin_pos: Point,
|
|
||||||
pin_rot: f64,
|
|
||||||
r: f64,
|
r: f64,
|
||||||
layer: usize,
|
layer: usize,
|
||||||
net: usize,
|
net: usize,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
) {
|
) {
|
||||||
let circle = Circle {
|
let circle = Circle {
|
||||||
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, 0.0, 0.0),
|
pos: Self::pos(place, pin, 0.0, 0.0),
|
||||||
r,
|
r,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -527,10 +461,8 @@ impl SpecctraDesign {
|
||||||
|
|
||||||
fn add_rect(
|
fn add_rect(
|
||||||
board: &mut Board<SpecctraMesadata>,
|
board: &mut Board<SpecctraMesadata>,
|
||||||
place_pos: Point,
|
place: PointWithRotation,
|
||||||
place_rot: f64,
|
pin: PointWithRotation,
|
||||||
pin_pos: Point,
|
|
||||||
pin_rot: f64,
|
|
||||||
x1: f64,
|
x1: f64,
|
||||||
y1: f64,
|
y1: f64,
|
||||||
x2: f64,
|
x2: f64,
|
||||||
|
|
@ -552,7 +484,7 @@ impl SpecctraDesign {
|
||||||
let dot_1_1 = board.add_poly_fixed_dot_infringably(
|
let dot_1_1 = board.add_poly_fixed_dot_infringably(
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x1, y1),
|
pos: Self::pos(place, pin, x1, y1),
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -563,7 +495,7 @@ impl SpecctraDesign {
|
||||||
let dot_2_1 = board.add_poly_fixed_dot_infringably(
|
let dot_2_1 = board.add_poly_fixed_dot_infringably(
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x2, y1),
|
pos: Self::pos(place, pin, x2, y1),
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -574,7 +506,7 @@ impl SpecctraDesign {
|
||||||
let dot_2_2 = board.add_poly_fixed_dot_infringably(
|
let dot_2_2 = board.add_poly_fixed_dot_infringably(
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x2, y2),
|
pos: Self::pos(place, pin, x2, y2),
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -585,7 +517,7 @@ impl SpecctraDesign {
|
||||||
let dot_1_2 = board.add_poly_fixed_dot_infringably(
|
let dot_1_2 = board.add_poly_fixed_dot_infringably(
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x1, y2),
|
pos: Self::pos(place, pin, x1, y2),
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -638,10 +570,8 @@ impl SpecctraDesign {
|
||||||
|
|
||||||
fn add_path(
|
fn add_path(
|
||||||
board: &mut Board<SpecctraMesadata>,
|
board: &mut Board<SpecctraMesadata>,
|
||||||
place_pos: Point,
|
place: PointWithRotation,
|
||||||
place_rot: f64,
|
pin: PointWithRotation,
|
||||||
pin_pos: Point,
|
|
||||||
pin_rot: f64,
|
|
||||||
coords: &Vec<structure::Point>,
|
coords: &Vec<structure::Point>,
|
||||||
width: f64,
|
width: f64,
|
||||||
layer: usize,
|
layer: usize,
|
||||||
|
|
@ -649,14 +579,7 @@ impl SpecctraDesign {
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
) {
|
) {
|
||||||
// add the first coordinate in the wire path as a dot and save its index
|
// add the first coordinate in the wire path as a dot and save its index
|
||||||
let mut prev_pos = Self::pos(
|
let mut prev_pos = Self::pos(place, pin, coords[0].x, coords[0].y);
|
||||||
place_pos,
|
|
||||||
place_rot,
|
|
||||||
pin_pos,
|
|
||||||
pin_rot,
|
|
||||||
coords[0].x,
|
|
||||||
coords[0].y,
|
|
||||||
);
|
|
||||||
let mut prev_index = board.add_fixed_dot_infringably(
|
let mut prev_index = board.add_fixed_dot_infringably(
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
|
|
@ -671,7 +594,7 @@ impl SpecctraDesign {
|
||||||
|
|
||||||
// iterate through path coords starting from the second
|
// iterate through path coords starting from the second
|
||||||
for coord in coords.iter().skip(1) {
|
for coord in coords.iter().skip(1) {
|
||||||
let pos = Self::pos(place_pos, place_rot, pin_pos, pin_rot, coord.x, coord.y);
|
let pos = Self::pos(place, pin, coord.x, coord.y);
|
||||||
|
|
||||||
if pos == prev_pos {
|
if pos == prev_pos {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -708,10 +631,8 @@ impl SpecctraDesign {
|
||||||
|
|
||||||
fn add_polygon(
|
fn add_polygon(
|
||||||
board: &mut Board<SpecctraMesadata>,
|
board: &mut Board<SpecctraMesadata>,
|
||||||
place_pos: Point,
|
place: PointWithRotation,
|
||||||
place_rot: f64,
|
pin: PointWithRotation,
|
||||||
pin_pos: Point,
|
|
||||||
pin_rot: f64,
|
|
||||||
coords: &Vec<structure::Point>,
|
coords: &Vec<structure::Point>,
|
||||||
width: f64,
|
width: f64,
|
||||||
layer: usize,
|
layer: usize,
|
||||||
|
|
@ -731,14 +652,7 @@ impl SpecctraDesign {
|
||||||
let mut prev_index = board.add_poly_fixed_dot_infringably(
|
let mut prev_index = board.add_poly_fixed_dot_infringably(
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(
|
pos: Self::pos(place, pin, coords[0].x, coords[0].y),
|
||||||
place_pos,
|
|
||||||
place_rot,
|
|
||||||
pin_pos,
|
|
||||||
pin_rot,
|
|
||||||
coords[0].x,
|
|
||||||
coords[0].y,
|
|
||||||
),
|
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -754,8 +668,7 @@ impl SpecctraDesign {
|
||||||
let index = board.add_poly_fixed_dot_infringably(
|
let index = board.add_poly_fixed_dot_infringably(
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, coord.x, coord.y)
|
pos: Self::pos(place, pin, coord.x, coord.y).into(),
|
||||||
.into(),
|
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -783,14 +696,12 @@ impl SpecctraDesign {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pos(
|
fn pos(
|
||||||
place_pos: Point,
|
place: PointWithRotation,
|
||||||
place_rot: f64,
|
pin: PointWithRotation,
|
||||||
pin_pos: Point,
|
|
||||||
pin_rot: f64,
|
|
||||||
x: f64,
|
x: f64,
|
||||||
y: f64,
|
y: f64,
|
||||||
) -> Point {
|
) -> Point {
|
||||||
let pos = (point! {x: x, y: y} + pin_pos).rotate_around_point(pin_rot, pin_pos);
|
let pos = (point! {x: x, y: y} + pin.pos).rotate_around_point(pin.rot, pin.pos);
|
||||||
(pos + place_pos).rotate_around_point(place_rot, place_pos)
|
(pos + place.pos).rotate_around_point(place.rot, place.pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use super::read::ReadDsn;
|
||||||
use super::read::{ListTokenizer, ParseError, ParseErrorContext};
|
use super::read::{ListTokenizer, ParseError, ParseErrorContext};
|
||||||
use super::write::ListWriter;
|
use super::write::ListWriter;
|
||||||
use super::write::WriteSes;
|
use super::write::WriteSes;
|
||||||
|
use crate::math::PointWithRotation;
|
||||||
use specctra_derive::ReadDsn;
|
use specctra_derive::ReadDsn;
|
||||||
use specctra_derive::WriteSes;
|
use specctra_derive::WriteSes;
|
||||||
|
|
||||||
|
|
@ -176,6 +177,15 @@ pub struct Place {
|
||||||
pub PN: Option<String>,
|
pub PN: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Place {
|
||||||
|
pub fn point_with_rotation(&self) -> PointWithRotation {
|
||||||
|
PointWithRotation {
|
||||||
|
pos: (self.x, self.y).into(),
|
||||||
|
rot: self.rotation,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteSes, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Library {
|
pub struct Library {
|
||||||
#[vec("image")]
|
#[vec("image")]
|
||||||
|
|
@ -184,6 +194,12 @@ pub struct Library {
|
||||||
pub padstacks: Vec<Padstack>,
|
pub padstacks: Vec<Padstack>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Library {
|
||||||
|
pub fn find_padstack_by_name(&self, name: &str) -> Option<&Padstack> {
|
||||||
|
self.padstacks.iter().find(|padstack| &padstack.name == name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteSes, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
#[anon]
|
#[anon]
|
||||||
|
|
@ -214,6 +230,15 @@ pub struct Pin {
|
||||||
pub y: f64,
|
pub y: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Pin {
|
||||||
|
pub fn point_with_rotation(&self) -> PointWithRotation {
|
||||||
|
PointWithRotation {
|
||||||
|
pos: (self.x, self.y).into(),
|
||||||
|
rot: self.rotate.unwrap_or(0.0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteSes, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Keepout {
|
pub struct Keepout {
|
||||||
#[anon]
|
#[anon]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue