- 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

@@ -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