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): ...@@ -82,12 +82,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
[_("Extrude"),("extrude"),(5,0),(225,200,200),(1,2)], [_("Extrude"),("extrude"),(5,0),(225,200,200),(1,2)],
[_("Reverse"),("reverse"),(6,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.custombuttons=[]
self.btndict={} self.btndict={}
self.parse_cmdline(sys.argv[1:]) self.parse_cmdline(sys.argv[1:])
...@@ -139,6 +133,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -139,6 +133,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
wx.CallAfter(self.connectbtn.Disable) wx.CallAfter(self.connectbtn.Disable)
for i in self.printerControls: for i in self.printerControls:
wx.CallAfter(i.Enable) wx.CallAfter(i.Enable)
self.xyb.enable()
self.zb.enable()
if self.filename: if self.filename:
wx.CallAfter(self.printbtn.Enable) wx.CallAfter(self.printbtn.Enable)
...@@ -461,22 +457,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -461,22 +457,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#lls.Add((200,375)) #lls.Add((200,375))
xyb = XYButtons(self.panel, self.moveXY) self.xyb = XYButtons(self.panel, self.moveXY, self.homeButtonClicked)
lls.Add(xyb, pos=(2,0), span=(1,6), flag=wx.ALIGN_CENTER) lls.Add(self.xyb, pos=(2,0), span=(1,6), flag=wx.ALIGN_CENTER)
zb = ZButtons(self.panel, self.moveZ) self.zb = ZButtons(self.panel, self.moveZ)
lls.Add(zb, pos=(2,7), span=(1,2), flag=wx.ALIGN_CENTER) lls.Add(self.zb, pos=(2,7), span=(1,2), flag=wx.ALIGN_CENTER)
wx.CallAfter(xyb.SetFocus) wx.CallAfter(self.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)
for i in self.cpbuttons: for i in self.cpbuttons:
btn=wx.Button(self.panel,-1,i[0])#,size=(60,-1)) btn=wx.Button(self.panel,-1,i[0])#,size=(60,-1))
btn.SetBackgroundColour(i[3]) btn.SetBackgroundColour(i[3])
...@@ -894,6 +880,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -894,6 +880,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
else: else:
e.Skip() 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): def moveXY(self, x, y):
if x != 0: if x != 0:
self.onecmd('move X %s' % x) self.onecmd('move X %s' % x)
...@@ -903,10 +899,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -903,10 +899,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def moveZ(self, z): def moveZ(self, z):
if z != 0: if z != 0:
self.onecmd('move Z %s' % z) self.onecmd('move Z %s' % z)
def home(self):
self.onecmd('home')
def procbutton(self,e): def procbutton(self,e):
try: try:
if hasattr(e.GetEventObject(),"custombutton"): if hasattr(e.GetEventObject(),"custombutton"):
......
This diff is collapsed.
...@@ -10,8 +10,8 @@ def sign(n): ...@@ -10,8 +10,8 @@ def sign(n):
else: return 0 else: return 0
class ZButtons(BufferedCanvas): class ZButtons(BufferedCanvas):
button_ydistances = [8, 30, 56, 84, 118] button_ydistances = [7, 30, 55, 83, 112]
center = (32, 146) center = (30, 118)
def __init__(self, parent, moveCallback=None, ID=-1): def __init__(self, parent, moveCallback=None, ID=-1):
self.bg_bmp = wx.Image(imagefile("control_z.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.bg_bmp = wx.Image(imagefile("control_z.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap()
...@@ -19,10 +19,11 @@ class ZButtons(BufferedCanvas): ...@@ -19,10 +19,11 @@ class ZButtons(BufferedCanvas):
self.direction = None self.direction = None
self.orderOfMagnitudeIdx = 0 # 0 means '1', 1 means '10', 2 means '100', etc. self.orderOfMagnitudeIdx = 0 # 0 means '1', 1 means '10', 2 means '100', etc.
self.moveCallback = moveCallback self.moveCallback = moveCallback
self.enabled = False
BufferedCanvas.__init__(self, parent, ID) BufferedCanvas.__init__(self, parent, ID)
self.SetSize(wx.Size(87, 295)) self.SetSize(wx.Size(59, 244))
# Set up mouse and keyboard event capture # Set up mouse and keyboard event capture
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
...@@ -30,6 +31,12 @@ class ZButtons(BufferedCanvas): ...@@ -30,6 +31,12 @@ class ZButtons(BufferedCanvas):
self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
def disable(self):
self.enabled = False
def enable(self):
self.enabled = True
def lookupRange(self, ydist): def lookupRange(self, ydist):
idx = -1 idx = -1
for d in ZButtons.button_ydistances: for d in ZButtons.button_ydistances:
...@@ -44,7 +51,7 @@ class ZButtons(BufferedCanvas): ...@@ -44,7 +51,7 @@ class ZButtons(BufferedCanvas):
fudge = 11 fudge = 11
x = 0 + fudge x = 0 + fudge
w = 72 - fudge*2 w = 59 - fudge*2
if rng >= 0: if rng >= 0:
k = 1 if dir > 0 else 0 k = 1 if dir > 0 else 0
y = ZButtons.center[1] - (dir * ZButtons.button_ydistances[rng+k]) y = ZButtons.center[1] - (dir * ZButtons.button_ydistances[rng+k])
...@@ -57,7 +64,32 @@ class ZButtons(BufferedCanvas): ...@@ -57,7 +64,32 @@ class ZButtons(BufferedCanvas):
ydelta = ZButtons.center[1] - pos[1] ydelta = ZButtons.center[1] - pos[1]
return (self.lookupRange(abs(ydelta)), sign(ydelta)) 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): def OnMotion(self, event):
if not self.enabled:
return
oldr, oldd = self.range, self.direction oldr, oldd = self.range, self.direction
mpos = event.GetPosition() mpos = event.GetPosition()
...@@ -67,6 +99,9 @@ class ZButtons(BufferedCanvas): ...@@ -67,6 +99,9 @@ class ZButtons(BufferedCanvas):
self.update() self.update()
def OnLeftDown(self, event): def OnLeftDown(self, event):
if not self.enabled:
return
mpos = event.GetPosition() mpos = event.GetPosition()
r, d = self.getRangeDir(mpos) r, d = self.getRangeDir(mpos)
if r >= 0: if r >= 0:
...@@ -78,17 +113,3 @@ class ZButtons(BufferedCanvas): ...@@ -78,17 +113,3 @@ class ZButtons(BufferedCanvas):
self.range = None self.range = None
self.direction = None self.direction = None
self.update() 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