- the application now uses only the default values from the app.options dict, the app.defaults dict holds the definitive default values

- fixed some outstanding issues from the PyQt6 port
- PEP8 fixes
- minor fixes
- updated the saving of Preferences to update the self.options too: the `Apply` action will update the self.options but the `Save` action will save the updated preferences to the file on disk
This commit is contained in:
Marius Stanciu
2022-02-18 23:06:58 +02:00
committed by Marius
parent 14d9ea5470
commit 65d8dcc0b2
92 changed files with 1881 additions and 1882 deletions

View File

@@ -300,28 +300,28 @@ class AppObject(QtCore.QObject):
if obj.kind in ['excellon', 'gerber']:
try:
if obj.kind == 'excellon':
if self.app.defaults["excellon_color"]:
obj.fill_color = self.app.defaults["excellon_color"][0]
obj.outline_color = self.app.defaults["excellon_color"][1]
if self.app.options["excellon_color"]:
obj.fill_color = self.app.options["excellon_color"][0]
obj.outline_color = self.app.options["excellon_color"][1]
else:
obj.fill_color = self.app.defaults["excellon_plot_fill"]
obj.outline_color = self.app.defaults["excellon_plot_line"]
obj.fill_color = self.app.options["excellon_plot_fill"]
obj.outline_color = self.app.options["excellon_plot_line"]
if obj.kind == 'gerber':
if self.app.defaults["gerber_store_color_list"] is True:
if self.app.options["gerber_store_color_list"] is True:
group = self.app.collection.group_items["gerber"]
index = group.child_count() - 1
# when loading a Gerber object always create a color tuple (line color, fill_color, layer_name)
# and add it to the self.app.defaults["gerber_color_list"] from where it will be picked and used
# and add it to the self.app.options["gerber_color_list"] from where it will be picked and used
try:
colors = self.app.defaults["gerber_color_list"][index]
colors = self.app.options["gerber_color_list"][index]
except IndexError:
obj.outline_color = self.app.defaults["gerber_plot_line"]
obj.fill_color = self.app.defaults["gerber_plot_fill"]
obj.outline_color = self.app.options["gerber_plot_line"]
obj.fill_color = self.app.options["gerber_plot_fill"]
obj.alpha_level = str(hex(int(obj.fill_color[7:9], 16))[2:])
colors = (obj.outline_color, obj.fill_color, '%s_%d' % (_("Layer"), int(index)))
self.app.defaults["gerber_color_list"].append(colors)
self.app.options["gerber_color_list"].append(colors)
new_line_color = colors[0]
new_fill = colors[1]
@@ -330,9 +330,9 @@ class AppObject(QtCore.QObject):
obj.fill_color = new_fill
obj.alpha_level = new_alpha
else:
obj.outline_color = self.app.defaults["gerber_plot_line"]
obj.fill_color = self.app.defaults["gerber_plot_fill"]
obj.alpha_level = str(hex(int(self.app.defaults['gerber_plot_fill'][7:9], 16))[2:])
obj.outline_color = self.app.options["gerber_plot_line"]
obj.fill_color = self.app.options["gerber_plot_fill"]
obj.alpha_level = str(hex(int(self.app.options['gerber_plot_fill'][7:9], 16))[2:])
except Exception as e:
self.app.log.error("AppObject.new_object() -> setting colors error. %s" % str(e))
@@ -352,7 +352,7 @@ class AppObject(QtCore.QObject):
def plotting_task(t_obj):
with self.app.proc_container.new('%s ...' % _("Plotting")):
if t_obj.kind == 'cncjob':
t_obj.plot(kind=self.app.defaults["cncjob_plot_kind"])
t_obj.plot(kind=self.app.options["cncjob_plot_kind"])
elif t_obj.kind == 'gerber':
t_obj.plot(color=t_obj.outline_color, face_color=t_obj.fill_color)
else:
@@ -363,8 +363,8 @@ class AppObject(QtCore.QObject):
self.app.log.debug(msg)
self.object_plotted.emit(t_obj)
if t_obj.kind == 'gerber' and self.app.defaults["gerber_buffering"] != 'full' and \
self.app.defaults["gerber_delayed_buffering"]:
if t_obj.kind == 'gerber' and self.app.options["gerber_buffering"] != 'full' and \
self.app.options["gerber_delayed_buffering"]:
t_obj.do_buffer_signal.emit()
# Send to worker

View File

