Skip to content

Commit

Permalink
[Do Not Fit footprint crosses][Fixed] Not centered
Browse files Browse the repository at this point in the history
- Problems with footprints where the center isn't the geometric center

Fixes #725
  • Loading branch information
set-soft committed Nov 21, 2024
1 parent 0c5aa1e commit 22d4a5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- iBoM and Schematic print didn't take it into account (#716)
- BoM
- The field name `Reference` was accepted, but didn't work
- Do Not Fit footprint crosses:
- Problems with footprints where the center isn't the geometric center (#725)

### Changed
- Default temporal layer for internal use is now "Margin", instead of "User.9"
Expand Down
5 changes: 5 additions & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ Fixed

- The field name ``Reference`` was accepted, but didn’t work

- Do Not Fit footprint crosses:

- Problems with footprints where the center isn’t the geometric
center (#725)

Changed
~~~~~~~

Expand Down
12 changes: 7 additions & 5 deletions kibot/out_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,20 +335,21 @@ def cross_module(m, rect, layer, angle):
The rect is a Rect object with the size.
The layer is which layer id will be used.
The angle is the cross angle, which matches the footprint. """
center = GS.p2v_k7(m.GetCenter())
seg1 = GS.create_module_element(m)
seg1.SetWidth(120000)
seg1.SetStart(GS.p2v_k7(wxPoint(rect.x1, rect.y1)))
seg1.SetEnd(GS.p2v_k7(wxPoint(rect.x2, rect.y2)))
seg1.SetLayer(layer)
seg1.Rotate(GS.p2v_k7(seg1.GetCenter()), GS.angle(angle))
seg1.Rotate(center, GS.angle(angle))
GS.footprint_update_local_coords(seg1)
m.Add(seg1)
seg2 = GS.create_module_element(m)
seg2.SetWidth(120000)
seg2.SetStart(GS.p2v_k7(wxPoint(rect.x1, rect.y2)))
seg2.SetEnd(GS.p2v_k7(wxPoint(rect.x2, rect.y1)))
seg2.SetLayer(layer)
seg2.Rotate(GS.p2v_k7(seg2.GetCenter()), GS.angle(angle))
seg2.Rotate(center, GS.angle(angle))
GS.footprint_update_local_coords(seg2)
m.Add(seg2)
return [seg1, seg2]
Expand All @@ -375,16 +376,17 @@ def cross_modules(self, board, comps_hash):
if c and c.included and not c.fitted:
# Measure the component BBox (only graphics)
fp_angle = m.GetOrientationDegrees()
m.Rotate(GS.p2v_k7(m.GetCenter()), GS.angle(-fp_angle))
center = GS.p2v_k7(m.GetCenter())
m.Rotate(center, GS.angle(-fp_angle))
for gi in m.GraphicalItems():
if gi.GetClass() == GS.footprint_gr_type:
l_gi = gi.GetLayer()
if l_gi == ffab:
frect.Union(GS.get_rect_for(gi.GetBoundingBox()))
if l_gi == bfab:
brect.Union(GS.get_rect_for(gi.GetBoundingBox()))
# Rotate the footprint back
m.Rotate(GS.p2v_k7(m.GetCenter()), GS.angle(fp_angle))
# Rotate the footprint back (using the same center)
m.Rotate(center, GS.angle(fp_angle))
# Cross the graphics in *.Fab
if frect.x1 is not None:
extra_tlay_lines.append(self.cross_module(m, frect, tlay, fp_angle))
Expand Down

0 comments on commit 22d4a5d

Please sign in to comment.