Commit 5b4b84d8 authored by Clarence Risher's avatar Clarence Risher

add bed center coordinate option, sort options in dialog

parent d9193e44
import wx,time import wx,time
class window(wx.Frame): class window(wx.Frame):
def __init__(self,f,size=(600,600),bedsize=(200,200),grid=(10,50),extrusion_width=0.5): def __init__(self,f,size=(600,600),bedsize=(200,200),center=(100,100),grid=(10,50),extrusion_width=0.5):
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,grid=grid,extrusion_width=extrusion_width) self.p=gviz(self,size=size,bedsize=bedsize,center=center,grid=grid,extrusion_width=extrusion_width)
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),grid=(10,50),extrusion_width=0.5): def __init__(self,parent,size=(200,200),bedsize=(200,200),center=(100,100),grid=(10,50),extrusion_width=0.5):
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.center=center
self.grid=grid self.grid=grid
self.lastpos=[0,0,0,0,0,0,0] self.lastpos=[0,0,0,0,0,0,0]
self.hilightpos=self.lastpos[:] self.hilightpos=self.lastpos[:]
...@@ -236,13 +237,15 @@ class gviz(wx.Panel): ...@@ -236,13 +237,15 @@ class gviz(wx.Panel):
return target return target
def _y(y): def _y(y):
return self.bedsize[1]-y return self.bedsize[1]-(y+(self.bedsize[0]/2-self.center[0]))
def _x(x):
return x+(self.bedsize[0]/2-self.center[0])
start_pos = self.hilightpos[:] if hilight else self.lastpos[:] start_pos = self.hilightpos[:] if hilight else self.lastpos[:]
if gcode[0] == "g1": if gcode[0] == "g1":
target = _readgcode() target = _readgcode()
line = [ start_pos[0], _y(start_pos[1]), target[0], _y(target[1]) ] line = [ _x(start_pos[0]), _y(start_pos[1]), _x(target[0]), _y(target[1]) ]
if not hilight: if not hilight:
self.lines[ target[2] ] += [line] self.lines[ target[2] ] += [line]
self.pens[ target[2] ] += [self.mainpen if target[3] != self.lastpos[3] else self.travelpen] self.pens[ target[2] ] += [self.mainpen if target[3] != self.lastpos[3] else self.travelpen]
...@@ -255,9 +258,9 @@ class gviz(wx.Panel): ...@@ -255,9 +258,9 @@ class gviz(wx.Panel):
if gcode[0] in [ "g2", "g3" ]: if gcode[0] in [ "g2", "g3" ]:
target = _readgcode() target = _readgcode()
arc = [] arc = []
arc += [ start_pos[0], _y(start_pos[1]) ] arc += [ _x(start_pos[0]), _y(start_pos[1]) ]
arc += [ target[0], _y(target[1]) ] arc += [ _x(target[0]), _y(target[1]) ]
arc += [ start_pos[0] + target[5], _y(start_pos[1] + target[6]) ] # center arc += [ _x(start_pos[0] + target[5]), _y(start_pos[1] + target[6]) ] # center
if gcode[0] == "g2": # clockwise, reverse endpoints if gcode[0] == "g2": # clockwise, reverse endpoints
arc[0], arc[1], arc[2], arc[3] = arc[2], arc[3], arc[0], arc[1] arc[0], arc[1], arc[2], arc[3] = arc[2], arc[3], arc[0], arc[1]
......
...@@ -59,6 +59,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -59,6 +59,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.settings.last_bed_temperature = 0.0 self.settings.last_bed_temperature = 0.0
self.settings.bed_size_x = 200. self.settings.bed_size_x = 200.
self.settings.bed_size_y = 200. self.settings.bed_size_y = 200.
self.settings.bed_center_x = 100.
self.settings.bed_center_y = 100.
self.settings.preview_grid_step1 = 10. self.settings.preview_grid_step1 = 10.
self.settings.preview_grid_step2 = 50. self.settings.preview_grid_step2 = 50.
self.settings.preview_extrusion_width = 0.5 self.settings.preview_extrusion_width = 0.5
...@@ -610,11 +612,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -610,11 +612,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
# 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), self.gviz=gviz.gviz(self.panel,(300,300),
bedsize=(self.settings.bed_size_x,self.settings.bed_size_y), bedsize=(self.settings.bed_size_x,self.settings.bed_size_y),
center=(self.settings.bed_center_x,self.settings.bed_center_y),
grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2), grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2),
extrusion_width=self.settings.preview_extrusion_width) extrusion_width=self.settings.preview_extrusion_width)
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), bedsize=(self.settings.bed_size_x,self.settings.bed_size_y),
center=(self.settings.bed_center_x,self.settings.bed_center_y),
grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2), grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2),
extrusion_width=self.settings.preview_extrusion_width) extrusion_width=self.settings.preview_extrusion_width)
self.gviz.Bind(wx.EVT_LEFT_DOWN,self.showwin) self.gviz.Bind(wx.EVT_LEFT_DOWN,self.showwin)
...@@ -1539,7 +1543,7 @@ class options(wx.Dialog): ...@@ -1539,7 +1543,7 @@ class options(wx.Dialog):
grid=wx.GridSizer(rows=0,cols=2,hgap=8,vgap=2) grid=wx.GridSizer(rows=0,cols=2,hgap=8,vgap=2)
vbox.Add(grid,0,wx.EXPAND) vbox.Add(grid,0,wx.EXPAND)
ctrls = {} ctrls = {}
for k,v in pronterface.settings._all_settings().items(): for k,v in sorted(pronterface.settings._all_settings().items(), key=lambda item: item[0]):
grid.Add(wx.StaticText(self,-1,k),0,wx.BOTTOM+wx.RIGHT) grid.Add(wx.StaticText(self,-1,k),0,wx.BOTTOM+wx.RIGHT)
ctrls[k] = wx.TextCtrl(self,-1,str(v)) ctrls[k] = wx.TextCtrl(self,-1,str(v))
grid.Add(ctrls[k],1,wx.EXPAND) grid.Add(ctrls[k],1,wx.EXPAND)
......
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