Commit b9d947d5 authored by Guillaume Seguin's avatar Guillaume Seguin

Fix #586 by passing glines instead of raw gcodes to 2D viewer

We used to have our own gcode analyzer in gviz but this was clearly
suboptimal and broken. Position of drawn things should not differ in
anyway from the original GCode anyway.
parent 67d60a80
......@@ -223,7 +223,6 @@ class Gviz(wx.Panel):
self.gcode = None
self.lastpos = [0, 0, 0, 0, 0, 0, 0]
self.hilightpos = self.lastpos[:]
self.gcoder = gcoder.GCode([], get_home_pos(self.build_dimensions))
self.lines = {}
self.pens = {}
self.arcs = {}
......@@ -525,14 +524,7 @@ class Gviz(wx.Panel):
wx.CallAfter(self.Refresh)
yield None
def addgcodehighlight(self, gcode = "M105"):
gcode = gcode.split("*")[0]
gcode = gcode.split(";")[0]
gcode = gcode.lower().strip()
if not gcode:
return
gline = self.gcoder.append(gcode, store = False)
def addgcodehighlight(self, gline):
if gline.command not in ["G0", "G1", "G2", "G3"]:
return
......
......@@ -148,7 +148,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.current_pos = [0, 0, 0]
self.paused = False
self.uploading = False
self.sentlines = Queue.Queue(0)
self.sentglines = Queue.Queue(0)
self.cpbuttons = {
"motorsoff": SpecialButton(_("Motors off"), ("M84"), (250, 250, 250), _("Switch all motors off")),
"extrude": SpecialButton(_("Extrude"), ("pront_extrude"), (225, 200, 200), _("Advance extruder by set length")),
......@@ -979,10 +979,10 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
# temperature monitoring and status loop sleep
pronsole.pronsole.statuschecker_inner(self, self.settings.monitor)
try:
while not self.sentlines.empty():
gc = self.sentlines.get_nowait()
while not self.sentglines.empty():
gc = self.sentglines.get_nowait()
wx.CallAfter(self.gviz.addgcodehighlight, gc)
self.sentlines.task_done()
self.sentglines.task_done()
except Queue.Empty:
pass
......@@ -1534,7 +1534,8 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
elif gline.command.startswith("T"):
tool = gline.command[1:]
if hasattr(self, "extrudersel"): wx.CallAfter(self.extrudersel.SetValue, tool)
self.sentlines.put_nowait(line)
if gline.is_move:
self.sentglines.put_nowait(gline)
def is_excluded_move(self, gline):
"""Check whether the given moves ends at a position specified as
......
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