- fixes issues with units conversion when the tool diameters are a list of comma separated values (NCC Tool, SolderPaste Tool and Geometry Object)

- fixed a "typo" kind of bug in SolderPaste Tool
- RELEASE 8.919
This commit is contained in:
Marius Stanciu 2019-06-23 00:04:49 +03:00
parent 259a62230e
commit 429753d211
16 changed files with 1280 additions and 1147 deletions

View File

@ -95,7 +95,7 @@ class App(QtCore.QObject):
# Version # Version
version = 8.919 version = 8.919
version_date = "2019/06/22" version_date = "2019/06/23"
beta = True beta = True
# current date now # current date now
@ -780,7 +780,7 @@ class App(QtCore.QObject):
# Geometry General # Geometry General
"geometry_plot": True, "geometry_plot": True,
"geometry_circle_steps": 128, "geometry_circle_steps": 128,
"geometry_cnctooldia": 0.016, "geometry_cnctooldia": "0.016",
# Geometry Options # Geometry Options
"geometry_cutz": -0.002, "geometry_cutz": -0.002,
@ -2059,9 +2059,9 @@ class App(QtCore.QObject):
except Exception as e: except Exception as e:
log.debug("App.defaults_read_form() --> %s" % str(e)) log.debug("App.defaults_read_form() --> %s" % str(e))
def defaults_write_form(self, factor=None): def defaults_write_form(self, factor=None, fl_units=None):
for option in self.defaults: for option in self.defaults:
self.defaults_write_form_field(option, factor=factor) self.defaults_write_form_field(option, factor=factor, units=fl_units)
# try: # try:
# self.defaults_form_fields[option].set_value(self.defaults[option]) # self.defaults_form_fields[option].set_value(self.defaults[option])
# except KeyError: # except KeyError:
@ -2069,12 +2069,22 @@ class App(QtCore.QObject):
# # TODO: Rethink this? # # TODO: Rethink this?
# pass # pass
def defaults_write_form_field(self, field, factor=None): def defaults_write_form_field(self, field, factor=None, units=None):
try: try:
if factor is None: if factor is None:
self.defaults_form_fields[field].set_value(self.defaults[field]) if units is None:
self.defaults_form_fields[field].set_value(self.defaults[field])
elif units == 'IN' and (field == 'global_gridx' or field == 'global_gridy'):
self.defaults_form_fields[field].set_value(self.defaults[field], decimals=6)
elif units == 'MM' and (field == 'global_gridx' or field == 'global_gridy'):
self.defaults_form_fields[field].set_value(self.defaults[field], decimals=4)
else: else:
self.defaults_form_fields[field].set_value(self.defaults[field] * factor) if units is None:
self.defaults_form_fields[field].set_value(self.defaults[field] * factor)
elif units == 'IN' and (field == 'global_gridx' or field == 'global_gridy'):
self.defaults_form_fields[field].set_value((self.defaults[field] * factor), decimals=6)
elif units == 'MM' and (field == 'global_gridx' or field == 'global_gridy'):
self.defaults_form_fields[field].set_value((self.defaults[field] * factor), decimals=4)
except KeyError: except KeyError:
# self.log.debug("defaults_write_form(): No field for: %s" % option) # self.log.debug("defaults_write_form(): No field for: %s" % option)
# TODO: Rethink this? # TODO: Rethink this?
@ -3679,28 +3689,59 @@ class App(QtCore.QObject):
coords_xy[1] *= sfactor coords_xy[1] *= sfactor
self.options['geometry_toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1]) self.options['geometry_toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1])
elif dim == 'geometry_cnctooldia': elif dim == 'geometry_cnctooldia':
tools_diameters = []
try:
tools_string = self.defaults["geometry_cnctooldia"].split(",")
tools_diameters = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
self.options['geometry_cnctooldia'] = '' self.options['geometry_cnctooldia'] = ''
tools_diameters = [float(eval(a)) for a in self.defaults["geometry_cnctooldia"].split(",")]
for t in range(len(tools_diameters)): for t in range(len(tools_diameters)):
tools_diameters[t] *= sfactor tools_diameters[t] *= sfactor
self.options['geometry_cnctooldia'] += "%f, " % tools_diameters[t] self.options['geometry_cnctooldia'] += "%f," % tools_diameters[t]
elif dim == 'tools_ncctools': elif dim == 'tools_ncctools':
ncctools = []
try:
tools_string = self.defaults["tools_ncctools"].split(",")
ncctools = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
self.options['tools_ncctools'] = '' self.options['tools_ncctools'] = ''
ncctols = [float(eval(a)) for a in self.defaults["tools_ncctools"].split(",")] for t in range(len(ncctools)):
for t in range(len(ncctols)): ncctools[t] *= sfactor
ncctols[t] *= sfactor self.options['tools_ncctools'] += "%f," % ncctools[t]
self.options['tools_ncctools'] += "%f, " % ncctols[t]
elif dim == 'tools_solderpaste_tools': elif dim == 'tools_solderpaste_tools':
sptools = []
try:
tools_string = self.defaults["tools_solderpaste_tools"].split(",")
sptools = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
self.options['tools_solderpaste_tools'] = "" self.options['tools_solderpaste_tools'] = ""
sp_tools = [float(eval(a)) for a in self.defaults["tools_solderpaste_tools"].split(",")] for t in range(len(sptools)):
for t in range(len(sp_tools)): sptools[t] *= sfactor
sp_tools[t] *= sfactor self.options['tools_solderpaste_tools'] += "%f," % sptools[t]
self.options['tools_solderpaste_tools'] = "%f, " % sp_tools[t]
elif dim == 'tools_solderpaste_xy_toolchange': elif dim == 'tools_solderpaste_xy_toolchange':
sp_coords = [float(eval(a)) for a in self.defaults["tools_solderpaste_xy_toolchange"].split(",")] sp_coords = [float(eval(a)) for a in self.defaults["tools_solderpaste_xy_toolchange"].split(",")]
sp_coords[0] *= sfactor sp_coords[0] *= sfactor
sp_coords[1] *= sfactor sp_coords[1] *= sfactor
self.options['tools_solderpaste_xy_toolchange'] = "%f, %f" % (sp_coords[0], sp_coords[1]) self.options['tools_solderpaste_xy_toolchange'] = "%f, %f" % (sp_coords[0], sp_coords[1])
elif dim == 'global_gridx' or dim == 'global_gridy':
if new_units == 'IN':
try:
val = float(self.defaults[dim]) * sfactor
self.options[dim] = float('%.6f' % val)
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
else:
try:
val = float(self.defaults[dim]) * sfactor
self.options[dim] = float('%.4f' % val)
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
else: else:
try: try:
self.options[dim] = float(self.options[dim]) * sfactor self.options[dim] = float(self.options[dim]) * sfactor
@ -3720,28 +3761,59 @@ class App(QtCore.QObject):
coords_xy[1] *= sfactor coords_xy[1] *= sfactor
self.defaults['geometry_toolchangexy'] = "%.4f, %.4f" % (coords_xy[0], coords_xy[1]) self.defaults['geometry_toolchangexy'] = "%.4f, %.4f" % (coords_xy[0], coords_xy[1])
elif dim == 'geometry_cnctooldia': elif dim == 'geometry_cnctooldia':
tools_diameters = []
try:
tools_string = self.defaults["geometry_cnctooldia"].split(",")
tools_diameters = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
self.defaults['geometry_cnctooldia'] = '' self.defaults['geometry_cnctooldia'] = ''
tools_diameters = [float(eval(a)) for a in self.defaults["geometry_cnctooldia"].split(",")]
for t in range(len(tools_diameters)): for t in range(len(tools_diameters)):
tools_diameters[t] *= sfactor tools_diameters[t] *= sfactor
self.defaults['geometry_cnctooldia'] += "%.4f, " % tools_diameters[t] self.defaults['geometry_cnctooldia'] += "%.4f," % tools_diameters[t]
elif dim == 'tools_ncctools': elif dim == 'tools_ncctools':
ncctools = []
try:
tools_string = self.defaults["tools_ncctools"].split(",")
ncctools = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
self.defaults['tools_ncctools'] = '' self.defaults['tools_ncctools'] = ''
ncctols = [float(eval(a)) for a in self.defaults["tools_ncctools"].split(",")] for t in range(len(ncctools)):
for t in range(len(ncctols)): ncctools[t] *= sfactor
ncctols[t] *= sfactor self.defaults['tools_ncctools'] += "%.4f," % ncctools[t]
self.defaults['tools_ncctools'] += "%.4f, " % ncctols[t]
elif dim == 'tools_solderpaste_tools': elif dim == 'tools_solderpaste_tools':
sptools = []
try:
tools_string = self.defaults["tools_solderpaste_tools"].split(",")
sptools = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
self.defaults['tools_solderpaste_tools'] = "" self.defaults['tools_solderpaste_tools'] = ""
sp_tools = [float(eval(a)) for a in self.defaults["tools_solderpaste_tools"].split(",")] for t in range(len(sptools)):
for t in range(len(sp_tools)): sptools[t] *= sfactor
sp_tools[t] *= sfactor self.defaults['tools_solderpaste_tools'] += "%.4f," % sptools[t]
self.defaults['tools_solderpaste_tools'] = "%.4f, " % sp_tools[t]
elif dim == 'tools_solderpaste_xy_toolchange': elif dim == 'tools_solderpaste_xy_toolchange':
sp_coords = [float(eval(a)) for a in self.defaults["tools_solderpaste_xy_toolchange"].split(",")] sp_coords = [float(eval(a)) for a in self.defaults["tools_solderpaste_xy_toolchange"].split(",")]
sp_coords[0] *= sfactor sp_coords[0] *= sfactor
sp_coords[1] *= sfactor sp_coords[1] *= sfactor
self.defaults['tools_solderpaste_xy_toolchange'] = "%.4f, %.4f" % (sp_coords[0], sp_coords[1]) self.defaults['tools_solderpaste_xy_toolchange'] = "%.4f, %.4f" % (sp_coords[0], sp_coords[1])
elif dim == 'global_gridx' or dim == 'global_gridy':
if new_units == 'IN':
try:
val = float(self.defaults[dim]) * sfactor
self.defaults[dim] = float('%.6f' % val)
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
else:
try:
val = float(self.defaults[dim]) * sfactor
self.defaults[dim] = float('%.4f' % val)
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
else: else:
try: try:
self.defaults[dim] = float(self.defaults[dim]) * sfactor self.defaults[dim] = float(self.defaults[dim]) * sfactor
@ -3775,7 +3847,7 @@ class App(QtCore.QObject):
self.defaults_read_form() self.defaults_read_form()
scale_defaults(factor) scale_defaults(factor)
self.defaults_write_form() self.defaults_write_form(fl_units=new_units)
self.should_we_save = True self.should_we_save = True
@ -3791,9 +3863,8 @@ class App(QtCore.QObject):
val_y = float(self.ui.grid_gap_y_entry.get_value()) * factor val_y = float(self.ui.grid_gap_y_entry.get_value()) * factor
self.ui.grid_gap_y_entry.set_value(val_y, decimals=dec) self.ui.grid_gap_y_entry.set_value(val_y, decimals=dec)
units = self.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
for obj in self.collection.get_list(): for obj in self.collection.get_list():
obj.convert_units(units) obj.convert_units(new_units)
# make that the properties stored in the object are also updated # make that the properties stored in the object are also updated
self.object_changed.emit(obj) self.object_changed.emit(obj)
@ -3806,9 +3877,9 @@ class App(QtCore.QObject):
current.to_form() current.to_form()
self.plot_all() self.plot_all()
self.inform.emit(_("[success] Converted units to %s") % units) self.inform.emit(_("[success] Converted units to %s") % new_units)
# self.ui.units_label.setText("[" + self.options["units"] + "]") # self.ui.units_label.setText("[" + self.options["units"] + "]")
self.set_screen_units(units) self.set_screen_units(new_units)
else: else:
# Undo toggling # Undo toggling
self.toggle_units_ignore = True self.toggle_units_ignore = True

