Commit edaa0e93 authored by Guillaume Seguin's avatar Guillaume Seguin

Apply b597639e to gviz

parent b597639e
......@@ -436,7 +436,9 @@ class Gviz(wx.Panel):
def add_parsed_gcodes(self, gcode):
start_time = time.time()
for layer_idx, layer in enumerate(gcode.all_layers):
layer_idx = 0
while layer_idx < len(gcode.all_layers):
layer = gcode.all_layers[layer_idx]
has_move = False
for gline in layer:
if gline.is_move:
......@@ -467,11 +469,15 @@ class Gviz(wx.Panel):
# unfinished layer
self.layers[layer_idx] = viz_layer
self.layersz.append(layer.z)
# Refresh display if more than 0.2s have passed
if time.time() - start_time > 0.2:
start_time = time.time()
self.dirty = 1
wx.CallAfter(self.Refresh)
layer_idx += 1
self.dirty = 1
wx.CallAfter(self.Refresh)
......
......@@ -1104,9 +1104,10 @@ class pronsole(cmd.Cmd):
self.log(_("Loaded %s, %d lines.") % (filename, len(self.fgcode)))
self.log(_("Estimated duration: %d layers, %s") % self.fgcode.estimate_duration())
def load_gcode(self, filename):
def load_gcode(self, filename, layer_callback = None):
self.fgcode = gcoder.GCode(open(filename, "rU"),
get_home_pos(self.build_dimensions_list))
get_home_pos(self.build_dimensions_list),
layer_callback = layer_callback)
self.fgcode.estimate_duration()
self.filename = filename
......
......@@ -1248,7 +1248,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
fn = self.filename
try:
self.filename = self.model_to_gcode_filename(self.filename)
self.load_gcode(self.filename)
self.load_gcode(self.filename, layer_callback = self.layer_ready_cb)
if self.p.online:
wx.CallAfter(self.printbtn.Enable)
......@@ -1342,7 +1342,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.skein(name)
else:
self.filename = name
self.load_gcode(self.filename)
self.load_gcode(self.filename, layer_callback = self.layer_ready_cb)
self.statusbar.SetStatusText(_("Loaded %s, %d lines") % (name, len(self.fgcode)))
print _("Loaded %s, %d lines") % (name, len(self.fgcode))
wx.CallAfter(self.printbtn.SetLabel, _("Print"))
......@@ -1356,6 +1356,10 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
else:
dlg.Destroy()
def layer_ready_cb(self, gcode, layer):
print gcode, layer
print gcode.all_layers[layer].z
def post_gcode_load(self, print_stats = True):
if print_stats:
self.output_gcode_stats()
......
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