- refactoring all the references to object options property to obj_options to make a difference with the application options property
This commit is contained in:
@@ -119,12 +119,12 @@ class AppObject(QtCore.QObject):
|
||||
obj.notHovering = True
|
||||
|
||||
# IMPORTANT
|
||||
# The key names in defaults and options dictionary's are not random:
|
||||
# The key names in defaults and options dictionaries are not random:
|
||||
# they have to have in name first the type of the object (geometry, excellon, cncjob and gerber) or how it's
|
||||
# called here, the 'kind' followed by an underline. Above the App default values from self.defaults are
|
||||
# copied to self.options. After that, below, depending on the type of
|
||||
# copied to self.obj_options. After that, below, depending on the type of
|
||||
# object that is created, it will strip the name of the object and the underline (if the original key was
|
||||
# let's say "excellon_toolchange", it will strip the excellon_) and to the obj.options the key will become
|
||||
# let's say "excellon_toolchange", it will strip the excellon_) and to the obj.obj_options the key will become
|
||||
# "toolchange"
|
||||
|
||||
# ############################################################################################################
|
||||
@@ -133,27 +133,27 @@ class AppObject(QtCore.QObject):
|
||||
for option in self.app.options:
|
||||
if option.find(kind + "_") == 0:
|
||||
oname = option[len(kind) + 1:]
|
||||
obj.options[oname] = self.app.options[option]
|
||||
obj.obj_options[oname] = self.app.options[option]
|
||||
|
||||
# add some of the FlatCAM Tools related properties
|
||||
# it is done like this to preserve some kind of order in the keys
|
||||
if kind == 'excellon':
|
||||
for option in self.app.options:
|
||||
if option.find('tools_drill_') == 0:
|
||||
obj.options[option] = self.app.options[option]
|
||||
obj.obj_options[option] = self.app.options[option]
|
||||
if kind == 'gerber':
|
||||
for option in self.app.options:
|
||||
if option.find('tools_iso_') == 0:
|
||||
obj.options[option] = self.app.options[option]
|
||||
obj.obj_options[option] = self.app.options[option]
|
||||
|
||||
# the milling options should be inherited by all manufacturing objects
|
||||
if kind in ['excellon', 'gerber', 'geometry', 'cncjob']:
|
||||
for option in self.app.options:
|
||||
if option.find('tools_mill_') == 0:
|
||||
obj.options[option] = self.app.options[option]
|
||||
obj.obj_options[option] = self.app.options[option]
|
||||
for option in self.app.options:
|
||||
if option.find('tools_') == 0:
|
||||
obj.options[option] = self.app.options[option]
|
||||
obj.obj_options[option] = self.app.options[option]
|
||||
# ############################################################################################################
|
||||
# ############################################################################################################
|
||||
|
||||
@@ -193,16 +193,16 @@ class AppObject(QtCore.QObject):
|
||||
self.app.log.debug("%f seconds converting units." % (t3 - t2))
|
||||
|
||||
# ############################################################################################################
|
||||
# Create the bounding box for the object and then add the results to the obj.options
|
||||
# Create the bounding box for the object and then add the results to the obj.obj_options
|
||||
# But not for Scripts or for Documents
|
||||
# ############################################################################################################
|
||||
if kind != 'document' and kind != 'script':
|
||||
try:
|
||||
xmin, ymin, xmax, ymax = obj.bounds()
|
||||
obj.options['xmin'] = xmin
|
||||
obj.options['ymin'] = ymin
|
||||
obj.options['xmax'] = xmax
|
||||
obj.options['ymax'] = ymax
|
||||
obj.obj_options['xmin'] = xmin
|
||||
obj.obj_options['ymin'] = ymin
|
||||
obj.obj_options['xmax'] = xmax
|
||||
obj.obj_options['ymax'] = ymax
|
||||
except Exception as e:
|
||||
self.app.log.error("AppObject.new_object() -> The object has no bounds properties. %s" % str(e))
|
||||
return "fail"
|
||||
@@ -252,7 +252,7 @@ class AppObject(QtCore.QObject):
|
||||
self.app.all_objects_list = self.app.collection.get_list()
|
||||
|
||||
# self.app.inform.emit('[selected] %s created & selected: %s' %
|
||||
# (str(obj.kind).capitalize(), str(obj.options['name'])))
|
||||
# (str(obj.kind).capitalize(), str(obj.obj_options['name'])))
|
||||
|
||||
# #############################################################################################################
|
||||
# ###################### Set colors for the message in the Status Bar #######################################
|
||||
@@ -261,37 +261,37 @@ class AppObject(QtCore.QObject):
|
||||
self.app.inform.emit('[selected] {kind} {tx}: <span style="color:{color};">{name}</span>'.format(
|
||||
kind=obj.kind.capitalize(),
|
||||
color='green',
|
||||
name=str(obj.options['name']), tx=_("created/selected"))
|
||||
name=str(obj.obj_options['name']), tx=_("created/selected"))
|
||||
)
|
||||
elif obj.kind == 'excellon':
|
||||
self.app.inform.emit('[selected] {kind} {tx}: <span style="color:{color};">{name}</span>'.format(
|
||||
kind=obj.kind.capitalize(),
|
||||
color='brown',
|
||||
name=str(obj.options['name']), tx=_("created/selected"))
|
||||
name=str(obj.obj_options['name']), tx=_("created/selected"))
|
||||
)
|
||||
elif obj.kind == 'cncjob':
|
||||
self.app.inform.emit('[selected] {kind} {tx}: <span style="color:{color};">{name}</span>'.format(
|
||||
kind=obj.kind.capitalize(),
|
||||
color='blue',
|
||||
name=str(obj.options['name']), tx=_("created/selected"))
|
||||
name=str(obj.obj_options['name']), tx=_("created/selected"))
|
||||
)
|
||||
elif obj.kind == 'geometry':
|
||||
self.app.inform.emit('[selected] {kind} {tx}: <span style="color:{color};">{name}</span>'.format(
|
||||
kind=obj.kind.capitalize(),
|
||||
color='red',
|
||||
name=str(obj.options['name']), tx=_("created/selected"))
|
||||
name=str(obj.obj_options['name']), tx=_("created/selected"))
|
||||
)
|
||||
elif obj.kind == 'script':
|
||||
self.app.inform.emit('[selected] {kind} {tx}: <span style="color:{color};">{name}</span>'.format(
|
||||
kind=obj.kind.capitalize(),
|
||||
color='orange',
|
||||
name=str(obj.options['name']), tx=_("created/selected"))
|
||||
name=str(obj.obj_options['name']), tx=_("created/selected"))
|
||||
)
|
||||
elif obj.kind == 'document':
|
||||
self.app.inform.emit('[selected] {kind} {tx}: <span style="color:{color};">{name}</span>'.format(
|
||||
kind=obj.kind.capitalize(),
|
||||
color='darkCyan',
|
||||
name=str(obj.options['name']), tx=_("created/selected"))
|
||||
name=str(obj.obj_options['name']), tx=_("created/selected"))
|
||||
)
|
||||
|
||||
# ############################################################################################################
|
||||
@@ -344,7 +344,7 @@ class AppObject(QtCore.QObject):
|
||||
if auto_select or self.app.ui.notebook.currentWidget() is self.app.ui.properties_tab:
|
||||
# select the just opened object but deselect the previous ones
|
||||
self.app.collection.set_all_inactive()
|
||||
self.app.collection.set_active(obj.options["name"])
|
||||
self.app.collection.set_active(obj.obj_options["name"])
|
||||
else:
|
||||
self.app.collection.set_all_inactive()
|
||||
|
||||
@@ -380,7 +380,7 @@ class AppObject(QtCore.QObject):
|
||||
"""
|
||||
Called whenever the geometry of the object was changed in some way.
|
||||
This require the update of it's bounding values so it can be the selected on canvas.
|
||||
Update the bounding box data from obj.options
|
||||
Update the bounding box data from obj.obj_options
|
||||
|
||||
:param obj: the object that was changed
|
||||
:return: None
|
||||
@@ -390,12 +390,12 @@ class AppObject(QtCore.QObject):
|
||||
xmin, ymin, xmax, ymax = obj.bounds()
|
||||
except TypeError:
|
||||
return
|
||||
obj.options['xmin'] = xmin
|
||||
obj.options['ymin'] = ymin
|
||||
obj.options['xmax'] = xmax
|
||||
obj.options['ymax'] = ymax
|
||||
obj.obj_options['xmin'] = xmin
|
||||
obj.obj_options['ymin'] = ymin
|
||||
obj.obj_options['xmax'] = xmax
|
||||
obj.obj_options['ymax'] = ymax
|
||||
|
||||
self.app.log.debug("Object changed, updating the bounding box data on self.options")
|
||||
self.app.log.debug("Object changed, updating the bounding box data on self.obj_options")
|
||||
# delete the old selection shape
|
||||
self.app.delete_selection_shape()
|
||||
self.app.should_we_save = True
|
||||
@@ -489,10 +489,10 @@ class AppObject(QtCore.QObject):
|
||||
new_obj.follow_geometry = []
|
||||
|
||||
try:
|
||||
new_obj.options['xmin'] = 0
|
||||
new_obj.options['ymin'] = 0
|
||||
new_obj.options['xmax'] = 0
|
||||
new_obj.options['ymax'] = 0
|
||||
new_obj.obj_options['xmin'] = 0
|
||||
new_obj.obj_options['ymin'] = 0
|
||||
new_obj.obj_options['xmax'] = 0
|
||||
new_obj.obj_options['ymax'] = 0
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
|
||||
self.kind = "cncjob"
|
||||
|
||||
self.options.update({
|
||||
self.obj_options.update({
|
||||
"plot": True,
|
||||
"tooldia": 0.03937, # 0.4mm in inches
|
||||
"append": "",
|
||||
@@ -191,11 +191,11 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
self.ui.cnc_tools_table.hide()
|
||||
self.ui.exc_cnc_tools_table.hide()
|
||||
|
||||
if self.options['type'].lower() == 'geometry':
|
||||
if self.obj_options['type'].lower() == 'geometry':
|
||||
self.build_cnc_tools_table()
|
||||
self.ui.cnc_tools_table.show()
|
||||
|
||||
if self.options['type'].lower() == 'excellon':
|
||||
if self.obj_options['type'].lower() == 'excellon':
|
||||
try:
|
||||
self.build_excellon_cnc_tools()
|
||||
except Exception as err:
|
||||
@@ -651,7 +651,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
self.app.defaults.report_usage("cncjob_on_exportgcode_button")
|
||||
|
||||
self.read_form()
|
||||
name = self.app.collection.get_active().options['name']
|
||||
name = self.app.collection.get_active().obj_options['name']
|
||||
save_gcode = False
|
||||
|
||||
if 'Roland' in self.pp_excellon_name or 'Roland' in self.pp_geometry_name:
|
||||
@@ -833,7 +833,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
start_comment = comment_start_symbol if comment_start_symbol is not None else '('
|
||||
stop_comment = comment_stop_symbol if comment_stop_symbol is not None else ')'
|
||||
|
||||
if self.options['type'].lower() == 'geometry':
|
||||
if self.obj_options['type'].lower() == 'geometry':
|
||||
try:
|
||||
for key in self.tools:
|
||||
ppg = self.tools[key]['data']['tools_mill_ppname_g']
|
||||
@@ -853,22 +853,22 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
pass
|
||||
|
||||
try:
|
||||
if 'marlin' in self.options['tools_drill_ppname_e'].lower() or \
|
||||
'repetier' in self.options['tools_drill_ppname_e'].lower():
|
||||
if 'marlin' in self.obj_options['tools_drill_ppname_e'].lower() or \
|
||||
'repetier' in self.obj_options['tools_drill_ppname_e'].lower():
|
||||
marlin = True
|
||||
except KeyError:
|
||||
# self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
|
||||
pass
|
||||
|
||||
try:
|
||||
if "toolchange_probe" in self.options['tools_drill_ppname_e'].lower():
|
||||
if "toolchange_probe" in self.obj_options['tools_drill_ppname_e'].lower():
|
||||
probe_pp = True
|
||||
except KeyError:
|
||||
# self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e))
|
||||
pass
|
||||
|
||||
try:
|
||||
if 'nccad' in self.options['tools_drill_ppname_e'].lower():
|
||||
if 'nccad' in self.obj_options['tools_drill_ppname_e'].lower():
|
||||
nccad_pp = True
|
||||
except KeyError:
|
||||
pass
|
||||
@@ -877,8 +877,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
gcode += ';Marlin(Repetier) G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s\n' % \
|
||||
(str(self.app.version), str(self.app.version_date)) + '\n'
|
||||
|
||||
gcode += ';Name: ' + str(self.options['name']) + '\n'
|
||||
gcode += ';Type: ' + "G-code from " + str(self.options['type']) + '\n'
|
||||
gcode += ';Name: ' + str(self.obj_options['name']) + '\n'
|
||||
gcode += ';Type: ' + "G-code from " + str(self.obj_options['type']) + '\n'
|
||||
|
||||
gcode += ';Units: ' + self.units.upper() + '\n' + "\n"
|
||||
gcode += ';Created on ' + time_str + '\n' + '\n'
|
||||
@@ -886,8 +886,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
gcode += 'CO "HPGL CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s' % \
|
||||
(str(self.app.version), str(self.app.version_date)) + '";\n'
|
||||
|
||||
gcode += 'CO "Name: ' + str(self.options['name']) + '";\n'
|
||||
gcode += 'CO "Type: ' + "HPGL code from " + str(self.options['type']) + '";\n'
|
||||
gcode += 'CO "Name: ' + str(self.obj_options['name']) + '";\n'
|
||||
gcode += 'CO "Type: ' + "HPGL code from " + str(self.obj_options['type']) + '";\n'
|
||||
|
||||
gcode += 'CO "Units: ' + self.units.upper() + '";\n'
|
||||
gcode += 'CO "Created on ' + time_str + '";\n'
|
||||
@@ -901,8 +901,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
'(mount the probe and adjust the Z so more or less the probe tip touch the plate. ' \
|
||||
'Then zero the Z axis.)\n' + '\n'
|
||||
|
||||
gcode += '(Name: ' + str(self.options['name']) + ')\n'
|
||||
gcode += '(Type: ' + "G-code from " + str(self.options['type']) + ')\n'
|
||||
gcode += '(Name: ' + str(self.obj_options['name']) + ')\n'
|
||||
gcode += '(Type: ' + "G-code from " + str(self.obj_options['type']) + ')\n'
|
||||
|
||||
gcode += '(Units: ' + self.units.upper() + ')\n' + "\n"
|
||||
gcode += '(Created on ' + time_str + ')\n' + '\n'
|
||||
@@ -910,8 +910,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
gcode += ';NCCAD9 G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s\n' % \
|
||||
(str(self.app.version), str(self.app.version_date)) + '\n'
|
||||
|
||||
gcode += ';Name: ' + str(self.options['name']) + '\n'
|
||||
gcode += ';Type: ' + "G-code from " + str(self.options['type']) + '\n'
|
||||
gcode += ';Name: ' + str(self.obj_options['name']) + '\n'
|
||||
gcode += ';Type: ' + "G-code from " + str(self.obj_options['type']) + '\n'
|
||||
|
||||
gcode += ';Units: ' + self.units.upper() + '\n' + "\n"
|
||||
gcode += ';Created on ' + time_str + '\n' + '\n'
|
||||
@@ -919,8 +919,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
gcode += '%sG-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s%s\n' % \
|
||||
(start_comment, str(self.app.version), str(self.app.version_date), stop_comment) + '\n'
|
||||
|
||||
gcode += '%sName: ' % start_comment + str(self.options['name']) + '%s\n' % stop_comment
|
||||
gcode += '%sType: ' % start_comment + "G-code from " + str(self.options['type']) + '%s\n' % stop_comment
|
||||
gcode += '%sName: ' % start_comment + str(self.obj_options['name']) + '%s\n' % stop_comment
|
||||
gcode += '%sType: ' % start_comment + "G-code from " + str(self.obj_options['type']) + '%s\n' % stop_comment
|
||||
|
||||
gcode += '%sUnits: ' % start_comment + self.units.upper() + '%s\n' % stop_comment + "\n"
|
||||
gcode += '%sCreated on ' % start_comment + time_str + '%s\n' % stop_comment + '\n'
|
||||
@@ -974,7 +974,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
pass
|
||||
|
||||
# if this dict is not empty then the object is a Geometry object
|
||||
if self.options['type'].lower() == 'geometry':
|
||||
if self.obj_options['type'].lower() == 'geometry':
|
||||
# for the case that self.tools is empty: old projects
|
||||
try:
|
||||
first_key = list(self.tools.keys())[0]
|
||||
@@ -984,7 +984,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
include_header = self.app.preprocessors['default'].include_header
|
||||
|
||||
# if this dict is not empty then the object is an Excellon object
|
||||
if self.options['type'].lower() == 'excellon':
|
||||
if self.obj_options['type'].lower() == 'excellon':
|
||||
# for the case that self.tools is empty: old projects
|
||||
try:
|
||||
first_key = list(self.tools.keys())[0]
|
||||
@@ -1006,7 +1006,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
# detect if using multi-tool and make the Gcode summation correctly for each case
|
||||
if self.multitool is True:
|
||||
try:
|
||||
if self.options['type'].lower() == 'geometry':
|
||||
if self.obj_options['type'].lower() == 'geometry':
|
||||
for tooluid_key in self.tools:
|
||||
for key, value in self.tools[tooluid_key].items():
|
||||
if key == 'gcode':
|
||||
@@ -1033,7 +1033,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
if self.multitool is True:
|
||||
# for the case that self.tools is empty: old projects
|
||||
try:
|
||||
if self.options['type'].lower() == 'excellon':
|
||||
if self.obj_options['type'].lower() == 'excellon':
|
||||
for tooluid_key in self.tools:
|
||||
for key, value in self.tools[tooluid_key].items():
|
||||
if key == 'gcode' and value:
|
||||
@@ -1057,13 +1057,13 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
hpgl = False
|
||||
# for the case that self.tools is empty: old projects
|
||||
try:
|
||||
if self.options['type'].lower() == 'geometry':
|
||||
if self.obj_options['type'].lower() == 'geometry':
|
||||
for key in self.tools:
|
||||
if 'tools_mill_ppname_g' in self.tools[key]['data']:
|
||||
if 'hpgl' in self.tools[key]['data']['tools_mill_ppname_g']:
|
||||
hpgl = True
|
||||
break
|
||||
elif self.options['type'].lower() == 'excellon':
|
||||
elif self.obj_options['type'].lower() == 'excellon':
|
||||
for key in self.tools:
|
||||
if 'ppname_e' in self.tools[key]['data']:
|
||||
if 'hpgl' in self.tools[key]['data']['ppname_e']:
|
||||
@@ -1176,7 +1176,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
# """
|
||||
#
|
||||
# try:
|
||||
# if 'toolchange_custom' not in str(self.options['ppname_e']).lower():
|
||||
# if 'toolchange_custom' not in str(self.obj_options['ppname_e']).lower():
|
||||
# if self.ui.toolchange_cb.get_value():
|
||||
# self.ui.toolchange_cb.set_value(False)
|
||||
# self.app.inform.emit('[WARNING_NOTCL] %s' %
|
||||
@@ -1252,7 +1252,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
kind = self.ui.cncplot_method_combo.get_value()
|
||||
|
||||
self.shapes.clear(update=True)
|
||||
if self.options['type'].lower() == "excellon":
|
||||
if self.obj_options['type'].lower() == "excellon":
|
||||
for r in range(self.ui.exc_cnc_tools_table.rowCount()):
|
||||
row_dia = float('%.*f' % (self.decimals, float(self.ui.exc_cnc_tools_table.item(r, 1).text())))
|
||||
for tooluid_key in self.tools:
|
||||
@@ -1302,35 +1302,35 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
if not FlatCAMObj.plot(self):
|
||||
return
|
||||
|
||||
visible = visible if visible else self.options['plot']
|
||||
visible = visible if visible else self.obj_options['plot']
|
||||
|
||||
# Geometry shapes plotting
|
||||
try:
|
||||
if self.multitool is False: # single tool usage
|
||||
dia_plot = dia
|
||||
if dia_plot is None:
|
||||
if self.options['type'].lower() == "excellon":
|
||||
if self.obj_options['type'].lower() == "excellon":
|
||||
try:
|
||||
dia_plot = float(self.options["tooldia"])
|
||||
dia_plot = float(self.obj_options["tooldia"])
|
||||
except ValueError:
|
||||
# we may have a tuple with only one element and a comma
|
||||
dia_plot = [float(el) for el in self.options["tooldia"].split(',') if el != ''][0]
|
||||
dia_plot = [float(el) for el in self.obj_options["tooldia"].split(',') if el != ''][0]
|
||||
else:
|
||||
# try:
|
||||
# dia_plot = float(self.options["tools_mill_tooldia"])
|
||||
# dia_plot = float(self.obj_options["tools_mill_tooldia"])
|
||||
# except ValueError:
|
||||
# # we may have a tuple with only one element and a comma
|
||||
# dia_plot = [
|
||||
# float(el) for el in self.options["tools_mill_tooldia"].split(',') if el != ''
|
||||
# float(el) for el in self.obj_options["tools_mill_tooldia"].split(',') if el != ''
|
||||
# ][0]
|
||||
dia_plot = float(self.options["cncjob_tooldia"])
|
||||
dia_plot = float(self.obj_options["cncjob_tooldia"])
|
||||
|
||||
self.plot2(tooldia=dia_plot, obj=self, visible=visible, kind=kind)
|
||||
else:
|
||||
# I do this so the travel lines thickness will reflect the tool diameter
|
||||
# may work only for objects created within the app and not Gcode imported from elsewhere for which we
|
||||
# don't know the origin
|
||||
if self.options['type'].lower() == "excellon":
|
||||
if self.obj_options['type'].lower() == "excellon":
|
||||
if self.tools:
|
||||
for toolid_key in self.tools:
|
||||
dia_plot = self.app.dec_format(float(self.tools[toolid_key]['tooldia']), self.decimals)
|
||||
@@ -1406,7 +1406,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
self.app.log.debug("FlatCAMObj.FlatCAMECNCjob.convert_units()")
|
||||
|
||||
factor = CNCjob.convert_units(self, units)
|
||||
self.options["tooldia"] = float(self.options["tooldia"]) * factor
|
||||
self.obj_options["tooldia"] = float(self.obj_options["tooldia"]) * factor
|
||||
|
||||
param_list = ['cutz', 'depthperpass', 'travelz', 'feedrate', 'feedrate_z', 'feedrate_rapid',
|
||||
'endz', 'toolchangez']
|
||||
|
||||
@@ -162,14 +162,14 @@ class DocumentObject(FlatCAMObj):
|
||||
|
||||
# try to not add too many times a tab that it is already installed
|
||||
for idx in range(self.app.ui.plot_tab_area.count()):
|
||||
if self.app.ui.plot_tab_area.widget(idx).objectName() == self.options['name'] + "_editor_tab":
|
||||
if self.app.ui.plot_tab_area.widget(idx).objectName() == self.obj_options['name'] + "_editor_tab":
|
||||
tab_here = True
|
||||
break
|
||||
|
||||
# add the tab if it is not already added
|
||||
if tab_here is False:
|
||||
self.app.ui.plot_tab_area.addTab(self.document_editor_tab, '%s' % _("Document Editor"))
|
||||
self.document_editor_tab.setObjectName(self.options['name'] + "_editor_tab")
|
||||
self.document_editor_tab.setObjectName(self.obj_options['name'] + "_editor_tab")
|
||||
|
||||
# Switch plot_area to CNCJob tab
|
||||
self.app.ui.plot_tab_area.setCurrentWidget(self.document_editor_tab)
|
||||
|
||||
@@ -47,7 +47,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
|
||||
self.kind = "excellon"
|
||||
|
||||
self.options.update({
|
||||
self.obj_options.update({
|
||||
"plot": True,
|
||||
"solid": False,
|
||||
"multicolored": False,
|
||||
@@ -123,12 +123,12 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
|
||||
self.units = self.app.app_units.upper()
|
||||
|
||||
# # fill in self.options values for the Drilling Tool from self.app.options
|
||||
# # fill in self.obj_options values for the Drilling Tool from self.app.options
|
||||
# for opt_key, opt_val in self.app.options.items():
|
||||
# if opt_key.find('tools_drill_') == 0:
|
||||
# self.options[opt_key] = deepcopy(opt_val)
|
||||
# self.obj_options[opt_key] = deepcopy(opt_val)
|
||||
#
|
||||
# # fill in self.default_data values from self.options
|
||||
# # fill in self.default_data values from self.obj_options
|
||||
# for opt_key, opt_val in self.app.options.items():
|
||||
# if opt_key.find('excellon_') == 0 or opt_key.find('tools_drill_') == 0:
|
||||
# self.default_data[opt_key] = deepcopy(opt_val)
|
||||
@@ -282,8 +282,8 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
tools = [i[0] for i in sorted_tools]
|
||||
|
||||
new_options = {}
|
||||
for opt in self.options:
|
||||
new_options[opt] = self.options[opt]
|
||||
for opt in self.obj_options:
|
||||
new_options[opt] = self.obj_options[opt]
|
||||
|
||||
for tool_no in tools:
|
||||
try:
|
||||
@@ -919,7 +919,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
tools = self.get_selected_tools_list()
|
||||
|
||||
if outname is None:
|
||||
outname = self.options["name"] + "_mill"
|
||||
outname = self.obj_options["name"] + "_mill"
|
||||
|
||||
if tooldia is None:
|
||||
tooldia = self.ui.tooldia_entry.get_value()
|
||||
@@ -962,9 +962,9 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
|
||||
# ## Add properties to the object
|
||||
|
||||
geo_obj.options['type'] = 'Excellon Geometry'
|
||||
geo_obj.options["tools_mill_tooldia"] = str(tooldia)
|
||||
geo_obj.options["multidepth"] = app_obj.defaults["tools_mill_multidepth"]
|
||||
geo_obj.obj_options['type'] = 'Excellon Geometry'
|
||||
geo_obj.obj_options["tools_mill_tooldia"] = str(tooldia)
|
||||
geo_obj.obj_options["multidepth"] = app_obj.defaults["tools_mill_multidepth"]
|
||||
geo_obj.solid_geometry = []
|
||||
|
||||
# in case that the tool used has the same diameter with the hole, and since the maximum resolution
|
||||
@@ -1024,10 +1024,10 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
tools = self.get_selected_tools_list()
|
||||
|
||||
if outname is None:
|
||||
outname = self.options["name"] + "_mill"
|
||||
outname = self.obj_options["name"] + "_mill"
|
||||
|
||||
if tooldia is None:
|
||||
tooldia = float(self.options["slot_tooldia"])
|
||||
tooldia = float(self.obj_options["slot_tooldia"])
|
||||
|
||||
# Sort tools by diameter. items() -> [('name', diameter), ...]
|
||||
# sorted_tools = sorted(list(self.tools.items()), key=lambda tl: tl[1]) # no longer works in Python3
|
||||
@@ -1059,9 +1059,9 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
|
||||
# ## Add properties to the object
|
||||
|
||||
geo_obj.options['type'] = 'Excellon Geometry'
|
||||
geo_obj.options["tools_mill_tooldia"] = str(tooldia)
|
||||
geo_obj.options["tools_mill_multidepth"] = app_obj.defaults["tools_mill_multidepth"]
|
||||
geo_obj.obj_options['type'] = 'Excellon Geometry'
|
||||
geo_obj.obj_options["tools_mill_tooldia"] = str(tooldia)
|
||||
geo_obj.obj_options["tools_mill_multidepth"] = app_obj.defaults["tools_mill_multidepth"]
|
||||
geo_obj.solid_geometry = []
|
||||
|
||||
# in case that the tool used has the same diameter with the hole, and since the maximum resolution
|
||||
@@ -1122,14 +1122,14 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
Excellon.convert_units(self, units)
|
||||
|
||||
# factor = Excellon.convert_units(self, units)
|
||||
# self.options['drillz'] = float(self.options['drillz']) * factor
|
||||
# self.options['travelz'] = float(self.options['travelz']) * factor
|
||||
# self.options['feedrate'] = float(self.options['feedrate']) * factor
|
||||
# self.options['feedrate_rapid'] = float(self.options['feedrate_rapid']) * factor
|
||||
# self.options['toolchangez'] = float(self.options['toolchangez']) * factor
|
||||
# self.obj_options['drillz'] = float(self.obj_options['drillz']) * factor
|
||||
# self.obj_options['travelz'] = float(self.obj_options['travelz']) * factor
|
||||
# self.obj_options['feedrate'] = float(self.obj_options['feedrate']) * factor
|
||||
# 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"] == '':
|
||||
# self.options['toolchangexy'] = "0.0, 0.0"
|
||||
# self.obj_options['toolchangexy'] = "0.0, 0.0"
|
||||
# else:
|
||||
# coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")]
|
||||
# if len(coords_xy) < 2:
|
||||
@@ -1139,11 +1139,11 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
# return 'fail'
|
||||
# coords_xy[0] *= factor
|
||||
# coords_xy[1] *= factor
|
||||
# self.options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1])
|
||||
# self.obj_options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1])
|
||||
#
|
||||
# if self.options['startz'] is not None:
|
||||
# self.options['startz'] = float(self.options['startz']) * factor
|
||||
# self.options['endz'] = float(self.options['endz']) * factor
|
||||
# if self.obj_options['startz'] is not None:
|
||||
# self.obj_options['startz'] = float(self.obj_options['startz']) * factor
|
||||
# self.obj_options['endz'] = float(self.obj_options['endz']) * factor
|
||||
|
||||
def on_solid_cb_click(self):
|
||||
if self.muted_ui:
|
||||
@@ -1332,10 +1332,10 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
for exc in flattened_list:
|
||||
# copy options of the current excellon obj to the final excellon obj
|
||||
# only the last object options will survive
|
||||
for option in exc.options:
|
||||
for option in exc.obj_options:
|
||||
if option != 'name':
|
||||
try:
|
||||
exc_final.options[option] = deepcopy(exc.options[option])
|
||||
exc_final.obj_options[option] = deepcopy(exc.obj_options[option])
|
||||
except Exception:
|
||||
if log:
|
||||
log.warning("Failed to copy option.", option)
|
||||
|
||||
@@ -54,7 +54,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
|
||||
self.kind = "geometry"
|
||||
|
||||
self.options.update({
|
||||
self.obj_options.update({
|
||||
"plot": True,
|
||||
"multicolored": False,
|
||||
|
||||
@@ -88,18 +88,18 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
"tools_mill_feedrate_probe": 3.0,
|
||||
})
|
||||
|
||||
if "tools_mill_tooldia" not in self.options:
|
||||
if "tools_mill_tooldia" not in self.obj_options:
|
||||
if type(self.app.defaults["tools_mill_tooldia"]) == float:
|
||||
self.options["tools_mill_tooldia"] = self.app.defaults["tools_mill_tooldia"]
|
||||
self.obj_options["tools_mill_tooldia"] = self.app.defaults["tools_mill_tooldia"]
|
||||
else:
|
||||
try:
|
||||
tools_string = self.app.defaults["tools_mill_tooldia"].split(",")
|
||||
tools_diameters = [eval(a) for a in tools_string if a != '']
|
||||
self.options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0
|
||||
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.options["tools_mill_startz"] = self.app.defaults["tools_mill_startz"]
|
||||
self.obj_options["tools_mill_startz"] = self.app.defaults["tools_mill_startz"]
|
||||
|
||||
# this will hold the tool unique ID that is useful when having multiple tools with same diameter
|
||||
self.tooluid = 0
|
||||
@@ -311,14 +311,14 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
# store here the default data for Geometry Data
|
||||
self.default_data = {}
|
||||
|
||||
# fill in self.default_data values from self.options
|
||||
self.default_data.update(self.options)
|
||||
# fill in self.default_data values from self.obj_options
|
||||
self.default_data.update(self.obj_options)
|
||||
|
||||
if type(self.options["tools_mill_tooldia"]) == float:
|
||||
tools_list = [self.options["tools_mill_tooldia"]]
|
||||
if type(self.obj_options["tools_mill_tooldia"]) == float:
|
||||
tools_list = [self.obj_options["tools_mill_tooldia"]]
|
||||
else:
|
||||
try:
|
||||
temp_tools = self.options["tools_mill_tooldia"].split(",")
|
||||
temp_tools = self.obj_options["tools_mill_tooldia"].split(",")
|
||||
tools_list = [
|
||||
float(eval(dia)) for dia in temp_tools if dia != ''
|
||||
]
|
||||
@@ -635,17 +635,17 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
"""
|
||||
|
||||
# use the name of the first tool selected in self.geo_tools_table which has the diameter passed as tool_dia
|
||||
outname = "%s_%s" % (self.options["name"], 'cnc') if outname is None else outname
|
||||
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'])
|
||||
|
||||
try:
|
||||
xmin = self.options['xmin']
|
||||
ymin = self.options['ymin']
|
||||
xmax = self.options['xmax']
|
||||
ymax = self.options['ymax']
|
||||
xmin = self.obj_options['xmin']
|
||||
ymin = self.obj_options['ymin']
|
||||
xmax = self.obj_options['xmax']
|
||||
ymax = self.obj_options['ymax']
|
||||
except Exception as e:
|
||||
self.app.log.error("FlatCAMObj.GeometryObject.mtool_gen_cncjob() --> %s\n" % str(e))
|
||||
|
||||
@@ -664,10 +664,10 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
self.app.log.debug("Creating a CNCJob out of a single-geometry")
|
||||
assert job_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(job_obj)
|
||||
|
||||
job_obj.options['xmin'] = xmin
|
||||
job_obj.options['ymin'] = ymin
|
||||
job_obj.options['xmax'] = xmax
|
||||
job_obj.options['ymax'] = ymax
|
||||
job_obj.obj_options['xmin'] = xmin
|
||||
job_obj.obj_options['ymin'] = ymin
|
||||
job_obj.obj_options['xmax'] = xmax
|
||||
job_obj.obj_options['ymax'] = ymax
|
||||
|
||||
# count the tools
|
||||
tool_cnt = 0
|
||||
@@ -736,7 +736,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
toolchangexy = tools_dict[tooluid_key]['data']["tools_mill_toolchangexy"]
|
||||
startz = tools_dict[tooluid_key]['data']["tools_mill_startz"]
|
||||
endz = tools_dict[tooluid_key]['data']["tools_mill_endz"]
|
||||
endxy = self.options["tools_mill_endxy"]
|
||||
endxy = self.obj_options["tools_mill_endxy"]
|
||||
spindlespeed = tools_dict[tooluid_key]['data']["tools_mill_spindlespeed"]
|
||||
dwell = tools_dict[tooluid_key]['data']["tools_mill_dwell"]
|
||||
dwelltime = tools_dict[tooluid_key]['data']["tools_mill_dwelltime"]
|
||||
@@ -749,9 +749,9 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"]
|
||||
|
||||
# Propagate options
|
||||
job_obj.options["tooldia"] = tooldia_val
|
||||
job_obj.options['type'] = 'Geometry'
|
||||
job_obj.options['tool_dia'] = tooldia_val
|
||||
job_obj.obj_options["tooldia"] = tooldia_val
|
||||
job_obj.obj_options['type'] = 'Geometry'
|
||||
job_obj.obj_options['tool_dia'] = tooldia_val
|
||||
|
||||
tool_lst = list(tools_dict.keys())
|
||||
is_first = True if tooluid_key == tool_lst[0] else False
|
||||
@@ -806,10 +806,10 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
self.app.log.debug("Creating a CNCJob out of a multi-geometry")
|
||||
assert job_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(job_obj)
|
||||
|
||||
job_obj.options['xmin'] = xmin
|
||||
job_obj.options['ymin'] = ymin
|
||||
job_obj.options['xmax'] = xmax
|
||||
job_obj.options['ymax'] = ymax
|
||||
job_obj.obj_options['xmin'] = xmin
|
||||
job_obj.obj_options['ymin'] = ymin
|
||||
job_obj.obj_options['xmax'] = xmax
|
||||
job_obj.obj_options['ymax'] = ymax
|
||||
|
||||
# count the tools
|
||||
tool_cnt = 0
|
||||
@@ -890,7 +890,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
# toolchangexy = tools_dict[tooluid_key]['data']["toolchangexy"]
|
||||
# startz = tools_dict[tooluid_key]['data']["startz"]
|
||||
# endz = tools_dict[tooluid_key]['data']["endz"]
|
||||
# endxy = self.options["endxy"]
|
||||
# endxy = self.obj_options["endxy"]
|
||||
# spindlespeed = tools_dict[tooluid_key]['data']["spindlespeed"]
|
||||
# dwell = tools_dict[tooluid_key]['data']["dwell"]
|
||||
# dwelltime = tools_dict[tooluid_key]['data']["dwelltime"]
|
||||
@@ -903,9 +903,9 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"]
|
||||
|
||||
# Propagate options
|
||||
job_obj.options["tooldia"] = tooldia_val
|
||||
job_obj.options['type'] = 'Geometry'
|
||||
job_obj.options['tool_dia'] = tooldia_val
|
||||
job_obj.obj_options["tooldia"] = tooldia_val
|
||||
job_obj.obj_options['type'] = 'Geometry'
|
||||
job_obj.obj_options['tool_dia'] = tooldia_val
|
||||
|
||||
# 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
|
||||
@@ -1020,55 +1020,55 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
|
||||
self.app.log.debug("FlatCAMGeometry.GeometryObject.generatecncjob()")
|
||||
|
||||
tooldia = dia if dia else float(self.options["tools_mill_tooldia"])
|
||||
outname = outname if outname is not None else self.options["name"]
|
||||
tooldia = dia if dia else float(self.obj_options["tools_mill_tooldia"])
|
||||
outname = outname if outname is not None else self.obj_options["name"]
|
||||
|
||||
z_cut = z_cut if z_cut is not None else float(self.options["tools_mill_cutz"])
|
||||
z_move = z_move if z_move is not None else float(self.options["tools_mill_travelz"])
|
||||
z_cut = z_cut if z_cut is not None else float(self.obj_options["tools_mill_cutz"])
|
||||
z_move = z_move if z_move is not None else float(self.obj_options["tools_mill_travelz"])
|
||||
|
||||
feedrate = feedrate if feedrate is not None else float(self.options["tools_mill_feedrate"])
|
||||
feedrate_z = feedrate_z if feedrate_z is not None else float(self.options["tools_mill_feedrate_z"])
|
||||
feedrate_rapid = feedrate_rapid if feedrate_rapid is not None else float(self.options[
|
||||
feedrate = feedrate if feedrate is not None else float(self.obj_options["tools_mill_feedrate"])
|
||||
feedrate_z = feedrate_z if feedrate_z is not None else float(self.obj_options["tools_mill_feedrate_z"])
|
||||
feedrate_rapid = feedrate_rapid if feedrate_rapid is not None else float(self.obj_options[
|
||||
"tools_mill_feedrate_rapid"])
|
||||
|
||||
multidepth = multidepth if multidepth is not None else self.options["tools_mill_multidepth"]
|
||||
depthperpass = dpp if dpp is not None else float(self.options["tools_mill_depthperpass"])
|
||||
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'])
|
||||
|
||||
extracut = extracut if extracut is not None else float(self.options["tools_mill_extracut"])
|
||||
extracut_length = extracut_length if extracut_length is not None else float(self.options[
|
||||
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[
|
||||
"tools_mill_extracut_length"])
|
||||
|
||||
startz = startz if startz is not None else self.options["tools_mill_startz"]
|
||||
endz = endz if endz is not None else float(self.options["tools_mill_endz"])
|
||||
startz = startz if startz is not None else self.obj_options["tools_mill_startz"]
|
||||
endz = endz if endz is not None else float(self.obj_options["tools_mill_endz"])
|
||||
|
||||
endxy = endxy if endxy else self.options["tools_mill_endxy"]
|
||||
endxy = endxy if endxy else self.obj_options["tools_mill_endxy"]
|
||||
if isinstance(endxy, str):
|
||||
endxy = re.sub('[()\[\]]', '', endxy)
|
||||
if endxy and endxy != '':
|
||||
endxy = [float(eval(a)) for a in endxy.split(",")]
|
||||
|
||||
toolchangez = toolchangez if toolchangez else float(self.options["tools_mill_toolchangez"])
|
||||
toolchangez = toolchangez if toolchangez else float(self.obj_options["tools_mill_toolchangez"])
|
||||
|
||||
toolchangexy = toolchangexy if toolchangexy else self.options["tools_mill_toolchangexy"]
|
||||
toolchangexy = toolchangexy if toolchangexy else self.obj_options["tools_mill_toolchangexy"]
|
||||
if isinstance(toolchangexy, str):
|
||||
toolchangexy = re.sub('[()\[\]]', '', toolchangexy)
|
||||
if toolchangexy and toolchangexy != '':
|
||||
toolchangexy = [float(eval(a)) for a in toolchangexy.split(",")]
|
||||
|
||||
toolchange = toolchange if toolchange else self.options["tools_mill_toolchange"]
|
||||
toolchange = toolchange if toolchange else self.obj_options["tools_mill_toolchange"]
|
||||
|
||||
offset = offset if offset else 0.0
|
||||
|
||||
# int or None.
|
||||
spindlespeed = spindlespeed if spindlespeed else self.options['tools_mill_spindlespeed']
|
||||
las_min_pwr = las_min_pwr if las_min_pwr else self.options['tools_mill_min_power']
|
||||
dwell = dwell if dwell else self.options["tools_mill_dwell"]
|
||||
dwelltime = dwelltime if dwelltime else float(self.options["tools_mill_dwelltime"])
|
||||
spindlespeed = spindlespeed if spindlespeed else self.obj_options['tools_mill_spindlespeed']
|
||||
las_min_pwr = las_min_pwr if las_min_pwr else self.obj_options['tools_mill_min_power']
|
||||
dwell = dwell if dwell else self.obj_options["tools_mill_dwell"]
|
||||
dwelltime = dwelltime if dwelltime else float(self.obj_options["tools_mill_dwelltime"])
|
||||
|
||||
ppname_g = pp if pp else self.options["tools_mill_ppname_g"]
|
||||
ppname_g = pp if pp else self.obj_options["tools_mill_ppname_g"]
|
||||
|
||||
# Object initialization function for app.app_obj.new_object()
|
||||
# RUNNING ON SEPARATE THREAD!
|
||||
@@ -1076,25 +1076,25 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
assert job_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(job_obj)
|
||||
|
||||
# Propagate options
|
||||
job_obj.options["tooldia"] = tooldia
|
||||
job_obj.options["tools_mill_tooldia"] = tooldia
|
||||
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.options['type'] = 'Geometry'
|
||||
job_obj.options['tool_dia'] = tooldia
|
||||
job_obj.obj_options['type'] = 'Geometry'
|
||||
job_obj.obj_options['tool_dia'] = tooldia
|
||||
|
||||
job_obj.segx = segx
|
||||
job_obj.segy = segy
|
||||
|
||||
job_obj.z_pdepth = float(self.options["tools_mill_z_pdepth"])
|
||||
job_obj.feedrate_probe = float(self.options["tools_mill_feedrate_probe"])
|
||||
job_obj.z_pdepth = float(self.obj_options["tools_mill_z_pdepth"])
|
||||
job_obj.feedrate_probe = float(self.obj_options["tools_mill_feedrate_probe"])
|
||||
|
||||
job_obj.options['xmin'] = self.options['xmin']
|
||||
job_obj.options['ymin'] = self.options['ymin']
|
||||
job_obj.options['xmax'] = self.options['xmax']
|
||||
job_obj.options['ymax'] = self.options['ymax']
|
||||
job_obj.obj_options['xmin'] = self.obj_options['xmin']
|
||||
job_obj.obj_options['ymin'] = self.obj_options['ymin']
|
||||
job_obj.obj_options['xmax'] = self.obj_options['xmax']
|
||||
job_obj.obj_options['ymax'] = self.obj_options['ymax']
|
||||
|
||||
# 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
|
||||
@@ -1305,22 +1305,22 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
|
||||
factor = Geometry.convert_units(self, units)
|
||||
|
||||
self.options['cutz'] = float(self.options['cutz']) * factor
|
||||
self.options['depthperpass'] = float(self.options['depthperpass']) * factor
|
||||
self.options['travelz'] = float(self.options['travelz']) * factor
|
||||
self.options['feedrate'] = float(self.options['feedrate']) * factor
|
||||
self.options['feedrate_z'] = float(self.options['feedrate_z']) * factor
|
||||
self.options['feedrate_rapid'] = float(self.options['feedrate_rapid']) * factor
|
||||
self.options['endz'] = float(self.options['endz']) * factor
|
||||
# self.options['tools_mill_tooldia'] *= factor
|
||||
# self.options['painttooldia'] *= factor
|
||||
# self.options['paintmargin'] *= factor
|
||||
# self.options['paintoverlap'] *= factor
|
||||
self.obj_options['cutz'] = float(self.obj_options['cutz']) * factor
|
||||
self.obj_options['depthperpass'] = float(self.obj_options['depthperpass']) * factor
|
||||
self.obj_options['travelz'] = float(self.obj_options['travelz']) * factor
|
||||
self.obj_options['feedrate'] = float(self.obj_options['feedrate']) * factor
|
||||
self.obj_options['feedrate_z'] = float(self.obj_options['feedrate_z']) * factor
|
||||
self.obj_options['feedrate_rapid'] = float(self.obj_options['feedrate_rapid']) * factor
|
||||
self.obj_options['endz'] = float(self.obj_options['endz']) * factor
|
||||
# self.obj_options['tools_mill_tooldia'] *= factor
|
||||
# self.obj_options['painttooldia'] *= factor
|
||||
# self.obj_options['paintmargin'] *= factor
|
||||
# self.obj_options['paintoverlap'] *= factor
|
||||
|
||||
self.options["toolchangez"] = float(self.options["toolchangez"]) * factor
|
||||
self.obj_options["toolchangez"] = float(self.obj_options["toolchangez"]) * factor
|
||||
|
||||
if self.app.defaults["tools_mill_toolchangexy"] == '':
|
||||
self.options['toolchangexy'] = "0.0, 0.0"
|
||||
self.obj_options['toolchangexy'] = "0.0, 0.0"
|
||||
else:
|
||||
coords_xy = [float(eval(coord)) for coord in self.app.defaults["tools_mill_toolchangexy"].split(",")]
|
||||
if len(coords_xy) < 2:
|
||||
@@ -1332,10 +1332,10 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
return 'fail'
|
||||
coords_xy[0] *= factor
|
||||
coords_xy[1] *= factor
|
||||
self.options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1])
|
||||
self.obj_options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1])
|
||||
|
||||
if self.options['startz'] is not None:
|
||||
self.options['startz'] = float(self.options['startz']) * factor
|
||||
if self.obj_options['startz'] is not None:
|
||||
self.obj_options['startz'] = float(self.obj_options['startz']) * factor
|
||||
|
||||
param_list = ['cutz', 'depthperpass', 'travelz', 'feedrate', 'feedrate_z', 'feedrate_rapid',
|
||||
'endz', 'toolchangez']
|
||||
@@ -1404,7 +1404,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
if color is None:
|
||||
color = '#FF0000FF'
|
||||
|
||||
visible = visible if visible else self.options['plot']
|
||||
visible = visible if visible else self.obj_options['plot']
|
||||
try:
|
||||
if isinstance(element, (MultiPolygon, MultiLineString)):
|
||||
for sub_el in element.geoms:
|
||||
@@ -1464,7 +1464,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
if 'override_color' in self.tools[tooluid_key]['data']:
|
||||
color = self.tools[tooluid_key]['data']['override_color']
|
||||
else:
|
||||
color = random_color() if self.options['multicolored'] else \
|
||||
color = random_color() if self.obj_options['multicolored'] else \
|
||||
self.app.defaults["geometry_plot_line"]
|
||||
|
||||
self.plot_element(solid_geometry, visible=visible, color=color)
|
||||
@@ -1473,7 +1473,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
if 'override_color' in self.tools[plot_tool]['data']:
|
||||
color = self.tools[plot_tool]['data']['override_color']
|
||||
else:
|
||||
color = random_color() if self.options['multicolored'] else \
|
||||
color = random_color() if self.obj_options['multicolored'] else \
|
||||
self.app.defaults["geometry_plot_line"]
|
||||
|
||||
self.plot_element(solid_geometry, visible=visible, color=color)
|
||||
@@ -1486,7 +1486,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
|
||||
self.plot_element(solid_geometry, visible=visible, color=color)
|
||||
|
||||
# self.plot_element(self.solid_geometry, visible=self.options['plot'])
|
||||
# self.plot_element(self.solid_geometry, visible=self.obj_options['plot'])
|
||||
|
||||
self.shapes.redraw()
|
||||
|
||||
@@ -1581,10 +1581,10 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
new_tools = {}
|
||||
|
||||
for geo_obj in geo_list:
|
||||
for option in geo_obj.options:
|
||||
for option in geo_obj.obj_options:
|
||||
if option != 'name':
|
||||
try:
|
||||
new_options[option] = deepcopy(geo_obj.options[option])
|
||||
new_options[option] = deepcopy(geo_obj.obj_options[option])
|
||||
except Exception as e:
|
||||
if log:
|
||||
log.error("Failed to copy option %s. Error: %s" % (str(option), str(e)))
|
||||
@@ -1619,7 +1619,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
max_uid += 1
|
||||
new_tools[max_uid] = deepcopy(geo_obj.tools[tool_uid])
|
||||
|
||||
geo_final.options.update(new_options)
|
||||
geo_final.obj_options.update(new_options)
|
||||
geo_final.solid_geometry = new_solid_geometry
|
||||
|
||||
if new_tools and fuse_tools is True:
|
||||
|
||||
@@ -50,9 +50,9 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
|
||||
self.kind = "gerber"
|
||||
|
||||
# The 'name' is already in self.options from FlatCAMObj
|
||||
# The 'name' is already in self.obj_options from FlatCAMObj
|
||||
# Automatically updates the UI
|
||||
self.options.update({
|
||||
self.obj_options.update({
|
||||
"plot": True,
|
||||
"multicolored": False,
|
||||
"solid": False,
|
||||
@@ -444,7 +444,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
self.app.defaults.report_usage("gerber_on_generatenoncopper_button")
|
||||
|
||||
self.read_form()
|
||||
name = self.options["name"] + "_noncopper"
|
||||
name = self.obj_options["name"] + "_noncopper"
|
||||
|
||||
def geo_init(geo_obj, app_obj):
|
||||
assert geo_obj.kind == 'geometry', "Expected a Geometry object got %s" % type(geo_obj)
|
||||
@@ -455,8 +455,8 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
except Exception:
|
||||
self.solid_geometry = unary_union(self.solid_geometry)
|
||||
|
||||
bounding_box = self.solid_geometry.envelope.buffer(float(self.options["noncoppermargin"]))
|
||||
if not self.options["noncopperrounded"]:
|
||||
bounding_box = self.solid_geometry.envelope.buffer(float(self.obj_options["noncoppermargin"]))
|
||||
if not self.obj_options["noncopperrounded"]:
|
||||
bounding_box = bounding_box.envelope
|
||||
non_copper = bounding_box.difference(self.solid_geometry)
|
||||
non_copper = flatten_shapely_geometry(non_copper)
|
||||
@@ -471,7 +471,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
def on_generatebb_button_click(self, *args):
|
||||
self.app.defaults.report_usage("gerber_on_generatebb_button")
|
||||
self.read_form()
|
||||
name = self.options["name"] + "_bbox"
|
||||
name = self.obj_options["name"] + "_bbox"
|
||||
|
||||
def geo_init(geo_obj, app_obj):
|
||||
assert geo_obj.kind == 'geometry', "Expected a Geometry object got %s" % type(geo_obj)
|
||||
@@ -482,7 +482,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
except Exception:
|
||||
self.solid_geometry = unary_union(self.solid_geometry)
|
||||
|
||||
distance = float(self.options["bboxmargin"])
|
||||
distance = float(self.obj_options["bboxmargin"])
|
||||
|
||||
# Bounding box with rounded corners
|
||||
if distance >= 0:
|
||||
@@ -507,7 +507,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
bounding_box = self.solid_geometry.envelope.buffer(abs(distance*2)).interiors
|
||||
bounding_box = unary_union(bounding_box).buffer(-distance).exterior
|
||||
|
||||
if not self.options["bboxrounded"]: # Remove rounded corners
|
||||
if not self.obj_options["bboxrounded"]: # Remove rounded corners
|
||||
bounding_box = bounding_box.envelope
|
||||
|
||||
if bounding_box is None or bounding_box.is_empty:
|
||||
@@ -562,7 +562,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
else:
|
||||
iso_t = iso_type
|
||||
|
||||
base_name = self.options["name"]
|
||||
base_name = self.obj_options["name"]
|
||||
|
||||
if combine:
|
||||
if outname is None:
|
||||
@@ -577,7 +577,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
|
||||
def iso_init(geo_obj, app_obj):
|
||||
# Propagate options
|
||||
geo_obj.options["tools_mill_tooldia"] = str(dia)
|
||||
geo_obj.obj_options["tools_mill_tooldia"] = str(dia)
|
||||
geo_obj.tool_type = self.app.defaults["tools_iso_tool_shape"]
|
||||
geo_obj.multigeo = True
|
||||
|
||||
@@ -585,7 +585,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
|
||||
# store here the default data for Geometry Data
|
||||
default_data = {}
|
||||
for opt_key, opt_val in app_obj.options.items():
|
||||
for opt_key, opt_val in app_obj.obj_options.items():
|
||||
if opt_key.find('geometry' + "_") == 0:
|
||||
oname = opt_key[len('geometry') + 1:]
|
||||
default_data[oname] = self.app.options[opt_key]
|
||||
@@ -637,7 +637,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
if empty_cnt == len(w_geo):
|
||||
raise ValidationError("Empty Geometry", None)
|
||||
elif plot:
|
||||
msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"])
|
||||
msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.obj_options["name"])
|
||||
app_obj.inform.emit(msg)
|
||||
|
||||
# ############################################################
|
||||
@@ -675,7 +675,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
|
||||
def iso_init(geo_obj, app_obj):
|
||||
# Propagate options
|
||||
geo_obj.options["tools_mill_tooldia"] = str(dia)
|
||||
geo_obj.obj_options["tools_mill_tooldia"] = str(dia)
|
||||
geo_obj.tool_type = self.app.defaults["tools_iso_tool_shape"]
|
||||
geo_obj.multigeo = True
|
||||
|
||||
@@ -692,7 +692,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
|
||||
# store here the default data for Geometry Data
|
||||
default_data = {}
|
||||
for opt_key, opt_val in app_obj.options.items():
|
||||
for opt_key, opt_val in app_obj.obj_options.items():
|
||||
if opt_key.find('geometry' + "_") == 0:
|
||||
oname = opt_key[len('geometry') + 1:]
|
||||
default_data[oname] = self.app.options[opt_key]
|
||||
@@ -728,7 +728,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
if empty_cnt == len(w_geo):
|
||||
raise ValidationError("Empty Geometry", None)
|
||||
elif plot:
|
||||
msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"])
|
||||
msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.obj_options["name"])
|
||||
app_obj.inform.emit(msg)
|
||||
|
||||
# ############################################################
|
||||
@@ -786,7 +786,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
"""
|
||||
|
||||
if outname is None:
|
||||
follow_name = self.options["name"] + "_follow"
|
||||
follow_name = self.obj_options["name"] + "_follow"
|
||||
else:
|
||||
follow_name = outname
|
||||
|
||||
@@ -805,14 +805,14 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
|
||||
# Propagate options
|
||||
new_obj.multigeo = True
|
||||
# new_obj.options["tools_mill_tooldia"] = str(self.app.defaults["tools_iso_tooldia"])
|
||||
# new_obj.obj_options["tools_mill_tooldia"] = str(self.app.defaults["tools_iso_tooldia"])
|
||||
new_obj.solid_geometry = deepcopy(self.follow_geometry)
|
||||
|
||||
new_obj.options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"]
|
||||
new_obj.obj_options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"]
|
||||
|
||||
# store here the default data for Geometry Data
|
||||
default_data = {}
|
||||
for opt_key, opt_val in app_obj.options.items():
|
||||
for opt_key, opt_val in app_obj.obj_options.items():
|
||||
if opt_key.find('geometry' + "_") == 0:
|
||||
oname = opt_key[len('geometry') + 1:]
|
||||
default_data[oname] = self.app.options[opt_key]
|
||||
@@ -903,8 +903,8 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
|
||||
Gerber.convert_units(self, units)
|
||||
|
||||
# self.options['isotooldia'] = float(self.options['isotooldia']) * factor
|
||||
# self.options['bboxmargin'] = float(self.options['bboxmargin']) * factor
|
||||
# self.obj_options['isotooldia'] = float(self.obj_options['isotooldia']) * factor
|
||||
# self.obj_options['bboxmargin'] = float(self.obj_options['bboxmargin']) * factor
|
||||
|
||||
def plot(self, kind=None, **kwargs):
|
||||
"""
|
||||
@@ -931,7 +931,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
face_color = self.fill_color
|
||||
|
||||
if 'visible' not in kwargs:
|
||||
visible = self.options['plot']
|
||||
visible = self.obj_options['plot']
|
||||
else:
|
||||
visible = kwargs['visible']
|
||||
|
||||
@@ -966,11 +966,11 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
plot_geometry = geometry.geoms if isinstance(geometry, (MultiPolygon, MultiLineString)) else geometry
|
||||
try:
|
||||
for g in plot_geometry:
|
||||
if self.options["solid"]:
|
||||
if self.obj_options["solid"]:
|
||||
used_color = color
|
||||
used_face_color = random_color() if self.options['multicolored'] else face_color
|
||||
used_face_color = random_color() if self.obj_options['multicolored'] else face_color
|
||||
else:
|
||||
used_color = random_color() if self.options['multicolored'] else 'black'
|
||||
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:
|
||||
@@ -981,11 +981,11 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
g = LineString(g)
|
||||
self.add_shape(shape=g, color=used_color, face_color=used_face_color, visible=visible)
|
||||
except TypeError:
|
||||
if self.options["solid"]:
|
||||
if self.obj_options["solid"]:
|
||||
used_color = color
|
||||
used_face_color = random_color() if self.options['multicolored'] else face_color
|
||||
used_face_color = random_color() if self.obj_options['multicolored'] else face_color
|
||||
else:
|
||||
used_color = random_color() if self.options['multicolored'] else 'black'
|
||||
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:
|
||||
@@ -1707,10 +1707,10 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
if type(grb) is list:
|
||||
GerberObject.merge(grb_list=grb, grb_final=grb_final)
|
||||
else: # If not list, just append
|
||||
for option in grb.options:
|
||||
for option in grb.obj_options:
|
||||
if option != 'name':
|
||||
try:
|
||||
grb_final.options[option] = grb.options[option]
|
||||
grb_final.obj_options[option] = grb.obj_options[option]
|
||||
except KeyError:
|
||||
self.app.log.warning("Failed to copy option.", option)
|
||||
|
||||
@@ -1758,12 +1758,12 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
Gerber.skew(self, angle_x=angle_x, angle_y=angle_y, point=point)
|
||||
self.replotApertures.emit()
|
||||
|
||||
def buffer(self, distance, join=2, factor=None):
|
||||
Gerber.buffer(self, distance=distance, join=join, factor=factor)
|
||||
def buffer(self, distance, join=2, factor=None, only_exterior=False):
|
||||
Gerber.buffer(self, distance=distance, join=join, factor=factor, only_exterior=only_exterior)
|
||||
self.replotApertures.emit()
|
||||
|
||||
def serialize(self):
|
||||
return {
|
||||
"options": self.options,
|
||||
"obj_options": self.obj_options,
|
||||
"kind": self.kind
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ class FlatCAMObj(QtCore.QObject):
|
||||
# set True by the collection.append() when the object load is complete
|
||||
self.load_complete = None
|
||||
|
||||
self.options = LoudDict(name=name)
|
||||
self.options.set_change_callback(self.on_options_change)
|
||||
self.obj_options = LoudDict(name=name)
|
||||
self.obj_options.set_change_callback(self.on_options_change)
|
||||
|
||||
self.form_fields = {}
|
||||
|
||||
@@ -128,14 +128,14 @@ class FlatCAMObj(QtCore.QObject):
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
return "<FlatCAMObj({:12s}): {:20s}>".format(self.kind, self.options["name"])
|
||||
return "<FlatCAMObj({:12s}): {:20s}>".format(self.kind, self.obj_options["name"])
|
||||
|
||||
def from_dict(self, d):
|
||||
"""
|
||||
This supersedes ``from_dict`` in derived classes. Derived classes
|
||||
must inherit from FlatCAMObj first, then from derivatives of Geometry.
|
||||
|
||||
``self.options`` is only updated, not overwritten. This ensures that
|
||||
``self.obj_options`` is only updated, not overwritten. This ensures that
|
||||
options set by the app do not vanish when reading the objects
|
||||
from a project file.
|
||||
|
||||
@@ -146,7 +146,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
for attr in self.ser_attrs:
|
||||
|
||||
if attr == 'options':
|
||||
self.options.update(d[attr])
|
||||
self.obj_options.update(d[attr])
|
||||
else:
|
||||
try:
|
||||
setattr(self, attr, d[attr])
|
||||
@@ -162,7 +162,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
|
||||
# Set object visibility for objects that are edited
|
||||
if key == 'plot' and self.app.call_source != 'app':
|
||||
self.visible = self.options['plot']
|
||||
self.visible = self.obj_options['plot']
|
||||
|
||||
self.optionChanged.emit(key)
|
||||
|
||||
@@ -325,7 +325,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
self.muted_ui = False
|
||||
|
||||
def on_name_activate(self, silent=None):
|
||||
old_name = copy(self.options["name"])
|
||||
old_name = copy(self.obj_options["name"])
|
||||
new_name = self.ui.name_entry.get_value()
|
||||
|
||||
if new_name != old_name:
|
||||
@@ -339,7 +339,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
self.app.log.debug(
|
||||
"on_name_activate() --> Could not remove the old object name from auto-completer model list")
|
||||
|
||||
self.options["name"] = self.ui.name_entry.get_value()
|
||||
self.obj_options["name"] = self.ui.name_entry.get_value()
|
||||
self.default_data["name"] = self.ui.name_entry.get_value()
|
||||
self.app.collection.update_view()
|
||||
if silent:
|
||||
@@ -418,7 +418,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
:return: None
|
||||
"""
|
||||
self.app.log.debug(str(inspect.stack()[1][3]) + " --> FlatCAMObj.to_form()")
|
||||
for option in self.options:
|
||||
for option in self.obj_options:
|
||||
try:
|
||||
self.set_form_item(option)
|
||||
except Exception as err:
|
||||
@@ -426,13 +426,13 @@ class FlatCAMObj(QtCore.QObject):
|
||||
|
||||
def read_form(self):
|
||||
"""
|
||||
Reads form into ``self.options``.
|
||||
Reads form into ``self.obj_options``.
|
||||
|
||||
:return: None
|
||||
:rtype: None
|
||||
"""
|
||||
self.app.log.debug(str(inspect.stack()[1][3]) + "--> FlatCAMObj.read_form()")
|
||||
for option in self.options:
|
||||
for option in self.obj_options:
|
||||
try:
|
||||
self.read_form_item(option)
|
||||
except Exception:
|
||||
@@ -442,27 +442,27 @@ class FlatCAMObj(QtCore.QObject):
|
||||
"""
|
||||
Copies the specified option to the UI form.
|
||||
|
||||
:param option: Name of the option (Key in ``self.options``).
|
||||
:param option: Name of the option (Key in ``self.obj_options``).
|
||||
:type option: str
|
||||
:return: None
|
||||
"""
|
||||
|
||||
try:
|
||||
self.form_fields[option].set_value(self.options[option])
|
||||
self.form_fields[option].set_value(self.obj_options[option])
|
||||
except KeyError:
|
||||
# self.app.log.warn("Tried to set an option or field that does not exist: %s" % option)
|
||||
pass
|
||||
|
||||
def read_form_item(self, option):
|
||||
"""
|
||||
Reads the specified option from the UI form into ``self.options``.
|
||||
Reads the specified option from the UI form into ``self.obj_options``.
|
||||
|
||||
:param option: Name of the option.
|
||||
:type option: str
|
||||
:return: None
|
||||
"""
|
||||
try:
|
||||
self.options[option] = self.form_fields[option].get_value()
|
||||
self.obj_options[option] = self.form_fields[option].get_value()
|
||||
except KeyError:
|
||||
pass
|
||||
# self.app.log.warning("Failed to read option from field: %s" % option)
|
||||
@@ -701,10 +701,10 @@ class FlatCAMObj(QtCore.QObject):
|
||||
self.app.worker_task.emit({'fcn': job_thread, 'params': [obj]})
|
||||
|
||||
# Options items
|
||||
for option in obj.options:
|
||||
for option in obj.obj_options:
|
||||
if option == 'name':
|
||||
continue
|
||||
self.treeWidget.addChild(options, [str(option), str(obj.options[option])], True)
|
||||
self.treeWidget.addChild(options, [str(option), str(obj.obj_options[option])], True)
|
||||
|
||||
# Items that depend on the object type
|
||||
if obj.kind.lower() == 'gerber' and obj.tools:
|
||||
@@ -809,7 +809,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
self.treeWidget.addChild(geo_tool, [str(k), str(v)], True)
|
||||
elif obj.kind.lower() == 'cncjob':
|
||||
# for CNCJob objects made from Gerber or Geometry
|
||||
if obj.options['type'].lower() == 'geometry':
|
||||
if obj.obj_options['type'].lower() == 'geometry':
|
||||
for tool, value in obj.tools.items():
|
||||
geo_tool = self.treeWidget.addParent(
|
||||
tools, str(tool), expanded=False, color=p_color, font=font)
|
||||
@@ -835,7 +835,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
self.treeWidget.addChild(tool_data, [str(data_k).capitalize(), str(data_v)], True)
|
||||
|
||||
# for CNCJob objects made from Excellon
|
||||
if obj.options['type'].lower() == 'excellon':
|
||||
if obj.obj_options['type'].lower() == 'excellon':
|
||||
for tool_id, value in obj.tools.items():
|
||||
tool_dia = value['tooldia']
|
||||
exc_tool = self.treeWidget.addParent(
|
||||
@@ -994,7 +994,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
def delete(self):
|
||||
# Free resources
|
||||
del self.ui
|
||||
del self.options
|
||||
del self.obj_options
|
||||
|
||||
# Set flag
|
||||
self.deleted = True
|
||||
|
||||
@@ -38,7 +38,7 @@ class ScriptObject(FlatCAMObj):
|
||||
|
||||
self.kind = "script"
|
||||
|
||||
self.options.update({
|
||||
self.obj_options.update({
|
||||
"plot": True,
|
||||
"type": 'Script',
|
||||
"source_file": '',
|
||||
@@ -82,17 +82,17 @@ class ScriptObject(FlatCAMObj):
|
||||
# tab_here = False
|
||||
# # try to not add too many times a tab that it is already installed
|
||||
# for idx in range(self.app.ui.plot_tab_area.count()):
|
||||
# if self.app.ui.plot_tab_area.widget(idx).objectName() == self.options['name']:
|
||||
# if self.app.ui.plot_tab_area.widget(idx).objectName() == self.obj_options['name']:
|
||||
# tab_here = True
|
||||
# break
|
||||
#
|
||||
# # add the tab if it is not already added
|
||||
# if tab_here is False:
|
||||
# self.app.ui.plot_tab_area.addTab(self.script_editor_tab, '%s' % _("Script Editor"))
|
||||
# self.script_editor_tab.setObjectName(self.options['name'])
|
||||
# self.script_editor_tab.setObjectName(self.obj_options['name'])
|
||||
|
||||
# self.app.ui.plot_tab_area.addTab(self.script_editor_tab, '%s' % _("Script Editor"))
|
||||
# self.script_editor_tab.setObjectName(self.options['name'])
|
||||
# self.script_editor_tab.setObjectName(self.obj_options['name'])
|
||||
|
||||
# first clear previous text in text editor (if any)
|
||||
# self.script_editor_tab.code_editor.clear()
|
||||
@@ -148,14 +148,14 @@ class ScriptObject(FlatCAMObj):
|
||||
tab_here = False
|
||||
# try to not add too many times a tab that it is already installed
|
||||
for idx in range(self.app.ui.plot_tab_area.count()):
|
||||
if self.app.ui.plot_tab_area.widget(idx).objectName() == (self.options['name'] + "_editor_tab"):
|
||||
if self.app.ui.plot_tab_area.widget(idx).objectName() == (self.obj_options['name'] + "_editor_tab"):
|
||||
tab_here = True
|
||||
break
|
||||
|
||||
# add the tab if it is not already added
|
||||
if tab_here is False:
|
||||
self.app.ui.plot_tab_area.addTab(self.script_editor_tab, '%s' % _("Script Editor"))
|
||||
self.script_editor_tab.setObjectName(self.options['name'] + "_editor_tab")
|
||||
self.script_editor_tab.setObjectName(self.obj_options['name'] + "_editor_tab")
|
||||
self.app.ui.plot_tab_area.setCurrentWidget(self.script_editor_tab)
|
||||
|
||||
def change_level(self, level):
|
||||
|
||||
@@ -111,7 +111,7 @@ class EventSensitiveListView(QtWidgets.QTreeView):
|
||||
# if self.current_group == new_group:
|
||||
#
|
||||
# # delete it from the model
|
||||
# deleted_obj_name = self.dropped_obj.options['name']
|
||||
# deleted_obj_name = self.dropped_obj.obj_options['name']
|
||||
# self.model().delete_by_name(deleted_obj_name)
|
||||
#
|
||||
# # add the object to the new index
|
||||
@@ -477,7 +477,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
if role in [Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole]:
|
||||
obj = index.internalPointer().obj
|
||||
if obj:
|
||||
return obj.options["name"]
|
||||
return obj.obj_options["name"]
|
||||
else:
|
||||
return index.internalPointer().data(index.column())
|
||||
|
||||
@@ -486,7 +486,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
color_disabled = QColor(self.app.defaults['global_proj_item_dis_color'][:-2])
|
||||
obj = index.internalPointer().obj
|
||||
if obj:
|
||||
return QtGui.QBrush(color) if obj.options["plot"] else QtGui.QBrush(color_disabled)
|
||||
return QtGui.QBrush(color) if obj.obj_options["plot"] else QtGui.QBrush(color_disabled)
|
||||
else:
|
||||
return index.internalPointer().data(index.column())
|
||||
|
||||
@@ -503,7 +503,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
return None
|
||||
|
||||
if obj:
|
||||
text = obj.options['name']
|
||||
text = obj.obj_options['name']
|
||||
return text
|
||||
else:
|
||||
QtWidgets.QToolTip.hideText()
|
||||
@@ -516,11 +516,11 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
obj = index.internalPointer().obj
|
||||
|
||||
if obj:
|
||||
old_name = deepcopy(obj.options['name'])
|
||||
old_name = deepcopy(obj.obj_options['name'])
|
||||
new_name = str(data)
|
||||
if old_name != new_name and new_name != '':
|
||||
# rename the object
|
||||
obj.options["name"] = deepcopy(data)
|
||||
obj.obj_options["name"] = deepcopy(data)
|
||||
|
||||
self.app.object_status_changed.emit(obj, 'rename', old_name)
|
||||
|
||||
@@ -565,7 +565,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
def append(self, obj, active=False, to_index=None):
|
||||
self.app.log.debug(str(inspect.stack()[1][3]) + " --> OC.append()")
|
||||
|
||||
name = obj.options["name"]
|
||||
name = obj.obj_options["name"]
|
||||
|
||||
# Check promises and clear if exists
|
||||
if name in self.promises:
|
||||
@@ -585,7 +585,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
name = base + str(num + 1)
|
||||
else: # No: add a number!
|
||||
name += "_1"
|
||||
obj.options["name"] = name
|
||||
obj.obj_options["name"] = name
|
||||
|
||||
# ############################################################################################################
|
||||
# update the KeyWords list with the name of the file
|
||||
@@ -640,7 +640,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
"""
|
||||
|
||||
# log.debug(str(inspect.stack()[1][3]) + " --> OC.get_names()")
|
||||
return [x.options['name'] for x in self.get_list()]
|
||||
return [x.obj_options['name'] for x in self.get_list()]
|
||||
|
||||
def get_bounds(self):
|
||||
"""
|
||||
@@ -685,11 +685,11 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
|
||||
if isCaseSensitive is None or isCaseSensitive is True:
|
||||
for obj in self.get_list():
|
||||
if obj.options['name'] == name:
|
||||
if obj.obj_options['name'] == name:
|
||||
return obj
|
||||
else:
|
||||
for obj in self.get_list():
|
||||
if obj.options['name'].lower() == name.lower():
|
||||
if obj.obj_options['name'].lower() == name.lower():
|
||||
return obj
|
||||
return None
|
||||
|
||||
@@ -707,12 +707,12 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
# some objects add a Tab on creation, close it here
|
||||
for idx in range(self.app.ui.plot_tab_area.count()):
|
||||
widget_name = self.app.ui.plot_tab_area.widget(idx).objectName()
|
||||
if widget_name == active.obj.options['name'] or widget_name == (active.obj.options['name'] + "_editor_tab"):
|
||||
if widget_name == active.obj.obj_options['name'] or widget_name == (active.obj.obj_options['name'] + "_editor_tab"):
|
||||
self.app.ui.plot_tab_area.removeTab(idx)
|
||||
break
|
||||
|
||||
# update the SHELL auto-completer model data
|
||||
name = active.obj.options['name']
|
||||
name = active.obj.obj_options['name']
|
||||
try:
|
||||
self.app.myKeywords.remove(name)
|
||||
self.app.shell._edit.set_model_data(self.app.myKeywords)
|
||||
@@ -761,12 +761,12 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
# some objects add a Tab on creation, close it here
|
||||
for idx in range(self.app.ui.plot_tab_area.count()):
|
||||
wdg_name = self.app.ui.plot_tab_area.widget(idx).objectName()
|
||||
if wdg_name == deleted.obj.options['name'] or wdg_name == (deleted.obj.options['name'] + "_editor_tab"):
|
||||
if wdg_name == deleted.obj.obj_options['name'] or wdg_name == (deleted.obj.obj_options['name'] + "_editor_tab"):
|
||||
self.app.ui.plot_tab_area.removeTab(idx)
|
||||
break
|
||||
|
||||
# update the SHELL auto-completer model data
|
||||
name = deleted.obj.options['name']
|
||||
name = deleted.obj.obj_options['name']
|
||||
try:
|
||||
self.app.myKeywords.remove(name)
|
||||
self.app.shell._edit.set_model_data(self.app.myKeywords)
|
||||
@@ -952,42 +952,42 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
|
||||
try:
|
||||
obj = current.indexes()[0].internalPointer().obj
|
||||
self.item_selected.emit(obj.options['name'])
|
||||
self.item_selected.emit(obj.obj_options['name'])
|
||||
|
||||
if obj.kind == 'gerber':
|
||||
self.app.inform.emit('[selected]<span style="color:{color};">{name}</span> {tx}'.format(
|
||||
color='green',
|
||||
name=str(obj.options['name']),
|
||||
name=str(obj.obj_options['name']),
|
||||
tx=_("selected"))
|
||||
)
|
||||
elif obj.kind == 'excellon':
|
||||
self.app.inform.emit('[selected]<span style="color:{color};">{name}</span> {tx}'.format(
|
||||
color='brown',
|
||||
name=str(obj.options['name']),
|
||||
name=str(obj.obj_options['name']),
|
||||
tx=_("selected"))
|
||||
)
|
||||
elif obj.kind == 'cncjob':
|
||||
self.app.inform.emit('[selected]<span style="color:{color};">{name}</span> {tx}'.format(
|
||||
color='blue',
|
||||
name=str(obj.options['name']),
|
||||
name=str(obj.obj_options['name']),
|
||||
tx=_("selected"))
|
||||
)
|
||||
elif obj.kind == 'geometry':
|
||||
self.app.inform.emit('[selected]<span style="color:{color};">{name}</span> {tx}'.format(
|
||||
color='red',
|
||||
name=str(obj.options['name']),
|
||||
name=str(obj.obj_options['name']),
|
||||
tx=_("selected"))
|
||||
)
|
||||
elif obj.kind == 'script':
|
||||
self.app.inform.emit('[selected]<span style="color:{color};">{name}</span> {tx}'.format(
|
||||
color='orange',
|
||||
name=str(obj.options['name']),
|
||||
name=str(obj.obj_options['name']),
|
||||
tx=_("selected"))
|
||||
)
|
||||
elif obj.kind == 'document':
|
||||
self.app.inform.emit('[selected]<span style="color:{color};">{name}</span> {tx}'.format(
|
||||
color='darkCyan',
|
||||
name=str(obj.options['name']),
|
||||
name=str(obj.obj_options['name']),
|
||||
tx=_("selected"))
|
||||
)
|
||||
except IndexError:
|
||||
@@ -1074,7 +1074,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
# get the name of the selected objects and add them to a list
|
||||
name_list = []
|
||||
for obj in self.get_selected():
|
||||
name_list.append(obj.options['name'])
|
||||
name_list.append(obj.obj_options['name'])
|
||||
|
||||
# set all actions as unchecked but the ones selected make them checked
|
||||
for act in self.app.ui.menuobjects.actions():
|
||||
@@ -1178,7 +1178,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
|
||||
elif state == 'delete':
|
||||
for act in self.app.ui.menuobjects.actions():
|
||||
if act.text() == obj.options['name']:
|
||||
if act.text() == obj.obj_options['name']:
|
||||
try:
|
||||
act.triggered.disconnect()
|
||||
except TypeError:
|
||||
@@ -1189,11 +1189,11 @@ class ObjectCollection(QtCore.QAbstractItemModel):
|
||||
for act in self.app.ui.menuobjects.actions():
|
||||
if act.text() == old_name:
|
||||
add_action = QtGui.QAction(parent=self.app.ui.menuobjects)
|
||||
add_action.setText(obj.options['name'])
|
||||
add_action.setText(obj.obj_options['name'])
|
||||
add_action.setIcon(QtGui.QIcon(icon_files[obj.kind]))
|
||||
add_action.triggered.connect(
|
||||
lambda: self.set_active(obj.options['name']) if add_action.isChecked() is True else
|
||||
self.set_inactive(obj.options['name']))
|
||||
lambda: self.set_active(obj.obj_options['name']) if add_action.isChecked() is True else
|
||||
self.set_inactive(obj.obj_options['name']))
|
||||
|
||||
self.app.ui.menuobjects.insertAction(act, add_action)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user