Simplified the drill_marks stuff

- Setter/getter are no longer needed
This commit is contained in:
Salvador E. Tropea 2022-06-10 17:50:11 -03:00
parent aefe54d770
commit a7a50dcf6d
3 changed files with 16 additions and 40 deletions

View File

@ -21,12 +21,12 @@ DRILL_MARKS_REV_MAP = {
PCB_PLOT_PARAMS.SMALL_DRILL_SHAPE: 'small',
PCB_PLOT_PARAMS.FULL_DRILL_SHAPE: 'full',
}
DRILL_MARKS_HELP = "[none,small,full] What to use to indicate the drill places, can be none, small or full (for real scale)"
def drill_marks_help(self):
self._drill_marks = 'full'
self.set_doc('drill_marks', " [string='full'] "+DRILL_MARKS_HELP)
def add_drill_marks(self):
self.drill_marks = 'full'
self.set_doc('drill_marks', " [string='full'] [none,small,full] What to use to indicate the drill places, can be "
"none, small or full (for real scale)")
class DrillMarks(AnyLayerOptions):
@ -34,25 +34,17 @@ class DrillMarks(AnyLayerOptions):
Used by DXF, HPGL, PDF, PS and SVG formats. """
def __init__(self):
super().__init__()
drill_marks_help(self)
@property
def drill_marks(self):
return self._drill_marks
@drill_marks.setter
def drill_marks(self, val):
self._drill_marks = val
add_drill_marks(self)
def config(self, parent):
super().config(parent)
self._drill_marks = DRILL_MARKS_MAP[self._drill_marks]
self.drill_marks = DRILL_MARKS_MAP[self.drill_marks]
def _configure_plot_ctrl(self, po, output_dir):
super()._configure_plot_ctrl(po, output_dir)
# How we draw drill marks
po.SetDrillMarksType(self._drill_marks)
po.SetDrillMarksType(self.drill_marks)
def read_vals_from_po(self, po):
super().read_vals_from_po(po)
self._drill_marks = DRILL_MARKS_REV_MAP[po.GetDrillMarksType()]
self.drill_marks = DRILL_MARKS_REV_MAP[po.GetDrillMarksType()]

View File

@ -12,7 +12,7 @@ from .misc import CMD_PCBNEW_PRINT_LAYERS, URL_PCBNEW_PRINT_LAYERS, PDF_PCB_PRIN
from .out_base import VariantOptions
from .registrable import RegDependency
from .macros import macros, document, output_class # noqa: F401
from .drill_marks import drill_marks_help, DRILL_MARKS_MAP
from .drill_marks import add_drill_marks, DRILL_MARKS_MAP
from .layer import Layer
from . import log
@ -51,20 +51,12 @@ class Any_PCB_PrintOptions(VariantOptions):
""" Selects the color theme. Onlyu applies to KiCad 6.
To use the KiCad 6 default colors select `_builtin_default`.
Usually user colors are stored as `user`, but you can give it another name """
drill_marks_help(self)
add_drill_marks(self)
super().__init__()
@property
def drill_marks(self):
return self._drill_marks
@drill_marks.setter
def drill_marks(self, val):
self._drill_marks = val
def config(self, parent):
super().config(parent)
self._drill_marks = DRILL_MARKS_MAP[self._drill_marks]
self.drill_marks = DRILL_MARKS_MAP[self.drill_marks]
def filter_components(self, board, force_copy):
if not self._comps and not force_copy:
@ -92,7 +84,7 @@ class Any_PCB_PrintOptions(VariantOptions):
cmd = [CMD_PCBNEW_PRINT_LAYERS, 'export', '--output_name', output]
if BasePreFlight.get_option('check_zone_fills'):
cmd.append('-f')
cmd.extend(['--scaling', str(self.scaling), '--pads', str(self._drill_marks)])
cmd.extend(['--scaling', str(self.scaling), '--pads', str(self.drill_marks)])
if not self.plot_sheet_reference:
cmd.append('--no-title')
if self.monochrome:

View File

@ -28,7 +28,7 @@ from .kiplot import check_script, exec_with_retry, add_extra_options
from .registrable import RegDependency
from .create_pdf import create_pdf_from_pages
from .macros import macros, document, output_class # noqa: F401
from .drill_marks import DRILL_MARKS_MAP, drill_marks_help
from .drill_marks import DRILL_MARKS_MAP, add_drill_marks
from .layer import Layer, get_priority
from . import __version__
from . import log
@ -293,18 +293,10 @@ class PCB_PrintOptions(VariantOptions):
""" Color for the background when `add_background` is enabled """
self.background_image = ''
""" Background image, must be an SVG, only when `add_background` is enabled """
drill_marks_help(self)
add_drill_marks(self)
super().__init__()
self._expand_id = 'assembly'
@property
def drill_marks(self):
return self._drill_marks
@drill_marks.setter
def drill_marks(self, val):
self._drill_marks = val
def config(self, parent):
super().config(parent)
if isinstance(self.pages, type):
@ -321,7 +313,7 @@ class PCB_PrintOptions(VariantOptions):
la.color = layer_id2color[la._id]
else:
la.color = "#000000"
self._drill_marks = DRILL_MARKS_MAP[self._drill_marks]
self.drill_marks = DRILL_MARKS_MAP[self.drill_marks]
self._expand_ext = self.format.lower()
for member, color in self._pad_colors.items():
if getattr(self, member):
@ -933,7 +925,7 @@ class PCB_PrintOptions(VariantOptions):
po.SetPlotValue(la.plot_footprint_values)
po.SetPlotInvisibleText(la.force_plot_invisible_refs_vals)
# Avoid holes on non-copper layers
po.SetDrillMarksType(self._drill_marks if IsCopperLayer(id) else 0)
po.SetDrillMarksType(self.drill_marks if IsCopperLayer(id) else 0)
pc.SetLayer(id)
pc.OpenPlotfile(la.suffix, PLOT_FORMAT_SVG, p.sheet)
pc.PlotLayer()