Skip to content

Commit

Permalink
[PCB Print][KiCad 8][Fixed] Compatibility issue
Browse files Browse the repository at this point in the history
- When unsing high verbose levels
- The GetShownText() API changed (again)
  • Loading branch information
set-soft committed Mar 27, 2024
1 parent 92a9741 commit 7ca311b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions kibot/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions kibot/out_pcb_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion tests/test_plot/test_print_pcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/yaml_samples/pcb_print_2.kibot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ca311b

Please sign in to comment.