- working to differentiate between temporary units change and permanent units change
This commit is contained in:
@@ -163,7 +163,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
self.gcode_viewer_tab = None
|
||||
|
||||
self.source_file = ''
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
self.prepend_snippet = ''
|
||||
self.append_snippet = ''
|
||||
@@ -185,7 +185,7 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
FlatCAMObj.build_ui(self)
|
||||
self.app.log.debug("CNCJobObject.build_ui()")
|
||||
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units = self.app.app_units.upper()
|
||||
|
||||
# if the FlatCAM object is Excellon don't build the CNC Tools Table but hide it
|
||||
self.ui.cnc_tools_table.hide()
|
||||
@@ -414,8 +414,8 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
assert isinstance(self.ui, CNCObjectUI), \
|
||||
"Expected a CNCObjectUI, got %s" % type(self.ui)
|
||||
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units = self.app.app_units.upper()
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
# this signal has to be connected to it's slot before the defaults are populated
|
||||
# the decision done in the slot has to override the default value set below
|
||||
|
||||
@@ -51,7 +51,7 @@ class DocumentObject(FlatCAMObj):
|
||||
self.document_editor_tab = None
|
||||
|
||||
self._read_only = False
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
def set_ui(self, ui):
|
||||
FlatCAMObj.set_ui(self, ui)
|
||||
@@ -60,8 +60,8 @@ class DocumentObject(FlatCAMObj):
|
||||
assert isinstance(self.ui, DocumentObjectUI), \
|
||||
"Expected a DocumentObjectUI, got %s" % type(self.ui)
|
||||
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units = self.app.app_units.upper()
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
# Fill form fields only on object create
|
||||
self.to_form()
|
||||
|
||||
@@ -94,7 +94,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
self.source_file = ""
|
||||
|
||||
self.multigeo = False
|
||||
self.units_found = self.app.defaults['units']
|
||||
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']
|
||||
@@ -121,7 +121,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
|
||||
self.app.log.debug("ExcellonObject.set_ui()")
|
||||
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units = self.app.app_units.upper()
|
||||
|
||||
# # fill in self.options values for the Drilling Tool from self.app.options
|
||||
# for opt_key, opt_val in self.app.options.items():
|
||||
@@ -185,7 +185,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
|
||||
self.ui.table_visibility_cb.stateChanged.connect(self.on_table_visibility_toggle)
|
||||
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
self.set_offset_values()
|
||||
|
||||
@@ -251,7 +251,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
|
||||
"""
|
||||
FlatCAMObj.build_ui(self)
|
||||
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units = self.app.app_units.upper()
|
||||
|
||||
for row in range(self.ui.tools_table.rowCount()):
|
||||
try:
|
||||
|
||||
@@ -141,7 +141,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
|
||||
# self.old_pp_state = self.app.defaults["tools_mill_multidepth"]
|
||||
# self.old_toolchangeg_state = self.app.defaults["tools_mill_toolchange"]
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
# this variable can be updated by the Object that generates the geometry
|
||||
self.tool_type = 'C1'
|
||||
@@ -171,7 +171,7 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
|
||||
FlatCAMObj.build_ui(self)
|
||||
|
||||
self.units = self.app.defaults['units']
|
||||
self.units = self.app.app_units
|
||||
|
||||
row_idx = 0
|
||||
|
||||
@@ -300,8 +300,8 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
assert isinstance(self.ui, GeometryObjectUI), \
|
||||
"Expected a GeometryObjectUI, got %s" % type(self.ui)
|
||||
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units = self.app.app_units.upper()
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
self.form_fields.update({
|
||||
"plot": self.ui.plot_cb,
|
||||
@@ -549,8 +549,8 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||
msp = dwg.modelspace()
|
||||
|
||||
# add units
|
||||
dwg.units = ezdxf.InsertUnits(4) if self.app.defaults['units'].lower() == 'mm' else ezdxf.InsertUnits(1)
|
||||
dwg.header['$MEASUREMENT'] = 1 if self.app.defaults['units'].lower() == 'mm' else 0
|
||||
dwg.units = ezdxf.InsertUnits(4) if self.app.app_units.lower() == 'mm' else ezdxf.InsertUnits(1)
|
||||
dwg.header['$MEASUREMENT'] = 1 if self.app.app_units.lower() == 'mm' else 0
|
||||
|
||||
def g2dxf(dxf_space, geo_obj):
|
||||
if isinstance(geo_obj, MultiPolygon):
|
||||
|
||||
@@ -91,7 +91,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
# store the status of grid snapping
|
||||
self.grid_status_memory = None
|
||||
|
||||
self.units_found = self.app.defaults['units']
|
||||
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']
|
||||
@@ -120,7 +120,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
FlatCAMObj.set_ui(self, ui)
|
||||
log.debug("GerberObject.set_ui()")
|
||||
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units = self.app.app_units.upper()
|
||||
|
||||
self.replotApertures.connect(self.on_mark_cb_click_table)
|
||||
|
||||
@@ -195,7 +195,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
||||
self.on_aperture_table_visibility_change()
|
||||
|
||||
self.build_ui()
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
self.set_offset_values()
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
self.selection_shape_drawn = False
|
||||
|
||||
# self.units = 'IN'
|
||||
self.units = self.app.defaults['units']
|
||||
self.units = self.app.app_units
|
||||
|
||||
# this is the treeWidget from the UI; it is updated when the add_properties_items() method is called
|
||||
self.treeWidget = None
|
||||
@@ -530,7 +530,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
log.error("FlatCAMObj.add_properties_items() -> calculate dimensions --> %s" % str(ee))
|
||||
|
||||
# calculate box area
|
||||
if self.app.defaults['units'].lower() == 'mm':
|
||||
if self.app.app_units.lower() == 'mm':
|
||||
area = (length * width) / 100
|
||||
else:
|
||||
area = length * width
|
||||
@@ -586,7 +586,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
width = abs(ymax - ymin)
|
||||
|
||||
# calculate box area
|
||||
if self.app.defaults['units'].lower() == 'mm':
|
||||
if self.app.app_units.lower() == 'mm':
|
||||
area = (length * width) / 100
|
||||
else:
|
||||
area = length * width
|
||||
@@ -637,7 +637,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
area_chull = None
|
||||
log.error("FlatCAMObj.add_properties_items() area chull--> %s" % str(er))
|
||||
|
||||
if self.app.defaults['units'].lower() == 'mm' and area_chull:
|
||||
if self.app.app_units.lower() == 'mm' and area_chull:
|
||||
area_chull = area_chull / 100
|
||||
|
||||
if area_chull is None:
|
||||
@@ -726,7 +726,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
toolid,
|
||||
[
|
||||
_('Diameter'),
|
||||
'%.*f %s' % (self.decimals, value['tooldia'], self.app.defaults['units'].lower())
|
||||
'%.*f %s' % (self.decimals, value['tooldia'], self.app.app_units.lower())
|
||||
],
|
||||
True
|
||||
)
|
||||
@@ -792,7 +792,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
exc_tool,
|
||||
[
|
||||
_('Diameter'),
|
||||
'%.*f %s' % (self.decimals, tool_dia, self.app.defaults['units'].lower())
|
||||
'%.*f %s' % (self.decimals, tool_dia, self.app.app_units.lower())
|
||||
],
|
||||
True
|
||||
)
|
||||
@@ -820,7 +820,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
'%.*f %s' % (
|
||||
self.decimals,
|
||||
(obj.z_cut - abs(value['data']['tools_drill_offset'])),
|
||||
self.app.defaults['units'].lower()
|
||||
self.app.app_units.lower()
|
||||
)
|
||||
],
|
||||
True
|
||||
@@ -832,7 +832,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
'%.*f %s' % (
|
||||
self.decimals,
|
||||
obj.z_move,
|
||||
self.app.defaults['units'].lower()
|
||||
self.app.app_units.lower()
|
||||
)
|
||||
],
|
||||
True
|
||||
@@ -844,7 +844,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
'%.*f %s/min' % (
|
||||
self.decimals,
|
||||
obj.feedrate,
|
||||
self.app.defaults['units'].lower()
|
||||
self.app.app_units.lower()
|
||||
)
|
||||
],
|
||||
True
|
||||
@@ -874,7 +874,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
others,
|
||||
[
|
||||
'%s:' % _('Travelled distance'),
|
||||
'%.*f %s' % (self.decimals, obj.travel_distance, self.app.defaults['units'].lower())
|
||||
'%.*f %s' % (self.decimals, obj.travel_distance, self.app.app_units.lower())
|
||||
],
|
||||
True
|
||||
)
|
||||
@@ -886,17 +886,17 @@ class FlatCAMObj(QtCore.QObject):
|
||||
# add dimensions
|
||||
self.treeWidget.addChild(
|
||||
location,
|
||||
['%s:' % _('Length'), '%.*f %s' % (self.decimals, length, self.app.defaults['units'].lower())],
|
||||
['%s:' % _('Length'), '%.*f %s' % (self.decimals, length, self.app.app_units.lower())],
|
||||
True
|
||||
)
|
||||
self.treeWidget.addChild(
|
||||
location,
|
||||
['%s:' % _('Width'), '%.*f %s' % (self.decimals, width, self.app.defaults['units'].lower())],
|
||||
['%s:' % _('Width'), '%.*f %s' % (self.decimals, width, self.app.app_units.lower())],
|
||||
True
|
||||
)
|
||||
|
||||
# add box area
|
||||
if self.app.defaults['units'].lower() == 'mm':
|
||||
if self.app.app_units.lower() == 'mm':
|
||||
self.treeWidget.addChild(location, ['%s:' % _('Box Area'), '%.*f %s' % (self.decimals, area, 'cm2')], True)
|
||||
self.treeWidget.addChild(
|
||||
location,
|
||||
@@ -913,7 +913,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||
)
|
||||
|
||||
# add copper area
|
||||
if self.app.defaults['units'].lower() == 'mm':
|
||||
if self.app.app_units.lower() == 'mm':
|
||||
self.treeWidget.addChild(
|
||||
location, ['%s:' % _('Copper Area'), '%.*f %s' % (self.decimals, copper_area, 'cm2')], True)
|
||||
else:
|
||||
@@ -960,13 +960,13 @@ class FlatCAMObj(QtCore.QObject):
|
||||
|
||||
@property
|
||||
def drawing_tolerance(self):
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units = self.app.app_units.upper()
|
||||
tol = self._drawing_tolerance if self.units == 'MM' or not self.units else self._drawing_tolerance / 25.4
|
||||
return tol
|
||||
|
||||
@drawing_tolerance.setter
|
||||
def drawing_tolerance(self, value):
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units = self.app.app_units.upper()
|
||||
self._drawing_tolerance = value if self.units == 'MM' or not self.units else value / 25.4
|
||||
|
||||
def clear(self, update=False):
|
||||
|
||||
@@ -56,7 +56,7 @@ class ScriptObject(FlatCAMObj):
|
||||
self.script_code = ''
|
||||
self.script_filename = ''
|
||||
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
def set_ui(self, ui):
|
||||
"""
|
||||
@@ -70,8 +70,8 @@ class ScriptObject(FlatCAMObj):
|
||||
assert isinstance(self.ui, ScriptObjectUI), \
|
||||
"Expected a ScriptObjectUI, got %s" % type(self.ui)
|
||||
|
||||
self.units = self.app.defaults['units'].upper()
|
||||
self.units_found = self.app.defaults['units']
|
||||
self.units = self.app.app_units.upper()
|
||||
self.units_found = self.app.app_units
|
||||
|
||||
# Fill form fields only on object create
|
||||
self.to_form()
|
||||
|
||||
Reference in New Issue
Block a user