- fixed issues in units conversion
- in CNCJob UI Autolevelling - changed how the probing code is generated and when - changed some strings in CNCJob UI Autolevelling
This commit is contained in:
parent
3430d86dba
commit
01df27f45f
|
@ -7,6 +7,12 @@ CHANGELOG for FlatCAM beta
|
|||
|
||||
=================================================
|
||||
|
||||
24.08.2020
|
||||
|
||||
- fixed issues in units conversion
|
||||
- in CNCJob UI Autolevelling - changed how the probing code is generated and when
|
||||
- changed some strings in CNCJob UI Autolevelling
|
||||
|
||||
23.08.2020
|
||||
|
||||
- in CNCJob UI Autolevelling - autolevelling is made to be not available for cnc code generated with Roland or HPGL preprocessors
|
||||
|
|
|
@ -107,6 +107,11 @@ class AppTextEditor(QtWidgets.QWidget):
|
|||
self.button_copy_all.setToolTip(_("Will copy all the text in the Code Editor to the clipboard."))
|
||||
self.button_copy_all.setMinimumWidth(100)
|
||||
|
||||
self.button_update_code = QtWidgets.QToolButton()
|
||||
self.button_update_code.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png'))
|
||||
self.button_update_code.setToolTip(_("Save changes internally."))
|
||||
self.button_update_code.hide()
|
||||
|
||||
self.buttonOpen = FCButton(_('Open Code'))
|
||||
self.buttonOpen.setIcon(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'))
|
||||
self.buttonOpen.setToolTip(_("Will open a text file in the editor."))
|
||||
|
@ -131,6 +136,7 @@ class AppTextEditor(QtWidgets.QWidget):
|
|||
editor_hlay_1.addWidget(self.entryReplace)
|
||||
editor_hlay_1.addWidget(self.sel_all_cb)
|
||||
editor_hlay_1.addWidget(self.button_copy_all)
|
||||
editor_hlay_1.addWidget(self.button_update_code)
|
||||
self.work_editor_layout.addLayout(editor_hlay_1, 1, 0, 1, 5)
|
||||
|
||||
editor_hlay_2 = QtWidgets.QHBoxLayout()
|
||||
|
|
|
@ -694,7 +694,7 @@ class NumericalEvalTupleEntry(EvalEntry):
|
|||
def __init__(self, border_color=None):
|
||||
super().__init__(border_color=border_color)
|
||||
|
||||
regex = QtCore.QRegExp("[0-9\/\*\+\-\%\.\s\,]*")
|
||||
regex = QtCore.QRegExp("[0-9\/\*\+\-\%\.\s\,\[\]]*")
|
||||
validator = QtGui.QRegExpValidator(regex, self)
|
||||
self.setValidator(validator)
|
||||
|
||||
|
|
|
@ -2363,15 +2363,15 @@ class CNCObjectUI(ObjectUI):
|
|||
# #############################################################################################################
|
||||
|
||||
height_lay = QtWidgets.QHBoxLayout()
|
||||
self.h_gcode_button = FCButton(_("Generate Height Map GCode"))
|
||||
self.h_gcode_button = FCButton(_("Save Probing GCode"))
|
||||
self.h_gcode_button.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.MinimumExpanding)
|
||||
|
||||
height_lay.addWidget(self.h_gcode_button)
|
||||
self.view_h_gcode_button = QtWidgets.QToolButton()
|
||||
self.view_h_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/find32.png'))
|
||||
self.view_h_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/edit_file32.png'))
|
||||
# self.view_h_gcode_button.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
|
||||
self.view_h_gcode_button.setToolTip(
|
||||
_("View the probing GCode.")
|
||||
_("View/Edit the probing GCode.")
|
||||
)
|
||||
# height_lay.addStretch()
|
||||
height_lay.addWidget(self.view_h_gcode_button)
|
||||
|
|
|
@ -589,8 +589,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
self.ui.grbl_report_button.clicked.connect(lambda: self.send_grbl_command(command='?'))
|
||||
self.ui.grbl_get_param_button.clicked.connect(
|
||||
lambda: self.get_grbl_parameter(param=self.ui.grbl_parameter_entry.get_value()))
|
||||
self.ui.view_h_gcode_button.clicked.connect(self.on_view_probing_gcode)
|
||||
self.ui.h_gcode_button.clicked.connect(self.on_generate_probing_gcode)
|
||||
self.ui.view_h_gcode_button.clicked.connect(self.on_edit_probing_gcode)
|
||||
self.ui.h_gcode_button.clicked.connect(self.on_save_probing_gcode)
|
||||
self.ui.import_heights_button.clicked.connect(self.on_import_height_map)
|
||||
self.ui.pause_resume_button.clicked.connect(self.on_grbl_pause_resume)
|
||||
|
||||
|
@ -614,7 +614,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
))
|
||||
if 'Roland' in self.pp_excellon_name or 'Roland' in self.pp_geometry_name or 'hpgl' in \
|
||||
self.pp_geometry_name:
|
||||
pass
|
||||
self.ui.sal_cb.hide()
|
||||
self.ui.sal_cb.set_value(False)
|
||||
else:
|
||||
self.ui.sal_cb.show()
|
||||
self.ui.sal_cb.set_value(self.app.defaults["cncjob_al_status"])
|
||||
|
@ -720,8 +721,11 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
self.al_geometry_dict[pt_id] = deepcopy(new_dict)
|
||||
self.calculate_voronoi_diagram(pts=pts_list)
|
||||
|
||||
# generate Probing GCode
|
||||
self.probing_gcode_text = self.probing_gcode()
|
||||
|
||||
else:
|
||||
self.app.inform.emit(_("Click on canvas to add a Test Point..."))
|
||||
self.app.inform.emit(_("Click on canvas to add a Probe Point..."))
|
||||
|
||||
if self.app.is_legacy is False:
|
||||
self.app.plotcanvas.graph_event_disconnect('key_press', self.app.ui.keyPressEvent)
|
||||
|
@ -806,7 +810,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
|
||||
# rebuild the al table
|
||||
self.build_al_table_sig.emit()
|
||||
self.app.inform.emit(_("Added Test Point... Click again to add another or right click to finish ..."))
|
||||
self.app.inform.emit(_("Added a Probe Point... Click again to add another or right click to finish ..."))
|
||||
|
||||
# if RMB then we exit
|
||||
elif event.button == right_button and self.mouse_is_dragging is False:
|
||||
|
@ -828,13 +832,15 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
# restore selection
|
||||
self.app.defaults['global_selection_shape'] = self.old_selection_state
|
||||
|
||||
self.app.inform.emit(_("Finished manual adding of Test Point..."))
|
||||
self.app.inform.emit(_("Finished adding Probe Points..."))
|
||||
|
||||
pts_list = []
|
||||
for k in self.al_geometry_dict:
|
||||
pts_list.append(self.al_geometry_dict[k]['point'])
|
||||
self.calculate_voronoi_diagram(pts=pts_list)
|
||||
|
||||
self.probing_gcode_text = self.probing_gcode()
|
||||
|
||||
# rebuild the al table
|
||||
self.build_al_table_sig.emit()
|
||||
|
||||
|
@ -943,6 +949,12 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
self.ui.import_heights_button.show()
|
||||
self.ui.grbl_frame.hide()
|
||||
|
||||
# if the is empty then there is a chance that we've added probe points but the GRBL controller was selected
|
||||
# therefore no Probing GCode was genrated (it is different for GRBL on how it gets it's Probing GCode
|
||||
if not self.probing_gcode_text or self.probing_gcode_text == '':
|
||||
# generate Probing GCode
|
||||
self.probing_gcode_text = self.probing_gcode()
|
||||
|
||||
def list_serial_ports(self):
|
||||
"""
|
||||
Lists serial port names.
|
||||
|
@ -1223,20 +1235,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
self.send_grbl_command(command=cmd)
|
||||
self.app.inform.emit("%s" % _("GRBL paused."))
|
||||
|
||||
def probing_gcode(self, coords, pr_travel, probe_fr, pr_depth, controller):
|
||||
def probing_gcode(self):
|
||||
"""
|
||||
|
||||
:param coords: a list of (x, y) tuples of probe points coordinates
|
||||
:type coords: list
|
||||
:param pr_travel: the height (z) where the probe travel between probe points
|
||||
:type pr_travel: float
|
||||
:param probe_fr: feedrate when probing
|
||||
:type probe_fr: float
|
||||
:param pr_depth: how much to lower the probe searching for contact
|
||||
:type pr_depth: float
|
||||
:param controller: a string with the name of the GCode sender for which to create the probing GCode.
|
||||
Can be: 'MACH3', 'MACH4', 'LinuxCNC', 'GRBL'
|
||||
:type controller: str
|
||||
:return: Probing GCode
|
||||
:rtype: str
|
||||
"""
|
||||
|
@ -1245,6 +1245,22 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
header = ''
|
||||
time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now())
|
||||
|
||||
coords = []
|
||||
for id_key, value in self.al_geometry_dict.items():
|
||||
x = value['point'].x
|
||||
y = value['point'].y
|
||||
coords.append(
|
||||
(
|
||||
self.app.dec_format(x, dec=self.app.decimals),
|
||||
self.app.dec_format(y, dec=self.app.decimals)
|
||||
)
|
||||
)
|
||||
|
||||
pr_travel = self.ui.ptravelz_entry.get_value()
|
||||
probe_fr = self.ui.feedrate_probe_entry.get_value()
|
||||
pr_depth = self.ui.pdepth_entry.get_value()
|
||||
controller = self.ui.al_controller_combo.get_value()
|
||||
|
||||
header += '(G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s)\n' % \
|
||||
(str(self.app.version), str(self.app.version_date)) + '\n'
|
||||
|
||||
|
@ -1273,6 +1289,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
# probing_var = '#5422'
|
||||
openfile_command = '(PROBEOPEN a_probing_points_file.txt)'
|
||||
closefile_command = '(PROBECLOSE)'
|
||||
elif controller == 'GRBL':
|
||||
# do nothing here because the Probing GCode for GRBL is obtained differently
|
||||
return
|
||||
else:
|
||||
log.debug("CNCJobObject.probing_gcode() -> controller not supported")
|
||||
return
|
||||
|
@ -1327,24 +1346,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
|
||||
return p_gcode
|
||||
|
||||
def on_generate_probing_gcode(self):
|
||||
coords = []
|
||||
for id_key, value in self.al_geometry_dict.items():
|
||||
x = value['point'].x
|
||||
y = value['point'].y
|
||||
coords.append(
|
||||
(
|
||||
self.app.dec_format(x, dec=self.app.decimals),
|
||||
self.app.dec_format(y, dec=self.app.decimals)
|
||||
)
|
||||
)
|
||||
|
||||
pr_travel = self.ui.ptravelz_entry.get_value()
|
||||
probe_fr = self.ui.feedrate_probe_entry.get_value()
|
||||
pr_depth = self.ui.pdepth_entry.get_value()
|
||||
controller = self.ui.al_controller_combo.get_value()
|
||||
self.probing_gcode_text = self.probing_gcode(coords, pr_travel, probe_fr, pr_depth, controller)
|
||||
|
||||
def on_save_probing_gcode(self):
|
||||
lines = StringIO(self.probing_gcode_text)
|
||||
|
||||
_filter_ = self.app.defaults['cncjob_save_filters']
|
||||
|
@ -1383,7 +1385,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
)
|
||||
return 'fail'
|
||||
|
||||
def on_view_probing_gcode(self):
|
||||
def on_edit_probing_gcode(self):
|
||||
self.app.proc_container.view.set_busy(_("Loading..."))
|
||||
|
||||
gco = self.probing_gcode_text
|
||||
|
@ -1426,10 +1428,17 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
|||
self.gcode_viewer_tab.sel_all_cb.hide()
|
||||
self.gcode_viewer_tab.entryReplace.hide()
|
||||
|
||||
self.gcode_viewer_tab.code_editor.setReadOnly(True)
|
||||
self.gcode_viewer_tab.button_update_code.show()
|
||||
|
||||
# self.gcode_viewer_tab.code_editor.setReadOnly(True)
|
||||
|
||||
self.gcode_viewer_tab.button_update_code.clicked.connect(self.on_update_probing_gcode)
|
||||
|
||||
self.app.inform.emit('[success] %s...' % _('Loaded Machine Code into Code Viewer'))
|
||||
|
||||
def on_update_probing_gcode(self):
|
||||
self.probing_gcode_text = self.gcode_viewer_tab.code_editor.toPlainText()
|
||||
|
||||
def on_import_height_map(self):
|
||||
"""
|
||||
Import the height map file into the app
|
||||
|
|
211
app_Main.py
211
app_Main.py
|
@ -4160,141 +4160,166 @@ class App(QtCore.QObject):
|
|||
return
|
||||
|
||||
# Keys in self.defaults for which to scale their values
|
||||
dimensions = ['tools_iso_tooldia', 'gerber_noncoppermargin', 'gerber_bboxmargin',
|
||||
"gerber_editor_newsize", "gerber_editor_lin_pitch", "gerber_editor_buff_f",
|
||||
"tools_iso_tool_vtipdia",
|
||||
"tools_iso_tool_cutz", "gerber_editor_newdim", "gerber_editor_ma_low",
|
||||
"gerber_editor_ma_high",
|
||||
dimensions = [
|
||||
# Global
|
||||
'global_gridx', 'global_gridy', 'global_snap_max', "global_tolerance",
|
||||
'global_tpdf_bmargin', 'global_tpdf_tmargin', 'global_tpdf_rmargin', 'global_tpdf_lmargin',
|
||||
|
||||
'excellon_cutz', 'excellon_travelz', "excellon_toolchangexy", 'excellon_offset',
|
||||
'excellon_feedrate_z', 'excellon_feedrate_rapid', 'excellon_toolchangez',
|
||||
'excellon_tooldia', 'excellon_slot_tooldia', 'excellon_endz', 'excellon_endxy',
|
||||
"excellon_feedrate_probe", "excellon_milling_dia",
|
||||
"excellon_z_pdepth", "excellon_editor_newdia", "excellon_editor_lin_pitch",
|
||||
"excellon_editor_slot_lin_pitch", "excellon_editor_slot_length",
|
||||
# Gerber Object
|
||||
'gerber_noncoppermargin', 'gerber_bboxmargin',
|
||||
|
||||
'geometry_cutz', "geometry_depthperpass", 'geometry_travelz', 'geometry_feedrate',
|
||||
'geometry_feedrate_rapid', "geometry_toolchangez", "geometry_feedrate_z",
|
||||
"geometry_toolchangexy", 'geometry_cnctooldia', 'geometry_endz', 'geometry_endxy',
|
||||
"geometry_extracut_length", "geometry_z_pdepth",
|
||||
"geometry_feedrate_probe", "geometry_startz", "geometry_segx", "geometry_segy",
|
||||
# Gerber Editor
|
||||
"gerber_editor_newsize", "gerber_editor_lin_pitch", "gerber_editor_buff_f",
|
||||
"gerber_editor_newdim", "gerber_editor_ma_low", "gerber_editor_ma_high",
|
||||
|
||||
'cncjob_tooldia',
|
||||
# Excellon Object
|
||||
"excellon_milling_dia", 'excellon_tooldia', 'excellon_slot_tooldia',
|
||||
|
||||
'tools_paintoffset', 'tools_painttooldia', "tools_paintcutz", "tools_painttipdia",
|
||||
"tools_paintnewdia",
|
||||
# Excellon Editor
|
||||
"excellon_editor_newdia", "excellon_editor_lin_pitch", "excellon_editor_slot_lin_pitch",
|
||||
"excellon_editor_slot_length",
|
||||
|
||||
"tools_ncctools", "tools_nccmargin", "tools_ncccutz", "tools_ncctipdia",
|
||||
"tools_nccnewdia", "tools_ncc_offset_value",
|
||||
# Geometry Object
|
||||
'geometry_cutz', "geometry_depthperpass", 'geometry_travelz', 'geometry_feedrate',
|
||||
'geometry_feedrate_rapid', "geometry_toolchangez", "geometry_feedrate_z",
|
||||
"geometry_toolchangexy", 'geometry_cnctooldia', 'geometry_endz', 'geometry_endxy',
|
||||
"geometry_extracut_length", "geometry_z_pdepth",
|
||||
"geometry_feedrate_probe", "geometry_startz", "geometry_segx", "geometry_segy", "geometry_area_overz",
|
||||
|
||||
"tools_2sided_drilldia",
|
||||
"tools_film_boundary", "tools_film_scale_stroke",
|
||||
# CNCJob Object
|
||||
'cncjob_tooldia', "cncjob_al_travelz", "cncjob_al_probe_depth", "cncjob_al_grbl_jog_step",
|
||||
"cncjob_al_grbl_jog_fr", "cncjob_al_grbl_travelz",
|
||||
|
||||
"tools_cutouttooldia", 'tools_cutoutmargin', 'tools_cutoutgapsize', "tools_cutout_z",
|
||||
"tools_cutout_depthperpass",
|
||||
# Isolation Tool
|
||||
"tools_iso_tool_vtipdia", 'tools_iso_tooldia', "tools_iso_tool_cutz",
|
||||
|
||||
"tools_panelize_constrainx", "tools_panelize_constrainy", "tools_panelize_spacing_columns",
|
||||
"tools_panelize_spacing_rows",
|
||||
# Drilling Tool
|
||||
'tools_drill_cutz', 'tools_drill_depthperpass', 'tools_drill_travelz', 'tools_drill_endz',
|
||||
'tools_drill_endxy', 'tools_drill_feedrate_z', 'tools_drill_toolchangez', "tools_drill_drill_overlap",
|
||||
'tools_drill_offset', "tools_drill_toolchangexy", "tools_drill_startz", 'tools_drill_feedrate_rapid',
|
||||
"tools_drill_feedrate_probe", "tools_drill_z_pdepth", "tools_drill_area_overz",
|
||||
|
||||
# NCC Tool
|
||||
"tools_ncctools", "tools_nccmargin", "tools_ncc_offset_value", "tools_ncccutz", "tools_ncctipdia",
|
||||
"tools_nccnewdia",
|
||||
|
||||
"tools_calc_vshape_tip_dia", "tools_calc_vshape_cut_z",
|
||||
# Cutout Tool
|
||||
"tools_cutouttooldia", 'tools_cutoutmargin', "tools_cutout_z", "tools_cutout_depthperpass",
|
||||
'tools_cutoutgapsize',
|
||||
|
||||
"tools_transform_offset_x", "tools_transform_offset_y", "tools_transform_mirror_point",
|
||||
"tools_transform_buffer_dis",
|
||||
# Paint Tool
|
||||
"tools_painttooldia", 'tools_paintoffset', "tools_paintcutz", "tools_painttipdia", "tools_paintnewdia",
|
||||
|
||||
"tools_solderpaste_tools", "tools_solderpaste_new", "tools_solderpaste_z_start",
|
||||
"tools_solderpaste_z_dispense", "tools_solderpaste_z_stop", "tools_solderpaste_z_travel",
|
||||
"tools_solderpaste_z_toolchange", "tools_solderpaste_xy_toolchange", "tools_solderpaste_frxy",
|
||||
"tools_solderpaste_frz", "tools_solderpaste_frz_dispense",
|
||||
# 2Sided Tool
|
||||
"tools_2sided_drilldia",
|
||||
|
||||
"tools_cr_trace_size_val", "tools_cr_c2c_val", "tools_cr_c2o_val", "tools_cr_s2s_val",
|
||||
"tools_cr_s2sm_val", "tools_cr_s2o_val", "tools_cr_sm2sm_val", "tools_cr_ri_val",
|
||||
"tools_cr_h2h_val", "tools_cr_dh_val",
|
||||
# Film Tool
|
||||
"tools_film_boundary", "tools_film_scale_stroke",
|
||||
|
||||
"tools_fiducials_dia", "tools_fiducials_margin", "tools_fiducials_line_thickness",
|
||||
# Panel Tool
|
||||
"tools_panelize_spacing_columns", "tools_panelize_spacing_rows", "tools_panelize_constrainx",
|
||||
"tools_panelize_constrainy",
|
||||
|
||||
"tools_copper_thieving_clearance", "tools_copper_thieving_margin",
|
||||
"tools_copper_thieving_dots_dia", "tools_copper_thieving_dots_spacing",
|
||||
"tools_copper_thieving_squares_size", "tools_copper_thieving_squares_spacing",
|
||||
"tools_copper_thieving_lines_size", "tools_copper_thieving_lines_spacing",
|
||||
"tools_copper_thieving_rb_margin", "tools_copper_thieving_rb_thickness",
|
||||
"tools_copper_thieving_mask_clearance",
|
||||
# Calculators Tool
|
||||
"tools_calc_vshape_tip_dia", "tools_calc_vshape_cut_z",
|
||||
|
||||
"tools_cal_travelz", "tools_cal_verz", "tools_cal_toolchangez", "tools_cal_toolchange_xy",
|
||||
# Transform Tool
|
||||
"tools_transform_ref_point", "tools_transform_offset_x", "tools_transform_offset_y",
|
||||
"tools_transform_buffer_dis",
|
||||
|
||||
"tools_edrills_hole_fixed_dia", "tools_edrills_circular_ring", "tools_edrills_oblong_ring",
|
||||
"tools_edrills_square_ring", "tools_edrills_rectangular_ring", "tools_edrills_others_ring",
|
||||
# SolderPaste Tool
|
||||
"tools_solderpaste_tools", "tools_solderpaste_new", "tools_solderpaste_z_start",
|
||||
"tools_solderpaste_z_dispense", "tools_solderpaste_z_stop", "tools_solderpaste_z_travel",
|
||||
"tools_solderpaste_z_toolchange", "tools_solderpaste_xy_toolchange", "tools_solderpaste_frxy",
|
||||
"tools_solderpaste_frz", "tools_solderpaste_frz_dispense",
|
||||
|
||||
"tools_punch_hole_fixed_dia", "tools_punch_circular_ring", "tools_punch_oblong_ring",
|
||||
"tools_punch_square_ring", "tools_punch_rectangular_ring", "tools_punch_others_ring",
|
||||
# Corner Markers Tool
|
||||
"tools_corners_thickness", "tools_corners_length", "tools_corners_margin",
|
||||
|
||||
"tools_invert_margin",
|
||||
# Check Rules Tool
|
||||
"tools_cr_trace_size_val", "tools_cr_c2c_val", "tools_cr_c2o_val", "tools_cr_s2s_val", "tools_cr_s2sm_val",
|
||||
"tools_cr_s2o_val", "tools_cr_sm2sm_val", "tools_cr_ri_val", "tools_cr_h2h_val", "tools_cr_dh_val",
|
||||
|
||||
'global_gridx', 'global_gridy', 'global_snap_max', "global_tolerance",
|
||||
'global_tpdf_bmargin', 'global_tpdf_tmargin', 'global_tpdf_rmargin', 'global_tpdf_lmargin']
|
||||
# QRCode Tool
|
||||
"tools_qrcode_border_size",
|
||||
|
||||
# Copper Thieving Tool
|
||||
"tools_copper_thieving_clearance", "tools_copper_thieving_margin",
|
||||
"tools_copper_thieving_dots_dia", "tools_copper_thieving_dots_spacing",
|
||||
"tools_copper_thieving_squares_size", "tools_copper_thieving_squares_spacing",
|
||||
"tools_copper_thieving_lines_size", "tools_copper_thieving_lines_spacing",
|
||||
"tools_copper_thieving_rb_margin", "tools_copper_thieving_rb_thickness",
|
||||
"tools_copper_thieving_mask_clearance",
|
||||
|
||||
# Fiducials Tool
|
||||
"tools_fiducials_dia", "tools_fiducials_margin", "tools_fiducials_line_thickness",
|
||||
|
||||
# Calibration Tool
|
||||
"tools_cal_travelz", "tools_cal_verz", "tools_cal_toolchangez", "tools_cal_toolchange_xy",
|
||||
|
||||
# Drills Extraction Tool
|
||||
"tools_edrills_hole_fixed_dia", "tools_edrills_circular_ring", "tools_edrills_oblong_ring",
|
||||
"tools_edrills_square_ring", "tools_edrills_rectangular_ring", "tools_edrills_others_ring",
|
||||
|
||||
# Punch Gerber Tool
|
||||
"tools_punch_hole_fixed_dia", "tools_punch_circular_ring", "tools_punch_oblong_ring",
|
||||
"tools_punch_square_ring", "tools_punch_rectangular_ring", "tools_punch_others_ring",
|
||||
|
||||
# Invert Gerber Tool
|
||||
"tools_invert_margin",
|
||||
|
||||
]
|
||||
|
||||
def scale_defaults(sfactor):
|
||||
for dim in dimensions:
|
||||
if dim in [
|
||||
'gerber_editor_newdim', 'excellon_toolchangexy', 'geometry_toolchangexy', 'excellon_endxy',
|
||||
'geometry_endxy', 'tools_solderpaste_xy_toolchange', 'tools_cal_toolchange_xy',
|
||||
'tools_transform_mirror_point'
|
||||
]:
|
||||
if self.defaults[dim] is None or self.defaults[dim] == '':
|
||||
if dim in ['geometry_cnctooldia', 'tools_ncctools', 'tools_solderpaste_tools', 'tools_iso_tooldia',
|
||||
'tools_painttooldia', 'tools_transform_ref_point', 'tools_cal_toolchange_xy',
|
||||
'gerber_editor_newdim', 'tools_drill_toolchangexy', 'tools_drill_endxy',
|
||||
'geometry_toolchangexy', 'geometry_endxy', 'tools_solderpaste_xy_toolchange']:
|
||||
if not self.defaults[dim] or self.defaults[dim] == '':
|
||||
continue
|
||||
|
||||
try:
|
||||
coordinates = self.defaults[dim].split(",")
|
||||
coords_xy = [float(eval(a)) for a in coordinates if a != '']
|
||||
coords_xy[0] *= sfactor
|
||||
coords_xy[1] *= sfactor
|
||||
self.defaults[dim] = "%.*f, %.*f" % (
|
||||
self.decimals, coords_xy[0], self.decimals, coords_xy[1])
|
||||
except Exception as e:
|
||||
log.debug("App.on_toggle_units.scale_defaults() --> 'string tuples': %s" % str(e))
|
||||
|
||||
elif dim in [
|
||||
'geometry_cnctooldia', 'tools_ncctools', 'tools_solderpaste_tools'
|
||||
]:
|
||||
if self.defaults[dim] is None or self.defaults[dim] == '':
|
||||
continue
|
||||
|
||||
try:
|
||||
self.defaults[dim] = float(self.defaults[dim])
|
||||
tools_diameters = [self.defaults[dim]]
|
||||
except ValueError:
|
||||
if isinstance(self.defaults[dim], str):
|
||||
try:
|
||||
tools_string = self.defaults[dim].split(",")
|
||||
tools_diameters = [eval(a) for a in tools_string if a != '']
|
||||
tools_diameters = eval(self.defaults[dim])
|
||||
except Exception as e:
|
||||
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
|
||||
log.debug("App.on_toggle_units().scale_defaults() lists --> %s" % str(e))
|
||||
continue
|
||||
|
||||
self.defaults[dim] = ''
|
||||
td_len = len(tools_diameters)
|
||||
if td_len > 1:
|
||||
for t in range(td_len):
|
||||
tools_diameters[t] *= sfactor
|
||||
self.defaults[dim] += "%.*f," % (self.decimals, tools_diameters[t])
|
||||
elif isinstance(self.defaults[dim], (float, int)):
|
||||
tools_diameters = [self.defaults[dim]]
|
||||
else:
|
||||
tools_diameters[0] *= sfactor
|
||||
self.defaults[dim] += "%.*f" % (self.decimals, tools_diameters[0])
|
||||
tools_diameters = list(self.defaults[dim])
|
||||
|
||||
if isinstance(tools_diameters, (tuple, list)):
|
||||
pass
|
||||
elif isinstance(tools_diameters, (int, float)):
|
||||
tools_diameters = [self.defaults[dim]]
|
||||
else:
|
||||
continue
|
||||
|
||||
td_len = len(tools_diameters)
|
||||
conv_list = []
|
||||
for t in range(td_len):
|
||||
conv_list.append(float(tools_diameters[t]) * sfactor)
|
||||
|
||||
elif dim in ['global_gridx', 'global_gridy']:
|
||||
# format the number of decimals to the one specified in self.decimals
|
||||
try:
|
||||
val = float(self.defaults[dim]) * sfactor
|
||||
except Exception as e:
|
||||
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
|
||||
log.debug('App.on_toggle_units().scale_defaults() grids --> %s' % str(e))
|
||||
continue
|
||||
|
||||
self.defaults[dim] = float('%.*f' % (self.decimals, val))
|
||||
self.defaults[dim] = self.dec_format(val, self.decimals)
|
||||
else:
|
||||
# the number of decimals for the rest is kept unchanged
|
||||
if self.defaults[dim]:
|
||||
try:
|
||||
val = float(self.defaults[dim]) * sfactor
|
||||
except Exception as e:
|
||||
log.debug('App.on_toggle_units().scale_defaults() --> Value: %s %s' % (str(dim), str(e)))
|
||||
log.debug(
|
||||
'App.on_toggle_units().scale_defaults() standard --> Value: %s %s' % (str(dim), str(e))
|
||||
)
|
||||
continue
|
||||
|
||||
self.defaults[dim] = val
|
||||
|
|
|
@ -595,7 +595,6 @@ class FlatCAMDefaults:
|
|||
"tools_dist_snap_center": False,
|
||||
|
||||
# Corner Markers Tool
|
||||
|
||||
"tools_corners_thickness": 0.1,
|
||||
"tools_corners_length": 3.0,
|
||||
"tools_corners_margin": 0.0,
|
||||
|
|
Loading…
Reference in New Issue