Skip to content

Commit

Permalink
[BoardView][Fixed] X axis mirroring issues
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Mar 5, 2024
1 parent 2a0596e commit 5bbb18d
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 294 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
(#578)
- Filters: _none filter not always honored (i.e. exclude in BoM) (#580)
- PCB Parity: components excluded from the board reported anyways (#585)
- BoardView: X axis mirroring issues (whitequark/kicad-boardview#11)

## [1.6.4] - 2024-02-02
### Added
Expand Down
29 changes: 15 additions & 14 deletions kibot/out_boardview.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ def coord(nanometers):
return milliinches


def y_coord(obj, maxy, y):
if obj.IsFlipped():
return coord(y)
else:
return coord(maxy - y)
def y_coord(maxy, y, flipped):
# Adjust y-coordinate to start from the bottom of the board and account for flipped components
return coord(maxy - y) if not flipped else coord(y)


def pad_sort_key(pad):
Expand Down Expand Up @@ -70,11 +68,11 @@ def convert(pcb, brd):
for point in outline_points:
brd.write("{x} {y}\n"
.format(x=coord(point.x),
y=coord(point.y)))
y=y_coord(outline_maxy, point.y, False)))
if outline.IsClosed():
brd.write("{x} {y}\n"
.format(x=coord(outline_points[0].x),
y=coord(outline_points[0].y)))
y=y_coord(outline_maxy, outline_points[0].y, False)))
brd.write("\n")

# Nets
Expand All @@ -101,14 +99,15 @@ def convert(pcb, brd):
pin_at = 0
for module in modules:
module_bbox = module.GetBoundingBox()
flipped = module.IsFlipped()
brd.write("{ref} {x1} {y1} {x2} {y2} {pin} {side}\n"
.format(ref=module.GetReference(),
x1=coord(module_bbox.GetLeft()),
y1=y_coord(module, outline_maxy, module_bbox.GetTop()),
y1=y_coord(outline_maxy, module_bbox.GetTop(), flipped),
x2=coord(module_bbox.GetRight()),
y2=y_coord(module, outline_maxy, module_bbox.GetBottom()),
y2=y_coord(outline_maxy, module_bbox.GetBottom(), flipped),
pin=pin_at,
side=1 + module.IsFlipped()))
side=1 + flipped))
pin_at += module.GetPadCount()
brd.write("\n")

Expand All @@ -122,11 +121,12 @@ def convert(pcb, brd):
brd.write("PINS: {count}\n".format(count=len(pads)))
for pad in pads:
pad_pos = pad.GetPosition()
flipped = pad.IsFlipped()
brd.write("{x} {y} {net} {side}\n"
.format(x=coord(pad_pos.x),
y=y_coord(pad, outline_maxy, pad_pos.y),
y=y_coord(outline_maxy, pad_pos.y, flipped),
net=pad.GetNetCode(),
side=1 + pad.IsFlipped()))
side=1 + flipped))
brd.write("\n")

# Nails
Expand All @@ -141,12 +141,13 @@ def convert(pcb, brd):
brd.write("NAILS: {count}\n".format(count=len(testpoints)))
for module, pad in testpoints:
pad_pos = pad.GetPosition()
flipped = pad.IsFlipped()
brd.write("{probe} {x} {y} {net} {side}\n"
.format(probe=module.GetReference()[2:],
x=coord(pad_pos.x),
y=y_coord(pad, outline_maxy, pad_pos.y),
y=y_coord(outline_maxy, pad_pos.y, flipped),
net=pad.GetNetCode(),
side=1 + pad.IsFlipped()))
side=1 + flipped))
brd.write("\n")


