Commit ae83d8e1 authored by Guillaume Seguin's avatar Guillaume Seguin

Add printsend callback to printcore and pronterface

This callback is useful to broadcast the last print line sent in the form of
the parsed gcoder.Line object. We can then augment the gcoder.Line to do
awesome stuff, such as updating the print status in the 3D viewer.
parent 79af67f1
...@@ -61,6 +61,7 @@ class printcore(): ...@@ -61,6 +61,7 @@ class printcore():
self.tempcb = None #impl (wholeline) self.tempcb = None #impl (wholeline)
self.recvcb = None #impl (wholeline) self.recvcb = None #impl (wholeline)
self.sendcb = None #impl (wholeline) self.sendcb = None #impl (wholeline)
self.printsendcb = None #impl (wholeline)
self.errorcb = None #impl (wholeline) self.errorcb = None #impl (wholeline)
self.startcb = None #impl () self.startcb = None #impl ()
self.endcb = None #impl () self.endcb = None #impl ()
...@@ -381,7 +382,8 @@ class printcore(): ...@@ -381,7 +382,8 @@ class printcore():
return return
if self.printing and self.queueindex < len(self.mainqueue.idxs): if self.printing and self.queueindex < len(self.mainqueue.idxs):
(layer, line) = self.mainqueue.idxs[self.queueindex] (layer, line) = self.mainqueue.idxs[self.queueindex]
tline = self.mainqueue.all_layers[layer].lines[line].raw gline = self.mainqueue.all_layers[layer].lines[line].raw
tline = gline.raw
#check for host command #check for host command
if tline.lstrip().startswith(";@"): if tline.lstrip().startswith(";@"):
self.processHostCommand(tline) self.processHostCommand(tline)
...@@ -392,6 +394,9 @@ class printcore(): ...@@ -392,6 +394,9 @@ class printcore():
if len(tline) > 0: if len(tline) > 0:
self._send(tline, self.lineno, True) self._send(tline, self.lineno, True)
self.lineno += 1 self.lineno += 1
if self.printsendcb:
try: self.printsendcb(gline)
except: pass
else: else:
self.clear = True self.clear = True
self.queueindex += 1 self.queueindex += 1
......
...@@ -464,6 +464,10 @@ class GcodeViewFrame(wx.Frame): ...@@ -464,6 +464,10 @@ class GcodeViewFrame(wx.Frame):
self.objects = [GCObject(self.platform), GCObject(None)] self.objects = [GCObject(self.platform), GCObject(None)]
self.glpanel = GcodeViewPanel(self) self.glpanel = GcodeViewPanel(self)
def set_current_gline(self, gline):
if gline.is_move and self.model and self.model.loaded:
self.model.printed_until = gline.gcview_end_vertex
def addfile(self, gcode = None): def addfile(self, gcode = None):
self.model = actors.GcodeModel() self.model = actors.GcodeModel()
if gcode: if gcode:
......
...@@ -65,6 +65,9 @@ class window(wx.Frame): ...@@ -65,6 +65,9 @@ class window(wx.Frame):
gcode = gcoder.GCode(f) gcode = gcoder.GCode(f)
self.p.addfile(gcode) self.p.addfile(gcode)
def set_current_gline(self, gline):
return
def resetview(self, event): def resetview(self, event):
self.p.translate = [0.0, 0.0] self.p.translate = [0.0, 0.0]
self.p.scale = self.p.basescale self.p.scale = self.p.basescale
......
...@@ -186,6 +186,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -186,6 +186,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.skeining = 0 self.skeining = 0
self.mini = False self.mini = False
self.p.sendcb = self.sentcb self.p.sendcb = self.sentcb
self.p.printsendcb = self.printsentcb
self.p.startcb = self.startcb self.p.startcb = self.startcb
self.p.endcb = self.endcb self.p.endcb = self.endcb
self.starttime = 0 self.starttime = 0
...@@ -271,6 +272,10 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -271,6 +272,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
return return
self.sentlines.put_nowait(line) self.sentlines.put_nowait(line)
def printsentcb(self, gline):
if gline.is_move:
wx.CallAfter(self.gwindow.set_current_gline, gline)
def do_extrude(self, l = ""): def do_extrude(self, l = ""):
try: try:
if not l.__class__ in (str, unicode) or not len(l): if not l.__class__ in (str, unicode) or not len(l):
......
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