From 7ca311bddb887dcaeae387206524045c9f98cb3a Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 27 Mar 2024 06:31:41 -0300 Subject: [PATCH] [PCB Print][KiCad 8][Fixed] Compatibility issue - When unsing high verbose levels - The GetShownText() API changed (again) --- kibot/gs.py | 10 ++++++++++ kibot/out_pcb_print.py | 6 +++--- tests/test_plot/test_print_pcb.py | 2 +- tests/yaml_samples/pcb_print_2.kibot.yaml | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/kibot/gs.py b/kibot/gs.py index 945b08d3c..727c7abb4 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -879,3 +879,13 @@ def set_fields(footprint, flds): footprint.GetFieldByName(fld).SetVisible(False) elif GS.ki6: footprint.SetProperties(flds) + + @staticmethod + def get_shown_text(obj, allow_extra_text=True, a_depth=0): + if GS.ki8: # 8 + return obj.GetShownText(allow_extra_text, a_depth) + if GS.ki7: # 7 + return obj.GetShownText() + if GS.ki6: # 6 + return obj.GetShownText(a_depth, allow_extra_text) + return obj.GetShownText() # 5 diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index ac6c24a7f..6b10fda3e 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -1109,8 +1109,8 @@ def mirror_text(self, page, id): if g.GetLayer() == id: if hasattr(g, 'GetShownText'): if extra_debug: - logger.debug(f'- {g.GetClass()} {g.GetShownText()} @ {g.GetCenter()} mirrored: {g.IsMirrored()}' - f' just: {g.GetHorizJustify()}') + logger.debug(f'- {g.GetClass()} {GS.get_shown_text(g)} @ {g.GetCenter()}' + f' mirrored: {g.IsMirrored()} just: {g.GetHorizJustify()}') g.SetMirrored(not g.IsMirrored()) g.SetHorizJustify(-g.GetHorizJustify()) if page.mirror_footprint_text: @@ -1119,7 +1119,7 @@ def mirror_text(self, page, id): if g.GetLayer() == id: if hasattr(g, 'GetShownText'): if extra_debug: - logger.debug(f'- {g.GetClass()} {g.GetShownText()} @ {g.GetCenter()}' + logger.debug(f'- {g.GetClass()} {GS.get_shown_text(g)} @ {g.GetCenter()}' f' mirrored: {g.IsMirrored()} just: {g.GetHorizJustify()}') g.SetMirrored(not g.IsMirrored()) g.SetHorizJustify(-g.GetHorizJustify()) diff --git a/tests/test_plot/test_print_pcb.py b/tests/test_plot/test_print_pcb.py index 891df4098..65fc4764f 100644 --- a/tests/test_plot/test_print_pcb.py +++ b/tests/test_plot/test_print_pcb.py @@ -128,7 +128,7 @@ def test_print_wrong_paste(test_dir): def test_pcb_print_simple_1(test_dir): prj = 'light_control' ctx = context.TestContext(test_dir, prj, 'pcb_print_2') - ctx.run() + ctx.run(extra_debug=True) ctx.expect_out_file(prj+'-F_Cu_mono.png') ctx.expect_out_file(prj+'-F_Cu_color.png') if is_debian: diff --git a/tests/yaml_samples/pcb_print_2.kibot.yaml b/tests/yaml_samples/pcb_print_2.kibot.yaml index 2fa3032a0..d32f49418 100644 --- a/tests/yaml_samples/pcb_print_2.kibot.yaml +++ b/tests/yaml_samples/pcb_print_2.kibot.yaml @@ -56,6 +56,8 @@ outputs: - layer: B.Cu - layer: B.Mask color: '#14332440' + - layer: User.Drawings + - layer: User.Comments sort_layers: true monochrome: true mirror: true