Expand Down
138 changes: 69 additions & 69 deletions tests/reference/5_1_7/glasgow-boardview.brd
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
0
BRDOUT: 69 5118 4724
4976 2796
4991 2798
5006 2802
5020 2807
5034 2813
5048 2821
5060 2831
5071 2841
5082 2852
5091 2865
5099 2878
5106 2892
5111 2907
5115 2922
5117 2937
5118 2952
5118 4566
5117 4582
5115 4597
5111 4612
5106 4627
5099 4641
5091 4654
5082 4666
5071 4678
5060 4688
5048 4697
5034 4705
5020 4712
5006 4717
4991 4721
4976 4723
4960 4724
2125 4724
2110 4723
2095 4721
2080 4717
2065 4712
2051 4705
2038 4697
2026 4688
2014 4678
2004 4666
1995 4654
1987 4641
1980 4627
1975 4612
1971 4597
1969 4582
1968 4566
1968 2952
1969 2937
1971 2922
1975 2907
1980 2892
1987 2878
1995 2865
2004 2852
2014 2841
2026 2831
2038 2821
2051 2813
2065 2807
2080 2802
2095 2798
2110 2796
2125 2795
4960 2795
4976 2796
4976 1928
4991 1926
5006 1922
5020 1917
5034 1910
5048 1902
5060 1893
5071 1883
5082 1871
5091 1859
5099 1845
5106 1831
5111 1817
5115 1802
5117 1787
5118 1771
5118 157
5117 142
5115 126
5111 111
5106 97
5099 83
5091 69
5082 57
5071 46
5060 35
5048 26
5034 18
5020 11
5006 6
4991 3
4976 0
4960 0
2125 0
2110 0
2095 3
2080 6
2065 11
2051 18
2038 26
2026 35
2014 46
2004 57
1995 69
1987 83
1980 97
1975 111
1971 126
1969 142
1968 157
1968 1771
1969 1787
1971 1802
1975 1817
1980 1831
1987 1845
1995 1859
2004 1871
2014 1883
2026 1893
2038 1902
2051 1910
2065 1917
2080 1922
2095 1926
2110 1928
2125 1929
4960 1929
4976 1928

NETS: 227
1 /SDA
Expand Down
138 changes: 69 additions & 69 deletions tests/reference/6_0_8/glasgow-boardview.brd
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
0
BRDOUT: 69 5118 4724
4976 2796
4991 2798
5006 2802
5020 2807
5034 2813
5048 2821
5060 2831
5071 2841
5082 2852
5091 2865
5099 2878
5106 2892
5111 2907
5115 2922
5117 2937
5118 2952
5118 4566
5117 4582
5115 4597
5111 4612
5106 4627
5099 4641
5091 4654
5082 4666
5071 4678
5060 4688
5048 4697
5034 4705
5020 4712
5006 4717
4991 4721
4976 4723
4960 4724
2125 4724
2110 4723
2095 4721
2080 4717
2065 4712
2051 4705
2038 4697
2026 4688
2014 4678
2004 4666
1995 4654
1987 4641
1980 4627
1975 4612
1971 4597
1969 4582
1968 4566
1968 2952
1969 2937
1971 2922
1975 2907
1980 2892
1987 2878
1995 2865
2004 2852
2014 2841
2026 2831
2038 2821
2051 2813
2065 2807
2080 2802
2095 2798
2110 2796
2125 2795
4960 2795
4976 2796
4976 1928
4991 1926
5006 1922
5020 1917
5034 1910
5048 1902
5060 1893
5071 1883
5082 1871
5091 1859
5099 1845
5106 1831
5111 1817
5115 1802
5117 1787
5118 1771
5118 157
5117 142
5115 126
5111 111
5106 97
5099 83
5091 69
5082 57
5071 46
5060 35
5048 26
5034 18
5020 11
5006 6
4991 3
4976 0
4960 0
2125 0
2110 0
2095 3
2080 6
2065 11
2051 18
2038 26
2026 35
2014 46
2004 57
1995 69
1987 83
1980 97
1975 111
1971 126
1969 142
1968 157
1968 1771
1969 1787
1971 1802
1975 1817
1980 1831
1987 1845
1995 1859
2004 1871
2014 1883
2026 1893
2038 1902
2051 1910
2065 1917
2080 1922
2095 1926
2110 1928
2125 1929
4960 1929
4976 1928

NETS: 227
1 /SDA
Expand Down
Loading

0 comments on commit 5bbb18d

Please sign in to comment.