- added a fix in the Gerber parser to work even when there is no information about zero suppression in the Gerber file

- added new settings in Edit -> Preferences -> Gerber for Gerber Units and Gerber Zeros to be used as defaults in case that those informations are missing from the Gerber file
This commit is contained in:
Marius Stanciu 2019-10-01 15:08:49 +03:00
parent 6d3770ee3f
commit ce666e2dbf
4 changed files with 70 additions and 13 deletions

View File

@ -500,6 +500,8 @@ class App(QtCore.QObject):
"gerber_solid": self.ui.gerber_defaults_form.gerber_gen_group.solid_cb,
"gerber_multicolored": self.ui.gerber_defaults_form.gerber_gen_group.multicolored_cb,
"gerber_circle_steps": self.ui.gerber_defaults_form.gerber_gen_group.circle_steps_entry,
"gerber_def_units": self.ui.gerber_defaults_form.gerber_gen_group.gerber_units_radio,
"gerber_def_zeros": self.ui.gerber_defaults_form.gerber_gen_group.gerber_zeros_radio,
# Gerber Options
"gerber_isotooldia": self.ui.gerber_defaults_form.gerber_opt_group.iso_tool_dia_entry,
@ -922,6 +924,8 @@ class App(QtCore.QObject):
"gerber_multicolored": False,
"gerber_circle_steps": 128,
"gerber_use_buffer_for_union": True,
"gerber_def_units": 'IN',
"gerber_def_zeros": 'L',
# Gerber Options
"gerber_isotooldia": 0.00787402,

View File

@ -14,7 +14,9 @@ CAD program, and create G-Code for Isolation routing.
- fixed the FCSpinner and FCDoubleSpinner GUI elements to select all on first click and deselect on second click in the Spinbox LineEdit
- for Gerber object in Selected Tab added ability to chose a V-Shape tool and therefore control the isolation better by adjusting the cut width of the isolation in function of the cut depth, tip width of the tool and the tip angle of the tool
- when in Gerber UI is selectd the V-Shape tool, all those parameters (tip dia, dip angle, tool_type = 'V' and cut Z) are transferred to the generated Geometry and prefilled in the Geoemtry UI
- when in Gerber UI is selected the V-Shape tool, all those parameters (tip dia, dip angle, tool_type = 'V' and cut Z) are transferred to the generated Geometry and prefilled in the Geoemtry UI
- added a fix in the Gerber parser to work even when there is no information about zero suppression in the Gerber file
- added new settings in Edit -> Preferences -> Gerber for Gerber Units and Gerber Zeros to be used as defaults in case that those informations are missing from the Gerber file
30.09.2019

View File

