[PCB Print][Added] Options to mirror the text
In the user layers when creating a mirrored page Closes #561
This commit is contained in:
parent
c04067d603
commit
c04f7e52c8
|
|
@ -77,6 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Expand text variables and KiBot %X markers in text objects (see #497)
|
||||
- PCB Print:
|
||||
- Support for CURRENT_DATE text variable
|
||||
- Options to mirror the text in the user layers when creating a mirrored page
|
||||
(#561)
|
||||
- Populate:
|
||||
- Basic support for regular list items (#480)
|
||||
- Position:
|
||||
|
|
|
|||
|
|
@ -2367,6 +2367,10 @@ outputs:
|
|||
line_width: 0.1
|
||||
# [boolean=false] Print mirrored (X axis inverted)
|
||||
mirror: false
|
||||
# [boolean=true] Mirror text in the footprints when mirror option is enabled and we plot a user layer
|
||||
mirror_footprint_text: true
|
||||
# [boolean=true] Mirror text in the PCB when mirror option is enabled and we plot a user layer
|
||||
mirror_pcb_text: true
|
||||
# [boolean=false] Print in gray scale
|
||||
monochrome: false
|
||||
# [boolean=false] Invert black and white. Only useful for a single layer
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ Parameters:
|
|||
- ``holes_color`` :index:`: <pair: output - pcb_print - options - pages; holes_color>` [string='#000000'] Color used for the holes when `colored_holes` is enabled.
|
||||
- ``line_width`` :index:`: <pair: output - pcb_print - options - pages; line_width>` [number=0.1] [0.02,2] For objects without width [mm] (KiCad 5).
|
||||
- ``mirror`` :index:`: <pair: output - pcb_print - options - pages; mirror>` [boolean=false] Print mirrored (X axis inverted).
|
||||
- ``mirror_footprint_text`` :index:`: <pair: output - pcb_print - options - pages; mirror_footprint_text>` [boolean=true] Mirror text in the footprints when mirror option is enabled and we plot a user layer.
|
||||
- ``mirror_pcb_text`` :index:`: <pair: output - pcb_print - options - pages; mirror_pcb_text>` [boolean=true] Mirror text in the PCB when mirror option is enabled and we plot a user layer.
|
||||
- ``monochrome`` :index:`: <pair: output - pcb_print - options - pages; monochrome>` [boolean=false] Print in gray scale.
|
||||
- ``negative_plot`` :index:`: <pair: output - pcb_print - options - pages; negative_plot>` [boolean=false] Invert black and white. Only useful for a single layer.
|
||||
- ``page_id`` :index:`: <pair: output - pcb_print - options - pages; page_id>` [string='%02d'] Text to differentiate the pages. Use %d (like in C) to get the page number.
|
||||
|
|
|
|||
|
|
@ -157,6 +157,10 @@ class PagesOptions(Optionable):
|
|||
with document:
|
||||
self.mirror = False
|
||||
""" Print mirrored (X axis inverted) """
|
||||
self.mirror_pcb_text = True
|
||||
""" Mirror text in the PCB when mirror option is enabled and we plot a user layer """
|
||||
self.mirror_footprint_text = True
|
||||
""" Mirror text in the footprints when mirror option is enabled and we plot a user layer """
|
||||
self.monochrome = False
|
||||
""" Print in gray scale """
|
||||
self.scaling = None
|
||||
|
|
@ -1083,6 +1087,33 @@ class PCB_PrintOptions(VariantOptions):
|
|||
return False
|
||||
return True
|
||||
|
||||
def mirror_text(self, page, id):
|
||||
""" Mirror text in the user layers """
|
||||
if not page.mirror:
|
||||
return
|
||||
extra_debug = GS.debug_level > 2
|
||||
if extra_debug:
|
||||
logger.debug('mirror_text processing')
|
||||
if page.mirror_pcb_text:
|
||||
for g in GS.board.GetDrawings():
|
||||
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()}')
|
||||
g.SetMirrored(not g.IsMirrored())
|
||||
g.SetHorizJustify(-g.GetHorizJustify())
|
||||
if page.mirror_footprint_text:
|
||||
for m in GS.get_modules():
|
||||
for g in m.GraphicalItems():
|
||||
if g.GetLayer() == id:
|
||||
if hasattr(g, 'GetShownText'):
|
||||
if extra_debug:
|
||||
logger.debug(f'- {g.GetClass()} {g.GetShownText()} @ {g.GetCenter()}'
|
||||
f' mirrored: {g.IsMirrored()} just: {g.GetHorizJustify()}')
|
||||
g.SetMirrored(not g.IsMirrored())
|
||||
g.SetHorizJustify(-g.GetHorizJustify())
|
||||
|
||||
def generate_output(self, output):
|
||||
self.check_tools()
|
||||
# Avoid KiCad 5 complaining about fake vias diameter == drill == 0
|
||||
|
|
@ -1176,6 +1207,7 @@ class PCB_PrintOptions(VariantOptions):
|
|||
filelist = []
|
||||
if self.force_edge_cuts and next(filter(lambda x: x._id == edge_id, p.layers), None) is None:
|
||||
p.layers.append(edge_layer)
|
||||
user_layer_ids = set(Layer._get_user().values())
|
||||
for la in p.layers:
|
||||
id = la._id
|
||||
logger.debug('- Plotting layer {} ({})'.format(la.layer, id))
|
||||
|
|
@ -1185,8 +1217,12 @@ class PCB_PrintOptions(VariantOptions):
|
|||
# Avoid holes on non-copper layers
|
||||
po.SetDrillMarksType(self.drill_marks if IsCopperLayer(id) else 0)
|
||||
pc.SetLayer(id)
|
||||
if id in user_layer_ids:
|
||||
self.mirror_text(p, id)
|
||||
pc.OpenPlotfile(la.suffix, PLOT_FORMAT_SVG, p.sheet)
|
||||
pc.PlotLayer()
|
||||
if id in user_layer_ids:
|
||||
self.mirror_text(p, id)
|
||||
pc.ClosePlot()
|
||||
filelist.append((pc.GetPlotFileName(), la.color))
|
||||
self.plot_extra_cu(id, la, pc, p, filelist)
|
||||
|
|
|
|||
Loading…
Reference in New Issue