Commit 48b981f2 authored by kliment's avatar kliment

Bigger gcode visualization window on click, layer progress bar

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