Use a deque instead of a list to store hilighted lines

This might speed up Pronterface while printing.
Indeed, as we keep adding items we keep expanding the list and Python has to
move it all the time.
master
Guillaume Seguin 2013-05-19 13:13:03 +02:00
parent c5de6439e0
commit 75afa014e3
2 changed files with 8 additions and 5 deletions

View File

@ -12,7 +12,9 @@
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import wx, time
from collections import deque
from printrun import gcoder
from printrun_utils import imagefile
@ -151,8 +153,8 @@ class gviz(wx.Panel):
self.fades = [wx.Pen(wx.Colour(250-0.6**i*100, 250-0.6**i*100, 200-0.4**i*50), penwidth) for i in xrange(6)]
self.penslist = [self.mainpen, self.travelpen, self.hlpen]+self.fades
self.showall = 0
self.hilight = []
self.hilightarcs = []
self.hilight = deque()
self.hilightarcs = deque()
self.dirty = 1
self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0], self.GetClientSize()[1],-1)
@ -168,8 +170,8 @@ class gviz(wx.Panel):
self.arcs = {}
self.arcpens = {}
self.layers = []
self.hilight = []
self.hilightarcs = []
self.hilight.clear()
self.hilightarcs.clear()
self.layerindex = 0
self.showall = 0
self.dirty = 1

View File

@ -251,7 +251,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
layer = float(line.split("Z")[1].split()[0].split("*")[0])
if layer != self.curlayer:
self.curlayer = layer
self.gviz.hilight = []
self.gviz.hilight.clear()
self.gviz.hilightarcs.clear()
threading.Thread(target = wx.CallAfter, args = (self.gviz.setlayer, layer)).start()
except:
pass