@@ -50,7 +50,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
CNCjob.__init__(self, units=units, kind=kind, z_move=z_move,
feedrate=feedrate, feedrate_rapid=feedrate_rapid, z_cut=z_cut, tooldia=tooldia,
spindlespeed=spindlespeed, steps_per_circle=int(self.app.defaults["cncjob_steps_per_circle"]))
spindlespeed=spindlespeed, steps_per_circle=int(self.app.options["cncjob_steps_per_circle"]))
FlatCAMObj.__init__(self, name)
@@ -66,16 +66,16 @@ class CNCJobObject(FlatCAMObj, CNCjob):
"type": 'Geometry',
# "toolchange_macro": '',
# "toolchange_macro_enable": False
"tools_al_travelz": self.app.defaults["tools_al_travelz"],
"tools_al_probe_depth": self.app.defaults["tools_al_probe_depth"],
"tools_al_probe_fr": self.app.defaults["tools_al_probe_fr"],
"tools_al_controller": self.app.defaults["tools_al_controller"],
"tools_al_method": self.app.defaults["tools_al_method"],
"tools_al_mode": self.app.defaults["tools_al_mode"],
"tools_al_rows": self.app.defaults["tools_al_rows"],
"tools_al_columns": self.app.defaults["tools_al_columns"],
"tools_al_grbl_jog_step": self.app.defaults["tools_al_grbl_jog_step"],
"tools_al_grbl_jog_fr": self.app.defaults["tools_al_grbl_jog_fr"],
"tools_al_travelz": self.app.options["tools_al_travelz"],
"tools_al_probe_depth": self.app.options["tools_al_probe_depth"],
"tools_al_probe_fr": self.app.options["tools_al_probe_fr"],
"tools_al_controller": self.app.options["tools_al_controller"],
"tools_al_method": self.app.options["tools_al_method"],
"tools_al_mode": self.app.options["tools_al_mode"],
"tools_al_rows": self.app.options["tools_al_rows"],
"tools_al_columns": self.app.options["tools_al_columns"],
"tools_al_grbl_jog_step": self.app.options["tools_al_grbl_jog_step"],
"tools_al_grbl_jog_fr": self.app.options["tools_al_grbl_jog_fr"],
})
'''
@@ -474,7 +474,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.ui.updateplot_button.hide()
# set the kind of geometries are plotted by default with plot2() from camlib.CNCJob
self.ui.cncplot_method_combo.set_value(self.app.defaults["cncjob_plot_kind"])
self.ui.cncplot_method_combo.set_value(self.app.options["cncjob_plot_kind"])
# #############################################################################################################
# ##################################### SIGNALS CONNECTIONS ###################################################
@@ -489,7 +489,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.ui.annotation_cb.stateChanged.connect(self.on_annotation_change)
# set if to display text annotations
self.ui.annotation_cb.set_value(self.app.defaults["cncjob_annotation"])
self.ui.annotation_cb.set_value(self.app.options["cncjob_annotation"])
# update plot button - active only for SingleGeo type objects
self.ui.updateplot_button.clicked.connect(self.on_updateplot_button_click)
@@ -518,8 +518,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# ###################################### END Signal connections ###############################################
# #############################################################################################################
self.append_snippet = self.app.defaults['cncjob_append']
self.prepend_snippet = self.app.defaults['cncjob_prepend']
self.append_snippet = self.app.options['cncjob_append']
self.prepend_snippet = self.app.options['cncjob_prepend']
if self.append_snippet != '' or self.prepend_snippet != '':
self.ui.snippets_cb.set_value(True)
@@ -543,7 +543,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
self.source_file = gc
# Show/Hide Advanced Options
app_mode = self.app.defaults["global_app_level"]
app_mode = self.app.options["global_app_level"]
self.change_level(app_mode)
def change_level(self, level):
@@ -669,7 +669,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
_filter_ = "HPGL Files .plt (*.plt);;All Files (*.*)"
else:
save_gcode = True
_filter_ = self.app.defaults['cncjob_save_filters']
_filter_ = self.app.options['cncjob_save_filters']
try:
dir_file_to_save = self.app.get_last_save_folder() + '/' + str(name)
@@ -719,7 +719,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
return 'fail'
try:
force_windows_line_endings = self.app.defaults['cncjob_line_ending']
force_windows_line_endings = self.app.options['cncjob_line_ending']
if force_windows_line_endings and sys.platform != 'win32':
with open(filename, 'w', newline='\r\n') as f:
for line in self.source_file:
@@ -738,7 +738,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
)
return 'fail'
if self.app.defaults["global_open_style"] is False:
if self.app.options["global_open_style"] is False:
self.app.file_opened.emit("gcode", filename)
self.app.file_saved.emit("gcode", filename)
self.app.inform.emit('[success] %s: %s' % (_("File saved to"), filename))
@@ -966,9 +966,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
include_header = True
if preamble == '':
preamble = self.app.defaults["cncjob_prepend"]
preamble = self.app.options["cncjob_prepend"]
if postamble == '':
postamble = self.app.defaults["cncjob_append"]
postamble = self.app.options["cncjob_append"]
try:
if self.special_group:
@@ -1026,7 +1026,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# g = self.gc_start + '\n' + preamble + '\n' + gcode + '\n' + postamble
g = ''
end_gcode = self.gcode_footer() if self.app.defaults['cncjob_footer'] is True else ''
end_gcode = self.gcode_footer() if self.app.options['cncjob_footer'] is True else ''
if preamble != '' and postamble != '':
g = self.gc_start + '\n' + preamble + '\n' + gcode + '\n' + postamble + '\n' + end_gcode
if preamble == '':
@@ -1058,7 +1058,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
else:
gcode += self.gcode
end_gcode = self.gcode_footer() if self.app.defaults['cncjob_footer'] is True else ''
end_gcode = self.gcode_footer() if self.app.options['cncjob_footer'] is True else ''
# detect if using a HPGL preprocessor
hpgl = False
@@ -1146,7 +1146,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
# Write
if filename is not None:
try:
force_windows_line_endings = self.app.defaults['cncjob_line_ending']
force_windows_line_endings = self.app.options['cncjob_line_ending']
if force_windows_line_endings and sys.platform != 'win32':
with open(filename, 'w', newline='\r\n') as f:
for line in lines:
@@ -1166,7 +1166,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
return 'fail'
elif to_file is False:
# Just for adding it to the recent files list.
if self.app.defaults["global_open_style"] is False:
if self.app.options["global_open_style"] is False:
self.app.file_opened.emit("cncjob", filename)
self.app.file_saved.emit("cncjob", filename)

View File

@@ -65,7 +65,7 @@ class DocumentObject(FlatCAMObj):
self.to_form()
# Show/Hide Advanced Options
app_mode = self.app.defaults["global_app_level"]
app_mode = self.app.options["global_app_level"]
self.change_level(app_mode)
self.document_editor_tab = AppTextEditor(app=self.app)
@@ -73,15 +73,15 @@ class DocumentObject(FlatCAMObj):
QTextEdit {selection-background-color:%s;
selection-color:white;
}
""" % self.app.defaults["document_sel_color"]
""" % self.app.options["document_sel_color"]
self.document_editor_tab.code_editor.setStyleSheet(stylesheet)
self.document_editor_tab.buttonRun.hide()
self.ui.autocomplete_cb.set_value(self.app.defaults['document_autocompleter'])
self.on_autocomplete_changed(state=self.app.defaults['document_autocompleter'])
self.on_tab_size_change(val=self.app.defaults['document_tab_size'])
self.ui.autocomplete_cb.set_value(self.app.options['document_autocompleter'])
self.on_autocomplete_changed(state=self.app.options['document_autocompleter'])
self.on_tab_size_change(val=self.app.options['document_tab_size'])
flt = "FlatCAM Docs (*.FlatDoc);;All Files (*.*)"
@@ -122,15 +122,15 @@ class DocumentObject(FlatCAMObj):
self.ui.tab_size_spinner.returnPressed.connect(self.on_tab_size_change)
# #######################################################################
self.ui.font_color_entry.set_value(self.app.defaults['document_font_color'])
self.ui.font_color_entry.set_value(self.app.options['document_font_color'])
self.ui.font_color_button.setStyleSheet(
"background-color:%s" % str(self.app.defaults['document_font_color']))
"background-color:%s" % str(self.app.options['document_font_color']))
self.ui.sel_color_entry.set_value(self.app.defaults['document_sel_color'])
self.ui.sel_color_entry.set_value(self.app.options['document_sel_color'])
self.ui.sel_color_button.setStyleSheet(
"background-color:%s" % self.app.defaults['document_sel_color'])
"background-color:%s" % self.app.options['document_sel_color'])
self.ui.font_size_cb.setCurrentIndex(int(self.app.defaults['document_font_size']))
self.ui.font_size_cb.setCurrentIndex(int(self.app.options['document_font_size']))
# self.document_editor_tab.handleTextChanged()
self.ser_attrs = ['options', 'kind', 'source_file']
@@ -224,7 +224,7 @@ class DocumentObject(FlatCAMObj):
tab_balue = int(self.ui.tab_size_spinner.get_value())
self.document_editor_tab.code_editor.setTabStopDistance(tab_balue)
self.app.defaults['document_tab_size'] = tab_balue
self.app.options['document_tab_size'] = tab_balue
self.ui.tab_size_spinner.returnPressed.connect(self.on_tab_size_change)
@@ -268,11 +268,11 @@ class DocumentObject(FlatCAMObj):
# Setting font colors handlers
def on_font_color_entry(self):
self.app.defaults['document_font_color'] = self.ui.font_color_entry.get_value()
self.ui.font_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['document_font_color']))
self.app.options['document_font_color'] = self.ui.font_color_entry.get_value()
self.ui.font_color_button.setStyleSheet("background-color:%s" % str(self.app.options['document_font_color']))
def on_font_color_button(self):
current_color = QtGui.QColor(self.app.defaults['document_font_color'])
current_color = QtGui.QColor(self.app.options['document_font_color'])
c_dialog = QtWidgets.QColorDialog()
font_color = c_dialog.getColor(initial=current_color)
@@ -285,15 +285,15 @@ class DocumentObject(FlatCAMObj):
new_val = str(font_color.name())
self.ui.font_color_entry.set_value(new_val)
self.app.defaults['document_font_color'] = new_val
self.app.options['document_font_color'] = new_val
# Setting selection colors handlers
def on_selection_color_entry(self):
self.app.defaults['document_sel_color'] = self.ui.sel_color_entry.get_value()
self.ui.sel_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['document_sel_color']))
self.app.options['document_sel_color'] = self.ui.sel_color_entry.get_value()
self.ui.sel_color_button.setStyleSheet("background-color:%s" % str(self.app.options['document_sel_color']))
def on_selection_color_button(self):
current_color = QtGui.QColor(self.app.defaults['document_sel_color'])
current_color = QtGui.QColor(self.app.options['document_sel_color'])
c_dialog = QtWidgets.QColorDialog()
sel_color = c_dialog.getColor(initial=current_color)
@@ -311,7 +311,7 @@ class DocumentObject(FlatCAMObj):
new_val = str(sel_color.name())
self.ui.sel_color_entry.set_value(new_val)
self.app.defaults['document_sel_color'] = new_val
self.app.options['document_sel_color'] = new_val
def mirror(self, axis, point):
pass

View File

@@ -40,7 +40,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
def __init__(self, name):
self.decimals = self.app.decimals
self.circle_steps = int(self.app.defaults["excellon_circle_steps"])
self.circle_steps = int(self.app.options["excellon_circle_steps"])
Excellon.__init__(self, excellon_circle_steps=self.circle_steps)
FlatCAMObj.__init__(self, name)
@@ -96,8 +96,8 @@ class ExcellonObject(FlatCAMObj, Excellon):
self.multigeo = False
self.units_found = self.app.app_units
self.fill_color = self.app.defaults['excellon_plot_fill']
self.outline_color = self.app.defaults['excellon_plot_line']
self.fill_color = self.app.options['excellon_plot_fill']
self.outline_color = self.app.options['excellon_plot_line']
self.alpha_level = 'bf'
# the key is the tool id and the value is a list of shapes keys (indexes)
@@ -189,7 +189,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
self.init_context_menu()
# Show/Hide Advanced Options
app_mode = self.app.defaults["global_app_level"]
app_mode = self.app.options["global_app_level"]
self.change_level(app_mode)
def set_offset_values(self):
@@ -244,8 +244,8 @@ class ExcellonObject(FlatCAMObj, Excellon):
self.ui.tools_table.setColumnHidden(4, False)
self.ui.tools_table.setColumnHidden(5, False)
self.ui.table_visibility_cb.show()
self.ui.table_visibility_cb.set_value(self.app.defaults["excellon_tools_table_display"])
self.on_table_visibility_toggle(state=self.app.defaults["excellon_tools_table_display"])
self.ui.table_visibility_cb.set_value(self.app.options["excellon_tools_table_display"])
self.on_table_visibility_toggle(state=self.app.options["excellon_tools_table_display"])
self.ui.autoload_db_cb.show()
# Context Menu section
@@ -356,8 +356,8 @@ class ExcellonObject(FlatCAMObj, Excellon):
h_color = QtGui.QColor(red, green, blue, alpha)
self.ui.tools_table.item(self.tool_row, 4).setBackground(h_color)
else:
h1 = self.app.defaults["excellon_plot_fill"][1:7]
h2 = self.app.defaults["excellon_plot_fill"][7:9]
h1 = self.app.options["excellon_plot_fill"][1:7]
h2 = self.app.options["excellon_plot_fill"][7:9]
h_color = QtGui.QColor('#' + h2 + h1)
self.ui.tools_table.item(self.tool_row, 4).setBackground(h_color)
@@ -1184,10 +1184,10 @@ class ExcellonObject(FlatCAMObj, Excellon):
# self.obj_options['feedrate_rapid'] = float(self.obj_options['feedrate_rapid']) * factor
# self.obj_options['toolchangez'] = float(self.obj_options['toolchangez']) * factor
#
# if self.app.defaults["excellon_toolchangexy"] == '':
# if self.app.options["excellon_toolchangexy"] == '':
# self.obj_options['toolchangexy'] = "0.0, 0.0"
# else:
# coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")]
# coords_xy = [float(eval(coord)) for coord in self.app.options["excellon_toolchangexy"].split(",")]
# if len(coords_xy) < 2:
# self.app.inform.emit('[ERROR] %s' % _("The Toolchange X,Y field in Edit -> Preferences has to be "
# "in the format (x, y) \n"
@@ -1216,7 +1216,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
self.build_ui()
def on_autoload_db_toggled(self, state):
self.app.defaults["excellon_autoload_db"] = True if state else False
self.app.options["excellon_autoload_db"] = True if state else False
def on_plot_cb_click(self):
if self.muted_ui:

View File

@@ -47,7 +47,7 @@ class GeometryObject(FlatCAMObj, Geometry):
def __init__(self, name):
self.decimals = self.app.decimals
self.circle_steps = int(self.app.defaults["geometry_circle_steps"])
self.circle_steps = int(self.app.options["geometry_circle_steps"])
FlatCAMObj.__init__(self, name)
Geometry.__init__(self, geo_steps_per_circle=self.circle_steps)
@@ -89,17 +89,17 @@ class GeometryObject(FlatCAMObj, Geometry):
})
if "tools_mill_tooldia" not in self.obj_options:
if type(self.app.defaults["tools_mill_tooldia"]) == float:
self.obj_options["tools_mill_tooldia"] = self.app.defaults["tools_mill_tooldia"]
if type(self.app.options["tools_mill_tooldia"]) == float:
self.obj_options["tools_mill_tooldia"] = self.app.options["tools_mill_tooldia"]
else:
try:
tools_string = self.app.defaults["tools_mill_tooldia"].split(",")
tools_string = self.app.options["tools_mill_tooldia"].split(",")
tools_diameters = [eval(a) for a in tools_string if a != '']
self.obj_options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0
except Exception as e:
self.app.log.error("FlatCAMObj.GeometryObject.init() --> %s" % str(e))
self.obj_options["tools_mill_startz"] = self.app.defaults["tools_mill_startz"]
self.obj_options["tools_mill_startz"] = self.app.options["tools_mill_startz"]
# this will hold the tool unique ID that is useful when having multiple tools with same diameter
self.tooluid = 0
@@ -136,24 +136,24 @@ class GeometryObject(FlatCAMObj, Geometry):
# engine of FlatCAM. Most likely are generated by some tools and are special cases of geometries.
self.special_group = None
# self.old_pp_state = self.app.defaults["tools_mill_multidepth"]
# self.old_toolchangeg_state = self.app.defaults["tools_mill_toolchange"]
# self.old_pp_state = self.app.options["tools_mill_multidepth"]
# self.old_toolchangeg_state = self.app.options["tools_mill_toolchange"]
self.units_found = self.app.app_units
# this variable can be updated by the Object that generates the geometry
self.tool_type = 'C1'
# save here the old value for the Cut Z before it is changed by selecting a V-shape type tool in the tool table
self.old_cutz = self.app.defaults["tools_mill_cutz"]
self.old_cutz = self.app.options["tools_mill_cutz"]
self.fill_color = self.app.defaults['geometry_plot_line']
self.outline_color = self.app.defaults['geometry_plot_line']
self.fill_color = self.app.options['geometry_plot_line']
self.outline_color = self.app.options['geometry_plot_line']
self.alpha_level = 'FF'
self.param_fields = {}
# store here the state of the exclusion checkbox state to be restored after building the UI
self.exclusion_area_cb_is_checked = self.app.defaults["tools_mill_area_exclusion"]
self.exclusion_area_cb_is_checked = self.app.options["tools_mill_area_exclusion"]
# Attributes to be included in serialization
# Always append to it because it carries contents
@@ -397,7 +397,7 @@ class GeometryObject(FlatCAMObj, Geometry):
self.ui.geo_tools_table.itemSelectionChanged.connect(self.on_row_changed)
self.ui.geo_tools_table.horizontalHeader().sectionClicked.connect(self.table_toggle_all)
# Show/Hide Advanced Options
app_mode = self.app.defaults["global_app_level"]
app_mode = self.app.options["global_app_level"]
self.change_level(app_mode)
def on_row_changed(self):
@@ -563,7 +563,7 @@ class GeometryObject(FlatCAMObj, Geometry):
def export_dxf(self):
dwg = None
dxf_format = self.app.defaults['geometry_dxf_format']
dxf_format = self.app.options['geometry_dxf_format']
try:
dwg = ezdxf.new(dxf_format)
@@ -638,8 +638,8 @@ class GeometryObject(FlatCAMObj, Geometry):
outname = "%s_%s" % (self.obj_options["name"], 'cnc') if outname is None else outname
tools_dict = self.sel_tools if tools_dict is None else tools_dict
segx = segx if segx is not None else float(self.app.defaults['geometry_segx'])
segy = segy if segy is not None else float(self.app.defaults['geometry_segy'])
segx = segx if segx is not None else float(self.app.options['geometry_segx'])
segy = segy if segy is not None else float(self.app.options['geometry_segy'])
try:
xmin = self.obj_options['xmin']
@@ -679,11 +679,11 @@ class GeometryObject(FlatCAMObj, Geometry):
job_obj.multigeo = False
job_obj.tools.clear()
job_obj.segx = segx if segx else float(self.app.defaults["geometry_segx"])
job_obj.segy = segy if segy else float(self.app.defaults["geometry_segy"])
job_obj.segx = segx if segx else float(self.app.options["geometry_segx"])
job_obj.segy = segy if segy else float(self.app.options["geometry_segy"])
job_obj.z_pdepth = float(self.app.defaults["tools_mill_z_pdepth"])
job_obj.feedrate_probe = float(self.app.defaults["tools_mill_feedrate_probe"])
job_obj.z_pdepth = float(self.app.options["tools_mill_z_pdepth"])
job_obj.feedrate_probe = float(self.app.options["tools_mill_feedrate_probe"])
total_gcode = ''
for tooluid_key in list(tools_dict.keys()):
@@ -742,11 +742,11 @@ class GeometryObject(FlatCAMObj, Geometry):
dwelltime = tools_dict[tooluid_key]['data']["tools_mill_dwelltime"]
pp_geometry_name = tools_dict[tooluid_key]['data']["tools_mill_ppname_g"]
spindledir = self.app.defaults['tools_mill_spindledir']
spindledir = self.app.options['tools_mill_spindledir']
tool_solid_geometry = self.solid_geometry
job_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"]
job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"]
job_obj.coords_decimals = self.app.options["cncjob_coords_decimals"]
job_obj.fr_decimals = self.app.options["cncjob_fr_decimals"]
# Propagate options
job_obj.obj_options["tooldia"] = tooldia_val
@@ -758,7 +758,7 @@ class GeometryObject(FlatCAMObj, Geometry):
# it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially
# to a value of 0.0005 which is 20 times less than 0.01
tol = float(self.app.defaults['global_tolerance']) / 20
tol = float(self.app.options['global_tolerance']) / 20
res, start_gcode = job_obj.generate_from_geometry_2(
self, tooldia=tooldia_val, offset=tool_offset, tolerance=tol,
z_cut=z_cut, z_move=z_move,
@@ -821,11 +821,11 @@ class GeometryObject(FlatCAMObj, Geometry):
job_obj.multigeo = True
job_obj.tools.clear()
job_obj.segx = segx if segx else float(self.app.defaults["geometry_segx"])
job_obj.segy = segy if segy else float(self.app.defaults["geometry_segy"])
job_obj.segx = segx if segx else float(self.app.options["geometry_segx"])
job_obj.segy = segy if segy else float(self.app.options["geometry_segy"])
job_obj.z_pdepth = float(self.app.defaults["tools_mill_z_pdepth"])
job_obj.feedrate_probe = float(self.app.defaults["tools_mill_feedrate_probe"])
job_obj.z_pdepth = float(self.app.options["tools_mill_z_pdepth"])
job_obj.feedrate_probe = float(self.app.options["tools_mill_feedrate_probe"])
# make sure that trying to make a CNCJob from an empty file is not creating an app crash
if not self.solid_geometry:
@@ -847,7 +847,7 @@ class GeometryObject(FlatCAMObj, Geometry):
})
if "optimization_type" not in tools_dict[tooluid_key]['data']:
tools_dict[tooluid_key]['data']["tools_mill_optimization_type"] = \
self.app.defaults["tools_mill_optimization_type"]
self.app.options["tools_mill_optimization_type"]
# find the tool_dia associated with the tooluid_key
# search in the self.tools for the sel_tool_dia and when found see what tooluid has
@@ -896,11 +896,11 @@ class GeometryObject(FlatCAMObj, Geometry):
# dwelltime = tools_dict[tooluid_key]['data']["dwelltime"]
# pp_geometry_name = tools_dict[tooluid_key]['data']["ppname_g"]
#
# spindledir = self.app.defaults['geometry_spindledir']
# spindledir = self.app.options['geometry_spindledir']
tool_solid_geometry = self.tools[tooluid_key]['solid_geometry']
job_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"]
job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"]
job_obj.coords_decimals = self.app.options["cncjob_coords_decimals"]
job_obj.fr_decimals = self.app.options["cncjob_fr_decimals"]
# Propagate options
job_obj.obj_options["tooldia"] = tooldia_val
@@ -909,7 +909,7 @@ class GeometryObject(FlatCAMObj, Geometry):
# it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially
# to a value of 0.0005 which is 20 times less than 0.01
tol = float(self.app.defaults['global_tolerance']) / 20
tol = float(self.app.options['global_tolerance']) / 20
tool_lst = list(tools_dict.keys())
is_first = True if tooluid_key == tool_lst[0] else False
@@ -1034,8 +1034,8 @@ class GeometryObject(FlatCAMObj, Geometry):
multidepth = multidepth if multidepth is not None else self.obj_options["tools_mill_multidepth"]
depthperpass = dpp if dpp is not None else float(self.obj_options["tools_mill_depthperpass"])
segx = segx if segx is not None else float(self.app.defaults['geometry_segx'])
segy = segy if segy is not None else float(self.app.defaults['geometry_segy'])
segx = segx if segx is not None else float(self.app.options['geometry_segx'])
segy = segy if segy is not None else float(self.app.options['geometry_segy'])
extracut = extracut if extracut is not None else float(self.obj_options["tools_mill_extracut"])
extracut_length = extracut_length if extracut_length is not None else float(self.obj_options[
@@ -1079,8 +1079,8 @@ class GeometryObject(FlatCAMObj, Geometry):
job_obj.obj_options["tooldia"] = tooldia
job_obj.obj_options["tools_mill_tooldia"] = tooldia
job_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"]
job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"]
job_obj.coords_decimals = self.app.options["cncjob_coords_decimals"]
job_obj.fr_decimals = self.app.options["cncjob_fr_decimals"]
job_obj.obj_options['type'] = 'Geometry'
job_obj.obj_options['tool_dia'] = tooldia
@@ -1098,7 +1098,7 @@ class GeometryObject(FlatCAMObj, Geometry):
# it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially
# to a value of 0.0005 which is 20 times less than 0.01
tol = float(self.app.defaults['global_tolerance']) / 20
tol = float(self.app.options['global_tolerance']) / 20
res, start_gcode = job_obj.generate_from_geometry_2(
self, tooldia=tooldia, offset=offset, tolerance=tol, z_cut=z_cut, z_move=z_move, feedrate=feedrate,
feedrate_z=feedrate_z, feedrate_rapid=feedrate_rapid, spindlespeed=spindlespeed, dwell=dwell,
@@ -1319,10 +1319,10 @@ class GeometryObject(FlatCAMObj, Geometry):
self.obj_options["toolchangez"] = float(self.obj_options["toolchangez"]) * factor
if self.app.defaults["tools_mill_toolchangexy"] == '':
if self.app.options["tools_mill_toolchangexy"] == '':
self.obj_options['toolchangexy'] = "0.0, 0.0"
else:
coords_xy = [float(eval(coord)) for coord in self.app.defaults["tools_mill_toolchangexy"].split(",")]
coords_xy = [float(eval(coord)) for coord in self.app.options["tools_mill_toolchangexy"].split(",")]
if len(coords_xy) < 2:
self.app.inform.emit('[ERROR] %s' %
_("The Toolchange X,Y field in Edit -> Preferences "
@@ -1465,7 +1465,7 @@ class GeometryObject(FlatCAMObj, Geometry):
color = self.tools[tooluid_key]['data']['override_color']
else:
color = random_color() if self.obj_options['multicolored'] else \
self.app.defaults["geometry_plot_line"]
self.app.options["geometry_plot_line"]
self.plot_element(solid_geometry, visible=visible, color=color)
else:
@@ -1474,7 +1474,7 @@ class GeometryObject(FlatCAMObj, Geometry):
color = self.tools[plot_tool]['data']['override_color']
else:
color = random_color() if self.obj_options['multicolored'] else \
self.app.defaults["geometry_plot_line"]
self.app.options["geometry_plot_line"]
self.plot_element(solid_geometry, visible=visible, color=color)
else:
@@ -1482,7 +1482,7 @@ class GeometryObject(FlatCAMObj, Geometry):
# for SingleGeo
if self.solid_geometry:
solid_geometry = self.solid_geometry
color = self.app.defaults["geometry_plot_line"]
color = self.app.options["geometry_plot_line"]
self.plot_element(solid_geometry, visible=visible, color=color)

View File

@@ -43,7 +43,7 @@ class GerberObject(FlatCAMObj, Gerber):
def __init__(self, name):
self.decimals = self.app.decimals
self.circle_steps = int(self.app.defaults["gerber_circle_steps"])
self.circle_steps = int(self.app.options["gerber_circle_steps"])
Gerber.__init__(self, steps_per_circle=self.circle_steps)
FlatCAMObj.__init__(self, name)
@@ -93,8 +93,8 @@ class GerberObject(FlatCAMObj, Gerber):
self.units_found = self.app.app_units
self.fill_color = self.app.defaults['gerber_plot_fill']
self.outline_color = self.app.defaults['gerber_plot_line']
self.fill_color = self.app.options['gerber_plot_fill']
self.outline_color = self.app.options['gerber_plot_line']
self.alpha_level = 'bf'
# keep track if the UI is built so we don't have to build it every time
@@ -178,10 +178,10 @@ class GerberObject(FlatCAMObj, Gerber):
self.do_buffer_signal.connect(self.on_generate_buffer)
# Show/Hide Advanced Options
app_mode = self.app.defaults["global_app_level"]
app_mode = self.app.options["global_app_level"]
self.change_level(app_mode)
if self.app.defaults["gerber_buffering"] == 'no':
if self.app.options["gerber_buffering"] == 'no':
self.ui.create_buffer_button.show()
try:
self.ui.create_buffer_button.clicked.disconnect(self.on_generate_buffer)
@@ -542,20 +542,20 @@ class GerberObject(FlatCAMObj, Gerber):
work_geo = geometry
if dia is None:
dia = float(self.app.defaults["tools_iso_tooldia"])
dia = float(self.app.options["tools_iso_tooldia"])
if passes is None:
passes = int(self.app.defaults["tools_iso_passes"])
passes = int(self.app.options["tools_iso_passes"])
if overlap is None:
overlap = float(self.app.defaults["tools_iso_overlap"])
overlap = float(self.app.options["tools_iso_overlap"])
overlap /= 100.0
combine = self.app.defaults["tools_iso_combine_passes"] if combine is None else bool(combine)
combine = self.app.options["tools_iso_combine_passes"] if combine is None else bool(combine)
if milling_type is None:
milling_type = self.app.defaults["tools_iso_milling_type"]
milling_type = self.app.options["tools_iso_milling_type"]
if iso_type is None:
iso_t = 2
@@ -578,7 +578,7 @@ class GerberObject(FlatCAMObj, Gerber):
def iso_init(geo_obj, app_obj):
# Propagate options
geo_obj.obj_options["tools_mill_tooldia"] = str(dia)
geo_obj.tool_type = self.app.defaults["tools_iso_tool_shape"]
geo_obj.tool_type = self.app.options["tools_iso_tool_shape"]
geo_obj.multigeo = True
geo_obj.solid_geometry = []
@@ -643,7 +643,7 @@ class GerberObject(FlatCAMObj, Gerber):
# ############################################################
# ########## AREA SUBTRACTION ################################
# ############################################################
# if self.app.defaults["tools_iso_except"]:
# if self.app.options["tools_iso_except"]:
# self.app.proc_container.update_view_text(' %s' % _("Subtracting Geo"))
# geo_obj.solid_geometry = self.area_subtraction(geo_obj.solid_geometry)
@@ -676,7 +676,7 @@ class GerberObject(FlatCAMObj, Gerber):
def iso_init(geo_obj, app_obj):
# Propagate options
geo_obj.obj_options["tools_mill_tooldia"] = str(dia)
geo_obj.tool_type = self.app.defaults["tools_iso_tool_shape"]
geo_obj.tool_type = self.app.options["tools_iso_tool_shape"]
geo_obj.multigeo = True
# if milling type is climb then the move is counter-clockwise around features
@@ -734,7 +734,7 @@ class GerberObject(FlatCAMObj, Gerber):
# ############################################################
# ########## AREA SUBTRACTION ################################
# ############################################################
# if self.app.defaults["tools_iso_except"]:
# if self.app.options["tools_iso_except"]:
# self.app.proc_container.update_view_text(' %s' % _("Subtracting Geo"))
# geo_obj.solid_geometry = self.area_subtraction(geo_obj.solid_geometry)
@@ -805,7 +805,7 @@ class GerberObject(FlatCAMObj, Gerber):
# Propagate options
new_obj.multigeo = True
# new_obj.obj_options["tools_mill_tooldia"] = str(self.app.defaults["tools_iso_tooldia"])
# new_obj.obj_options["tools_mill_tooldia"] = str(self.app.options["tools_iso_tooldia"])
new_obj.solid_geometry = deepcopy(self.follow_geometry)
new_obj.obj_options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"]
@@ -973,7 +973,7 @@ class GerberObject(FlatCAMObj, Gerber):
used_color = random_color() if self.obj_options['multicolored'] else 'black'
used_face_color = None
if self.app.defaults["gerber_plot_line_enable"] is False:
if self.app.options["gerber_plot_line_enable"] is False:
used_color = None
if isinstance(g, (Polygon, LineString)):
self.add_shape(shape=g, color=used_color, face_color=used_face_color, visible=visible)
@@ -988,7 +988,7 @@ class GerberObject(FlatCAMObj, Gerber):
used_color = random_color() if self.obj_options['multicolored'] else 'black'
used_face_color = None
if self.app.defaults["gerber_plot_line_disable"] is True:
if self.app.options["gerber_plot_line_disable"] is True:
used_color = None
if isinstance(plot_geometry, (Polygon, LineString)):
self.add_shape(shape=plot_geometry, color=used_color, face_color=used_face_color, visible=visible)
@@ -1024,7 +1024,7 @@ class GerberObject(FlatCAMObj, Gerber):
if 'color' in kwargs:
color = kwargs['color']
else:
color = self.app.defaults['gerber_plot_fill']
color = self.app.options['gerber_plot_fill']
if 'marked_aperture' in kwargs:
aperture_to_plot_mark = kwargs['marked_aperture']
@@ -1120,7 +1120,7 @@ class GerberObject(FlatCAMObj, Gerber):
if self.ui.apertures_table.cellWidget(cw_row, 5).isChecked():
self.marked_rows.append(True)
# self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True)
color = self.app.defaults['global_sel_draw_color']
color = self.app.options['global_sel_draw_color']
color = (color + 'AF') if len(color) == 7 else (color[:-2] + 'AF')
self.plot_aperture(color=color, marked_aperture=aperture, visible=True, run_thread=True)
else:
@@ -1158,7 +1158,7 @@ class GerberObject(FlatCAMObj, Gerber):
if mark_all:
for aperture in self.tools:
# self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True)
color = self.app.defaults['global_sel_draw_color']
color = self.app.options['global_sel_draw_color']
color = (color + 'AF') if len(color) == 7 else (color[:-2] + 'AF')
self.plot_aperture(color=color, marked_aperture=aperture, visible=True)
# HACK: enable/disable the grid for a better look

View File

@@ -105,8 +105,8 @@ class FlatCAMObj(QtCore.QObject):
self.deleted = False
try:
self._drawing_tolerance = float(self.app.defaults["global_tolerance"]) if \
self.app.defaults["global_tolerance"] else 0.001
self._drawing_tolerance = float(self.app.options["global_tolerance"]) if \
self.app.options["global_tolerance"] else 0.001
except ValueError:
self._drawing_tolerance = 0.001
@@ -493,12 +493,12 @@ class FlatCAMObj(QtCore.QObject):
used file extension as the first one in the special string
:param last_ext: The file extension that was last used to save a file
:param filter_string: A key in self.app.defaults that holds a string with the filter from QFileDialog
:param filter_string: A key in self.app.options that holds a string with the filter from QFileDialog
used when saving a file
:return: None
"""
filters = copy(self.app.defaults[filter_string])
filters = copy(self.app.options[filter_string])
filter_list = filters.split(';;')
filter_list_enum_1 = enumerate(filter_list)
@@ -521,7 +521,7 @@ class FlatCAMObj(QtCore.QObject):
# add back the element that should always be the last (All Files)
filter_list.append(last_elem)
self.app.defaults[filter_string] = ';;'.join(filter_list)
self.app.options[filter_string] = ';;'.join(filter_list)
return
def add_properties_items(self, obj, treeWidget):
@@ -536,7 +536,7 @@ class FlatCAMObj(QtCore.QObject):
font = QtGui.QFont()
font.setBold(True)
p_color = QtGui.QColor("#000000") if self.app.defaults['global_gray_icons'] is False \
p_color = QtGui.QColor("#000000") if self.app.options['global_gray_icons'] is False \
else QtGui.QColor("#FFFFFF")
# main Items categories

View File

@@ -74,7 +74,7 @@ class ScriptObject(FlatCAMObj):
self.to_form()
# Show/Hide Advanced Options
app_mode = self.app.defaults["global_app_level"]
app_mode = self.app.options["global_app_level"]
self.change_level(app_mode)
self.script_editor_tab = AppTextEditor(app=self.app, plain_text=True, parent=self.app.ui)
@@ -98,8 +98,8 @@ class ScriptObject(FlatCAMObj):
# self.script_editor_tab.code_editor.clear()
# self.script_editor_tab.code_editor.setReadOnly(False)
self.ui.autocomplete_cb.set_value(self.app.defaults['script_autocompleter'])
self.on_autocomplete_changed(state=self.app.defaults['script_autocompleter'])
self.ui.autocomplete_cb.set_value(self.app.options['script_autocompleter'])
self.on_autocomplete_changed(state=self.app.options['script_autocompleter'])
self.script_editor_tab.buttonRun.show()

View File

@@ -318,7 +318,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
self.view.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu)
self.view.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
if self.app.defaults["global_allow_edit_in_project_tab"] is True:
if self.app.options["global_allow_edit_in_project_tab"] is True:
self.view.setEditTriggers(QtWidgets.QTreeView.EditTrigger.SelectedClicked) # allow Edit on Tree
else:
self.view.setEditTriggers(QtWidgets.QTreeView.EditTrigger.NoEditTriggers)
@@ -482,8 +482,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
return index.internalPointer().data(index.column())
if role == Qt.ItemDataRole.ForegroundRole:
color = QColor(self.app.defaults['global_proj_item_color'][:-2])
color_disabled = QColor(self.app.defaults['global_proj_item_dis_color'][:-2])
color = QColor(self.app.options['global_proj_item_color'][:-2])
color_disabled = QColor(self.app.options['global_proj_item_dis_color'][:-2])
obj = index.internalPointer().obj
if obj:
return QtGui.QBrush(color) if obj.obj_options["plot"] else QtGui.QBrush(color_disabled)
@@ -627,7 +627,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
self.app.object_status_changed.emit(obj, 'append', name)
# decide if to show or hide the Notebook side of the screen
if self.app.defaults["global_project_autohide"] is True:
if self.app.options["global_project_autohide"] is True:
# always open the notebook on object added to collection
self.app.ui.splitter.setSizes([1, 1])
@@ -742,7 +742,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
self.app.should_we_save = True
# decide if to show or hide the Notebook side of the screen
if self.app.defaults["global_project_autohide"] is True:
if self.app.options["global_project_autohide"] is True:
# hide the notebook if there are no objects in the collection
if not self.get_list():
self.app.ui.splitter.setSizes([0, 1])
@@ -796,7 +796,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
self.app.should_we_save = True
# decide if to show or hide the Notebook side of the screen
if self.app.defaults["global_project_autohide"] is True:
if self.app.options["global_project_autohide"] is True:
# hide the notebook if there are no objects in the collection
if not self.get_list():
self.app.ui.splitter.setSizes([0, 1])
@@ -1014,7 +1014,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
# works only for mouse button 1 (left click)
if button == Qt.MouseButton.LeftButton:
# on Gerber object selection it will redrawn on top of the other Gerber objects
if self.app.defaults["gerber_plot_on_select"] is True:
if self.app.options["gerber_plot_on_select"] is True:
self.app.gerber_redraw()
def on_item_activated(self, index):