From 2f903633e6bdb27101f053138adf1d3bf5e00c6f Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 10 Feb 2023 13:24:23 -0300 Subject: [PATCH] Added support to cross components on KiCad 7 PCBs - Not the most elegant solution, but the less impact --- kibot/gs.py | 7 +++++++ kibot/out_base.py | 14 +++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/kibot/gs.py b/kibot/gs.py index a87bb7ce..4fb7b103 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -495,6 +495,13 @@ class GS(object): return pcbnew.BOX2I(pcbnew.VECTOR2I(tlx, tly), pcbnew.VECTOR2I(brx-tlx, bry-tly)) return pcbnew.EDA_RECT(pcbnew.wxPoint(tlx, tly), pcbnew.wxSize(brx-tlx, bry-tly)) + @staticmethod + def get_rect_for(bound): + if GS.ki7: + pos = bound.GetPosition() + return pcbnew.wxRect(pcbnew.wxPoint(pos.x, pos.y), pcbnew.wxSize(bound.GetWidth(), bound.GetHeight())) + return bound.getWxRect() + # @staticmethod # def create_wxpoint(x, y): # return pcbnew.wxPoint(x, y) diff --git a/kibot/out_base.py b/kibot/out_base.py index 0287cbd9..73b7141f 100644 --- a/kibot/out_base.py +++ b/kibot/out_base.py @@ -291,15 +291,15 @@ class VariantOptions(BaseOptions): The layer is which layer id will be used. """ seg1 = VariantOptions.create_module_element(m) seg1.SetWidth(120000) - seg1.SetStart(wxPoint(rect.x1, rect.y1)) - seg1.SetEnd(wxPoint(rect.x2, rect.y2)) + seg1.SetStart(GS.p2v_k7(wxPoint(rect.x1, rect.y1))) + seg1.SetEnd(GS.p2v_k7(wxPoint(rect.x2, rect.y2))) seg1.SetLayer(layer) seg1.SetLocalCoord() # Update the local coordinates m.Add(seg1) seg2 = VariantOptions.create_module_element(m) seg2.SetWidth(120000) - seg2.SetStart(wxPoint(rect.x1, rect.y2)) - seg2.SetEnd(wxPoint(rect.x2, rect.y1)) + seg2.SetStart(GS.p2v_k7(wxPoint(rect.x1, rect.y2))) + seg2.SetEnd(GS.p2v_k7(wxPoint(rect.x2, rect.y1))) seg2.SetLayer(layer) seg2.SetLocalCoord() # Update the local coordinates m.Add(seg2) @@ -326,9 +326,9 @@ class VariantOptions(BaseOptions): if gi.GetClass() == 'MGRAPHIC': l_gi = gi.GetLayer() if l_gi == ffab: - frect.Union(gi.GetBoundingBox().getWxRect()) + frect.Union(GS.get_rect_for(gi.GetBoundingBox())) if l_gi == bfab: - brect.Union(gi.GetBoundingBox().getWxRect()) + brect.Union(GS.get_rect_for(gi.GetBoundingBox())) # Cross the graphics in *.Fab if frect.x1 is not None: extra_ffab_lines.append(self.cross_module(m, frect, ffab)) @@ -676,7 +676,7 @@ class VariantOptions(BaseOptions): if gi.GetClass() == 'MGRAPHIC': l_gi = gi.GetLayer() if l_gi == fcrtyd or l_gi == bcrtyd: - bbox.Union(gi.GetBoundingBox().getWxRect()) + bbox.Union(GS.get_rect_for(gi.GetBoundingBox())) return bbox def highlight_3D_models(self, board, highlight):