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): ...@@ -223,7 +223,6 @@ class Gviz(wx.Panel):
self.gcode = None self.gcode = None
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([], get_home_pos(self.build_dimensions))
self.lines = {} self.lines = {}
self.pens = {} self.pens = {}
self.arcs = {} self.arcs = {}
...@@ -525,14 +524,7 @@ class Gviz(wx.Panel): ...@@ -525,14 +524,7 @@ class Gviz(wx.Panel):
wx.CallAfter(self.Refresh) wx.CallAfter(self.Refresh)
yield None yield None
def addgcodehighlight(self, gcode = "M105"): def addgcodehighlight(self, gline):
gcode = gcode.split("*")[0]
gcode = gcode.split(";")[0]
gcode = gcode.lower().strip()
if not gcode:
return
gline = self.gcoder.append(gcode, store = False)
if gline.command not in ["G0", "G1", "G2", "G3"]: if gline.command not in ["G0", "G1", "G2", "G3"]:
return return
......
...@@ -148,7 +148,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -148,7 +148,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.current_pos = [0, 0, 0] self.current_pos = [0, 0, 0]
self.paused = False self.paused = False
self.uploading = False self.uploading = False
self.sentlines = Queue.Queue(0) self.sentglines = Queue.Queue(0)
self.cpbuttons = { self.cpbuttons = {
"motorsoff": SpecialButton(_("Motors off"), ("M84"), (250, 250, 250), _("Switch all motors off")), "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")), "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/>.""" ...@@ -979,10 +979,10 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
# temperature monitoring and status loop sleep # temperature monitoring and status loop sleep
pronsole.pronsole.statuschecker_inner(self, self.settings.monitor) pronsole.pronsole.statuschecker_inner(self, self.settings.monitor)
try: try:
while not self.sentlines.empty(): while not self.sentglines.empty():
gc = self.sentlines.get_nowait() gc = self.sentglines.get_nowait()
wx.CallAfter(self.gviz.addgcodehighlight, gc) wx.CallAfter(self.gviz.addgcodehighlight, gc)
self.sentlines.task_done() self.sentglines.task_done()
except Queue.Empty: except Queue.Empty:
pass pass
...@@ -1534,7 +1534,8 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1534,7 +1534,8 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
elif gline.command.startswith("T"): elif gline.command.startswith("T"):
tool = gline.command[1:] tool = gline.command[1:]
if hasattr(self, "extrudersel"): wx.CallAfter(self.extrudersel.SetValue, tool) 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): def is_excluded_move(self, gline):
"""Check whether the given moves ends at a position specified as """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