Commit 510f85cc authored by Guillaume Seguin's avatar Guillaume Seguin

Fix reloading of visualization after UI change

parent f810f246
......@@ -273,7 +273,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
temppanel.Destroy()
self.panel.Layout()
if self.fgcode:
self.post_gcode_load(print_stats = False)
self.start_viz_thread()
self.ui_ready = True
self.Thaw()
......@@ -1363,10 +1363,13 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
def layer_ready_cb(self, gcode, layer):
self.viz_last_layer = layer
def start_viz_thread(self, gcode = None):
threading.Thread(target = self.loadviz, args = (gcode,)).start()
def pre_gcode_load(self):
gcode = gcoder.GCode(deferred = True)
self.viz_last_layer = -1
threading.Thread(target = self.loadviz, args = (gcode,)).start()
self.start_viz_thread(gcode)
return gcode
def post_gcode_load(self, print_stats = True):
......@@ -1384,32 +1387,38 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
print _("- from %.2f mm to %.2f mm in Z and is %.2f mm high") % (gcode.zmin, gcode.zmax, gcode.height)
print _("Estimated duration: %d layers, %s") % gcode.estimate_duration()
def loadviz(self, gcode):
def loadviz(self, gcode = None):
self.gviz.clear()
self.gwindow.p.clear()
generator = self.gviz.addfile_perlayer(gcode, True)
next_layer = 0
# Progressive loading of visualization
# We load layers up to the last one which has been processed in GCoder
# (self.viz_last_layer)
# Once the GCode has been entirely loaded, this variable becomes None,
# indicating that we can do the last generator call to finish the
# loading of the visualization, which will itself return None.
# During preloading we verify that the layer we added is the one we
# expected through the assert call.
while True:
max_layer = self.viz_last_layer
if max_layer is None:
break
while next_layer <= max_layer:
assert(generator.next() == next_layer)
next_layer += 1
time.sleep(0.1)
generator_output = generator.next()
while generator_output is not None:
assert(generator_output in (None, next_layer))
next_layer += 1
if gcode is not None:
generator = self.gviz.addfile_perlayer(gcode, True)
next_layer = 0
# Progressive loading of visualization
# We load layers up to the last one which has been processed in GCoder
# (self.viz_last_layer)
# Once the GCode has been entirely loaded, this variable becomes None,
# indicating that we can do the last generator call to finish the
# loading of the visualization, which will itself return None.
# During preloading we verify that the layer we added is the one we
# expected through the assert call.
while True:
max_layer = self.viz_last_layer
if max_layer is None:
break
while next_layer <= max_layer:
assert(generator.next() == next_layer)
next_layer += 1
time.sleep(0.1)
generator_output = generator.next()
while generator_output is not None:
assert(generator_output in (None, next_layer))
next_layer += 1
generator_output = generator.next()
else:
# If GCode is not being loaded asynchroneously, it is already
# loaded, so let's make visualization sequentially
gcode = self.fgcode
self.gviz.addfile(gcode)
wx.CallAfter(self.gviz.Refresh)
# Load external window sequentially now that everything is ready.
# We can't really do any better as the 3D viewer might clone the
......
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