mirror of https://codeberg.org/topola/topola.git
fix: Flip by X instead of rotating by 180 degrees
Obviously -- flip is undone by a flip, not a rotation. This corrects the previous commit.
This commit is contained in:
parent
b7a5d2ccb8
commit
987a4c6e9e
|
|
@ -239,7 +239,7 @@ impl Place {
|
||||||
pub fn point_with_rotation(&self) -> PointWithRotation {
|
pub fn point_with_rotation(&self) -> PointWithRotation {
|
||||||
PointWithRotation {
|
PointWithRotation {
|
||||||
pos: (self.x, self.y).into(),
|
pos: (self.x, self.y).into(),
|
||||||
rot: self.rotation + (self.side == "back").then_some(180.0).unwrap_or(0.0),
|
rot: self.rotation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
use std::collections::{btree_map::Entry as BTreeMapEntry, BTreeMap};
|
use std::collections::{btree_map::Entry as BTreeMapEntry, BTreeMap};
|
||||||
|
|
||||||
use geo::{point, Point, Rotate};
|
use geo::{Point, Rotate};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
board::{edit::BoardEdit, AccessMesadata, Board},
|
board::{edit::BoardEdit, AccessMesadata, Board},
|
||||||
|
|
@ -252,6 +252,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
Some(pinname.clone()),
|
Some(pinname.clone()),
|
||||||
|
!place_side_is_front,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Rect(rect) => {
|
Shape::Rect(rect) => {
|
||||||
|
|
@ -268,6 +269,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
Some(pinname.clone()),
|
Some(pinname.clone()),
|
||||||
|
!place_side_is_front,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Path(path) => {
|
Shape::Path(path) => {
|
||||||
|
|
@ -282,6 +284,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
Some(pinname.clone()),
|
Some(pinname.clone()),
|
||||||
|
!place_side_is_front,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Polygon(polygon) => {
|
Shape::Polygon(polygon) => {
|
||||||
|
|
@ -296,6 +299,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
Some(pinname.clone()),
|
Some(pinname.clone()),
|
||||||
|
!place_side_is_front,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -328,6 +332,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Rect(rect) => {
|
Shape::Rect(rect) => {
|
||||||
|
|
@ -344,6 +349,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Path(path) => {
|
Shape::Path(path) => {
|
||||||
|
|
@ -358,6 +364,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Polygon(polygon) => {
|
Shape::Polygon(polygon) => {
|
||||||
|
|
@ -372,6 +379,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -397,6 +405,7 @@ impl SpecctraDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
None,
|
None,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -432,9 +441,10 @@ impl SpecctraDesign {
|
||||||
layer: usize,
|
layer: usize,
|
||||||
maybe_net: Option<usize>,
|
maybe_net: Option<usize>,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
|
flip: bool,
|
||||||
) {
|
) {
|
||||||
let circle = Circle {
|
let circle = Circle {
|
||||||
pos: Self::pos(place, pin, 0.0, 0.0),
|
pos: Self::pos(place, pin, 0.0, 0.0, flip),
|
||||||
r,
|
r,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -461,13 +471,14 @@ impl SpecctraDesign {
|
||||||
layer: usize,
|
layer: usize,
|
||||||
maybe_net: Option<usize>,
|
maybe_net: Option<usize>,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
|
flip: bool,
|
||||||
) {
|
) {
|
||||||
// Corners.
|
// Corners.
|
||||||
let dot_1_1 = board.add_fixed_dot_infringably(
|
let dot_1_1 = board.add_fixed_dot_infringably(
|
||||||
recorder,
|
recorder,
|
||||||
FixedDotWeight(GeneralDotWeight {
|
FixedDotWeight(GeneralDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place, pin, x1, y1),
|
pos: Self::pos(place, pin, x1, y1, flip),
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -479,7 +490,7 @@ impl SpecctraDesign {
|
||||||
recorder,
|
recorder,
|
||||||
FixedDotWeight(GeneralDotWeight {
|
FixedDotWeight(GeneralDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place, pin, x2, y1),
|
pos: Self::pos(place, pin, x2, y1, flip),
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -491,7 +502,7 @@ impl SpecctraDesign {
|
||||||
recorder,
|
recorder,
|
||||||
FixedDotWeight(GeneralDotWeight {
|
FixedDotWeight(GeneralDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place, pin, x2, y2),
|
pos: Self::pos(place, pin, x2, y2, flip),
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -503,7 +514,7 @@ impl SpecctraDesign {
|
||||||
recorder,
|
recorder,
|
||||||
FixedDotWeight(GeneralDotWeight {
|
FixedDotWeight(GeneralDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place, pin, x1, y2),
|
pos: Self::pos(place, pin, x1, y2, flip),
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -584,9 +595,10 @@ impl SpecctraDesign {
|
||||||
layer: usize,
|
layer: usize,
|
||||||
maybe_net: Option<usize>,
|
maybe_net: Option<usize>,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
|
flip: bool,
|
||||||
) {
|
) {
|
||||||
// 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(place, pin, coords[0].x, coords[0].y);
|
let mut prev_pos = Self::pos(place, pin, coords[0].x, coords[0].y, flip);
|
||||||
let mut prev_index = board.add_fixed_dot_infringably(
|
let mut prev_index = board.add_fixed_dot_infringably(
|
||||||
recorder,
|
recorder,
|
||||||
FixedDotWeight(GeneralDotWeight {
|
FixedDotWeight(GeneralDotWeight {
|
||||||
|
|
@ -602,7 +614,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, pin, coord.x, coord.y);
|
let pos = Self::pos(place, pin, coord.x, coord.y, flip);
|
||||||
|
|
||||||
if pos == prev_pos {
|
if pos == prev_pos {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -649,6 +661,7 @@ impl SpecctraDesign {
|
||||||
layer: usize,
|
layer: usize,
|
||||||
maybe_net: Option<usize>,
|
maybe_net: Option<usize>,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
|
flip: bool,
|
||||||
) {
|
) {
|
||||||
let mut nodes = Vec::with_capacity(coords.len() * 2 - 1);
|
let mut nodes = Vec::with_capacity(coords.len() * 2 - 1);
|
||||||
|
|
||||||
|
|
@ -657,7 +670,7 @@ impl SpecctraDesign {
|
||||||
recorder,
|
recorder,
|
||||||
FixedDotWeight(GeneralDotWeight {
|
FixedDotWeight(GeneralDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place, pin, coords[0].x, coords[0].y),
|
pos: Self::pos(place, pin, coords[0].x, coords[0].y, flip),
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -686,7 +699,7 @@ impl SpecctraDesign {
|
||||||
recorder,
|
recorder,
|
||||||
FixedDotWeight(GeneralDotWeight {
|
FixedDotWeight(GeneralDotWeight {
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: Self::pos(place, pin, coord.x, coord.y),
|
pos: Self::pos(place, pin, coord.x, coord.y, flip),
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -721,8 +734,9 @@ impl SpecctraDesign {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pos(place: PointWithRotation, pin: PointWithRotation, x: f64, y: f64) -> Point {
|
fn pos(place: PointWithRotation, pin: PointWithRotation, x: f64, y: f64, flip: bool) -> Point {
|
||||||
let pos = (point! {x: x, y: y} + pin.pos).rotate_around_point(pin.rot, pin.pos);
|
let pos = (Point::new(x, y) + pin.pos).rotate_around_point(pin.rot, pin.pos);
|
||||||
(pos + place.pos).rotate_around_point(place.rot, place.pos)
|
(place.pos + flip.then_some(Point::new(-pos.x(), pos.y())).unwrap_or(pos))
|
||||||
|
.rotate_around_point(place.rot, place.pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue