Commit ab76f94d authored by Guillaume Seguin's avatar Guillaume Seguin

Heavily decrease CPU usage of stlview by removing Refresh thread

parent 95316691
...@@ -144,7 +144,6 @@ class StlViewPanel(wxGLPanel): ...@@ -144,7 +144,6 @@ class StlViewPanel(wxGLPanel):
def forceresize(self): def forceresize(self):
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] + 1)) self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] + 1))
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] - 1)) self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] - 1))
threading.Thread(target = self.update).start()
self.initialized = 0 self.initialized = 0
def move_shape(self, delta): def move_shape(self, delta):
...@@ -249,6 +248,7 @@ class StlViewPanel(wxGLPanel): ...@@ -249,6 +248,7 @@ class StlViewPanel(wxGLPanel):
self.zoom(factor, (x, y)) self.zoom(factor, (x, y))
else: else:
self.zoom(1 / factor, (x, y)) self.zoom(1 / factor, (x, y))
wx.CallAfter(self.Refresh)
def keypress(self, event): def keypress(self, event):
"""gets keypress events and moves/rotates acive shape""" """gets keypress events and moves/rotates acive shape"""
...@@ -278,14 +278,7 @@ class StlViewPanel(wxGLPanel): ...@@ -278,14 +278,7 @@ class StlViewPanel(wxGLPanel):
if keycode == 93: if keycode == 93:
self.rotate_shape(angle) self.rotate_shape(angle)
event.Skip() event.Skip()
def update(self):
while True:
time.sleep(0.05)
try:
wx.CallAfter(self.Refresh) wx.CallAfter(self.Refresh)
except:
return
def anim(self, obj): def anim(self, obj):
g = 50 * 9.8 g = 50 * 9.8
......
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