Commit 48b981f2 authored by kliment's avatar kliment

Bigger gcode visualization window on click, layer progress bar

parent f69de94a
import wx,time import wx,time
class window(wx.Frame): class window(wx.Frame):
def __init__(self): def __init__(self,f,size=(600,600),bedsize=(200,200)):
wx.Frame.__init__(self,None,title="Slicetest",size=(600,600)) wx.Frame.__init__(self,None,title="Slicetest",size=(size[0],size[1]))
self.p=gviz(self,size=(600,600),bedsize=(200,200)) self.p=gviz(self,size=size,bedsize=bedsize)
s=time.time() s=time.time()
for i in open("/home/kliment/designs/spinner/gearend_export.gcode"): for i in f:
self.p.addgcode(i) self.p.addgcode(i)
print time.time()-s #print time.time()-s
self.p.Bind(wx.EVT_KEY_DOWN,self.key) self.p.Bind(wx.EVT_KEY_DOWN,self.key)
def key(self, event): def key(self, event):
x=event.GetKeyCode() x=event.GetKeyCode()
...@@ -21,7 +21,8 @@ class window(wx.Frame): ...@@ -21,7 +21,8 @@ class window(wx.Frame):
class gviz(wx.Panel): class gviz(wx.Panel):
def __init__(self,parent,size=(200,200),bedsize=(200,200)): def __init__(self,parent,size=(200,200),bedsize=(200,200)):
wx.Panel.__init__(self,parent,-1,size=size) wx.Panel.__init__(self,parent,-1,size=(size[0],size[1]))
self.size=size
self.bedsize=bedsize self.bedsize=bedsize
self.lastpos=[0,0,0,0,0] self.lastpos=[0,0,0,0,0]
self.hilightpos=self.lastpos[:] self.hilightpos=self.lastpos[:]
...@@ -69,6 +70,11 @@ class gviz(wx.Panel): ...@@ -69,6 +70,11 @@ class gviz(wx.Panel):
dc=wx.PaintDC(self) dc=wx.PaintDC(self)
dc.SetBackground(wx.Brush((250,250,200))) dc.SetBackground(wx.Brush((250,250,200)))
dc.Clear() dc.Clear()
dc.SetBrush(wx.Brush((0,0,0)))
dc.DrawRectangle(self.size[0]-15,0,15,self.size[1])
dc.SetBrush(wx.Brush((0,255,0)))
if len(self.layers):
dc.DrawRectangle(self.size[0]-14,(1.0-(1.0*self.layerindex)/len(self.layers))*self.size[1],13,self.size[1]-1)
if self.showall: if self.showall:
l=[] l=[]
for i in self.layers: for i in self.layers:
...@@ -87,10 +93,6 @@ class gviz(wx.Panel): ...@@ -87,10 +93,6 @@ class gviz(wx.Panel):
dc.DrawLineList(l,self.hlpen) dc.DrawLineList(l,self.hlpen)
del dc del dc
def showall(self,v):
self.showall=v
self.Refresh()
def addgcode(self,gcode="M105",hilight=0): def addgcode(self,gcode="M105",hilight=0):
gcode=gcode.split("*")[0] gcode=gcode.split("*")[0]
if "g1" in gcode.lower(): if "g1" in gcode.lower():
...@@ -126,7 +128,7 @@ class gviz(wx.Panel): ...@@ -126,7 +128,7 @@ class gviz(wx.Panel):
if __name__ == '__main__': if __name__ == '__main__':
app = wx.App(False) app = wx.App(False)
main = window() main = window(open("/home/kliment/designs/spinner/gearend_export.gcode"))
main.Show() main.Show()
app.MainLoop() app.MainLoop()
...@@ -7,16 +7,12 @@ except: ...@@ -7,16 +7,12 @@ except:
import printcore, os, sys, glob, time, threading, traceback, StringIO, gviz import printcore, os, sys, glob, time, threading, traceback, StringIO, gviz
thread=threading.Thread thread=threading.Thread
winsize=(800,500) winsize=(800,500)
winssize=(800,120)
if os.name=="nt": if os.name=="nt":
winsize=(800,530) winsize=(800,530)
winssize=(800,140)
try: try:
import _winreg import _winreg
except: except:
pass pass
if sys.platform=="darwin":
winssize=(800,110)
import pronsole import pronsole
...@@ -112,6 +108,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -112,6 +108,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
except: except:
pass pass
self.gviz.addgcode(line,hilight=1) self.gviz.addgcode(line,hilight=1)
self.gwindow.p.addgcode(line,hilight=1)
def do_extrude(self,l=""): def do_extrude(self,l=""):
try: try:
...@@ -333,6 +330,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -333,6 +330,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.zfeedc.SetForegroundColour("black") self.zfeedc.SetForegroundColour("black")
lls.Add((10,0),pos=(0,11),span=(1,1)) lls.Add((10,0),pos=(0,11),span=(1,1))
self.gviz=gviz.gviz(self.panel,(200,200),(200,200)) self.gviz=gviz.gviz(self.panel,(200,200),(200,200))
self.gwindow=gviz.window([])
self.gviz.Bind(wx.EVT_LEFT_DOWN,self.showwin)
self.gwindow.Bind(wx.EVT_CLOSE,lambda x:self.gwindow.Hide())
lls.Add(self.gviz,pos=(0,10),span=(9,1)) lls.Add(self.gviz,pos=(0,10),span=(9,1))
self.uppersizer=wx.BoxSizer(wx.VERTICAL) self.uppersizer=wx.BoxSizer(wx.VERTICAL)
...@@ -355,8 +355,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -355,8 +355,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#self.panel.Fit() #self.panel.Fit()
#uts.Layout() #uts.Layout()
def showwin(self,event):
pass self.gwindow.Show()
def setfeeds(self,e): def setfeeds(self,e):
try: try:
...@@ -400,6 +400,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -400,6 +400,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.statuscheck=0 self.statuscheck=0
self.p.recvcb=None self.p.recvcb=None
self.p.disconnect() self.p.disconnect()
try:
self.gwindow.Destroy()
except:
pass
self.Destroy() self.Destroy()
...@@ -595,6 +599,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -595,6 +599,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.gviz.clear() self.gviz.clear()
for i in self.f: for i in self.f:
self.gviz.addgcode(i) self.gviz.addgcode(i)
self.gwindow.p.addgcode(i)
self.gviz.showall=1 self.gviz.showall=1
wx.CallAfter(self.gviz.Refresh) wx.CallAfter(self.gviz.Refresh)
......
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