[PCB Print] Added option to configure the forced edge color.

Closes #281
This commit is contained in:
Salvador E. Tropea 2022-09-06 11:06:44 -03:00
parent 43aae8b0fe
commit 22d618a425
4 changed files with 15 additions and 4 deletions

View File

@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
KiCad bug [11562](https://gitlab.com/kicad/code/kicad/-/issues/11562) KiCad bug [11562](https://gitlab.com/kicad/code/kicad/-/issues/11562)
- Internal BoM: KiCad 6 text variables expansion in the fields (#247) - Internal BoM: KiCad 6 text variables expansion in the fields (#247)
- Compress: Option to store symlinks. (See #265) - Compress: Option to store symlinks. (See #265)
- PCB Print: Option to configure the forced edge color. (#281)
### Fixed ### Fixed
- OAR computation (Report) (#225) - OAR computation (Report) (#225)

View File

@ -2227,6 +2227,7 @@ Notes:
- `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted. - `dnf_filter`: [string|list(string)='_none'] Name of the filter to mark components as not fitted.
A short-cut to use for simple cases where a variant is an overkill. A short-cut to use for simple cases where a variant is an overkill.
- `drill_marks`: [string='full'] [none,small,full] What to use to indicate the drill places, can be none, small or full (for real scale). - `drill_marks`: [string='full'] [none,small,full] What to use to indicate the drill places, can be none, small or full (for real scale).
- `forced_edge_cuts_color`: [string=''] Color used for the `force_edge_cuts` option.
- `frame_plot_mechanism`: [string='internal'] [gui,internal,plot] Plotting the frame from Python is problematic. - `frame_plot_mechanism`: [string='internal'] [gui,internal,plot] Plotting the frame from Python is problematic.
This option selects a workaround strategy. This option selects a workaround strategy.
gui: uses KiCad GUI to do it. Is slow but you get the correct frame. gui: uses KiCad GUI to do it. Is slow but you get the correct frame.

View File

@ -1090,6 +1090,8 @@ outputs:
drill_marks: 'full' drill_marks: 'full'
# [boolean=false] Add the `Edge.Cuts` to all the pages # [boolean=false] Add the `Edge.Cuts` to all the pages
force_edge_cuts: false force_edge_cuts: false
# [string=''] Color used for the `force_edge_cuts` option
forced_edge_cuts_color: ''
# [string='PDF'] [PDF,SVG,PNG,EPS,PS] Format for the output file/s. # [string='PDF'] [PDF,SVG,PNG,EPS,PS] Format for the output file/s.
# Note that for PS you need `ghostscript` which isn't part of the default docker images # Note that for PS you need `ghostscript` which isn't part of the default docker images
format: 'PDF' format: 'PDF'

View File

@ -264,6 +264,8 @@ class PCB_PrintOptions(VariantOptions):
""" Store the temporal page and layer files in the output dir and don't delete them """ """ Store the temporal page and layer files in the output dir and don't delete them """
self.force_edge_cuts = False self.force_edge_cuts = False
""" *Add the `Edge.Cuts` to all the pages """ """ *Add the `Edge.Cuts` to all the pages """
self.forced_edge_cuts_color = ''
""" Color used for the `force_edge_cuts` option """
self.scaling = 1.0 self.scaling = 1.0
""" *Default scale factor (0 means autoscaling)""" """ *Default scale factor (0 means autoscaling)"""
self.realistic_solder_mask = True self.realistic_solder_mask = True
@ -303,6 +305,8 @@ class PCB_PrintOptions(VariantOptions):
self.validate_color(member) self.validate_color(member)
else: else:
setattr(self, member, getattr(self._color_theme, color)) setattr(self, member, getattr(self._color_theme, color))
if self.forced_edge_cuts_color:
self.validate_color('forced_edge_cuts_color')
if self.frame_plot_mechanism == 'plot' and GS.ki5: if self.frame_plot_mechanism == 'plot' and GS.ki5:
raise KiPlotConfigurationError("You can't use `plot` for `frame_plot_mechanism` with KiCad 5. It will crash.") raise KiPlotConfigurationError("You can't use `plot` for `frame_plot_mechanism` with KiCad 5. It will crash.")
KiConf.init(GS.pcb_file) KiConf.init(GS.pcb_file)
@ -921,11 +925,14 @@ class PCB_PrintOptions(VariantOptions):
if self.force_edge_cuts: if self.force_edge_cuts:
edge_layer = LayerOptions.create_layer('Edge.Cuts') edge_layer = LayerOptions.create_layer('Edge.Cuts')
edge_id = edge_layer._id edge_id = edge_layer._id
layer_id2color = self._color_theme.layer_id2color if self.forced_edge_cuts_color:
if edge_id in layer_id2color: edge_layer.color = self.forced_edge_cuts_color
edge_layer.color = layer_id2color[edge_id]
else: else:
edge_layer.color = "#000000" layer_id2color = self._color_theme.layer_id2color
if edge_id in layer_id2color:
edge_layer.color = layer_id2color[edge_id]
else:
edge_layer.color = "#000000"
# Generate the output, page by page # Generate the output, page by page
pages = [] pages = []
for n, p in enumerate(self.pages): for n, p in enumerate(self.pages):