View File

@ -9,6 +9,12 @@ CAD program, and create G-Code for Isolation routing.
================================================= =================================================
23.06.2019
- fixes issues with units conversion when the tool diameters are a list of comma separated values (NCC Tool, SolderPaste Tool and Geometry Object)
- fixed a "typo" kind of bug in SolderPaste Tool
- RELEASE 8.919
22.06.2019 22.06.2019
- some GUI layout optimizations in Edit -> Preferences - some GUI layout optimizations in Edit -> Preferences
@ -28,7 +34,6 @@ CAD program, and create G-Code for Isolation routing.
- optimized the toggle of annotations; now there is no need to replot the entire CNCJob object too on toggling of the annotations - optimized the toggle of annotations; now there is no need to replot the entire CNCJob object too on toggling of the annotations
- on toggling off the plot visibility the annotations are turned off too - on toggling off the plot visibility the annotations are turned off too
- updated translations; Russian translation at 76% (using Yandex translator engine - needs verification by a native speaker of Russian) - updated translations; Russian translation at 76% (using Yandex translator engine - needs verification by a native speaker of Russian)
- RELEASE 8.919
20.06.2019 20.06.2019

View File

@ -6142,7 +6142,7 @@ class CNCjob(Geometry):
gcode += self.doformat(p.down_z_start_code) gcode += self.doformat(p.down_z_start_code)
gcode += self.doformat(p.spindle_fwd_code) # Start dispensing gcode += self.doformat(p.spindle_fwd_code) # Start dispensing
gcode += self.doformat(p.dwell_fwd_code) gcode += self.doformat(p.dwell_fwd_code)
gcode += self.doformat(p.z_feedrate_dispense_code) gcode += self.doformat(p.feedrate_z_dispense_code)
gcode += self.doformat(p.lift_z_dispense_code) gcode += self.doformat(p.lift_z_dispense_code)
gcode += self.doformat(p.feedrate_xy_code) gcode += self.doformat(p.feedrate_xy_code)
@ -6161,7 +6161,7 @@ class CNCjob(Geometry):
elif type(geometry) == Point: elif type(geometry) == Point:
gcode += self.doformat(p.linear_code, x=path[0][0], y=path[0][1]) # Move to first point gcode += self.doformat(p.linear_code, x=path[0][0], y=path[0][1]) # Move to first point
gcode += self.doformat(p.z_feedrate_dispense_code) gcode += self.doformat(p.feedrate_z_dispense_code)
gcode += self.doformat(p.down_z_start_code) gcode += self.doformat(p.down_z_start_code)
gcode += self.doformat(p.spindle_fwd_code) # Start dispensing gcode += self.doformat(p.spindle_fwd_code) # Start dispensing
gcode += self.doformat(p.dwell_fwd_code) gcode += self.doformat(p.dwell_fwd_code)

