Commit 75afa014 authored by Guillaume Seguin's avatar Guillaume Seguin

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.
parent c5de6439
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>. # along with Printrun. If not, see <http://www.gnu.org/licenses/>.
import wx, time import wx, time
from collections import deque
from printrun import gcoder from printrun import gcoder
from printrun_utils import imagefile from printrun_utils import imagefile
...@@ -151,8 +153,8 @@ class gviz(wx.Panel): ...@@ -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.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.penslist = [self.mainpen, self.travelpen, self.hlpen]+self.fades
self.showall = 0 self.showall = 0
self.hilight = [] self.hilight = deque()
self.hilightarcs = [] self.hilightarcs = deque()
self.dirty = 1 self.dirty = 1
self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0], self.GetClientSize()[1],-1) self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0], self.GetClientSize()[1],-1)
...@@ -168,8 +170,8 @@ class gviz(wx.Panel): ...@@ -168,8 +170,8 @@ class gviz(wx.Panel):
self.arcs = {} self.arcs = {}
self.arcpens = {} self.arcpens = {}
self.layers = [] self.layers = []
self.hilight = [] self.hilight.clear()
self.hilightarcs = [] self.hilightarcs.clear()
self.layerindex = 0 self.layerindex = 0
self.showall = 0 self.showall = 0
self.dirty = 1 self.dirty = 1
......
...@@ -251,7 +251,8 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -251,7 +251,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
layer = float(line.split("Z")[1].split()[0].split("*")[0]) layer = float(line.split("Z")[1].split()[0].split("*")[0])
if layer != self.curlayer: if layer != self.curlayer:
self.curlayer = layer 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() threading.Thread(target = wx.CallAfter, args = (self.gviz.setlayer, layer)).start()
except: except:
pass pass
......
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