Commit 12ea0d1f authored by Guillaume Seguin's avatar Guillaume Seguin

Use stateful parser for GCodes in 2D viewer as per #443

parent 0d6d7175
...@@ -217,6 +217,7 @@ class Gviz(wx.Panel): ...@@ -217,6 +217,7 @@ class Gviz(wx.Panel):
def clear(self): def clear(self):
self.lastpos = [0, 0, 0, 0, 0, 0, 0] self.lastpos = [0, 0, 0, 0, 0, 0, 0]
self.hilightpos = self.lastpos[:] self.hilightpos = self.lastpos[:]
self.gcoder = gcoder.GCode([])
self.lines = {} self.lines = {}
self.pens = {} self.pens = {}
self.arcs = {} self.arcs = {}
...@@ -463,9 +464,7 @@ class Gviz(wx.Panel): ...@@ -463,9 +464,7 @@ class Gviz(wx.Panel):
gcode = gcode.lower().strip() gcode = gcode.lower().strip()
if not gcode: if not gcode:
return return
gline = gcoder.Line(gcode) gline = self.gcoder.append(gcode, store = False)
split_raw = gcoder.split(gline)
gcoder.parse_coordinates(gline, split_raw, imperial = False)
def _y(y): def _y(y):
return self.build_dimensions[1] - (y - self.build_dimensions[4]) return self.build_dimensions[1] - (y - self.build_dimensions[4])
...@@ -481,9 +480,9 @@ class Gviz(wx.Panel): ...@@ -481,9 +480,9 @@ class Gviz(wx.Panel):
target = start_pos[:] target = start_pos[:]
target[5] = 0.0 target[5] = 0.0
target[6] = 0.0 target[6] = 0.0
if gline.x is not None: target[0] = gline.x if gline.current_x is not None: target[0] = gline.current_x
if gline.y is not None: target[1] = gline.y if gline.current_y is not None: target[1] = gline.current_y
if gline.z is not None: target[2] = gline.z if gline.current_z is not None: target[2] = gline.current_z
if gline.e is not None: target[3] = gline.e if gline.e is not None: target[3] = gline.e
if gline.f is not None: target[4] = gline.f if gline.f is not None: target[4] = gline.f
if gline.i is not None: target[5] = gline.i if gline.i is not None: target[5] = gline.i
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment