Skip to content

Commit e6dab9d

Browse files
committed
qt5_graphics: always report gcode props in gcode's units
Previously this was calculated based on the state of metric_units at the time of file load. metric_units reflected the current G20/G21 state (or if 'metric-mode-changed' was emitted). Therefore it was possible that the properties for an imperial gcode file were reported in metric, and vice versa.
1 parent 76303f0 commit e6dab9d

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

src/emc/usr_intf/gremlin/qt5_graphics.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def C(s):
306306
Qt.RightButton]
307307
self._invertWheelZoom = False
308308

309-
# base units of config. updated by subclaas (gcode_graphics)
309+
# base units of config. updated by subclass (gcode_graphics)
310310
self.mach_units = 'Metric'
311311

312312
# add a 100ms timer to poll linuxcnc stats
@@ -458,17 +458,17 @@ def from_internal_units(pos, unit=None):
458458
lines = sum(1 for line in open(loaded_file))
459459
props['size'] = "%(size)s bytes\n%(lines)s gcode lines" % {'size': size, 'lines': lines}
460460

461-
if self.metric_units:
462-
conv = 1
463-
units = "mm"
464-
fmt = "%.3f"
465-
else:
466-
conv = 1/25.4
461+
# report props in gcode's units
462+
if 200 in canon.state.gcodes:
467463
units = "in"
468464
fmt = "%.4f"
465+
conv = 1/25
466+
else:
467+
units = "mm"
468+
fmt = "%.3f"
469+
conv = 1
469470

470471
mf = max_speed
471-
#print canon.traverse[0]
472472

473473
g0 = sum(dist(l[1][:3], l[2][:3]) for l in canon.traverse)
474474
g1 = (sum(dist(l[1][:3], l[2][:3]) for l in canon.feed) +
@@ -501,11 +501,7 @@ def from_internal_units(pos, unit=None):
501501
props[c + '_zero_rxy'] = "%f to %f = %f %s".replace("%f", fmt) % ( d, e, e-d, units)
502502
props['machine_unit_sys'] = self.mach_units
503503

504-
if 200 in canon.state.gcodes:
505-
gcode_units = "in"
506-
else:
507-
gcode_units = "mm"
508-
props['gcode_units'] = gcode_units
504+
props['gcode_units'] = units
509505

510506
self.gcode_properties = props
511507

0 commit comments

Comments
 (0)