@ -2142,7 +2142,7 @@ class Gerber (Geometry):
self.frac_digits = 4
"""Number of fraction digits in Gerber numbers. Used during parsing."""
self.gerber_zeros = 'L'
self.gerber_zeros = self.app.defaults['gerber_def_zeros']
"""Zeros in Gerber numbers. If 'L' then remove leading zeros, if 'T' remove trailing zeros. Used during parsing.
"""
@ -2166,7 +2166,7 @@ class Gerber (Geometry):
'''
# store the file units here:
self.gerber_units = 'IN'
self.gerber_units = self.app.defaults['gerber_def_units']
# aperture storage
self.apertures = {}
@ -2197,9 +2197,9 @@ class Gerber (Geometry):
# The format of X and Y must be the same!
# L-omit leading zeros, T-omit trailing zeros, D-no zero supression
# A-absolute notation, I-incremental notation
self.fmt_re = re.compile(r'%?FS([LTD])([AI])X(\d)(\d)Y\d\d\*%?$')
self.fmt_re_alt = re.compile(r'%FS([LT])([AI])X(\d)(\d)Y\d\d\*MO(IN|MM)\*%$')
self.fmt_re_orcad = re.compile(r'(G\d+)*\**%FS([LT])([AI]).*X(\d)(\d)Y\d\d\*%$')
self.fmt_re = re.compile(r'%?FS([LTD])?([AI])X(\d)(\d)Y\d\d\*%?$')
self.fmt_re_alt = re.compile(r'%FS([LTD])?([AI])X(\d)(\d)Y\d\d\*MO(IN|MM)\*%$')
self.fmt_re_orcad = re.compile(r'(G\d+)*\**%FS([LTD])?([AI]).*X(\d)(\d)Y\d\d\*%$')
# Mode (IN/MM)
self.mode_re = re.compile(r'^%?MO(IN|MM)\*%?$')
@ -2408,9 +2408,6 @@ class Gerber (Geometry):
# Coordinates of the current path, each is [x, y]
path = []
# store the file units here:
self.gerber_units = 'IN'
# this is for temporary storage of solid geometry until it is added to poly_buffer
geo_s = None
@ -2555,7 +2552,8 @@ class Gerber (Geometry):
match = self.fmt_re.search(gline)
if match:
absolute = {'A': 'Absolute', 'I': 'Relative'}[match.group(2)]
self.gerber_zeros = match.group(1)
if match.group(1) is not None:
self.gerber_zeros = match.group(1)
self.int_digits = int(match.group(3))
self.frac_digits = int(match.group(4))
log.debug("Gerber format found. (%s) " % str(gline))
@ -2582,7 +2580,8 @@ class Gerber (Geometry):
match = self.fmt_re_alt.search(gline)
if match:
absolute = {'A': 'Absolute', 'I': 'Relative'}[match.group(2)]
self.gerber_zeros = match.group(1)
if match.group(1) is not None:
self.gerber_zeros = match.group(1)
self.int_digits = int(match.group(3))
self.frac_digits = int(match.group(4))
log.debug("Gerber format found. (%s) " % str(gline))
@ -2608,7 +2607,9 @@ class Gerber (Geometry):
elif match.group(1) == 'G75':
quadrant_mode = 'MULTI'
absolute = {'A': 'Absolute', 'I': 'Relative'}[match.group(3)]
self.gerber_zeros = match.group(2)
if match.group(2) is not None:
self.gerber_zeros = match.group(2)
self.int_digits = int(match.group(4))
self.frac_digits = int(match.group(5))
log.debug("Gerber format found. (%s) " % str(gline))

View File

@ -1115,7 +1115,57 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
)
self.circle_steps_entry = IntEntry()
grid0.addWidget(self.circle_steps_label, 1, 0)
grid0.addWidget(self.circle_steps_entry, 1, 1)
grid0.addWidget(self.circle_steps_entry, 1, 1, 1, 2)
grid0.addWidget(QtWidgets.QLabel(''), 2, 0, 1, 3)
# Default format for Gerber
self.gerber_default_label = QtWidgets.QLabel('<b>%s:</b>' % _('Default Values'))
self.gerber_default_label.setToolTip(
_("Those values will be used as fallback values\n"
"in case that they are not found in the Gerber file.")
)
grid0.addWidget(self.gerber_default_label, 3, 0, 1, 3)
# Gerber Units
self.gerber_units_label = QtWidgets.QLabel('%s:' % _('Units'))
self.gerber_units_label.setToolTip(
_("The units used in the Gerber file.")
)
self.gerber_units_radio = RadioSet([{'label': _('INCH'), 'value': 'IN'},
{'label': _('MM'), 'value': 'MM'}])
self.gerber_units_radio.setToolTip(
_("The units used in the Gerber file.")
)
grid0.addWidget(self.gerber_units_label, 4, 0)
grid0.addWidget(self.gerber_units_radio, 4, 1, 1, 2)
# Gerber Zeros
self.gerber_zeros_label = QtWidgets.QLabel('%s:' % _('Zeros'))
self.gerber_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
self.gerber_zeros_label.setToolTip(
_("This sets the type of Gerber zeros.\n"
"If LZ then Leading Zeros are removed and\n"
"Trailing Zeros are kept.\n"
"If TZ is checked then Trailing Zeros are removed\n"
"and Leading Zeros are kept.")
)
self.gerber_zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'L'},
{'label': _('TZ'), 'value': 'T'}])
self.gerber_zeros_radio.setToolTip(
_("This sets the type of Gerber zeros.\n"
"If LZ then Leading Zeros are removed and\n"
"Trailing Zeros are kept.\n"
"If TZ is checked then Trailing Zeros are removed\n"
"and Leading Zeros are kept.")
)
grid0.addWidget(self.gerber_zeros_label, 5, 0)
grid0.addWidget(self.gerber_zeros_radio, 5, 1, 1, 2)
self.layout.addStretch()