Commit eaa2a4c0 authored by Keegi's avatar Keegi

settings for bed size/grid lines

parent df051e60
import wx,time import wx,time
class window(wx.Frame): class window(wx.Frame):
def __init__(self,f,size=(600,600),bedsize=(200,200)): def __init__(self,f,size=(600,600),bedsize=(200,200),grid=(10,50)):
wx.Frame.__init__(self,None,title="Layer view (Use shift+mousewheel to switch layers)",size=(size[0],size[1])) wx.Frame.__init__(self,None,title="Layer view (Use shift+mousewheel to switch layers)",size=(size[0],size[1]))
self.p=gviz(self,size=size,bedsize=bedsize) self.p=gviz(self,size=size,bedsize=bedsize,grid=grid)
s=time.time() s=time.time()
for i in f: for i in f:
self.p.addgcode(i) self.p.addgcode(i)
...@@ -53,10 +53,11 @@ class window(wx.Frame): ...@@ -53,10 +53,11 @@ class window(wx.Frame):
elif z < 0: self.p.zoom(event.GetX(),event.GetY(),1/1.2) elif z < 0: self.p.zoom(event.GetX(),event.GetY(),1/1.2)
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),grid=(10,50)):
wx.Panel.__init__(self,parent,-1,size=(size[0],size[1])) wx.Panel.__init__(self,parent,-1,size=(size[0],size[1]))
self.size=size self.size=size
self.bedsize=bedsize self.bedsize=bedsize
self.grid=grid
self.lastpos=[0,0,0,0,0] self.lastpos=[0,0,0,0,0]
self.hilightpos=self.lastpos[:] self.hilightpos=self.lastpos[:]
self.Bind(wx.EVT_PAINT,self.paint) self.Bind(wx.EVT_PAINT,self.paint)
...@@ -126,14 +127,14 @@ class gviz(wx.Panel): ...@@ -126,14 +127,14 @@ class gviz(wx.Panel):
dc.SelectObject(self.blitmap) dc.SelectObject(self.blitmap)
dc.SetBackground(wx.Brush((250,250,200))) dc.SetBackground(wx.Brush((250,250,200)))
dc.Clear() dc.Clear()
dc.SetPen(wx.Pen(wx.Colour(100,100,100))) dc.SetPen(wx.Pen(wx.Colour(180,180,150)))
for i in xrange(max(self.bedsize)/10): for grid_unit in self.grid:
dc.DrawLine(self.translate[0],self.translate[1]+i*self.scale[1]*10,self.translate[0]+self.scale[0]*max(self.bedsize),self.translate[1]+i*self.scale[1]*10) if grid_unit > 0:
dc.DrawLine(self.translate[0]+i*self.scale[0]*10,self.translate[1],self.translate[0]+i*self.scale[0]*10,self.translate[1]+self.scale[1]*max(self.bedsize)) for x in xrange(int(self.bedsize[0]/grid_unit)+1):
dc.DrawLine(self.translate[0]+x*self.scale[0]*grid_unit,self.translate[1],self.translate[0]+x*self.scale[0]*grid_unit,self.translate[1]+self.scale[1]*max(self.bedsize))
for y in xrange(int(self.bedsize[1]/grid_unit)+1):
dc.DrawLine(self.translate[0],self.translate[1]+y*self.scale[1]*grid_unit,self.translate[0]+self.scale[0]*max(self.bedsize),self.translate[1]+y*self.scale[1]*grid_unit)
dc.SetPen(wx.Pen(wx.Colour(0,0,0))) dc.SetPen(wx.Pen(wx.Colour(0,0,0)))
for i in xrange(max(self.bedsize)/50):
dc.DrawLine(self.translate[0],self.translate[1]+i*self.scale[1]*50,self.translate[0]+self.scale[0]*max(self.bedsize),self.translate[1]+i*self.scale[1]*50)
dc.DrawLine(self.translate[0]+i*self.scale[0]*50,self.translate[1],self.translate[0]+i*self.scale[0]*50,self.translate[1]+self.scale[1]*max(self.bedsize))
if not self.showall: if not self.showall:
self.size = self.GetSize() self.size = self.GetSize()
dc.SetBrush(wx.Brush((43,144,255))) dc.SetBrush(wx.Brush((43,144,255)))
......
...@@ -45,6 +45,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -45,6 +45,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.settings.last_file_path = "" self.settings.last_file_path = ""
self.settings.last_temperature = 0.0 self.settings.last_temperature = 0.0
self.settings.last_bed_temperature = 0.0 self.settings.last_bed_temperature = 0.0
self.settings.bed_size_x = 200.
self.settings.bed_size_y = 200.
self.settings.preview_grid_step1 = 10.
self.settings.preview_grid_step2 = 50.
self.filename=filename self.filename=filename
os.putenv("UBUNTU_MENUPROXY","0") os.putenv("UBUNTU_MENUPROXY","0")
wx.Frame.__init__(self,None,title="Printer Interface",size=size); wx.Frame.__init__(self,None,title="Printer Interface",size=size);
...@@ -509,9 +513,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -509,9 +513,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.zfeedc.SetBackgroundColour((180,255,180)) self.zfeedc.SetBackgroundColour((180,255,180))
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,(300,300),(200,200)) self.gviz=gviz.gviz(self.panel,(300,300),
bedsize=(self.settings.bed_size_x,self.settings.bed_size_y),
grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2))
self.gviz.showall=1 self.gviz.showall=1
self.gwindow=gviz.window([]) self.gwindow=gviz.window([],
bedsize=(self.settings.bed_size_x,self.settings.bed_size_y),
grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2))
self.gviz.Bind(wx.EVT_LEFT_DOWN,self.showwin) self.gviz.Bind(wx.EVT_LEFT_DOWN,self.showwin)
self.gwindow.Bind(wx.EVT_CLOSE,lambda x:self.gwindow.Hide()) self.gwindow.Bind(wx.EVT_CLOSE,lambda x:self.gwindow.Hide())
cs=self.centersizer=wx.GridBagSizer() cs=self.centersizer=wx.GridBagSizer()
......
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