Commit 7c310d7b authored by Duane Johnson's avatar Duane Johnson

Shrunk XY and Z controls. Added Home buttons. Added enable/disable.

parent b0cd17ee
images/control_xy.png

58.5 KB | W: | H:

images/control_xy.png

61.7 KB | W: | H:

images/control_xy.png
images/control_xy.png
images/control_xy.png
images/control_xy.png
  • 2-up
  • Swipe
  • Onion skin
images/control_z.png

10.7 KB | W: | H:

images/control_z.png

8.46 KB | W: | H:

images/control_z.png
images/control_z.png
images/control_z.png
images/control_z.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -82,12 +82,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
[_("Extrude"),("extrude"),(5,0),(225,200,200),(1,2)],
[_("Reverse"),("reverse"),(6,0),(225,200,200),(1,2)],
]
self.absbuttons=[
[_("Home"),("home"),(0,380),(250,250,250),(1,2)],
[_("HomeX"),("home X"),(0,100),(205,205,78),(1,2)],
[_("HomeY"),("home Y"),(270, 100),(150,150,205),(1,2)],
[_("HomeZ"),("home Z"),(270, 380),(150,205,150),(1,2)],
]
self.custombuttons=[]
self.btndict={}
self.parse_cmdline(sys.argv[1:])
......@@ -139,6 +133,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.connectbtn.Disable)
for i in self.printerControls:
wx.CallAfter(i.Enable)
self.xyb.enable()
self.zb.enable()
if self.filename:
wx.CallAfter(self.printbtn.Enable)
......@@ -461,21 +457,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#lls.Add((200,375))
xyb = XYButtons(self.panel, self.moveXY)
lls.Add(xyb, pos=(2,0), span=(1,6), flag=wx.ALIGN_CENTER)
zb = ZButtons(self.panel, self.moveZ)
lls.Add(zb, pos=(2,7), span=(1,2), flag=wx.ALIGN_CENTER)
wx.CallAfter(xyb.SetFocus)
# Absolute-positioned Home buttons that cover the XYButtons control
for i in self.absbuttons:
btn=wx.Button(self.panel,-1,i[0],pos=i[2])
btn.SetBackgroundColour(i[3])
btn.SetForegroundColour("black")
btn.properties=i
btn.Bind(wx.EVT_BUTTON,self.procbutton)
self.btndict[i[1]]=btn
self.printerControls.append(btn)
self.xyb = XYButtons(self.panel, self.moveXY, self.homeButtonClicked)
lls.Add(self.xyb, pos=(2,0), span=(1,6), flag=wx.ALIGN_CENTER)
self.zb = ZButtons(self.panel, self.moveZ)
lls.Add(self.zb, pos=(2,7), span=(1,2), flag=wx.ALIGN_CENTER)
wx.CallAfter(self.xyb.SetFocus)
for i in self.cpbuttons:
btn=wx.Button(self.panel,-1,i[0])#,size=(60,-1))
......@@ -894,6 +880,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
else:
e.Skip()
def homeButtonClicked(self, corner):
if corner == 0: # upper-left
self.onecmd('home X')
if corner == 1: # upper-right
self.onecmd('home Y')
if corner == 2: # lower-right
self.onecmd('home Z')
if corner == 3: # lower-left
self.onecmd('home')
def moveXY(self, x, y):
if x != 0:
self.onecmd('move X %s' % x)
......@@ -904,9 +900,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if z != 0:
self.onecmd('move Z %s' % z)
def home(self):
self.onecmd('home')
def procbutton(self,e):
try:
if hasattr(e.GetEventObject(),"custombutton"):
......
This diff is collapsed.
......@@ -10,8 +10,8 @@ def sign(n):
else: return 0
class ZButtons(BufferedCanvas):
button_ydistances = [8, 30, 56, 84, 118]
center = (32, 146)
button_ydistances = [7, 30, 55, 83, 112]
center = (30, 118)
def __init__(self, parent, moveCallback=None, ID=-1):
self.bg_bmp = wx.Image(imagefile("control_z.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap()
......@@ -19,10 +19,11 @@ class ZButtons(BufferedCanvas):
self.direction = None
self.orderOfMagnitudeIdx = 0 # 0 means '1', 1 means '10', 2 means '100', etc.
self.moveCallback = moveCallback
self.enabled = False
BufferedCanvas.__init__(self, parent, ID)
self.SetSize(wx.Size(87, 295))
self.SetSize(wx.Size(59, 244))
# Set up mouse and keyboard event capture
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
......@@ -30,6 +31,12 @@ class ZButtons(BufferedCanvas):
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
def disable(self):
self.enabled = False
def enable(self):
self.enabled = True
def lookupRange(self, ydist):
idx = -1
for d in ZButtons.button_ydistances:
......@@ -44,7 +51,7 @@ class ZButtons(BufferedCanvas):
fudge = 11
x = 0 + fudge
w = 72 - fudge*2
w = 59 - fudge*2
if rng >= 0:
k = 1 if dir > 0 else 0
y = ZButtons.center[1] - (dir * ZButtons.button_ydistances[rng+k])
......@@ -57,7 +64,32 @@ class ZButtons(BufferedCanvas):
ydelta = ZButtons.center[1] - pos[1]
return (self.lookupRange(abs(ydelta)), sign(ydelta))
def draw(self, dc, w, h):
dc.Clear()
gc = wx.GraphicsContext.Create(dc)
w, h = (self.bg_bmp.GetWidth(), self.bg_bmp.GetHeight())
gc.DrawBitmap(self.bg_bmp, 0, 0, w, h)
if self.enabled:
gc.SetPen(wx.Pen(wx.Colour(100,100,100,172), 4))
gc.SetBrush(wx.Brush(wx.Colour(0,0,0,128)))
if self.range != None and self.direction != None:
self.highlight(gc, self.range, self.direction)
else:
gc.SetPen(wx.Pen(wx.Colour(255,255,255,0), 4))
gc.SetBrush(wx.Brush(wx.Colour(255,255,255,128)))
gc.DrawRectangle(0, 0, w, h)
## ------ ##
## Events ##
## ------ ##
def OnMotion(self, event):
if not self.enabled:
return
oldr, oldd = self.range, self.direction
mpos = event.GetPosition()
......@@ -67,6 +99,9 @@ class ZButtons(BufferedCanvas):
self.update()
def OnLeftDown(self, event):
if not self.enabled:
return
mpos = event.GetPosition()
r, d = self.getRangeDir(mpos)
if r >= 0:
......@@ -78,17 +113,3 @@ class ZButtons(BufferedCanvas):
self.range = None
self.direction = None
self.update()
def draw(self, dc, w, h):
dc.Clear()
gc = wx.GraphicsContext.Create(dc)
gc.SetPen(wx.Pen(wx.Colour(100,100,100,172), 4))
gc.SetBrush(wx.Brush(wx.Colour(0,0,0,128)))
gc.DrawBitmap(self.bg_bmp, 0, 0, self.bg_bmp.GetWidth(), self.bg_bmp.GetHeight())
if self.range != None and self.direction != None:
self.highlight(gc, self.range, self.direction)
return True
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