Commit 62e31e73 authored by Guillaume Seguin's avatar Guillaume Seguin

Refresh 2D view every 0.2s during viz loading

parent e2b25795
......@@ -16,6 +16,7 @@
from Queue import Queue
from collections import deque
import wx
import time
from printrun import gcoder
from printrun_utils import imagefile, install_locale
......@@ -380,8 +381,9 @@ class Gviz(wx.Panel):
if self.paint_overlay:
self.paint_overlay(dc)
def addfile(self, gcode):
def addfile(self, gcode, showall = False):
self.clear()
self.showall = showall
self.add_parsed_gcodes(gcode)
max_layers = len(self.layers)
if hasattr(self.parent, "layerslider"):
......@@ -399,6 +401,8 @@ class Gviz(wx.Panel):
def _x(x):
return x - self.build_dimensions[3]
start_time = time.time()
for layer_idx, layer in enumerate(gcode.all_layers):
has_move = False
for gline in layer:
......@@ -411,7 +415,6 @@ class Gviz(wx.Panel):
self.pens[layer.z] = []
self.arcs[layer.z] = []
self.arcpens[layer.z] = []
self.layers.append(layer.z)
for gline in layer:
if not gline.is_move:
continue
......@@ -448,8 +451,16 @@ class Gviz(wx.Panel):
self.arcpens[layer.z].append(self.arcpen)
self.lastpos = target
# Only add layer.z to self.layers now to prevent the display of an
# unfinished layer
self.layers.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
self.Refresh()
wx.CallAfter(self.Refresh)
self.dirty = 1
wx.CallAfter(self.Refresh)
def addgcode(self, gcode = "M105", hilight = 0):
gcode = gcode.split("*")[0]
......@@ -519,7 +530,7 @@ class Gviz(wx.Panel):
self.dirty = 1
else:
self.hilightpos = target
self.Refresh()
wx.CallAfter(self.Refresh)
if __name__ == '__main__':
import sys
......
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