Commit 00c69a8a authored by Guillaume Seguin's avatar Guillaume Seguin

Rework excluder logic (#413)

parent d99be75b
...@@ -183,6 +183,9 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -183,6 +183,9 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def _set_fgcode(self, value): def _set_fgcode(self, value):
self._fgcode = value self._fgcode = value
self.excluder = None self.excluder = None
self.excluder_e = None
self.excluder_z_abs = None
self.excluder_z_rel = None
fgcode = property(_get_fgcode, _set_fgcode) fgcode = property(_get_fgcode, _set_fgcode)
def __init__(self, filename = None, size = winsize): def __init__(self, filename = None, size = winsize):
...@@ -414,8 +417,6 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -414,8 +417,6 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def is_excluded_move(self, gline): def is_excluded_move(self, gline):
if not gline.is_move or not self.excluder or not self.excluder.rectangles: if not gline.is_move or not self.excluder or not self.excluder.rectangles:
return False return False
if gline.x == None and gline.y == None:
return False
for (x0, y0, x1, y1) in self.excluder.rectangles: for (x0, y0, x1, y1) in self.excluder.rectangles:
if x0 <= gline.current_x <= x1 and y0 <= gline.current_y <= y1: if x0 <= gline.current_x <= x1 and y0 <= gline.current_y <= y1:
return True return True
...@@ -425,13 +426,38 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -425,13 +426,38 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if not self.is_excluded_move(gline): if not self.is_excluded_move(gline):
return gline return gline
else: else:
# Check if next move will be excluded too and if it will emit an absolute E set if gline.z != None:
if next_gline != None and self.is_excluded_move(next_gline) and next_gline.e != None and not next_gline.relative_e: if gline.relative:
return None # nothing to do: next move will set absolute E if needed if self.excluder_z_abs != None:
else: # else, check if this is an extrusion move with non relative E and replace it self.excluder_z_abs += gline.z
elif self.excluder_z_rel != None:
self.excluder_z_rel += gline.z
else:
self.excluder_z_rel = gline.z
else:
self.excluder_z_rel = None
self.excluder_z_abs = gline.z
if gline.e != None and not gline.relative_e: if gline.e != None and not gline.relative_e:
return gcoder.Line("G92 E%.5f" % gline.e) self.excluder_e = gline.e
else: # or just do nothing # If next move won't be excluded, push the changes we have to do
if next_gline != None and not self.is_excluded_move(next_gline):
if self.excluder_e != None:
self.p.send_now("G92 E%.5f" % self.excluder_e)
self.excluder_e = None
if self.excluder_z_abs != None:
if gline.relative:
self.p.send_now("G90")
self.p.send_now("G1 Z.5f" % self.excluder_z_abs)
self.excluder_z_abs = None
if gline.relative:
self.p.send_now("G91")
if self.excluder_z_rel != None:
if not gline.relative:
self.p.send_now("G91")
self.p.send_now("G1 Z.5f" % self.excluder_z_rel)
self.excluder_z_rel = None
if not gline.relative:
self.p.send_now("G90")
return None return None
def printsentcb(self, gline): def printsentcb(self, gline):
......
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