Skip to content

Commit

Permalink
Bigger gcode visualization window on click, layer progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
kliment committed Jun 22, 2011
1 parent f69de94 commit 48b981f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
24 changes: 13 additions & 11 deletions gviz.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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()
Expand All @@ -21,7 +21,8 @@ def key(self, event):

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[:]
Expand Down Expand Up @@ -69,6 +70,11 @@ def paint(self,event):
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:
Expand All @@ -87,10 +93,6 @@ def paint(self,event):
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():
Expand Down Expand Up @@ -126,7 +128,7 @@ def addgcode(self,gcode="M105",hilight=0):

if __name__ == '__main__':
app = wx.App(False)
main = window()
main = window(open("/home/kliment/designs/spinner/gearend_export.gcode"))
main.Show()
app.MainLoop()

17 changes: 11 additions & 6 deletions pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
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
Expand Down Expand Up @@ -112,6 +108,7 @@ def sentcb(self,line):
except:
pass
self.gviz.addgcode(line,hilight=1)
self.gwindow.p.addgcode(line,hilight=1)

def do_extrude(self,l=""):
try:
Expand Down Expand Up @@ -333,6 +330,9 @@ def popwindow(self):
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)
Expand All @@ -355,8 +355,8 @@ def popwindow(self):
#self.panel.Fit()
#uts.Layout()

pass
def showwin(self,event):
self.gwindow.Show()

def setfeeds(self,e):
try:
Expand Down Expand Up @@ -400,6 +400,10 @@ def kill(self,e):
self.statuscheck=0
self.p.recvcb=None
self.p.disconnect()
try:
self.gwindow.Destroy()
except:
pass
self.Destroy()


Expand Down Expand Up @@ -595,6 +599,7 @@ def loadviz(self):
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)

Expand Down

0 comments on commit 48b981f

Please sign in to comment.