Commit 0603d9c7 authored by kliment's avatar kliment

Merge pull request #220 from jezmy/experimental

Fix print button, add tooltips, add icons to layer preview
parents e9d686a5 a49194a1
......@@ -20,26 +20,52 @@ class window(wx.Frame):
wx.Frame.__init__(self,None,title="Gcode view, shift to move view, mousewheel to set layer",size=(size[0],size[1]))
self.p=gviz(self,size=size,build_dimensions=build_dimensions,grid=grid,extrusion_width=extrusion_width)
# Set up a status bar for displaying info (Jezmy)
vbox = wx.BoxSizer(wx.VERTICAL)
toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
toolbar.AddSimpleTool(1, wx.Image('./images/zoom_in.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Zoom In [+]', '')
toolbar.AddSimpleTool(2, wx.Image('./images/zoom_out.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Zoom Out [-]', '')
toolbar.AddSeparator()
toolbar.AddSimpleTool(3, wx.Image('./images/arrow_up.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Move Up a Layer [U]', '')
toolbar.AddSimpleTool(4, wx.Image('./images/arrow_down.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Move Down a Layer [D]', '')
toolbar.AddSeparator()
#toolbar.AddSimpleTool(5, wx.Image('./images/inject.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Insert Code at start of this layer', '')
toolbar.Realize()
vbox.Add(toolbar, 0, border=5)
self.SetSizer(vbox)
self.Bind(wx.EVT_TOOL, lambda x:self.p.zoom(200,200,1.2), id=1)
self.Bind(wx.EVT_TOOL, lambda x:self.p.zoom(200,200,1/1.2), id=2)
self.Bind(wx.EVT_TOOL, lambda x:self.p.layerup(), id=3)
self.Bind(wx.EVT_TOOL, lambda x:self.p.layerdown(), id=4)
#self.Bind(wx.EVT_TOOL, lambda x:self.p.inject(), id=5)
self.CreateStatusBar(1);
self.SetStatusText("Layer number and Z position show here when you scroll");
self.bu=wx.Button(self.p,-1,"U",pos=(0,0),size=(40,40))
self.bd=wx.Button(self.p,-1,"D",pos=(0,40),size=(40,40))
self.bi=wx.Button(self.p,-1,"+",pos=(40,0),size=(40,40))
self.bo=wx.Button(self.p,-1,"-",pos=(40,40),size=(40,40))
self.bu.Bind(wx.EVT_BUTTON,lambda x:self.p.layerup())
self.bd.Bind(wx.EVT_BUTTON,lambda x:self.p.layerdown())
self.bi.Bind(wx.EVT_BUTTON,lambda x:self.p.zoom(200,200,1.2))
self.bo.Bind(wx.EVT_BUTTON,lambda x:self.p.zoom(200,200,1/1.2))
#self.bu=wx.Button(self.p,-1,"U",pos=(0,100),size=(40,140))
#self.bd=wx.Button(self.p,-1,"D",pos=(0,140),size=(40,140))
#self.bi=wx.Button(self.p,-1,"+",pos=(40,100),size=(40,140))
#self.bo=wx.Button(self.p,-1,"-",pos=(40,140),size=(40,140))
#self.bs=wx.Button(self.p, -1, "Inject", pos=(85, 103), size=(50, 20))
#self.bu.SetToolTip(wx.ToolTip("Move up one layer"))
#self.bd.SetToolTip(wx.ToolTip("Move down one layer"))
#self.bi.SetToolTip(wx.ToolTip("Zoom view in"))
#self.bo.SetToolTip(wx.ToolTip("Zoom view out"))
#self.bs.SetToolTip(wx.ToolTip("Insert Code at start of this layer"))
#self.bu.Bind(wx.EVT_BUTTON,lambda x:self.p.layerup())
#self.bd.Bind(wx.EVT_BUTTON,lambda x:self.p.layerdown())
#self.bi.Bind(wx.EVT_BUTTON,lambda x:self.p.zoom(200,200,1.2))
#self.bo.Bind(wx.EVT_BUTTON,lambda x:self.p.zoom(200,200,1/1.2))
#self.bs.Bind(wx.EVT_BUTTON,lambda x:self.p.inject())
s=time.time()
#print time.time()-s
self.initpos=[0,0]
self.p.Bind(wx.EVT_KEY_DOWN,self.key)
self.bu.Bind(wx.EVT_KEY_DOWN,self.key)
self.bd.Bind(wx.EVT_KEY_DOWN,self.key)
self.bi.Bind(wx.EVT_KEY_DOWN,self.key)
self.bo.Bind(wx.EVT_KEY_DOWN,self.key)
#self.bu.Bind(wx.EVT_KEY_DOWN,self.key)
#self.bd.Bind(wx.EVT_KEY_DOWN,self.key)
#self.bi.Bind(wx.EVT_KEY_DOWN,self.key)
#self.bo.Bind(wx.EVT_KEY_DOWN,self.key)
self.Bind(wx.EVT_KEY_DOWN,self.key)
self.p.Bind(wx.EVT_MOUSEWHEEL,self.zoom)
self.Bind(wx.EVT_MOUSEWHEEL,self.zoom)
......@@ -64,21 +90,33 @@ class window(wx.Frame):
else:
event.Skip()
def key(self, event):
# Keycode definitions
kup=[85, 315] # Up keys
kdo=[68, 317] # Down Keys
kzi=[388, 316, 61] # Zoom In Keys
kzo=[390, 314, 45] # Zoom Out Keys
x=event.GetKeyCode()
if event.ShiftDown():
#print "Key event - "+str(x)
#if event.ShiftDown():
cx,cy=self.p.translate
if x==wx.WXK_UP:
self.p.zoom(cx,cy,1.2)
if x==wx.WXK_DOWN:
self.p.zoom(cx,cy,1/1.2)
else:
if x==wx.WXK_UP:
# if x==wx.WXK_UP:
# self.p.zoom(cx,cy,1.2)
# if x==wx.WXK_DOWN:
# self.p.zoom(cx,cy,1/1.2)
#else:
# if x==wx.WXK_UP:
# self.p.layerup()
# if x==wx.WXK_DOWN:
# self.p.layerdown()
if x in kup:
self.p.layerup()
if x==wx.WXK_DOWN:
if x in kdo:
self.p.layerdown()
#print x
if x in kzi:
self.p.zoom(cx,cy,1.2)
if x in kzo:
self.p.zoom(cx, cy, 1/1.2)
#print p.lines.keys()
def zoom(self, event):
......@@ -124,6 +162,11 @@ class gviz(wx.Panel):
self.dirty=1
self.blitmap=wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1)
def inject(self):
#import pdb; pdb.set_trace()
print"Inject code here..."
print "Layer "+str(self.layerindex +1)+" - Z = "+str(self.layers[self.layerindex])+" mm"
def clear(self):
self.lastpos=[0,0,0,0,0,0,0]
self.lines={}
......
......@@ -110,10 +110,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
ycol=(180,180,255)
zcol=(180,255,180)
self.cpbuttons=[
[_("Motors off"),("M84"),None,(250,250,250),0],
[_("Check temp"),("M105"),(2,5),(225,200,200),(1,1)],
[_("Extrude"),("extrude"),(4,0),(225,200,200),(1,2)],
[_("Reverse"),("reverse"),(5,0),(225,200,200),(1,2)],
[_("Motors off"),("M84"),None,(250,250,250),0, _("Switch all motors off")],
[_("Check temp"),("M105"),(2,5),(225,200,200),(1,1), _("Check current hotend temperature")],
[_("Extrude"),("extrude"),(4,0),(225,200,200),(1,2), _("Advance extruder by set length")],
[_("Reverse"),("reverse"),(5,0),(225,200,200),(1,2), _("Reverse extruder by set length")],
]
self.custombuttons=[]
self.btndict={}
......@@ -176,6 +176,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def online(self):
print _("Printer is now online.")
self.connectbtn.SetLabel(_("Disconnect"))
self.connectbtn.SetToolTip(wx.ToolTip("Disconnect from the printer"))
self.connectbtn.Bind(wx.EVT_BUTTON,self.disconnect)
for i in self.printerControls:
......@@ -500,19 +501,22 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
#lower section contains the rest of the window - manual controls, console, visualizations
#TOP ROW:
uts=self.uppertopsizer=wx.BoxSizer(wx.HORIZONTAL)
self.rescanbtn=wx.Button(self.panel,-1,_("Port"),size=(70, 25))
self.rescanbtn=wx.Button(self.panel,-1,_("Port"),size=buttonSize)
self.rescanbtn.SetToolTip(wx.ToolTip("Communication Settings\nClick to rescan ports"))
self.rescanbtn.Bind(wx.EVT_BUTTON,self.rescanports)
uts.Add(self.rescanbtn,0,wx.TOP|wx.LEFT,0)
self.serialport = wx.ComboBox(self.panel, -1,
choices=self.scanserial(),
style=wx.CB_DROPDOWN, size=(100, 25))
self.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to"))
self.rescanports()
uts.Add(self.serialport)
uts.Add(wx.StaticText(self.panel,-1,"@"),0,wx.RIGHT|wx.ALIGN_CENTER,0)
self.baud = wx.ComboBox(self.panel, -1,
choices=["2400", "9600", "19200", "38400", "57600", "115200", "250000"],
style=wx.CB_DROPDOWN, size=(100, 25))
self.baud.SetToolTip(wx.ToolTip("Select Baud rate for printer communication"))
try:
self.baud.SetValue("115200")
self.baud.SetValue(str(self.settings.baudrate))
......@@ -521,10 +525,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
uts.Add(self.baud)
self.connectbtn=wx.Button(self.panel,-1,_("Connect"), size=buttonSize)
uts.Add(self.connectbtn)
self.connectbtn.SetToolTipString(_("Connect to the printer"))
self.connectbtn.SetToolTip(wx.ToolTip("Connect to the printer"))
self.connectbtn.Bind(wx.EVT_BUTTON,self.connect)
self.resetbtn=wx.Button(self.panel,-1,_("Reset"),style=wx.BU_EXACTFIT,size=(-1,buttonSize[1]))
self.resetbtn.Bind(wx.EVT_BUTTON,self.reset)
self.resetbtn.SetToolTip(wx.ToolTip("Reset the printer"))
uts.Add(self.resetbtn)
#self.minibtn=wx.Button(self.panel,-1,_("Mini mode"),style=wx.BU_EXACTFIT)
#self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview)
......@@ -539,19 +544,26 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.loadbtn=wx.Button(self.panel,-1,_("Load file"),style=wx.BU_EXACTFIT,size=(-1,buttonSize[1]))
self.loadbtn.Bind(wx.EVT_BUTTON,self.loadfile)
self.loadbtn.SetToolTip(wx.ToolTip("Load a 3D model file"))
ubs.Add(self.loadbtn)
self.platebtn=wx.Button(self.panel,-1,_("Compose"),style=wx.BU_EXACTFIT,size=(-1,buttonSize[1]))
self.platebtn.Bind(wx.EVT_BUTTON,self.plate)
self.platebtn.SetToolTip(wx.ToolTip("Simple Plater System"))
#self.printerControls.append(self.uploadbtn)
ubs.Add(self.platebtn)
self.sdbtn=wx.Button(self.panel,-1,_("SD"),style=wx.BU_EXACTFIT,size=(-1,buttonSize[1]))
self.sdbtn.Bind(wx.EVT_BUTTON,self.sdmenu)
self.sdbtn.SetToolTip(wx.ToolTip("SD Card Printing"))
self.printerControls.append(self.sdbtn)
ubs.Add(self.sdbtn)
self.printbtn=wx.Button(self.panel,-1,_("Print"), size=buttonSize)
self.printbtn.Bind(wx.EVT_BUTTON,self.printfile)
self.printbtn.SetToolTip(wx.ToolTip("Start Printing Loaded File"))
self.printbtn.Disable()
ubs.Add(self.printbtn)
self.pausebtn=wx.Button(self.panel,-1,_("Pause"), size=buttonSize)
self.pausebtn.SetToolTip(wx.ToolTip("Pause Current Print"))
self.pausebtn.Bind(wx.EVT_BUTTON,self.pause)
ubs.Add(self.pausebtn)
#Right full view
lrs=self.lowerrsizer=wx.BoxSizer(wx.VERTICAL)
......@@ -560,10 +572,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lrs.Add(self.logbox,1,wx.EXPAND)
lbrs=wx.BoxSizer(wx.HORIZONTAL)
self.commandbox=wx.TextCtrl(self.panel,style = wx.TE_PROCESS_ENTER)
self.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)"))
self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline)
#self.printerControls.append(self.commandbox)
lbrs.Add(self.commandbox,1)
self.sendbtn=wx.Button(self.panel,-1,_("Send"),style=wx.BU_EXACTFIT)
self.sendbtn.SetToolTip(wx.ToolTip("Send Command to Printer"))
self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline)
#self.printerControls.append(self.sendbtn)
lbrs.Add(self.sendbtn)
......@@ -588,7 +602,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
for i in self.cpbuttons:
btn=wx.Button(self.panel,-1,i[0],style=wx.BU_EXACTFIT)#)
btn=wx.Button(self.panel,-1,i[0],style=wx.BU_EXACTFIT)
btn.SetToolTip(wx.ToolTip(i[5]))
btn.SetBackgroundColour(i[3])
btn.SetForegroundColour("black")
btn.properties=i
......@@ -602,13 +617,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lls.Add(btn,pos=i[2],span=i[4])
self.xyfeedc=wx.SpinCtrl(self.panel,-1,str(self.settings.xy_feedrate),min=0,max=50000,size=(70,-1))
self.xyfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for X & Y axes (mm/min)"))
llts.Add(wx.StaticText(self.panel,-1,_("XY:")), flag=wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
llts.Add(self.xyfeedc)
llts.Add(wx.StaticText(self.panel,-1,_("mm/min Z:")), flag=wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
self.zfeedc=wx.SpinCtrl(self.panel,-1,str(self.settings.z_feedrate),min=0,max=50000,size=(70,-1))
self.zfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for Z axis (mm/min)"))
llts.Add(self.zfeedc,)
self.monitorbox=wx.CheckBox(self.panel,-1,_("Watch"))
self.monitorbox.SetToolTip(wx.ToolTip("Monitor Temperatures in Graph"))
lls.Add(self.monitorbox,pos=(2,6))
self.monitorbox.Bind(wx.EVT_CHECKBOX,self.setmonitor)
......@@ -617,6 +635,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
htemp_choices=[self.temps[i]+" ("+i+")" for i in sorted(self.temps.keys(),key=lambda x:self.temps[x])]
self.settoff=wx.Button(self.panel,-1,_("Off"),size=(36,-1),style=wx.BU_EXACTFIT)
self.settoff.SetToolTip(wx.ToolTip("Switch Hotend Off"))
self.settoff.Bind(wx.EVT_BUTTON,lambda e:self.do_settemp("off"))
self.printerControls.append(self.settoff)
lls.Add(self.settoff,pos=(2,1),span=(1,1))
......@@ -625,10 +644,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
htemp_choices = [str(self.settings.last_temperature)] + htemp_choices
self.htemp=wx.ComboBox(self.panel, -1,
choices=htemp_choices,style=wx.CB_DROPDOWN, size=(70,-1))
self.htemp.SetToolTip(wx.ToolTip("Select Temperature for Hotend"))
self.htemp.Bind(wx.EVT_COMBOBOX,self.htemp_change)
lls.Add(self.htemp,pos=(2,2),span=(1,2))
self.settbtn=wx.Button(self.panel,-1,_("Set"),size=(38,-1),style=wx.BU_EXACTFIT)
self.settbtn.SetToolTip(wx.ToolTip("Switch Hotend On"))
self.settbtn.Bind(wx.EVT_BUTTON,self.do_settemp)
self.printerControls.append(self.settbtn)
lls.Add(self.settbtn,pos=(2,4),span=(1,1))
......@@ -637,6 +658,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
btemp_choices=[self.bedtemps[i]+" ("+i+")" for i in sorted(self.bedtemps.keys(),key=lambda x:self.temps[x])]
self.setboff=wx.Button(self.panel,-1,_("Off"),size=(36,-1),style=wx.BU_EXACTFIT)
self.setboff.SetToolTip(wx.ToolTip("Switch Heated Bed Off"))
self.setboff.Bind(wx.EVT_BUTTON,lambda e:self.do_bedtemp("off"))
self.printerControls.append(self.setboff)
lls.Add(self.setboff,pos=(3,1),span=(1,1))
......@@ -645,10 +667,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
btemp_choices = [str(self.settings.last_bed_temperature)] + btemp_choices
self.btemp=wx.ComboBox(self.panel, -1,
choices=btemp_choices,style=wx.CB_DROPDOWN, size=(70,-1))
self.btemp.SetToolTip(wx.ToolTip("Select Temperature for Heated Bed"))
self.btemp.Bind(wx.EVT_COMBOBOX,self.btemp_change)
lls.Add(self.btemp,pos=(3,2),span=(1,2))
self.setbbtn=wx.Button(self.panel,-1,_("Set"),size=(38,-1),style=wx.BU_EXACTFIT)
self.setbbtn.SetToolTip(wx.ToolTip("Switch Heated Bed On"))
self.setbbtn.Bind(wx.EVT_BUTTON,self.do_bedtemp)
self.printerControls.append(self.setbbtn)
lls.Add(self.setbbtn,pos=(3,4),span=(1,1))
......@@ -681,7 +705,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.edist.SetForegroundColour("black")
lls.Add(self.edist,pos=(4,2),span=(1,2))
lls.Add(wx.StaticText(self.panel,-1,_("mm")),pos=(4,4),span=(1,1))
self.edist.SetToolTip(wx.ToolTip("Amount to Extrude or Retract (mm)"))
self.efeedc=wx.SpinCtrl(self.panel,-1,str(self.settings.e_feedrate),min=0,max=50000,size=(60,-1))
self.efeedc.SetToolTip(wx.ToolTip("Extrude / Retract speed (mm/min)"))
self.efeedc.SetBackgroundColour((225,200,200))
self.efeedc.SetForegroundColour("black")
self.efeedc.Bind(wx.EVT_SPINCTRL,self.setfeeds)
......@@ -712,6 +738,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
build_dimensions=self.build_dimensions_list,
grid=(self.settings.preview_grid_step1,self.settings.preview_grid_step2),
extrusion_width=self.settings.preview_extrusion_width)
self.gviz.SetToolTip(wx.ToolTip("Click to examine / edit\n layers of loaded file"))
self.gviz.showall=1
try:
raise ""
......@@ -791,6 +818,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def showwin(self,event):
if(self.f is not None):
self.gwindow.Show(True)
self.gwindow.SetToolTip(wx.ToolTip("Mousewheel zooms the display\nShift / Mousewheel scrolls layers"))
self.gwindow.Raise()
def setfeeds(self,e):
......@@ -1600,6 +1628,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.statuscheck=False
self.connectbtn.SetLabel("Connect")
self.connectbtn.SetToolTip(wx.ToolTip("Connect to the printer"))
self.connectbtn.Bind(wx.EVT_BUTTON,self.connect)
wx.CallAfter(self.printbtn.Disable);
......
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