View File

@ -3330,14 +3330,14 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
self.gridx_label.setToolTip( self.gridx_label.setToolTip(
_("This is the Grid snap value on X axis.") _("This is the Grid snap value on X axis.")
) )
self.gridx_entry = LengthEntry() self.gridx_entry = FCEntry3()
# Grid Y Entry # Grid Y Entry
self.gridy_label = QtWidgets.QLabel(_('Grid Y value:')) self.gridy_label = QtWidgets.QLabel(_('Grid Y value:'))
self.gridy_label.setToolTip( self.gridy_label.setToolTip(
_("This is the Grid snap value on Y axis.") _("This is the Grid snap value on Y axis.")
) )
self.gridy_entry = LengthEntry() self.gridy_entry = FCEntry3()
# Snap Max Entry # Snap Max Entry
self.snap_max_label = QtWidgets.QLabel(_('Snap Max:')) self.snap_max_label = QtWidgets.QLabel(_('Snap Max:'))

View File

@ -190,7 +190,7 @@ class LengthEntry(QtWidgets.QLineEdit):
units = raw[-2:] units = raw[-2:]
units = self.scales[self.output_units][units.upper()] units = self.scales[self.output_units][units.upper()]
value = raw[:-2] value = raw[:-2]
return float(eval(value))*units return float(eval(value))* units
except IndexError: except IndexError:
value = raw value = raw
return float(eval(value)) return float(eval(value))
@ -399,6 +399,33 @@ class FCEntry2(FCEntry):
self.setText('%.*f' % (decimals, fval)) self.setText('%.*f' % (decimals, fval))
class FCEntry3(FCEntry):
def __init__(self, parent=None):
super(FCEntry3, self).__init__(parent)
self.readyToEdit = True
self.editingFinished.connect(self.on_edit_finished)
def on_edit_finished(self):
self.clearFocus()
def set_value(self, val, decimals=4):
try:
fval = float(val)
except ValueError:
return
self.setText('%.*f' % (decimals, fval))
def get_value(self):
value = str(self.text()).strip(' ')
try:
return float(eval(value))
except Exception as e:
log.warning("Could not parse value in entry: %s" % str(e))
return None
class EvalEntry(QtWidgets.QLineEdit): class EvalEntry(QtWidgets.QLineEdit):
def __init__(self, parent=None): def __init__(self, parent=None):
super(EvalEntry, self).__init__(parent) super(EvalEntry, self).__init__(parent)

View File

@ -343,7 +343,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
}) })
try: try:
dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",")] dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",") if dia != '']
except: except:
log.error("At least one tool diameter needed. Verify in Edit -> Preferences -> TOOLS -> NCC Tools.") log.error("At least one tool diameter needed. Verify in Edit -> Preferences -> TOOLS -> NCC Tools.")
return return

View File

@ -482,7 +482,7 @@ class SolderPaste(FlatCAMTool):
self.on_tool_delete(rows_to_delete=None, all=None), icon=QtGui.QIcon("share/delete32.png")) self.on_tool_delete(rows_to_delete=None, all=None), icon=QtGui.QIcon("share/delete32.png"))
try: try:
dias = [float(eval(dia)) for dia in self.app.defaults["tools_solderpaste_tools"].split(",")] dias = [float(eval(dia)) for dia in self.app.defaults["tools_solderpaste_tools"].split(",") if dia != '']
except: except:
log.error("At least one Nozzle tool diameter needed. " log.error("At least one Nozzle tool diameter needed. "
"Verify in Edit -> Preferences -> TOOLS -> Solder Paste Tools.") "Verify in Edit -> Preferences -> TOOLS -> Solder Paste Tools.")

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff