Commit 7c78d539 authored by Guillaume Seguin's avatar Guillaume Seguin

Merge branch 'experimental' of github.com:kliment/Printrun into experimental

parents dea306eb a6848356
......@@ -48,7 +48,7 @@ class XYZControlsSizer(wx.GridBagSizer):
def __init__(self, root):
super(XYZControlsSizer, self).__init__()
root.xyb = XYButtons(root.panel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.settings.bgcolor)
root.xyb = XYButtons(root.panel, root.moveXY, root.homeButtonClicked, root.spacebarAction, root.settings.bgcolor, zcallback=root.moveZ)
self.Add(root.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER)
root.zb = ZButtons(root.panel, root.moveZ, root.settings.bgcolor)
self.Add(root.zb, pos = (0, 2), flag = wx.ALIGN_CENTER)
......
......@@ -41,7 +41,7 @@ class XYButtons(BufferedCanvas):
center = (124, 121)
spacer = 7
def __init__(self, parent, moveCallback = None, cornerCallback = None, spacebarCallback = None, bgcolor = "#FFFFFF", ID=-1):
def __init__(self, parent, moveCallback = None, cornerCallback = None, spacebarCallback = None, bgcolor = "#FFFFFF", ID=-1, zcallback=None):
self.bg_bmp = wx.Image(imagefile("control_xy.png"), wx.BITMAP_TYPE_PNG).ConvertToBitmap()
self.keypad_bmp = wx.Image(imagefile("arrow_keys.png"), wx.BITMAP_TYPE_PNG).ConvertToBitmap()
self.keypad_idx = -1
......@@ -51,6 +51,7 @@ class XYButtons(BufferedCanvas):
self.moveCallback = moveCallback
self.cornerCallback = cornerCallback
self.spacebarCallback = spacebarCallback
self.zCallback = zcallback
self.enabled = False
# Remember the last clicked buttons, so we can repeat when spacebar pressed
self.lastMove = None
......@@ -108,10 +109,13 @@ class XYButtons(BufferedCanvas):
self.update()
def getMovement(self):
xdir = [1, 0, -1, 0][self.quadrant]
ydir = [0, 1, 0, -1][self.quadrant]
xdir = [1, 0, -1, 0, 0, 0][self.quadrant]
ydir = [0, 1, 0, -1, 0 ,0][self.quadrant]
zdir = [0, 0, 0, 0, 1 ,-1][self.quadrant]
magnitude = math.pow(10, self.concentric-1)
return (magnitude * xdir, magnitude * ydir)
if not zdir == 0:
magnitude=min(magnitude,10)
return (magnitude * xdir, magnitude * ydir, magnitude * zdir)
def lookupConcentric(self, radius):
idx = 0
......@@ -285,14 +289,21 @@ class XYButtons(BufferedCanvas):
self.quadrant = 2
elif evt.GetKeyCode() == wx.WXK_RIGHT:
self.quadrant = 0
elif evt.GetKeyCode() == wx.WXK_PAGEUP:
self.quadrant = 4
elif evt.GetKeyCode() == wx.WXK_PAGEDOWN:
self.quadrant = 5
else:
evt.Skip()
return
self.concentric = self.keypad_idx
x, y, z = self.getMovement()
if self.moveCallback:
self.concentric = self.keypad_idx
x, y = self.getMovement()
if x!=0 or y!=0 and self.moveCallback:
self.moveCallback(x, y)
if z!=0 and self.zCallback:
self.zCallback(z)
elif evt.GetKeyCode() == wx.WXK_SPACE:
self.spacebarCallback()
......@@ -346,7 +357,7 @@ class XYButtons(BufferedCanvas):
if self.concentric != None:
if self.concentric < len(XYButtons.concentric_circle_radii):
if self.quadrant != None:
x, y = self.getMovement()
x, y, z = self.getMovement()
if self.moveCallback:
self.lastMove = (x, y)
self.lastCorner = None
......
......@@ -1285,6 +1285,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if len(target):
self.recvlisteners+=[self.waitforsdresponse]
self.p.send_now("M23 "+target.lower())
dlg.Destroy()
#print self.sdfiles
def getfiles(self):
......@@ -1368,8 +1369,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
basedir = os.path.split(self.filename)[0]
except:
pass
dlg = wx.FileDialog(self, _("Open file to print"), basedir, style = wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard(_("OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*"))
dlg=None
if filename is None:
dlg = wx.FileDialog(self, _("Open file to print"), basedir, style = wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard(_("OBJ, STL, and GCODE files (*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ)|*.gcode;*.gco;*.g;*.stl;*.STL;*.obj;*.OBJ|All Files (*.*)|*.*"))
if(filename is not None or dlg.ShowModal() == wx.ID_OK):
if filename is not None:
name = filename
......@@ -1377,6 +1380,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
name = dlg.GetPath()
if not(os.path.exists(name)):
self.status.SetStatusText(_("File not found!"))
if dlg is not None:
dlg.Destroy()
return
path = os.path.split(name)[0]
if path != self.settings.last_file_path:
......@@ -1397,6 +1402,8 @@ class PronterWindow(MainWindow, pronsole.pronsole):
if self.p.online:
wx.CallAfter(self.printbtn.Enable)
threading.Thread(target = self.loadviz).start()
if dlg is not None:
dlg.Destroy()
def loadviz(self):
gcode = self.fgcode
......@@ -1464,6 +1471,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.send_now("M21")
self.p.send_now("M28 "+str(dlg.GetValue()))
self.recvlisteners+=[self.uploadtrigger]
dlg.Destroy()
def pause(self, event):
print _("Paused.")
......@@ -1600,6 +1608,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.p.paused = 0
wx.CallAfter(self.pausebtn.SetLabel, _("Pause"))
self.paused = 0
dlg.Destroy()
class PronterApp(wx.App):
......
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