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,9 +1387,10 @@ 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()
if gcode is not None:
generator = self.gviz.addfile_perlayer(gcode, True)
next_layer = 0
# Progressive loading of visualization
......@@ -1410,6 +1414,11 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
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