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():
self.tempcb = None #impl (wholeline)
self.recvcb = None #impl (wholeline)
self.sendcb = None #impl (wholeline)
self.printsendcb = None #impl (wholeline)
self.errorcb = None #impl (wholeline)
self.startcb = None #impl ()
self.endcb = None #impl ()
......@@ -381,7 +382,8 @@ class printcore():
return
if self.printing and self.queueindex < len(self.mainqueue.idxs):
(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
if tline.lstrip().startswith(";@"):
self.processHostCommand(tline)
......@@ -392,6 +394,9 @@ class printcore():
if len(tline) > 0:
self._send(tline, self.lineno, True)
self.lineno += 1
if self.printsendcb:
try: self.printsendcb(gline)
except: pass
else:
self.clear = True
self.queueindex += 1
......
......@@ -464,6 +464,10 @@ class GcodeViewFrame(wx.Frame):
self.objects = [GCObject(self.platform), GCObject(None)]
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):
self.model = actors.GcodeModel()
if gcode:
......
......@@ -65,6 +65,9 @@ class window(wx.Frame):
gcode = gcoder.GCode(f)
self.p.addfile(gcode)
def set_current_gline(self, gline):
return
def resetview(self, event):
self.p.translate = [0.0, 0.0]
self.p.scale = self.p.basescale
......
......@@ -186,6 +186,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.skeining = 0
self.mini = False
self.p.sendcb = self.sentcb
self.p.printsendcb = self.printsentcb
self.p.startcb = self.startcb
self.p.endcb = self.endcb
self.starttime = 0
......@@ -271,6 +272,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
return
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 = ""):
try:
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