← Commit history

2.23.0: relayout leaves a symbol that draws itself alone

John Lauer ·942fbdae54 ·1mo ago ·parent 47cbc49
7 files changed +44−6
Cargo.lock+1−1
@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"  [[package]] name = "adom-lbr"-version = "2.22.3"+version = "2.23.0" dependencies = [  "altium-codec",  "anyhow",
Cargo.toml+1−1
@@ -1,6 +1,6 @@ [package] name = "adom-lbr"-version = "2.22.3"+version = "2.23.0" edition = "2021" description = "adom-lbr generator / EDA translator: the canonical adom-lbr JSON is the hub, with native converters to Altium (.SchLib/.PcbLib/.IntLib), EAGLE/Fusion (.lbr), and KiCad. Altium output is written natively — no Altium needed at conversion time." 
VERSION+1−1
@@ -1 +1 @@-2.22.3+2.23.0
bin/adom-lbr
⋯ 1 unchanged line ⋯
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.22.3",+  "version": "2.23.0",   "type": "app",   "description": "adom-lbr \u2014 the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad \u21c4 Altium \u21c4 EAGLE/Fusion) through one canonical adom-lbr JSON \u2014 symbol + footprint + 3D + pin\u2194pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",   "dependencies": {},
page.json+2−2
@@ -1,6 +1,6 @@ {   "slug": "adom-lbr",-  "version": "2.22.3",+  "version": "2.23.0",   "type": "app",   "description": "adom-lbr — the EDA library translator. Bring a component in from any supported EDA tool and convert it to any other (KiCad ⇄ Altium ⇄ EAGLE/Fusion) through one canonical adom-lbr JSON — symbol + footprint + 3D + pin↔pad map. Altium is written natively (no Altium needed). Includes the adom-lbr Manager: browse wiki components and view symbol/footprint/3D + the per-EDA layer stackup.",   "dependencies": {},@@ -88,4 +88,4 @@       "label": "Browse parts"     }   ]-}\ No newline at end of file+}
src/main.rs+38
@@ -840,6 +840,16 @@ pub(crate) fn relayout_two_columns(sym: &mut ParsedSymbol, force: bool) -> bool     if sym.pins.is_empty() || !(force || four_sided) {         return false;     }+    // A SYMBOL THAT DRAWS ITSELF IS NOT A PACKAGE MIRROR. Re-laying the pins moves them+    // away from artwork that was drawn around their original positions, and the relayout+    // replaces the body with a plain box, so a capacitor's two plates or a diode's triangle+    // are simply lost: the "fix" turns a correct symbol into two stubs on a rectangle. The+    // top/bottom-pin tell is meant to catch an IC laid out like its package, and a vertical+    // two-terminal passive trips it for reasons that have nothing to do with that.+    // --symbol-layout two-column still forces it, for a caller who really means it.+    if !force && !sym.graphics.is_empty() {+        return false;+    }      // side: 0 = left, 1 = right; rank orders the sections top→bottom in a column     fn placement(p: &KicadPin) -> (usize, u8) {@@ -3151,6 +3161,34 @@ mod lint_tests {         assert!(out.contains("2.5 x 0.5 mm"), "expected the copper extent: {out}");     } +    #[test]+    fn a_symbol_that_draws_itself_is_not_relaid_out() {+        use super::{relayout_two_columns, KicadPin, ParsedSymbol, SymGraphic};+        let pin = |number: &str, angle: u32, y: f64| KicadPin {+            name: "~".to_string(), number: number.to_string(),+            x: 0.0, y, angle, length: 2.794, pin_type: "passive".to_string(),+        };+        // A vertical two-terminal passive: pins on top and bottom, which is the same tell+        // an IC laid out like its package gives, plus artwork drawn around those positions.+        let mk = |graphics: Vec<SymGraphic>| ParsedSymbol {+            name: "C".into(), reference: "C".into(), value: "100pF".into(),+            footprint: String::new(), description: String::new(),+            pins: vec![pin("1", 270, 3.81), pin("2", 90, -3.81)],+            body: None, group_labels: vec![], graphics,+            package_name: None, package_description: None,+        };+        // with its own drawing (the capacitor's two plates) it must be LEFT ALONE+        let mut drawn = mk(vec![SymGraphic::Poly(vec![(-2.032, 0.762), (2.032, 0.762)])]);+        assert!(!relayout_two_columns(&mut drawn, false));+        assert_eq!(drawn.pins[0].y, 3.81, "pins must not move");+        // ...but forcing it is still allowed for a caller who means it+        let mut forced = mk(vec![SymGraphic::Poly(vec![(-2.032, 0.762), (2.032, 0.762)])]);+        assert!(relayout_two_columns(&mut forced, true));+        // and a symbol with NO artwork of its own still gets the EE-convention relayout+        let mut plain = mk(vec![]);+        assert!(relayout_two_columns(&mut plain, false));+    }+     #[test]     fn four_sided_symbol_relays_into_two_columns() {         use super::{relayout_two_columns, KicadPin, ParsedSymbol};