Commit 6f446e37 authored by Guillaume Seguin's avatar Guillaume Seguin

More automated cleanup

parent 77eb2440
...@@ -2,11 +2,19 @@ Some cleanup commands : ...@@ -2,11 +2,19 @@ Some cleanup commands :
To add a space after each comma : To add a space after each comma :
sed -e "s/\(\w\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py sed -e "s/\(\w\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\),\(\"\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\"\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\"\),\(\"\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\([)}\]]\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\([)}\]]\),\([\[{(]\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\),\([\[{(]\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
To add spaces around each = : To add spaces around each = :
sed -e "s/\(\w\)=\(\w\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py sed -e "s/\(\w\)=\(\w\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\)=\(\"\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py sed -e "s/\(\w\)=\(\"\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\)=\((\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py sed -e "s/\(\w\)=\((\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\)=\((\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
sed -e "s/\(\w\)=\([\[{(]\)/\1 = \2/g" -i *.py printrun/*.py printrun/svg/*.py
To add spaces around each == : To add spaces around each == :
sed -e "s/\(\w\)==\(\w\)/\1 == \2/g" -i *.py printrun/*.py printrun/svg/*.py sed -e "s/\(\w\)==\(\w\)/\1 == \2/g" -i *.py printrun/*.py printrun/svg/*.py
......
...@@ -443,7 +443,7 @@ class stlwin(wx.Frame): ...@@ -443,7 +443,7 @@ class stlwin(wx.Frame):
self.Refresh() self.Refresh()
#print time.time()-t #print time.time()-t
def load_stl_into_model(self, path, name, offset=[0, 0, 0], rotation = 0, scale=[1.0, 1.0, 1.0]): def load_stl_into_model(self, path, name, offset = [0, 0, 0], rotation = 0, scale = [1.0, 1.0, 1.0]):
newname = os.path.split(name.lower())[1] newname = os.path.split(name.lower())[1]
c = 1 c = 1
while newname in self.models: while newname in self.models:
......
...@@ -289,7 +289,7 @@ class printcore(): ...@@ -289,7 +289,7 @@ class printcore():
self.clear = True self.clear = True
return return
if self.resendfrom < self.lineno and self.resendfrom > -1: if self.resendfrom < self.lineno and self.resendfrom > -1:
self._send(self.sentlines[self.resendfrom],self.resendfrom, False) self._send(self.sentlines[self.resendfrom], self.resendfrom, False)
self.resendfrom += 1 self.resendfrom += 1
return return
self.resendfrom = -1 self.resendfrom = -1
...@@ -364,7 +364,7 @@ if __name__ == '__main__': ...@@ -364,7 +364,7 @@ if __name__ == '__main__':
p = printcore(port, baud) p = printcore(port, baud)
p.loud = loud p.loud = loud
time.sleep(2) time.sleep(2)
gcode = [i.replace("\n","") for i in open(filename)] gcode = [i.replace("\n", "") for i in open(filename)]
p.startprint(gcode) p.startprint(gcode)
try: try:
......
...@@ -86,9 +86,9 @@ help = u""" ...@@ -86,9 +86,9 @@ help = u"""
-t --temp Extrusion temperature in degrees Celsius (default: %d \xb0C, max %d \xb0C) -t --temp Extrusion temperature in degrees Celsius (default: %d \xb0C, max %d \xb0C)
-p --port Serial port the printer is connected to (default: %s) -p --port Serial port the printer is connected to (default: %s)
-h --help This cruft. -h --help This cruft.
"""[1:-1].encode('utf-8')%(sys.argv[0],n, k,temp, tempmax, port if port else 'auto') """[1:-1].encode('utf-8')%(sys.argv[0], n, k, temp, tempmax, port if port else 'auto')
try: try:
opts, args = getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help","length = ","steps = ","temp = ","port = "]) opts, args = getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help", "length=", "steps=", "temp=", "port="])
except getopt.GetoptError, err: except getopt.GetoptError, err:
print str(err) print str(err)
print help print help
......
...@@ -290,7 +290,7 @@ class gcline(object): ...@@ -290,7 +290,7 @@ class gcline(object):
] ]
def glcolor(self, upper_limit = None, lower_limit = 0, max_feedrate = 0): def glcolor(self, upper_limit = None, lower_limit = 0, max_feedrate = 0):
if self.extrusion_ratio == 0: if self.extrusion_ratio == 0:
return [255, 255, 255, 0,0, 0] return [255, 255, 255, 0, 0, 0]
else: else:
blue_color = 0 blue_color = 0
green_color = 0 green_color = 0
...@@ -430,7 +430,7 @@ class gcview(object): ...@@ -430,7 +430,7 @@ class gcview(object):
else: else:
self.lastf = cur[4] self.lastf = cur[4]
r = gcline(x = cur[0], y = cur[1], z = cur[2],e = cur[3], f = cur[4], prev_gcline = self.prev, orgline = orgline) r = gcline(x = cur[0], y = cur[1], z = cur[2], e = cur[3], f = cur[4], prev_gcline = self.prev, orgline = orgline)
self.prev = r self.prev = r
return r return r
return None return None
...@@ -927,7 +927,7 @@ class GCFrame(wx.Frame): ...@@ -927,7 +927,7 @@ class GCFrame(wx.Frame):
self.modelindex = 0 self.modelindex = 0
self.GLPanel1 = TestGlPanel(self, size) self.GLPanel1 = TestGlPanel(self, size)
def addfile(self, gcode=[]): def addfile(self, gcode = []):
self.models["GCODE"].gc.delete() self.models["GCODE"].gc.delete()
self.models["GCODE"].gc = gcview(gcode, batch = self.models["GCODE"].batch) self.models["GCODE"].gc = gcview(gcode, batch = self.models["GCODE"].batch)
self.setlayerindex(None) self.setlayerindex(None)
......
...@@ -78,21 +78,21 @@ class Graph(BufferedCanvas): ...@@ -78,21 +78,21 @@ class Graph(BufferedCanvas):
def drawgrid(self, dc, gc): def drawgrid(self, dc, gc):
#cold, medium, hot = wx.Colour(0, 167, 223),wx.Colour(239, 233, 119),wx.Colour(210, 50.100) #cold, medium, hot = wx.Colour(0, 167, 223), wx.Colour(239, 233, 119), wx.Colour(210, 50.100)
#col1 = wx.Colour(255, 0,0, 255) #col1 = wx.Colour(255, 0, 0, 255)
#col2 = wx.Colour(255, 255, 255, 128) #col2 = wx.Colour(255, 255, 255, 128)
#b = gc.CreateLinearGradientBrush(0, 0, w, h, col1, col2) #b = gc.CreateLinearGradientBrush(0, 0, w, h, col1, col2)
gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 4)) gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 4))
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(245, 245, 255, 252)))) #gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(245, 245, 255, 252))))
#gc.SetBrush(b) #gc.SetBrush(b)
gc.DrawRectangle(0, 0, self.width, self.height) gc.DrawRectangle(0, 0, self.width, self.height)
#gc.SetBrush(wx.Brush(wx.Colour(245, 245, 255, 52))) #gc.SetBrush(wx.Brush(wx.Colour(245, 245, 255, 52)))
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0,0, 255)))) #gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0, 255))))
#gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 4)) #gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 4))
#gc.DrawLines(wx.Point(0, 0), wx.Point(50, 10)) #gc.DrawLines(wx.Point(0, 0), wx.Point(50, 10))
...@@ -121,20 +121,20 @@ class Graph(BufferedCanvas): ...@@ -121,20 +121,20 @@ class Graph(BufferedCanvas):
if self.timer.IsRunning() == False: if self.timer.IsRunning() == False:
font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD) font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.BOLD)
gc.SetFont(font, wx.Colour(3, 4,4)) gc.SetFont(font, wx.Colour(3, 4, 4))
gc.DrawText("Graph offline", self.width/2 - (font.GetPointSize() * 3), self.height/2 - (font.GetPointSize() * 1)) gc.DrawText("Graph offline", self.width/2 - (font.GetPointSize() * 3), self.height/2 - (font.GetPointSize() * 1))
#dc.DrawCircle(50, 50, 1) #dc.DrawCircle(50, 50, 1)
#gc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 1)) #gc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1))
#gc.DrawLines([[20, 30], [10, 53]]) #gc.DrawLines([[20, 30], [10, 53]])
#dc.SetPen(wx.Pen(wx.Colour(255, 0,0, 0), 1)) #dc.SetPen(wx.Pen(wx.Colour(255, 0, 0, 0), 1))
def drawtemperature(self, dc, gc, temperature_list, text, text_xoffset, r, g, b, a): def drawtemperature(self, dc, gc, temperature_list, text, text_xoffset, r, g, b, a):
if self.timer.IsRunning() == False: if self.timer.IsRunning() == False:
dc.SetPen(wx.Pen(wx.Colour(128, 128, 128, 128), 1)) dc.SetPen(wx.Pen(wx.Colour(128, 128, 128, 128), 1))
else: else:
dc.SetPen(wx.Pen(wx.Colour(r, g,b, a), 1)) dc.SetPen(wx.Pen(wx.Colour(r, g, b, a), 1))
x_add = float(self.width)/self.xsteps x_add = float(self.width)/self.xsteps
x_pos = float(0.0) x_pos = float(0.0)
...@@ -155,7 +155,7 @@ class Graph(BufferedCanvas): ...@@ -155,7 +155,7 @@ class Graph(BufferedCanvas):
if self.timer.IsRunning() == False: if self.timer.IsRunning() == False:
gc.SetFont(font, wx.Colour(128, 128, 128)) gc.SetFont(font, wx.Colour(128, 128, 128))
else: else:
gc.SetFont(font, wx.Colour(r, g,b)) gc.SetFont(font, wx.Colour(r, g, b))
#gc.DrawText(text, self.width - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2)) #gc.DrawText(text, self.width - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2))
gc.DrawText(text, x_pos - x_add - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2)) gc.DrawText(text, x_pos - x_add - (font.GetPointSize() * ((len(text) * text_xoffset + 1))), self.height - self._lastyvalue - (font.GetPointSize() / 2))
...@@ -163,24 +163,24 @@ class Graph(BufferedCanvas): ...@@ -163,24 +163,24 @@ class Graph(BufferedCanvas):
def drawbedtemp(self, dc, gc): def drawbedtemp(self, dc, gc):
self.drawtemperature(dc, gc, self.bedtemps, "Bed",2, 255, 0,0, 128) self.drawtemperature(dc, gc, self.bedtemps, "Bed", 2, 255, 0, 0, 128)
def drawbedtargettemp(self, dc, gc): def drawbedtargettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.bedtargettemps, "Bed Target",2, 255, 120, 0, 128) self.drawtemperature(dc, gc, self.bedtargettemps, "Bed Target", 2, 255, 120, 0, 128)
def drawextruder0temp(self, dc, gc): def drawextruder0temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder0temps, "Ex0",1, 0, 155, 255, 128) self.drawtemperature(dc, gc, self.extruder0temps, "Ex0", 1, 0, 155, 255, 128)
def drawextruder0targettemp(self, dc, gc): def drawextruder0targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder0targettemps, "Ex0 Target",2, 0, 5,255, 128) self.drawtemperature(dc, gc, self.extruder0targettemps, "Ex0 Target", 2, 0, 5, 255, 128)
def drawextruder1temp(self, dc, gc): def drawextruder1temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1temps, "Ex1",3, 55, 55, 0, 128) self.drawtemperature(dc, gc, self.extruder1temps, "Ex1", 3, 55, 55, 0, 128)
def drawextruder1targettemp(self, dc, gc): def drawextruder1targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1targettemps, "Ex1 Target",2, 55, 55, 0, 128) self.drawtemperature(dc, gc, self.extruder1targettemps, "Ex1 Target", 2, 55, 55, 0, 128)
def SetBedTemperature(self, value): def SetBedTemperature(self, value):
......
...@@ -19,8 +19,8 @@ from printrun_utils import imagefile ...@@ -19,8 +19,8 @@ from printrun_utils import imagefile
ID_ABOUT = 101 ID_ABOUT = 101
ID_EXIT = 110 ID_EXIT = 110
class window(wx.Frame): class window(wx.Frame):
def __init__(self, f,size = (600, 600),build_dimensions=[200, 200, 100, 0,0, 0],grid = (10, 50),extrusion_width = 0.5): def __init__(self, f, size = (600, 600), build_dimensions = [200, 200, 100, 0, 0, 0], grid = (10, 50), extrusion_width = 0.5):
wx.Frame.__init__(self, None, title = "Gcode view, shift to move view, mousewheel to set layer",size = (size[0],size[1])) 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) self.p = gviz(self, size = size, build_dimensions = build_dimensions, grid = grid, extrusion_width = extrusion_width)
vbox = wx.BoxSizer(wx.VERTICAL) vbox = wx.BoxSizer(wx.VERTICAL)
...@@ -46,10 +46,10 @@ class window(wx.Frame): ...@@ -46,10 +46,10 @@ class window(wx.Frame):
self.CreateStatusBar(1); self.CreateStatusBar(1);
self.SetStatusText("Layer number and Z position show here when you scroll"); self.SetStatusText("Layer number and Z position show here when you scroll");
#self.bu = wx.Button(self.p,-1,"U",pos = (0, 100),size = (40, 140)) #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.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.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.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.bs = wx.Button(self.p, -1, "Inject", pos = (85, 103), size = (50, 20))
#self.bu.SetToolTip(wx.ToolTip("Move up one layer")) #self.bu.SetToolTip(wx.ToolTip("Move up one layer"))
...@@ -66,7 +66,7 @@ class window(wx.Frame): ...@@ -66,7 +66,7 @@ class window(wx.Frame):
s = time.time() s = time.time()
#print time.time()-s #print time.time()-s
self.initpos=[0, 0] self.initpos = [0, 0]
self.p.Bind(wx.EVT_KEY_DOWN, self.key) self.p.Bind(wx.EVT_KEY_DOWN, self.key)
#self.bu.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.bd.Bind(wx.EVT_KEY_DOWN, self.key)
...@@ -79,9 +79,9 @@ class window(wx.Frame): ...@@ -79,9 +79,9 @@ class window(wx.Frame):
self.Bind(wx.EVT_MOUSE_EVENTS, self.mouse) self.Bind(wx.EVT_MOUSE_EVENTS, self.mouse)
def resetview(self, event): def resetview(self, event):
self.p.translate=[0.0, 0.0] self.p.translate = [0.0, 0.0]
self.p.scale = self.p.basescale self.p.scale = self.p.basescale
self.p.zoom(0, 0,1.0) self.p.zoom(0, 0, 1.0)
def mouse(self, event): def mouse(self, event):
if event.ButtonUp(wx.MOUSE_BTN_LEFT): if event.ButtonUp(wx.MOUSE_BTN_LEFT):
...@@ -89,10 +89,10 @@ class window(wx.Frame): ...@@ -89,10 +89,10 @@ class window(wx.Frame):
self.initpos = None self.initpos = None
elif event.Dragging(): elif event.Dragging():
e = event.GetPositionTuple() e = event.GetPositionTuple()
if self.initpos is None or not hasattr(self,"basetrans"): if self.initpos is None or not hasattr(self, "basetrans"):
self.initpos = e self.initpos = e
self.basetrans = self.p.translate self.basetrans = self.p.translate
#print self.p.translate, e,self.initpos #print self.p.translate, e, self.initpos
self.p.translate = [ self.basetrans[0]+(e[0]-self.initpos[0]), self.p.translate = [ self.basetrans[0]+(e[0]-self.initpos[0]),
self.basetrans[1]+(e[1]-self.initpos[1]) ] self.basetrans[1]+(e[1]-self.initpos[1]) ]
self.p.repaint() self.p.repaint()
...@@ -103,10 +103,10 @@ class window(wx.Frame): ...@@ -103,10 +103,10 @@ class window(wx.Frame):
def key(self, event): def key(self, event):
# Keycode definitions # Keycode definitions
kup=[85, 315] # Up keys kup = [85, 315] # Up keys
kdo=[68, 317] # Down Keys kdo = [68, 317] # Down Keys
kzi=[388, 316, 61] # Zoom In Keys kzi = [388, 316, 61] # Zoom In Keys
kzo=[390, 314, 45] # Zoom Out Keys kzo = [390, 314, 45] # Zoom Out Keys
x = event.GetKeyCode() x = event.GetKeyCode()
#print "Key event - "+str(x) #print "Key event - "+str(x)
#if event.ShiftDown(): #if event.ShiftDown():
...@@ -136,42 +136,42 @@ class window(wx.Frame): ...@@ -136,42 +136,42 @@ class window(wx.Frame):
if z > 0: self.p.layerdown() if z > 0: self.p.layerdown()
elif z < 0: self.p.layerup() elif z < 0: self.p.layerup()
else: else:
if z > 0: self.p.zoom(event.GetX(),event.GetY(),1.2) if z > 0: self.p.zoom(event.GetX(), event.GetY(), 1.2)
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),build_dimensions=[200, 200, 100, 0,0, 0],grid = (10, 50),extrusion_width = 0.5): def __init__(self, parent, size = (200, 200), build_dimensions = [200, 200, 100, 0, 0, 0], 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.parent = parent self.parent = parent
self.size = size self.size = size
self.build_dimensions = build_dimensions self.build_dimensions = build_dimensions
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[:]
self.Bind(wx.EVT_PAINT, self.paint) self.Bind(wx.EVT_PAINT, self.paint)
self.Bind(wx.EVT_SIZE, self.resize) self.Bind(wx.EVT_SIZE, self.resize)
self.lines={} self.lines = {}
self.pens={} self.pens = {}
self.arcs={} self.arcs = {}
self.arcpens={} self.arcpens = {}
self.layers=[] self.layers = []
self.layerindex = 0 self.layerindex = 0
self.filament_width = extrusion_width # set it to 0 to disable scaling lines with zoom self.filament_width = extrusion_width # set it to 0 to disable scaling lines with zoom
self.basescale=[min(float(size[0])/build_dimensions[0],float(size[1])/build_dimensions[1])]*2 self.basescale = [min(float(size[0])/build_dimensions[0], float(size[1])/build_dimensions[1])]*2
self.scale = self.basescale self.scale = self.basescale
penwidth = max(1.0, self.filament_width*((self.scale[0]+self.scale[1])/2.0)) penwidth = max(1.0, self.filament_width*((self.scale[0]+self.scale[1])/2.0))
self.translate=[0.0, 0.0] self.translate = [0.0, 0.0]
self.mainpen = wx.Pen(wx.Colour(0, 0,0),penwidth) self.mainpen = wx.Pen(wx.Colour(0, 0, 0), penwidth)
self.arcpen = wx.Pen(wx.Colour(255, 0,0),penwidth) self.arcpen = wx.Pen(wx.Colour(255, 0, 0), penwidth)
self.travelpen = wx.Pen(wx.Colour(10, 80, 80),penwidth) self.travelpen = wx.Pen(wx.Colour(10, 80, 80), penwidth)
self.hlpen = wx.Pen(wx.Colour(200, 50, 50),penwidth) self.hlpen = wx.Pen(wx.Colour(200, 50, 50), penwidth)
self.fades=[wx.Pen(wx.Colour(250-0.6**i*100, 250-0.6**i*100, 200-0.4**i*50),penwidth) for i in xrange(6)] self.fades = [wx.Pen(wx.Colour(250-0.6**i*100, 250-0.6**i*100, 200-0.4**i*50), penwidth) for i in xrange(6)]
self.penslist=[self.mainpen, self.travelpen, self.hlpen]+self.fades self.penslist = [self.mainpen, self.travelpen, self.hlpen]+self.fades
self.showall = 0 self.showall = 0
self.hilight=[] self.hilight = []
self.hilightarcs=[] self.hilightarcs = []
self.dirty = 1 self.dirty = 1
self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1) self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0], self.GetClientSize()[1],-1)
def inject(self): def inject(self):
#import pdb; pdb.set_trace() #import pdb; pdb.set_trace()
...@@ -179,14 +179,14 @@ class gviz(wx.Panel): ...@@ -179,14 +179,14 @@ class gviz(wx.Panel):
print "Layer "+str(self.layerindex +1)+" - Z = "+str(self.layers[self.layerindex])+" mm" print "Layer "+str(self.layerindex +1)+" - Z = "+str(self.layers[self.layerindex])+" mm"
def clear(self): def clear(self):
self.lastpos=[0, 0,0, 0,0, 0,0] self.lastpos = [0, 0, 0, 0, 0, 0, 0]
self.lines={} self.lines = {}
self.pens={} self.pens = {}
self.arcs={} self.arcs = {}
self.arcpens={} self.arcpens = {}
self.layers=[] self.layers = []
self.hilight=[] self.hilight = []
self.hilightarcs=[] self.hilightarcs = []
self.layerindex = 0 self.layerindex = 0
self.showall = 0 self.showall = 0
self.dirty = 1 self.dirty = 1
...@@ -195,7 +195,7 @@ class gviz(wx.Panel): ...@@ -195,7 +195,7 @@ class gviz(wx.Panel):
if(self.layerindex+1<len(self.layers)): if(self.layerindex+1<len(self.layers)):
self.layerindex+=1 self.layerindex+=1
# Display layer info on statusbar (Jezmy) # Display layer info on statusbar (Jezmy)
self.parent.SetStatusText("Layer "+str(self.layerindex +1)+" - Going Up - Z = "+str(self.layers[self.layerindex])+" mm",0) self.parent.SetStatusText("Layer "+str(self.layerindex +1)+" - Going Up - Z = "+str(self.layers[self.layerindex])+" mm", 0)
self.repaint() self.repaint()
self.Refresh() self.Refresh()
...@@ -203,7 +203,7 @@ class gviz(wx.Panel): ...@@ -203,7 +203,7 @@ class gviz(wx.Panel):
if(self.layerindex>0): if(self.layerindex>0):
self.layerindex-=1 self.layerindex-=1
# Display layer info on statusbar (Jezmy) # Display layer info on statusbar (Jezmy)
self.parent.SetStatusText("Layer "+str(self.layerindex + 1)+" - Going Down - Z = "+str(self.layers[self.layerindex])+ " mm",0) self.parent.SetStatusText("Layer "+str(self.layerindex + 1)+" - Going Down - Z = "+str(self.layers[self.layerindex])+ " mm", 0)
self.repaint() self.repaint()
self.Refresh() self.Refresh()
...@@ -218,12 +218,12 @@ class gviz(wx.Panel): ...@@ -218,12 +218,12 @@ class gviz(wx.Panel):
def resize(self, event): def resize(self, event):
size = self.GetClientSize() size = self.GetClientSize()
newsize = min(float(size[0])/self.size[0],float(size[1])/self.size[1]) newsize = min(float(size[0])/self.size[0], float(size[1])/self.size[1])
self.size = self.GetClientSize() self.size = self.GetClientSize()
wx.CallAfter(self.zoom, 0,0, newsize) wx.CallAfter(self.zoom, 0, 0, newsize)
def zoom(self, x,y, factor): def zoom(self, x, y, factor):
self.scale = [s * factor for s in self.scale] self.scale = [s * factor for s in self.scale]
self.translate = [ x - (x-self.translate[0]) * factor, self.translate = [ x - (x-self.translate[0]) * factor,
...@@ -237,7 +237,7 @@ class gviz(wx.Panel): ...@@ -237,7 +237,7 @@ class gviz(wx.Panel):
def repaint(self): def repaint(self):
self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1) self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0], self.GetClientSize()[1],-1)
dc = wx.MemoryDC() dc = wx.MemoryDC()
dc.SelectObject(self.blitmap) dc.SelectObject(self.blitmap)
dc.SetBackground(wx.Brush((250, 250, 200))) dc.SetBackground(wx.Brush((250, 250, 200)))
...@@ -246,17 +246,17 @@ class gviz(wx.Panel): ...@@ -246,17 +246,17 @@ class gviz(wx.Panel):
for grid_unit in self.grid: for grid_unit in self.grid:
if grid_unit > 0: if grid_unit > 0:
for x in xrange(int(self.build_dimensions[0]/grid_unit)+1): for x in xrange(int(self.build_dimensions[0]/grid_unit)+1):
dc.DrawLine(self.translate[0]+x*self.scale[0]*grid_unit, self.translate[1],self.translate[0]+x*self.scale[0]*grid_unit, self.translate[1]+self.scale[1]*self.build_dimensions[1]) dc.DrawLine(self.translate[0]+x*self.scale[0]*grid_unit, self.translate[1], self.translate[0]+x*self.scale[0]*grid_unit, self.translate[1]+self.scale[1]*self.build_dimensions[1])
for y in xrange(int(self.build_dimensions[1]/grid_unit)+1): for y in xrange(int(self.build_dimensions[1]/grid_unit)+1):
dc.DrawLine(self.translate[0],self.translate[1]+y*self.scale[1]*grid_unit, self.translate[0]+self.scale[0]*self.build_dimensions[0],self.translate[1]+y*self.scale[1]*grid_unit) dc.DrawLine(self.translate[0], self.translate[1]+y*self.scale[1]*grid_unit, self.translate[0]+self.scale[0]*self.build_dimensions[0], self.translate[1]+y*self.scale[1]*grid_unit)
dc.SetPen(wx.Pen(wx.Colour(0, 0,0))) dc.SetPen(wx.Pen(wx.Colour(0, 0, 0)))
if not self.showall: if not self.showall:
self.size = self.GetSize() self.size = self.GetSize()
dc.SetBrush(wx.Brush((43, 144, 255))) dc.SetBrush(wx.Brush((43, 144, 255)))
dc.DrawRectangle(self.size[0]-15, 0,15, self.size[1]) dc.DrawRectangle(self.size[0]-15, 0, 15, self.size[1])
dc.SetBrush(wx.Brush((0, 255, 0))) dc.SetBrush(wx.Brush((0, 255, 0)))
if len(self.layers): if len(self.layers):
dc.DrawRectangle(self.size[0]-14,(1.0-(1.0*(self.layerindex+1))/len(self.layers))*self.size[1],13, self.size[1]-1) dc.DrawRectangle(self.size[0]-14, (1.0-(1.0*(self.layerindex+1))/len(self.layers))*self.size[1], 13, self.size[1]-1)
def _drawlines(lines, pens): def _drawlines(lines, pens):
def _scaler(x): def _scaler(x):
...@@ -282,14 +282,14 @@ class gviz(wx.Panel): ...@@ -282,14 +282,14 @@ class gviz(wx.Panel):
dc.DrawArc(*scaled_arcs[i]) dc.DrawArc(*scaled_arcs[i])
if self.showall: if self.showall:
l=[] l = []
for i in self.layers: for i in self.layers:
dc.DrawLineList(l, self.fades[0]) dc.DrawLineList(l, self.fades[0])
_drawlines(self.lines[i], self.pens[i]) _drawlines(self.lines[i], self.pens[i])
_drawarcs(self.arcs[i], self.arcpens[i]) _drawarcs(self.arcs[i], self.arcpens[i])
return return
if self.layerindex<len(self.layers) and self.layers[self.layerindex] in self.lines.keys(): if self.layerindex<len(self.layers) and self.layers[self.layerindex] in self.lines.keys():
for layer_i in xrange(max(0, self.layerindex-6),self.layerindex): for layer_i in xrange(max(0, self.layerindex-6), self.layerindex):
#print i, self.layerindex, self.layerindex-i #print i, self.layerindex, self.layerindex-i
_drawlines(self.lines[self.layers[layer_i]], self.fades[self.layerindex-layer_i-1]) _drawlines(self.lines[self.layers[layer_i]], self.fades[self.layerindex-layer_i-1])
_drawarcs(self.arcs[self.layers[layer_i]], self.fades[self.layerindex-layer_i-1]) _drawarcs(self.arcs[self.layers[layer_i]], self.fades[self.layerindex-layer_i-1])
...@@ -307,15 +307,15 @@ class gviz(wx.Panel): ...@@ -307,15 +307,15 @@ class gviz(wx.Panel):
self.repaint() self.repaint()
self.dirty = 0 self.dirty = 0
sz = self.GetClientSize() sz = self.GetClientSize()
dc.DrawBitmap(self.blitmap, 0,0) dc.DrawBitmap(self.blitmap, 0, 0)
del dc del dc
def addfile(self, gcodes=[]): def addfile(self, gcodes = []):
self.clear() self.clear()
for i in gcodes: for i in gcodes:
self.addgcode(i) self.addgcode(i)
def addgcode(self, gcode = "M105",hilight = 0): def addgcode(self, gcode = "M105", hilight = 0):
gcode = gcode.split("*")[0] gcode = gcode.split("*")[0]
gcode = gcode.split(";")[0] gcode = gcode.split(";")[0]
gcode = gcode.lower().strip().split() gcode = gcode.lower().strip().split()
......
...@@ -28,27 +28,27 @@ class macroed(wx.Dialog): ...@@ -28,27 +28,27 @@ class macroed(wx.Dialog):
self.callback = callback self.callback = callback
self.panel = wx.Panel(self,-1) self.panel = wx.Panel(self,-1)
titlesizer = wx.BoxSizer(wx.HORIZONTAL) titlesizer = wx.BoxSizer(wx.HORIZONTAL)
titletext = wx.StaticText(self.panel,-1," _") #title%macro_name) titletext = wx.StaticText(self.panel,-1, " _") #title%macro_name)
#title.SetFont(wx.Font(11, wx.NORMAL, wx.NORMAL, wx.BOLD)) #title.SetFont(wx.Font(11, wx.NORMAL, wx.NORMAL, wx.BOLD))
titlesizer.Add(titletext, 1) titlesizer.Add(titletext, 1)
self.findb = wx.Button(self.panel, -1, _("Find"),style = wx.BU_EXACTFIT) #New button for "Find" (Jezmy) self.findb = wx.Button(self.panel, -1, _("Find"), style = wx.BU_EXACTFIT) #New button for "Find" (Jezmy)
self.findb.Bind(wx.EVT_BUTTON, self.find) self.findb.Bind(wx.EVT_BUTTON, self.find)
self.okb = wx.Button(self.panel, -1, _("Save"),style = wx.BU_EXACTFIT) self.okb = wx.Button(self.panel, -1, _("Save"), style = wx.BU_EXACTFIT)
self.okb.Bind(wx.EVT_BUTTON, self.save) self.okb.Bind(wx.EVT_BUTTON, self.save)
self.Bind(wx.EVT_CLOSE, self.close) self.Bind(wx.EVT_CLOSE, self.close)
titlesizer.Add(self.findb) titlesizer.Add(self.findb)
titlesizer.Add(self.okb) titlesizer.Add(self.okb)
self.cancelb = wx.Button(self.panel, -1, _("Cancel"),style = wx.BU_EXACTFIT) self.cancelb = wx.Button(self.panel, -1, _("Cancel"), style = wx.BU_EXACTFIT)
self.cancelb.Bind(wx.EVT_BUTTON, self.close) self.cancelb.Bind(wx.EVT_BUTTON, self.close)
titlesizer.Add(self.cancelb) titlesizer.Add(self.cancelb)
topsizer = wx.BoxSizer(wx.VERTICAL) topsizer = wx.BoxSizer(wx.VERTICAL)
topsizer.Add(titlesizer, 0,wx.EXPAND) topsizer.Add(titlesizer, 0, wx.EXPAND)
self.e = wx.TextCtrl(self.panel, style = wx.TE_MULTILINE+wx.HSCROLL, size = (400, 400)) self.e = wx.TextCtrl(self.panel, style = wx.TE_MULTILINE+wx.HSCROLL, size = (400, 400))
if not self.gcode: if not self.gcode:
self.e.SetValue(self.unindent(definition)) self.e.SetValue(self.unindent(definition))
else: else:
self.e.SetValue("\n".join(definition)) self.e.SetValue("\n".join(definition))
topsizer.Add(self.e, 1,wx.ALL+wx.EXPAND) topsizer.Add(self.e, 1, wx.ALL+wx.EXPAND)
self.panel.SetSizer(topsizer) self.panel.SetSizer(topsizer)
topsizer.Layout() topsizer.Layout()
topsizer.Fit(self) topsizer.Fit(self)
...@@ -66,7 +66,7 @@ class macroed(wx.Dialog): ...@@ -66,7 +66,7 @@ class macroed(wx.Dialog):
position = somecode.find(FindValue, self.e.GetInsertionPoint()) position = somecode.find(FindValue, self.e.GetInsertionPoint())
if position == -1 : if position == -1 :
# ShowMessage(self,-1, "Not found!") # ShowMessage(self,-1, "Not found!")
titletext = wx.TextCtrl(self.panel,-1,"Not Found!") titletext = wx.TextCtrl(self.panel,-1, "Not Found!")
else: else:
# self.title.SetValue("Position : "+str(position)) # self.title.SetValue("Position : "+str(position))
...@@ -99,7 +99,7 @@ class macroed(wx.Dialog): ...@@ -99,7 +99,7 @@ class macroed(wx.Dialog):
if len(self.indent_chars) == 0: if len(self.indent_chars) == 0:
self.indent_chars = " " self.indent_chars = " "
unindented = "" unindented = ""
lines = re.split(r"(?:\r\n?|\n)",text) lines = re.split(r"(?:\r\n?|\n)", text)
#print lines #print lines
if len(lines) <= 1: if len(lines) <= 1:
return text return text
...@@ -110,7 +110,7 @@ class macroed(wx.Dialog): ...@@ -110,7 +110,7 @@ class macroed(wx.Dialog):
unindented += line + "\n" unindented += line + "\n"
return unindented return unindented
def reindent(self, text): def reindent(self, text):
lines = re.split(r"(?:\r\n?|\n)",text) lines = re.split(r"(?:\r\n?|\n)", text)
if len(lines) <= 1: if len(lines) <= 1:
return text return text
reindented = "" reindented = ""
...@@ -125,12 +125,12 @@ class options(wx.Dialog): ...@@ -125,12 +125,12 @@ class options(wx.Dialog):
wx.Dialog.__init__(self, None, title = _("Edit settings"), style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) wx.Dialog.__init__(self, None, title = _("Edit settings"), style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
topsizer = wx.BoxSizer(wx.VERTICAL) topsizer = wx.BoxSizer(wx.VERTICAL)
vbox = wx.StaticBoxSizer(wx.StaticBox(self, label = _("Defaults")) ,wx.VERTICAL) vbox = wx.StaticBoxSizer(wx.StaticBox(self, label = _("Defaults")) ,wx.VERTICAL)
topsizer.Add(vbox, 1,wx.ALL+wx.EXPAND) topsizer.Add(vbox, 1, wx.ALL+wx.EXPAND)
grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 8, vgap = 2) grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 8, vgap = 2)
grid.SetFlexibleDirection( wx.BOTH ) grid.SetFlexibleDirection( wx.BOTH )
grid.AddGrowableCol( 1 ) grid.AddGrowableCol( 1 )
grid.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) grid.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
vbox.Add(grid, 0,wx.EXPAND) vbox.Add(grid, 0, wx.EXPAND)
ctrls = {} ctrls = {}
for k, v in sorted(pronterface.settings._all_settings().items()): for k, v in sorted(pronterface.settings._all_settings().items()):
ctrls[k, 0] = wx.StaticText(self,-1, k) ctrls[k, 0] = wx.StaticText(self,-1, k)
...@@ -138,9 +138,9 @@ class options(wx.Dialog): ...@@ -138,9 +138,9 @@ class options(wx.Dialog):
if k in pronterface.helpdict: if k in pronterface.helpdict:
ctrls[k, 0].SetToolTipString(pronterface.helpdict.get(k)) ctrls[k, 0].SetToolTipString(pronterface.helpdict.get(k))
ctrls[k, 1].SetToolTipString(pronterface.helpdict.get(k)) ctrls[k, 1].SetToolTipString(pronterface.helpdict.get(k))
grid.Add(ctrls[k, 0],0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT) grid.Add(ctrls[k, 0], 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.ALIGN_RIGHT)
grid.Add(ctrls[k, 1],1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND) grid.Add(ctrls[k, 1], 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND)
topsizer.Add(self.CreateSeparatedButtonSizer(wx.OK+wx.CANCEL),0, wx.EXPAND) topsizer.Add(self.CreateSeparatedButtonSizer(wx.OK+wx.CANCEL), 0, wx.EXPAND)
self.SetSizer(topsizer) self.SetSizer(topsizer)
topsizer.Layout() topsizer.Layout()
topsizer.Fit(self) topsizer.Fit(self)
...@@ -153,29 +153,29 @@ class options(wx.Dialog): ...@@ -153,29 +153,29 @@ class options(wx.Dialog):
class ButtonEdit(wx.Dialog): class ButtonEdit(wx.Dialog):
"""Custom button edit dialog""" """Custom button edit dialog"""
def __init__(self, pronterface): def __init__(self, pronterface):
wx.Dialog.__init__(self, None, title = _("Custom button"),style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) wx.Dialog.__init__(self, None, title = _("Custom button"), style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
self.pronterface = pronterface self.pronterface = pronterface
topsizer = wx.BoxSizer(wx.VERTICAL) topsizer = wx.BoxSizer(wx.VERTICAL)
grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 4, vgap = 2) grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 4, vgap = 2)
grid.AddGrowableCol(1, 1) grid.AddGrowableCol(1, 1)
grid.Add(wx.StaticText(self,-1, _("Button title")), 0, wx.BOTTOM|wx.RIGHT) grid.Add(wx.StaticText(self,-1, _("Button title")), 0, wx.BOTTOM|wx.RIGHT)
self.name = wx.TextCtrl(self,-1,"") self.name = wx.TextCtrl(self,-1, "")
grid.Add(self.name, 1,wx.EXPAND) grid.Add(self.name, 1, wx.EXPAND)
grid.Add(wx.StaticText(self, -1, _("Command")), 0, wx.BOTTOM|wx.RIGHT) grid.Add(wx.StaticText(self, -1, _("Command")), 0, wx.BOTTOM|wx.RIGHT)
self.command = wx.TextCtrl(self,-1,"") self.command = wx.TextCtrl(self,-1, "")
xbox = wx.BoxSizer(wx.HORIZONTAL) xbox = wx.BoxSizer(wx.HORIZONTAL)
xbox.Add(self.command, 1,wx.EXPAND) xbox.Add(self.command, 1, wx.EXPAND)
self.command.Bind(wx.EVT_TEXT, self.macrob_enabler) self.command.Bind(wx.EVT_TEXT, self.macrob_enabler)
self.macrob = wx.Button(self,-1,"..",style = wx.BU_EXACTFIT) self.macrob = wx.Button(self,-1, "..", style = wx.BU_EXACTFIT)
self.macrob.Bind(wx.EVT_BUTTON, self.macrob_handler) self.macrob.Bind(wx.EVT_BUTTON, self.macrob_handler)
xbox.Add(self.macrob, 0) xbox.Add(self.macrob, 0)
grid.Add(xbox, 1,wx.EXPAND) grid.Add(xbox, 1, wx.EXPAND)
grid.Add(wx.StaticText(self,-1, _("Color")),0, wx.BOTTOM|wx.RIGHT) grid.Add(wx.StaticText(self,-1, _("Color")), 0, wx.BOTTOM|wx.RIGHT)
self.color = wx.TextCtrl(self,-1,"") self.color = wx.TextCtrl(self,-1, "")
grid.Add(self.color, 1,wx.EXPAND) grid.Add(self.color, 1, wx.EXPAND)
topsizer.Add(grid, 0,wx.EXPAND) topsizer.Add(grid, 0, wx.EXPAND)
topsizer.Add( (0, 0),1) topsizer.Add( (0, 0), 1)
topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL),0, wx.ALIGN_CENTER) topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL), 0, wx.ALIGN_CENTER)
self.SetSizer(topsizer) self.SetSizer(topsizer)
def macrob_enabler(self, e): def macrob_enabler(self, e):
...@@ -212,7 +212,7 @@ class ButtonEdit(wx.Dialog): ...@@ -212,7 +212,7 @@ class ButtonEdit(wx.Dialog):
class TempGauge(wx.Panel): class TempGauge(wx.Panel):
def __init__(self, parent, size = (200, 22),title = "",maxval = 240, gaugeColour = None): def __init__(self, parent, size = (200, 22), title = "", maxval = 240, gaugeColour = None):
wx.Panel.__init__(self, parent,-1, size = size) wx.Panel.__init__(self, parent,-1, size = size)
self.Bind(wx.EVT_PAINT, self.paint) self.Bind(wx.EVT_PAINT, self.paint)
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
...@@ -225,7 +225,7 @@ class TempGauge(wx.Panel): ...@@ -225,7 +225,7 @@ class TempGauge(wx.Panel):
self.recalc() self.recalc()
def recalc(self): def recalc(self):
mmax = max(int(self.setpoint*1.05),self.max) mmax = max(int(self.setpoint*1.05), self.max)
self.scale = float(self.width-2)/float(mmax) self.scale = float(self.width-2)/float(mmax)
self.ypt = max(16, int(self.scale*max(self.setpoint, self.max/6))) self.ypt = max(16, int(self.scale*max(self.setpoint, self.max/6)))
...@@ -251,25 +251,25 @@ class TempGauge(wx.Panel): ...@@ -251,25 +251,25 @@ class TempGauge(wx.Panel):
return wx.Colour(*map(int, rgb)) return wx.Colour(*map(int, rgb))
def paint(self, ev): def paint(self, ev):
x0, y0, x1, y1, xE, yE = 1, 1,self.ypt+1, 1,self.width+1-2, 20 x0, y0, x1, y1, xE, yE = 1, 1, self.ypt+1, 1, self.width+1-2, 20
dc = wx.PaintDC(self) dc = wx.PaintDC(self)
dc.SetBackground(wx.Brush((255, 255, 255))) dc.SetBackground(wx.Brush((255, 255, 255)))
dc.Clear() dc.Clear()
cold, medium, hot = wx.Colour(0, 167, 223),wx.Colour(239, 233, 119),wx.Colour(210, 50.100) cold, medium, hot = wx.Colour(0, 167, 223), wx.Colour(239, 233, 119), wx.Colour(210, 50.100)
gauge1, gauge2 = wx.Colour(255, 255, 210),(self.gaugeColour or wx.Colour(234, 82, 0)) gauge1, gauge2 = wx.Colour(255, 255, 210), (self.gaugeColour or wx.Colour(234, 82, 0))
shadow1, shadow2 = wx.Colour(110, 110, 110),wx.Colour(255, 255, 255) shadow1, shadow2 = wx.Colour(110, 110, 110), wx.Colour(255, 255, 255)
gc = wx.GraphicsContext.Create(dc) gc = wx.GraphicsContext.Create(dc)
# draw shadow first # draw shadow first
# corners # corners
gc.SetBrush(gc.CreateRadialGradientBrush(xE-7, 9,xE-7, 9,8, shadow1, shadow2)) gc.SetBrush(gc.CreateRadialGradientBrush(xE-7, 9, xE-7, 9, 8, shadow1, shadow2))
gc.DrawRectangle(xE-7, 1,8, 8) gc.DrawRectangle(xE-7, 1, 8, 8)
gc.SetBrush(gc.CreateRadialGradientBrush(xE-7, 17, xE-7, 17, 8,shadow1, shadow2)) gc.SetBrush(gc.CreateRadialGradientBrush(xE-7, 17, xE-7, 17, 8, shadow1, shadow2))
gc.DrawRectangle(xE-7, 17, 8,8) gc.DrawRectangle(xE-7, 17, 8, 8)
gc.SetBrush(gc.CreateRadialGradientBrush(x0+6, 17, x0+6, 17, 8,shadow1, shadow2)) gc.SetBrush(gc.CreateRadialGradientBrush(x0+6, 17, x0+6, 17, 8, shadow1, shadow2))
gc.DrawRectangle(0, 17, x0+6, 8) gc.DrawRectangle(0, 17, x0+6, 8)
# edges # edges
gc.SetBrush(gc.CreateLinearGradientBrush(xE-13, 0,xE-6, 0,shadow1, shadow2)) gc.SetBrush(gc.CreateLinearGradientBrush(xE-13, 0, xE-6, 0, shadow1, shadow2))
gc.DrawRectangle(xE-6, 9,10, 8) gc.DrawRectangle(xE-6, 9, 10, 8)
gc.SetBrush(gc.CreateLinearGradientBrush(x0, yE-2, x0, yE+5, shadow1, shadow2)) gc.SetBrush(gc.CreateLinearGradientBrush(x0, yE-2, x0, yE+5, shadow1, shadow2))
gc.DrawRectangle(x0+6, yE-2, xE-12, 7) gc.DrawRectangle(x0+6, yE-2, xE-12, 7)
# draw gauge background # draw gauge background
...@@ -283,7 +283,7 @@ class TempGauge(wx.Panel): ...@@ -283,7 +283,7 @@ class TempGauge(wx.Panel):
w2 = w1+width w2 = w1+width
value = x0+max(10, min(self.width+1-2, int(self.value*self.scale))) value = x0+max(10, min(self.width+1-2, int(self.value*self.scale)))
#gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0+3, x0, y0+15, gauge1, gauge2)) #gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0+3, x0, y0+15, gauge1, gauge2))
#gc.SetBrush(gc.CreateLinearGradientBrush(0, 3,0, 15, wx.Colour(255, 255, 255),wx.Colour(255, 90, 32))) #gc.SetBrush(gc.CreateLinearGradientBrush(0, 3, 0, 15, wx.Colour(255, 255, 255), wx.Colour(255, 90, 32)))
gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0+3, x0, y0+15, gauge1, self.interpolatedColour(value, x0, x1, xE, cold, medium, hot))) gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0+3, x0, y0+15, gauge1, self.interpolatedColour(value, x0, x1, xE, cold, medium, hot)))
val_path = gc.CreatePath() val_path = gc.CreatePath()
val_path.MoveToPoint(x0, w1) val_path.MoveToPoint(x0, w1)
...@@ -296,7 +296,7 @@ class TempGauge(wx.Panel): ...@@ -296,7 +296,7 @@ class TempGauge(wx.Panel):
gc.DrawPath(val_path) gc.DrawPath(val_path)
# draw setpoint markers # draw setpoint markers
setpoint = x0+max(10, int(self.setpoint*self.scale)) setpoint = x0+max(10, int(self.setpoint*self.scale))
gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0,0)))) gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0, 0))))
setp_path = gc.CreatePath() setp_path = gc.CreatePath()
setp_path.MoveToPoint(setpoint-4, y0) setp_path.MoveToPoint(setpoint-4, y0)
setp_path.AddLineToPoint(setpoint+4, y0) setp_path.AddLineToPoint(setpoint+4, y0)
...@@ -307,9 +307,9 @@ class TempGauge(wx.Panel): ...@@ -307,9 +307,9 @@ class TempGauge(wx.Panel):
gc.DrawPath(setp_path) gc.DrawPath(setp_path)
# draw readout # draw readout
text = u"T\u00B0 %u/%u"%(self.value, self.setpoint) text = u"T\u00B0 %u/%u"%(self.value, self.setpoint)
#gc.SetFont(gc.CreateFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD),wx.WHITE)) #gc.SetFont(gc.CreateFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), wx.WHITE))
#gc.DrawText(text, 29,-2) #gc.DrawText(text, 29,-2)
gc.SetFont(gc.CreateFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD),wx.WHITE)) gc.SetFont(gc.CreateFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD), wx.WHITE))
gc.DrawText(self.title, x0+19, y0+4) gc.DrawText(self.title, x0+19, y0+4)
gc.DrawText(text, x0+119, y0+4) gc.DrawText(text, x0+119, y0+4)
gc.SetFont(gc.CreateFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))) gc.SetFont(gc.CreateFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)))
......
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
import sys, struct, math import sys, struct, math
def cross(v1, v2): def cross(v1, v2):
return [v1[1]*v2[2]-v1[2]*v2[1],v1[2]*v2[0]-v1[0]*v2[2],v1[0]*v2[1]-v1[1]*v2[0]] return [v1[1]*v2[2]-v1[2]*v2[1], v1[2]*v2[0]-v1[0]*v2[2], v1[0]*v2[1]-v1[1]*v2[0]]
def genfacet(v): def genfacet(v):
veca=[v[1][0]-v[0][0],v[1][1]-v[0][1],v[1][2]-v[0][2]] veca = [v[1][0]-v[0][0], v[1][1]-v[0][1], v[1][2]-v[0][2]]
vecb=[v[2][0]-v[1][0],v[2][1]-v[1][1],v[2][2]-v[1][2]] vecb = [v[2][0]-v[1][0], v[2][1]-v[1][1], v[2][2]-v[1][2]]
vecx = cross(veca, vecb) vecx = cross(veca, vecb)
vlen = math.sqrt(sum(map(lambda x:x*x, vecx))) vlen = math.sqrt(sum(map(lambda x:x*x, vecx)))
if vlen == 0: if vlen == 0:
...@@ -28,11 +28,11 @@ def genfacet(v): ...@@ -28,11 +28,11 @@ def genfacet(v):
normal = map(lambda x:x/vlen, vecx) normal = map(lambda x:x/vlen, vecx)
return [normal, v] return [normal, v]
I=[ I = [
[1, 0,0, 0], [1, 0, 0, 0],
[0, 1,0, 0], [0, 1, 0, 0],
[0, 0,1, 0], [0, 0, 1, 0],
[0, 0,0, 1] [0, 0, 0, 1]
] ]
def transpose(matrix): def transpose(matrix):
...@@ -44,24 +44,24 @@ def multmatrix(vector, matrix): ...@@ -44,24 +44,24 @@ def multmatrix(vector, matrix):
def applymatrix(facet, matrix = I): def applymatrix(facet, matrix = I):
#return facet #return facet
#return [map(lambda x:-1.0*x, multmatrix(facet[0]+[1],matrix)[:3]),map(lambda x:multmatrix(x+[1],matrix)[:3],facet[1])] #return [map(lambda x:-1.0*x, multmatrix(facet[0]+[1], matrix)[:3]), map(lambda x:multmatrix(x+[1], matrix)[:3], facet[1])]
return genfacet(map(lambda x:multmatrix(x+[1],matrix)[:3],facet[1])) return genfacet(map(lambda x:multmatrix(x+[1], matrix)[:3], facet[1]))
f=[[0, 0,0],[[-3.022642, 0.642482, -9.510565],[-3.022642, 0.642482, -9.510565],[-3.022642, 0.642482, -9.510565]]] f = [[0, 0, 0],[[-3.022642, 0.642482, -9.510565],[-3.022642, 0.642482, -9.510565],[-3.022642, 0.642482, -9.510565]]]
m=[ m = [
[1, 0,0, 0], [1, 0, 0, 0],
[0, 1,0, 0], [0, 1, 0, 0],
[0, 0,1, 1], [0, 0, 1, 1],
[0, 0,0, 1] [0, 0, 0, 1]
] ]
def emitstl(filename, facets=[],objname = "stltool_export",binary = 1): def emitstl(filename, facets = [], objname = "stltool_export", binary = 1):
if filename is None: if filename is None:
return return
if binary: if binary:
f = open(filename,"wb") f = open(filename, "wb")
buf = "".join(["\0"]*80) buf = "".join(["\0"]*80)
buf+=struct.pack("<I",len(facets)) buf+=struct.pack("<I", len(facets))
facetformat = struct.Struct("<ffffffffffffH") facetformat = struct.Struct("<ffffffffffffH")
for i in facets: for i in facets:
l = list(i[0][:]) l = list(i[0][:])
...@@ -75,7 +75,7 @@ def emitstl(filename, facets=[],objname = "stltool_export",binary = 1): ...@@ -75,7 +75,7 @@ def emitstl(filename, facets=[],objname = "stltool_export",binary = 1):
return return
f = open(filename,"w") f = open(filename, "w")
f.write("solid "+objname+"\n") f.write("solid "+objname+"\n")
for i in facets: for i in facets:
f.write(" facet normal "+" ".join(map(str, i[0]))+"\n outer loop\n") f.write(" facet normal "+" ".join(map(str, i[0]))+"\n outer loop\n")
...@@ -90,10 +90,10 @@ def emitstl(filename, facets=[],objname = "stltool_export",binary = 1): ...@@ -90,10 +90,10 @@ def emitstl(filename, facets=[],objname = "stltool_export",binary = 1):
class stl: class stl:
def __init__(self, filename = None): def __init__(self, filename = None):
self.facet=[[0, 0,0],[[0, 0,0],[0, 0,0],[0, 0,0]]] self.facet = [[0, 0, 0],[[0, 0, 0],[0, 0, 0],[0, 0, 0]]]
self.facets=[] self.facets = []
self.facetsminz=[] self.facetsminz = []
self.facetsmaxz=[] self.facetsmaxz = []
self.name = "" self.name = ""
self.insolid = 0 self.insolid = 0
...@@ -105,14 +105,14 @@ class stl: ...@@ -105,14 +105,14 @@ class stl:
self.f = list(open(filename)) self.f = list(open(filename))
if not self.f[0].startswith("solid"): if not self.f[0].startswith("solid"):
print "Not an ascii stl solid - attempting to parse as binary" print "Not an ascii stl solid - attempting to parse as binary"
f = open(filename,"rb") f = open(filename, "rb")
buf = f.read(84) buf = f.read(84)
while(len(buf)<84): while(len(buf)<84):
newdata = f.read(84-len(buf)) newdata = f.read(84-len(buf))
if not len(newdata): if not len(newdata):
break break
buf+=newdata buf+=newdata
facetcount = struct.unpack_from("<I",buf, 80) facetcount = struct.unpack_from("<I", buf, 80)
facetformat = struct.Struct("<ffffffffffffH") facetformat = struct.Struct("<ffffffffffffH")
for i in xrange(facetcount[0]): for i in xrange(facetcount[0]):
buf = f.read(50) buf = f.read(50)
...@@ -123,72 +123,72 @@ class stl: ...@@ -123,72 +123,72 @@ class stl:
buf+=newdata buf+=newdata
fd = list(facetformat.unpack(buf)) fd = list(facetformat.unpack(buf))
self.name = "binary soloid" self.name = "binary soloid"
self.facet=[fd[:3],[fd[3:6],fd[6:9],fd[9:12]]] self.facet = [fd[:3],[fd[3:6], fd[6:9], fd[9:12]]]
self.facets+=[self.facet] self.facets+=[self.facet]
facet = self.facet facet = self.facet
self.facetsminz+=[(min(map(lambda x:x[2], facet[1])),facet)] self.facetsminz+=[(min(map(lambda x:x[2], facet[1])), facet)]
self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])),facet)] self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])), facet)]
f.close() f.close()
return return
for i in self.f: for i in self.f:
if not self.parseline(i): if not self.parseline(i):
return return
def translate(self, v=[0, 0,0]): def translate(self, v = [0, 0, 0]):
matrix=[ matrix = [
[1, 0,0, v[0]], [1, 0, 0, v[0]],
[0, 1,0, v[1]], [0, 1, 0, v[1]],
[0, 0,1, v[2]], [0, 0, 1, v[2]],
[0, 0,0, 1] [0, 0, 0, 1]
] ]
return self.transform(matrix) return self.transform(matrix)
def rotate(self, v=[0, 0,0]): def rotate(self, v = [0, 0, 0]):
import math import math
z = v[2] z = v[2]
matrix1=[ matrix1 = [
[math.cos(math.radians(z)),-math.sin(math.radians(z)),0, 0], [math.cos(math.radians(z)),-math.sin(math.radians(z)), 0, 0],
[math.sin(math.radians(z)),math.cos(math.radians(z)),0, 0], [math.sin(math.radians(z)), math.cos(math.radians(z)), 0, 0],
[0, 0,1, 0], [0, 0, 1, 0],
[0, 0,0, 1] [0, 0, 0, 1]
] ]
y = v[0] y = v[0]
matrix2=[ matrix2 = [
[1, 0,0, 0], [1, 0, 0, 0],
[0, math.cos(math.radians(y)),-math.sin(math.radians(y)),0], [0, math.cos(math.radians(y)),-math.sin(math.radians(y)), 0],
[0, math.sin(math.radians(y)),math.cos(math.radians(y)),0], [0, math.sin(math.radians(y)), math.cos(math.radians(y)), 0],
[0, 0,0, 1] [0, 0, 0, 1]
] ]
x = v[1] x = v[1]
matrix3=[ matrix3 = [
[math.cos(math.radians(x)),0,-math.sin(math.radians(x)),0], [math.cos(math.radians(x)), 0,-math.sin(math.radians(x)), 0],
[0, 1,0, 0], [0, 1, 0, 0],
[math.sin(math.radians(x)),0, math.cos(math.radians(x)),0], [math.sin(math.radians(x)), 0, math.cos(math.radians(x)), 0],
[0, 0,0, 1] [0, 0, 0, 1]
] ]
return self.transform(matrix1).transform(matrix2).transform(matrix3) return self.transform(matrix1).transform(matrix2).transform(matrix3)
def scale(self, v=[0, 0,0]): def scale(self, v = [0, 0, 0]):
matrix=[ matrix = [
[v[0],0, 0,0], [v[0], 0, 0, 0],
[0, v[1],0, 0], [0, v[1], 0, 0],
[0, 0,v[2],0], [0, 0, v[2], 0],
[0, 0,0, 1] [0, 0, 0, 1]
] ]
return self.transform(matrix) return self.transform(matrix)
def transform(self, m = I): def transform(self, m = I):
s = stl() s = stl()
s.facets=[applymatrix(i, m) for i in self.facets] s.facets = [applymatrix(i, m) for i in self.facets]
s.insolid = 0 s.insolid = 0
s.infacet = 0 s.infacet = 0
s.inloop = 0 s.inloop = 0
s.facetloc = 0 s.facetloc = 0
s.name = self.name s.name = self.name
for facet in s.facets: for facet in s.facets:
s.facetsminz+=[(min(map(lambda x:x[2], facet[1])),facet)] s.facetsminz+=[(min(map(lambda x:x[2], facet[1])), facet)]
s.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])),facet)] s.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])), facet)]
return s return s
def export(self, f = sys.stdout): def export(self, f = sys.stdout):
...@@ -214,19 +214,19 @@ class stl: ...@@ -214,19 +214,19 @@ class stl:
self.insolid = 0 self.insolid = 0
return 0 return 0
elif l.startswith("facet normal"): elif l.startswith("facet normal"):
l = l.replace(",",".") l = l.replace(", ",".")
self.infacet = 11 self.infacet = 11
self.facetloc = 0 self.facetloc = 0
self.facet=[[0, 0,0],[[0, 0,0],[0, 0,0],[0, 0,0]]] self.facet = [[0, 0, 0],[[0, 0, 0],[0, 0, 0],[0, 0, 0]]]
self.facet[0]=map(float, l.split()[2:]) self.facet[0]=map(float, l.split()[2:])
elif l.startswith("endfacet"): elif l.startswith("endfacet"):
self.infacet = 0 self.infacet = 0
self.facets+=[self.facet] self.facets+=[self.facet]
facet = self.facet facet = self.facet
self.facetsminz+=[(min(map(lambda x:x[2], facet[1])),facet)] self.facetsminz+=[(min(map(lambda x:x[2], facet[1])), facet)]
self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])),facet)] self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])), facet)]
elif l.startswith("vertex"): elif l.startswith("vertex"):
l = l.replace(",",".") l = l.replace(", ",".")
self.facet[1][self.facetloc]=map(float, l.split()[1:]) self.facet[1][self.facetloc]=map(float, l.split()[1:])
self.facetloc+=1 self.facetloc+=1
return 1 return 1
...@@ -246,5 +246,5 @@ if __name__ == "__main__": ...@@ -246,5 +246,5 @@ if __name__ == "__main__":
break break
print i, len(working) print i, len(working)
emitstl("../../Downloads/frame-vertex-neo-foot-x4-a.stl",s.facets,"emitted_object") emitstl("../../Downloads/frame-vertex-neo-foot-x4-a.stl", s.facets, "emitted_object")
#stl("../prusamendel/stl/mendelplate.stl") #stl("../prusamendel/stl/mendelplate.stl")
...@@ -839,7 +839,7 @@ class GCFrame(wx.Frame): ...@@ -839,7 +839,7 @@ class GCFrame(wx.Frame):
self.modelindex = 0 self.modelindex = 0
self.GLPanel1 = TestGlPanel(self, size) self.GLPanel1 = TestGlPanel(self, size)
def addfile(self, gcode=[]): def addfile(self, gcode = []):
self.models[""].gc.delete() self.models[""].gc.delete()
self.models[""].gc = gcview(gcode, batch = self.models[""].batch) self.models[""].gc = gcview(gcode, batch = self.models[""].batch)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import wx import wx
def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise = False): def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise = False):
""" Draws an arc of an ellipse within bounding rect (x, y,w, h) """ Draws an arc of an ellipse within bounding rect (x, y, w, h)
from startArc to endArc (in radians, relative to the horizontal line of the eclipse)""" from startArc to endArc (in radians, relative to the horizontal line of the eclipse)"""
if True: if True:
......
...@@ -35,7 +35,7 @@ url = ( ...@@ -35,7 +35,7 @@ url = (
#paint value will parse into a (type, details) tuple. #paint value will parse into a (type, details) tuple.
#For none and currentColor, the details tuple will be the empty tuple #For none and currentColor, the details tuple will be the empty tuple
#for CSS color declarations, it will be (type, (R, G,B)) #for CSS color declarations, it will be (type, (R, G, B))
#for URLs, it will be ("URL", ((url tuple), fallback)) #for URLs, it will be ("URL", ((url tuple), fallback))
#The url tuple will be as returned by urlparse.urlsplit, and can be #The url tuple will be as returned by urlparse.urlsplit, and can be
#an empty tuple if the parser has an error #an empty tuple if the parser has an error
......
...@@ -175,14 +175,14 @@ class SVGDocument(object): ...@@ -175,14 +175,14 @@ class SVGDocument(object):
) )
if transform == 'skewX': if transform == 'skewX':
matrix = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix( matrix = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix(
1, 0,math.tan(math.radians(args[0])),1, 0,0 1, 0, math.tan(math.radians(args[0])), 1, 0, 0
) )
ops.append( ops.append(
(wx.GraphicsContext.ConcatTransform, (matrix,)) (wx.GraphicsContext.ConcatTransform, (matrix,))
) )
if transform == 'skewY': if transform == 'skewY':
matrix = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix( matrix = wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix(
1, math.tan(math.radians(args[0])),0, 1,0, 0 1, math.tan(math.radians(args[0])), 0, 1, 0, 0
) )
ops.append( ops.append(
(wx.GraphicsContext.ConcatTransform, (matrix,)) (wx.GraphicsContext.ConcatTransform, (matrix,))
...@@ -465,29 +465,29 @@ class SVGDocument(object): ...@@ -465,29 +465,29 @@ class SVGDocument(object):
box = path.GetBox() box = path.GetBox()
x, y, w, h = box.Get() x, y, w, h = box.Get()
return wx.GraphicsRenderer.GetDefaultRenderer().CreateLinearGradientBrush( return wx.GraphicsRenderer.GetDefaultRenderer().CreateLinearGradientBrush(
x, y,x+w, y+h, wx.Colour(0, 0,255, 128), wx.RED x, y, x+w, y+h, wx.Colour(0, 0, 255, 128), wx.RED
) )
elif element.tag == '{http://www.w3.org/2000/svg}radialGradient': elif element.tag == '{http://www.w3.org/2000/svg}radialGradient':
box = path.GetBox() box = path.GetBox()
x, y, w, h = box.Get() x, y, w, h = box.Get()
#print w #print w
mx = wx.GraphicsRenderer.GetDefaultRenderer().CreateMatrix(x, y,w, h) mx = wx.GraphicsRenderer.GetDefaultRenderer().CreateMatrix(x, y, w, h)
cx, cy = mx.TransformPoint(0.5, 0.5) cx, cy = mx.TransformPoint(0.5, 0.5)
fx, fy = cx, cy fx, fy = cx, cy
return wx.GraphicsRenderer.GetDefaultRenderer().CreateRadialGradientBrush( return wx.GraphicsRenderer.GetDefaultRenderer().CreateRadialGradientBrush(
cx, cy, cx, cy,
fx, fy, fx, fy,
(max(w, h))/2, (max(w, h))/2,
wx.Colour(0, 0,255, 128), wx.RED wx.Colour(0, 0, 255, 128), wx.RED
) )
else: else:
#invlid gradient specified #invlid gradient specified
return wx.NullBrush return wx.NullBrush
r, g,b = 0, 0,0 r, g, b = 0, 0, 0
if type == 'CURRENTCOLOR': if type == 'CURRENTCOLOR':
type, details = paintValue.parseString(self.state.get('color', 'none')) type, details = paintValue.parseString(self.state.get('color', 'none'))
if type == 'RGB': if type == 'RGB':
r, g,b = details r, g, b = details
elif type == "NONE": elif type == "NONE":
return wx.NullBrush return wx.NullBrush
opacity = self.state.get('fill-opacity', self.state.get('opacity', '1')) opacity = self.state.get('fill-opacity', self.state.get('opacity', '1'))
...@@ -499,9 +499,9 @@ class SVGDocument(object): ...@@ -499,9 +499,9 @@ class SVGDocument(object):
#be created every time anyway in order to pass them, #be created every time anyway in order to pass them,
#defeating the purpose of the cache #defeating the purpose of the cache
try: try:
return SVGDocument.brushCache[(r, g,b, a)] return SVGDocument.brushCache[(r, g, b, a)]
except KeyError: except KeyError:
return SVGDocument.brushCache.setdefault((r, g,b, a), wx.Brush(wx.Colour(r, g,b, a))) return SVGDocument.brushCache.setdefault((r, g, b, a), wx.Brush(wx.Colour(r, g, b, a)))
def resolveURL(self, urlData): def resolveURL(self, urlData):
...@@ -584,7 +584,7 @@ class SVGDocument(object): ...@@ -584,7 +584,7 @@ class SVGDocument(object):
control1 = reflectPoint(self.lastControl, path.GetCurrentPoint()) control1 = reflectPoint(self.lastControl, path.GetCurrentPoint())
else: else:
control1 = path.GetCurrentPoint() control1 = path.GetCurrentPoint()
#~ print "S", self.lastControl,":",control1, control2, endpoint #~ print "S", self.lastControl, ":", control1, control2, endpoint
self.lastControl = control2 self.lastControl = control2
path.AddCurveToPoint( path.AddCurveToPoint(
control1, control1,
......
...@@ -208,13 +208,13 @@ class XMLstatus(object): ...@@ -208,13 +208,13 @@ class XMLstatus(object):
txt = txt+'<file>'+str(gPronterPtr.filename)+'</file>\n' txt = txt+'<file>'+str(gPronterPtr.filename)+'</file>\n'
txt = txt+'<status>'+str(gPronterPtr.status.GetStatusText())+'</status>\n' txt = txt+'<status>'+str(gPronterPtr.status.GetStatusText())+'</status>\n'
try: try:
temp = str(float(filter(lambda x:x.startswith("T:"),gPronterPtr.tempreport.split())[0].split(":")[1])) temp = str(float(filter(lambda x:x.startswith("T:"), gPronterPtr.tempreport.split())[0].split(":")[1]))
txt = txt+'<hotend>'+temp+'</hotend>\n' txt = txt+'<hotend>'+temp+'</hotend>\n'
except: except:
txt = txt+'<hotend>NA</hotend>\n' txt = txt+'<hotend>NA</hotend>\n'
pass pass
try: try:
temp = str(float(filter(lambda x:x.startswith("B:"),gPronterPtr.tempreport.split())[0].split(":")[1])) temp = str(float(filter(lambda x:x.startswith("B:"), gPronterPtr.tempreport.split())[0].split(":")[1]))
txt = txt+'<bed>'+temp+'</bed>\n' txt = txt+'<bed>'+temp+'</bed>\n'
except: except:
txt = txt+'<bed>NA</bed>\n' txt = txt+'<bed>NA</bed>\n'
...@@ -288,11 +288,11 @@ class WebInterface(object): ...@@ -288,11 +288,11 @@ class WebInterface(object):
pageText+="<img src='/images/control_xy.png' usemap='#xymap'/>" pageText+="<img src='/images/control_xy.png' usemap='#xymap'/>"
pageText+='<map name = "xymap">' pageText+='<map name = "xymap">'
pageText+='<area shape = "rect" coords = "8, 5,51, 48" href = "/home/axis/x" alt = "X Home" title = "X Home" />' pageText+='<area shape = "rect" coords = "8, 5, 51, 48" href = "/home/axis/x" alt = "X Home" title = "X Home" />'
pageText+='<area shape = "rect" coords = "195, 6,236, 46" href = "/home/axis/y" alt = "Y Home" title = "Y Home" />' pageText+='<area shape = "rect" coords = "195, 6, 236, 46" href = "/home/axis/y" alt = "Y Home" title = "Y Home" />'
pageText+='<area shape = "rect" coords = "7, 192, 48, 232" href = "/home/axis/all" alt = "All Home" title = "All Home" />' pageText+='<area shape = "rect" coords = "7, 192, 48, 232" href = "/home/axis/all" alt = "All Home" title = "All Home" />'
pageText+='<area shape = "rect" coords = "194, 192, 235, 232" href = "/home/axis/z" alt = "Z Home" title = "Z Home" />' pageText+='<area shape = "rect" coords = "194, 192, 235, 232" href = "/home/axis/z" alt = "Z Home" title = "Z Home" />'
pageText+='<area shape = "rect" coords = "62, 7,185, 34" href = "/move/axis/y/100" alt = "Y 100" title = "Y 100" />' pageText+='<area shape = "rect" coords = "62, 7, 185, 34" href = "/move/axis/y/100" alt = "Y 100" title = "Y 100" />'
pageText+='<area shape = "rect" coords = "68, 34, 175, 61" href = "/move/axis/y/10" alt = "Y 10" title = "Y 10" />' pageText+='<area shape = "rect" coords = "68, 34, 175, 61" href = "/move/axis/y/10" alt = "Y 10" title = "Y 10" />'
pageText+='<area shape = "rect" coords = "80, 60, 163, 84" href = "/move/axis/y/1" alt = "Y 1" title = "Y 1" />' pageText+='<area shape = "rect" coords = "80, 60, 163, 84" href = "/move/axis/y/1" alt = "Y 1" title = "Y 1" />'
pageText+='<area shape = "rect" coords = "106, 83, 138, 107" href = "/move/axis/y/.1" alt = "Y .1" title = "Y .1" />' pageText+='<area shape = "rect" coords = "106, 83, 138, 107" href = "/move/axis/y/.1" alt = "Y .1" title = "Y .1" />'
......
...@@ -42,8 +42,8 @@ class XYButtons(BufferedCanvas): ...@@ -42,8 +42,8 @@ class XYButtons(BufferedCanvas):
spacer = 7 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):
self.bg_bmp = wx.Image(imagefile("control_xy.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap() 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_bmp = wx.Image(imagefile("arrow_keys.png"), wx.BITMAP_TYPE_PNG).ConvertToBitmap()
self.keypad_idx = -1 self.keypad_idx = -1
self.quadrant = None self.quadrant = None
self.concentric = None self.concentric = None
...@@ -230,7 +230,7 @@ class XYButtons(BufferedCanvas): ...@@ -230,7 +230,7 @@ class XYButtons(BufferedCanvas):
if self.enabled: if self.enabled:
# Brush and pen for grey overlay when mouse hovers over # Brush and pen for grey overlay when mouse hovers over
gc.SetPen(wx.Pen(wx.Colour(100, 100, 100, 172), 4)) gc.SetPen(wx.Pen(wx.Colour(100, 100, 100, 172), 4))
gc.SetBrush(wx.Brush(wx.Colour(0, 0,0, 128))) gc.SetBrush(wx.Brush(wx.Colour(0, 0, 0, 128)))
if self.concentric != None: if self.concentric != None:
if self.concentric < len(XYButtons.concentric_circle_radii): if self.concentric < len(XYButtons.concentric_circle_radii):
......
...@@ -33,7 +33,7 @@ class ZButtons(BufferedCanvas): ...@@ -33,7 +33,7 @@ class ZButtons(BufferedCanvas):
} }
def __init__(self, parent, moveCallback = None, bgcolor = "#FFFFFF", ID=-1): def __init__(self, parent, moveCallback = None, bgcolor = "#FFFFFF", 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()
self.range = None self.range = None
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.
...@@ -117,7 +117,7 @@ class ZButtons(BufferedCanvas): ...@@ -117,7 +117,7 @@ class ZButtons(BufferedCanvas):
# Top 'layer' is the mouse-over highlights # Top 'layer' is the mouse-over highlights
gc.SetPen(wx.Pen(wx.Colour(100, 100, 100, 172), 4)) gc.SetPen(wx.Pen(wx.Colour(100, 100, 100, 172), 4))
gc.SetBrush(wx.Brush(wx.Colour(0, 0,0, 128))) gc.SetBrush(wx.Brush(wx.Colour(0, 0, 0, 128)))
if self.range != None and self.direction != None: if self.range != None and self.direction != None:
self.highlight(gc, self.range, self.direction) self.highlight(gc, self.range, self.direction)
else: else:
......
...@@ -17,57 +17,57 @@ import wx, math ...@@ -17,57 +17,57 @@ import wx, math
from stltool import * from stltool import *
a = wx.App() a = wx.App()
def genscape(data=[[0, 1,0, 0],[1, 0,2, 0],[1, 0,0, 0],[0, 1,0, 1]],pscale = 1.0, bheight = 1.0, zscale = 1.0): def genscape(data = [[0, 1, 0, 0],[1, 0, 2, 0],[1, 0, 0, 0],[0, 1, 0, 1]], pscale = 1.0, bheight = 1.0, zscale = 1.0):
o = stl(None) o = stl(None)
datal = len(data) datal = len(data)
datah = len(data[0]) datah = len(data[0])
#create bottom: #create bottom:
bmidpoint = (pscale*(datal-1)/2.0, pscale*(datah-1)/2.0) bmidpoint = (pscale*(datal-1)/2.0, pscale*(datah-1)/2.0)
#print range(datal),bmidpoint #print range(datal), bmidpoint
for i in zip(range(datal+1)[:-1],range(datal+1)[1:])[:-1]: for i in zip(range(datal+1)[:-1], range(datal+1)[1:])[:-1]:
#print (pscale*i[0],pscale*i[1]) #print (pscale*i[0], pscale*i[1])
o.facets+=[[[0, 0,-1],[[0.0, pscale*i[0],0.0],[0.0, pscale*i[1],0.0],[bmidpoint[0],bmidpoint[1],0.0]]]] o.facets+=[[[0, 0,-1],[[0.0, pscale*i[0], 0.0],[0.0, pscale*i[1], 0.0],[bmidpoint[0], bmidpoint[1], 0.0]]]]
o.facets+=[[[0, 0,-1],[[2.0*bmidpoint[1],pscale*i[1],0.0],[2.0*bmidpoint[1],pscale*i[0],0.0],[bmidpoint[0],bmidpoint[1],0.0]]]] o.facets+=[[[0, 0,-1],[[2.0*bmidpoint[1], pscale*i[1], 0.0],[2.0*bmidpoint[1], pscale*i[0], 0.0],[bmidpoint[0], bmidpoint[1], 0.0]]]]
o.facets+=[genfacet([[0.0, pscale*i[0],data[i[0]][0]*zscale+bheight],[0.0, pscale*i[1],data[i[1]][0]*zscale+bheight],[0.0, pscale*i[1],0.0]])] o.facets+=[genfacet([[0.0, pscale*i[0], data[i[0]][0]*zscale+bheight],[0.0, pscale*i[1], data[i[1]][0]*zscale+bheight],[0.0, pscale*i[1], 0.0]])]
o.facets+=[genfacet([[2.0*bmidpoint[1],pscale*i[1],data[i[1]][datah-1]*zscale+bheight],[2.0*bmidpoint[1],pscale*i[0],data[i[0]][datah-1]*zscale+bheight],[2.0*bmidpoint[1],pscale*i[1],0.0]])] o.facets+=[genfacet([[2.0*bmidpoint[1], pscale*i[1], data[i[1]][datah-1]*zscale+bheight],[2.0*bmidpoint[1], pscale*i[0], data[i[0]][datah-1]*zscale+bheight],[2.0*bmidpoint[1], pscale*i[1], 0.0]])]
o.facets+=[genfacet([[0.0, pscale*i[0],data[i[0]][0]*zscale+bheight],[0.0, pscale*i[1],0.0],[0.0, pscale*i[0],0.0]])] o.facets+=[genfacet([[0.0, pscale*i[0], data[i[0]][0]*zscale+bheight],[0.0, pscale*i[1], 0.0],[0.0, pscale*i[0], 0.0]])]
o.facets+=[genfacet([[2.0*bmidpoint[1],pscale*i[1],0.0],[2.0*bmidpoint[1],pscale*i[0],data[i[0]][datah-1]*zscale+bheight],[2.0*bmidpoint[1],pscale*i[0],0.0]])] o.facets+=[genfacet([[2.0*bmidpoint[1], pscale*i[1], 0.0],[2.0*bmidpoint[1], pscale*i[0], data[i[0]][datah-1]*zscale+bheight],[2.0*bmidpoint[1], pscale*i[0], 0.0]])]
#print o.facets[-1] #print o.facets[-1]
pass pass
#print o.facets[-4:] #print o.facets[-4:]
for i in zip(range(datah+1)[:-1],range(datah+1)[1:])[:-1]: for i in zip(range(datah+1)[:-1], range(datah+1)[1:])[:-1]:
#print (pscale*i[0],pscale*i[1]) #print (pscale*i[0], pscale*i[1])
o.facets+=[[[0, 0,-1],[[pscale*i[1],0.0, 0.0],[pscale*i[0],0.0, 0.0],[bmidpoint[0],bmidpoint[1],0.0]]]] o.facets+=[[[0, 0,-1],[[pscale*i[1], 0.0, 0.0],[pscale*i[0], 0.0, 0.0],[bmidpoint[0], bmidpoint[1], 0.0]]]]
o.facets+=[[[0, 0,-1],[[pscale*i[0],2.0*bmidpoint[0],0.0],[pscale*i[1],2.0*bmidpoint[0],0.0],[bmidpoint[0],bmidpoint[1],0.0]]]] o.facets+=[[[0, 0,-1],[[pscale*i[0], 2.0*bmidpoint[0], 0.0],[pscale*i[1], 2.0*bmidpoint[0], 0.0],[bmidpoint[0], bmidpoint[1], 0.0]]]]
o.facets+=[genfacet([[pscale*i[1],0.0, data[0][i[1]]*zscale+bheight],[pscale*i[0],0.0, data[0][i[0]]*zscale+bheight],[pscale*i[1],0.0, 0.0]])] o.facets+=[genfacet([[pscale*i[1], 0.0, data[0][i[1]]*zscale+bheight],[pscale*i[0], 0.0, data[0][i[0]]*zscale+bheight],[pscale*i[1], 0.0, 0.0]])]
#break #break
o.facets+=[genfacet([[pscale*i[0],2.0*bmidpoint[0],data[datal-1][i[0]]*zscale+bheight],[pscale*i[1],2.0*bmidpoint[0],data[datal-1][i[1]]*zscale+bheight],[pscale*i[1],2.0*bmidpoint[0],0.0]])] o.facets+=[genfacet([[pscale*i[0], 2.0*bmidpoint[0], data[datal-1][i[0]]*zscale+bheight],[pscale*i[1], 2.0*bmidpoint[0], data[datal-1][i[1]]*zscale+bheight],[pscale*i[1], 2.0*bmidpoint[0], 0.0]])]
o.facets+=[genfacet([[pscale*i[1],0.0, 0.0],[pscale*i[0],0.0, data[0][i[0]]*zscale+bheight],[pscale*i[0],0.0, 0.0]])] o.facets+=[genfacet([[pscale*i[1], 0.0, 0.0],[pscale*i[0], 0.0, data[0][i[0]]*zscale+bheight],[pscale*i[0], 0.0, 0.0]])]
o.facets+=[genfacet([[pscale*i[0],2.0*bmidpoint[0],data[datal-1][i[0]]*zscale+bheight],[pscale*i[1],2.0*bmidpoint[0],0.0],[pscale*i[0],2.0*bmidpoint[0],0.0]])] o.facets+=[genfacet([[pscale*i[0], 2.0*bmidpoint[0], data[datal-1][i[0]]*zscale+bheight],[pscale*i[1], 2.0*bmidpoint[0], 0.0],[pscale*i[0], 2.0*bmidpoint[0], 0.0]])]
pass pass
for i in xrange(datah-1): for i in xrange(datah-1):
for j in xrange(datal-1): for j in xrange(datal-1):
o.facets+=[genfacet([[pscale*i, pscale*j, data[j][i]*zscale+bheight],[pscale*(i+1),pscale*(j),data[j][i+1]*zscale+bheight],[pscale*(i+1),pscale*(j+1),data[j+1][i+1]*zscale+bheight]])] o.facets+=[genfacet([[pscale*i, pscale*j, data[j][i]*zscale+bheight],[pscale*(i+1), pscale*(j), data[j][i+1]*zscale+bheight],[pscale*(i+1), pscale*(j+1), data[j+1][i+1]*zscale+bheight]])]
o.facets+=[genfacet([[pscale*(i),pscale*(j+1),data[j+1][i]*zscale+bheight],[pscale*i, pscale*j, data[j][i]*zscale+bheight],[pscale*(i+1),pscale*(j+1),data[j+1][i+1]*zscale+bheight]])] o.facets+=[genfacet([[pscale*(i), pscale*(j+1), data[j+1][i]*zscale+bheight],[pscale*i, pscale*j, data[j][i]*zscale+bheight],[pscale*(i+1), pscale*(j+1), data[j+1][i+1]*zscale+bheight]])]
#print o.facets[-1] #print o.facets[-1]
facet=[[0, 0,0],[[0, 0,0],[0, 0,0],[0, 0,0]]] facet = [[0, 0, 0],[[0, 0, 0],[0, 0, 0],[0, 0, 0]]]
return o return o
def zimage(name, out): def zimage(name, out):
i = wx.Image(name) i = wx.Image(name)
s = i.GetSize() s = i.GetSize()
print len(map(ord, i.GetData()[::3])) print len(map(ord, i.GetData()[::3]))
b = map(ord, i.GetData()[::3]) b = map(ord, i.GetData()[::3])
data=[] data = []
for i in xrange(s[0]): for i in xrange(s[0]):
data+=[b[i*s[1]:(i+1)*s[1]]] data+=[b[i*s[1]:(i+1)*s[1]]]
#data=[i[::5] for i in data[::5]] #data = [i[::5] for i in data[::5]]
emitstl(out, genscape(data, zscale = 0.1).facets, name) emitstl(out, genscape(data, zscale = 0.1).facets, name)
""" """
class scapewin(wx.Frame): class scapewin(wx.Frame):
def __init__(self, size = (400, 530)): def __init__(self, size = (400, 530)):
wx.Frame.__init__(self, None, title = "Right-click to load an image",size = size) wx.Frame.__init__(self, None, title = "Right-click to load an image", size = size)
self.SetIcon(wx.Icon("plater.ico",wx.BITMAP_TYPE_ICO)) self.SetIcon(wx.Icon("plater.ico", wx.BITMAP_TYPE_ICO))
self.SetClientSize(size) self.SetClientSize(size)
self.panel = wx.Panel(self, size = size) self.panel = wx.Panel(self, size = size)
...@@ -80,5 +80,5 @@ if __name__ == '__main__': ...@@ -80,5 +80,5 @@ if __name__ == '__main__':
main.Show() main.Show()
app.MainLoop() app.MainLoop()
""" """
zimage("catposthtmap2.jpg","testobj.stl") zimage("catposthtmap2.jpg", "testobj.stl")
del a del a
...@@ -181,10 +181,10 @@ def estimate_duration(g): ...@@ -181,10 +181,10 @@ def estimate_duration(g):
return "{0:d} layers, ".format(int(layercount)) + str(datetime.timedelta(seconds = int(totalduration))) return "{0:d} layers, ".format(int(layercount)) + str(datetime.timedelta(seconds = int(totalduration)))
class Settings: class Settings:
#def _temperature_alias(self): return {"pla":210,"abs":230,"off":0} #def _temperature_alias(self): return {"pla":210, "abs":230, "off":0}
#def _temperature_validate(self, v): #def _temperature_validate(self, v):
# if v < 0: raise ValueError("You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0.") # if v < 0: raise ValueError("You cannot set negative temperatures. To turn the hotend off entirely, set its temperature to 0.")
#def _bedtemperature_alias(self): return {"pla":60,"abs":110,"off":0} #def _bedtemperature_alias(self): return {"pla":60, "abs":110, "off":0}
def _baudrate_list(self): return ["2400", "9600", "19200", "38400", "57600", "115200"] def _baudrate_list(self): return ["2400", "9600", "19200", "38400", "57600", "115200"]
def __init__(self): def __init__(self):
# defaults here. # defaults here.
...@@ -204,28 +204,28 @@ class Settings: ...@@ -204,28 +204,28 @@ class Settings:
def _set(self, key, value): def _set(self, key, value):
try: try:
value = getattr(self,"_%s_alias"%key)()[value] value = getattr(self, "_%s_alias"%key)()[value]
except KeyError: except KeyError:
pass pass
except AttributeError: except AttributeError:
pass pass
try: try:
getattr(self,"_%s_validate"%key)(value) getattr(self, "_%s_validate"%key)(value)
except AttributeError: except AttributeError:
pass pass
setattr(self, key, type(getattr(self, key))(value)) setattr(self, key, type(getattr(self, key))(value))
try: try:
getattr(self,"_%s_cb"%key)(key, value) getattr(self, "_%s_cb"%key)(key, value)
except AttributeError: except AttributeError:
pass pass
return value return value
def _tabcomplete(self, key): def _tabcomplete(self, key):
try: try:
return getattr(self,"_%s_list"%key)() return getattr(self, "_%s_list"%key)()
except AttributeError: except AttributeError:
pass pass
try: try:
return getattr(self,"_%s_alias"%key)().keys() return getattr(self, "_%s_alias"%key)().keys()
except AttributeError: except AttributeError:
pass pass
return [] return []
...@@ -239,19 +239,19 @@ class pronsole(cmd.Cmd): ...@@ -239,19 +239,19 @@ class pronsole(cmd.Cmd):
self.completekey = None self.completekey = None
self.p = printcore.printcore() self.p = printcore.printcore()
self.p.recvcb = self.recvcb self.p.recvcb = self.recvcb
self.recvlisteners=[] self.recvlisteners = []
self.prompt = "PC>" self.prompt = "PC>"
self.p.onlinecb = self.online self.p.onlinecb = self.online
self.f = None self.f = None
self.listing = 0 self.listing = 0
self.sdfiles=[] self.sdfiles = []
self.paused = False self.paused = False
self.sdprinting = 0 self.sdprinting = 0
self.temps={"pla":"185","abs":"230","off":"0"} self.temps = {"pla":"185", "abs":"230", "off":"0"}
self.bedtemps={"pla":"60","abs":"110","off":"0"} self.bedtemps = {"pla":"60", "abs":"110", "off":"0"}
self.percentdone = 0 self.percentdone = 0
self.tempreadings = "" self.tempreadings = ""
self.macros={} self.macros = {}
self.rc_loaded = False self.rc_loaded = False
self.processing_rc = False self.processing_rc = False
self.processing_args = False self.processing_args = False
...@@ -284,18 +284,18 @@ class pronsole(cmd.Cmd): ...@@ -284,18 +284,18 @@ class pronsole(cmd.Cmd):
if not key.startswith("bed"): if not key.startswith("bed"):
self.temps["pla"] = str(self.settings.temperature_pla) self.temps["pla"] = str(self.settings.temperature_pla)
self.temps["abs"] = str(self.settings.temperature_abs) self.temps["abs"] = str(self.settings.temperature_abs)
print "Hotend temperature presets updated, pla:%s, abs:%s" % (self.temps["pla"],self.temps["abs"]) print "Hotend temperature presets updated, pla:%s, abs:%s" % (self.temps["pla"], self.temps["abs"])
else: else:
self.bedtemps["pla"] = str(self.settings.bedtemp_pla) self.bedtemps["pla"] = str(self.settings.bedtemp_pla)
self.bedtemps["abs"] = str(self.settings.bedtemp_abs) self.bedtemps["abs"] = str(self.settings.bedtemp_abs)
print "Bed temperature presets updated, pla:%s, abs:%s" % (self.bedtemps["pla"],self.bedtemps["abs"]) print "Bed temperature presets updated, pla:%s, abs:%s" % (self.bedtemps["pla"], self.bedtemps["abs"])
def scanserial(self): def scanserial(self):
"""scan for available ports. return a list of device names.""" """scan for available ports. return a list of device names."""
baselist=[] baselist = []
if os.name == "nt": if os.name == "nt":
try: try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM")
i = 0 i = 0
while(1): while(1):
baselist+=[_winreg.EnumValue(key, i)[1]] baselist+=[_winreg.EnumValue(key, i)[1]]
...@@ -343,8 +343,8 @@ class pronsole(cmd.Cmd): ...@@ -343,8 +343,8 @@ class pronsole(cmd.Cmd):
if self.cur_macro_def!="": if self.cur_macro_def!="":
self.macros[self.cur_macro_name] = self.cur_macro_def self.macros[self.cur_macro_name] = self.cur_macro_def
macro = self.compile_macro(self.cur_macro_name, self.cur_macro_def) macro = self.compile_macro(self.cur_macro_name, self.cur_macro_def)
setattr(self.__class__,"do_"+self.cur_macro_name, lambda self, largs, macro = macro:macro(self,*largs.split())) setattr(self.__class__, "do_"+self.cur_macro_name, lambda self, largs, macro = macro:macro(self,*largs.split()))
setattr(self.__class__,"help_"+self.cur_macro_name, lambda self, macro_name = self.cur_macro_name: self.subhelp_macro(macro_name)) setattr(self.__class__, "help_"+self.cur_macro_name, lambda self, macro_name = self.cur_macro_name: self.subhelp_macro(macro_name))
if not self.processing_rc: if not self.processing_rc:
print "Macro '"+self.cur_macro_name+"' defined" print "Macro '"+self.cur_macro_name+"' defined"
# save it # save it
...@@ -385,7 +385,7 @@ class pronsole(cmd.Cmd): ...@@ -385,7 +385,7 @@ class pronsole(cmd.Cmd):
exec pycode exec pycode
return macro return macro
def start_macro(self, macro_name, prev_definition = "",suppress_instructions = False): def start_macro(self, macro_name, prev_definition = "", suppress_instructions = False):
if not self.processing_rc and not suppress_instructions: if not self.processing_rc and not suppress_instructions:
print "Enter macro using indented lines, end with empty line" print "Enter macro using indented lines, end with empty line"
self.cur_macro_name = macro_name self.cur_macro_name = macro_name
...@@ -395,20 +395,20 @@ class pronsole(cmd.Cmd): ...@@ -395,20 +395,20 @@ class pronsole(cmd.Cmd):
def delete_macro(self, macro_name): def delete_macro(self, macro_name):
if macro_name in self.macros.keys(): if macro_name in self.macros.keys():
delattr(self.__class__,"do_"+macro_name) delattr(self.__class__, "do_"+macro_name)
del self.macros[macro_name] del self.macros[macro_name]
print "Macro '"+macro_name+"' removed" print "Macro '"+macro_name+"' removed"
if not self.processing_rc and not self.processing_args: if not self.processing_rc and not self.processing_args:
self.save_in_rc("macro "+macro_name,"") self.save_in_rc("macro "+macro_name, "")
else: else:
print "Macro '"+macro_name+"' is not defined" print "Macro '"+macro_name+"' is not defined"
def do_macro(self, args): def do_macro(self, args):
if args.strip()=="": if args.strip()=="":
self.print_topics("User-defined macros",self.macros.keys(),15, 80) self.print_topics("User-defined macros", self.macros.keys(), 15, 80)
return return
arglist = args.split(None, 1) arglist = args.split(None, 1)
macro_name = arglist[0] macro_name = arglist[0]
if macro_name not in self.macros and hasattr(self.__class__,"do_"+macro_name): if macro_name not in self.macros and hasattr(self.__class__, "do_"+macro_name):
print "Name '"+macro_name+"' is being used by built-in command" print "Name '"+macro_name+"' is being used by built-in command"
return return
if len(arglist) == 2: if len(arglist) == 2:
...@@ -453,11 +453,11 @@ class pronsole(cmd.Cmd): ...@@ -453,11 +453,11 @@ class pronsole(cmd.Cmd):
t = type(getattr(self.settings, var)) t = type(getattr(self.settings, var))
value = self.settings._set(var, str) value = self.settings._set(var, str)
if not self.processing_rc and not self.processing_args: if not self.processing_rc and not self.processing_args:
self.save_in_rc("set "+var,"set %s %s" % (var, value)) self.save_in_rc("set "+var, "set %s %s" % (var, value))
except AttributeError: except AttributeError:
print "Unknown variable '%s'" % var print "Unknown variable '%s'" % var
except ValueError, ve: except ValueError, ve:
print "Bad value for variable '%s', expecting %s (%s)" % (var, repr(t)[1:-1],ve.args[0]) print "Bad value for variable '%s', expecting %s (%s)" % (var, repr(t)[1:-1], ve.args[0])
def do_set(self, argl): def do_set(self, argl):
args = argl.split(None, 1) args = argl.split(None, 1)
...@@ -468,11 +468,11 @@ class pronsole(cmd.Cmd): ...@@ -468,11 +468,11 @@ class pronsole(cmd.Cmd):
value = getattr(self.settings, args[0]) value = getattr(self.settings, args[0])
if len(args) < 2: if len(args) < 2:
try: try:
print "%s = %s" % (args[0],getattr(self.settings, args[0])) print "%s = %s" % (args[0], getattr(self.settings, args[0]))
except AttributeError: except AttributeError:
print "Unknown variable '%s'" % args[0] print "Unknown variable '%s'" % args[0]
return return
self.set(args[0],args[1]) self.set(args[0], args[1])
def help_set(self): def help_set(self):
print "Set variable: set <variable> <value>" print "Set variable: set <variable> <value>"
...@@ -494,13 +494,13 @@ class pronsole(cmd.Cmd): ...@@ -494,13 +494,13 @@ class pronsole(cmd.Cmd):
def load_rc(self, rc_filename): def load_rc(self, rc_filename):
self.processing_rc = True self.processing_rc = True
try: try:
rc = codecs.open(rc_filename,"r","utf-8") rc = codecs.open(rc_filename, "r", "utf-8")
self.rc_filename = os.path.abspath(rc_filename) self.rc_filename = os.path.abspath(rc_filename)
for rc_cmd in rc: for rc_cmd in rc:
if not rc_cmd.lstrip().startswith("#"): if not rc_cmd.lstrip().startswith("#"):
self.onecmd(rc_cmd) self.onecmd(rc_cmd)
rc.close() rc.close()
if hasattr(self,"cur_macro_def"): if hasattr(self, "cur_macro_def"):
self.end_macro() self.end_macro()
self.rc_loaded = True self.rc_loaded = True
finally: finally:
...@@ -509,12 +509,12 @@ class pronsole(cmd.Cmd): ...@@ -509,12 +509,12 @@ class pronsole(cmd.Cmd):
def load_default_rc(self, rc_filename = ".pronsolerc"): def load_default_rc(self, rc_filename = ".pronsolerc"):
try: try:
try: try:
self.load_rc(os.path.join(os.path.expanduser("~"),rc_filename)) self.load_rc(os.path.join(os.path.expanduser("~"), rc_filename))
except IOError: except IOError:
self.load_rc(rc_filename) self.load_rc(rc_filename)
except IOError: except IOError:
# make sure the filename is initialized # make sure the filename is initialized
self.rc_filename = os.path.abspath(os.path.join(os.path.expanduser("~"),rc_filename)) self.rc_filename = os.path.abspath(os.path.join(os.path.expanduser("~"), rc_filename))
def save_in_rc(self, key, definition): def save_in_rc(self, key, definition):
""" """
...@@ -536,8 +536,8 @@ class pronsole(cmd.Cmd): ...@@ -536,8 +536,8 @@ class pronsole(cmd.Cmd):
if os.path.exists(self.rc_filename): if os.path.exists(self.rc_filename):
import shutil import shutil
shutil.copy(self.rc_filename, self.rc_filename+"~bak") shutil.copy(self.rc_filename, self.rc_filename+"~bak")
rci = codecs.open(self.rc_filename+"~bak","r","utf-8") rci = codecs.open(self.rc_filename+"~bak", "r", "utf-8")
rco = codecs.open(self.rc_filename,"w","utf-8") rco = codecs.open(self.rc_filename, "w", "utf-8")
if rci is not None: if rci is not None:
overwriting = False overwriting = False
for rc_cmd in rci: for rc_cmd in rci:
...@@ -563,7 +563,7 @@ class pronsole(cmd.Cmd): ...@@ -563,7 +563,7 @@ class pronsole(cmd.Cmd):
#else: #else:
# print "Removed '"+key+"' from '"+self.rc_filename+"'" # print "Removed '"+key+"' from '"+self.rc_filename+"'"
except Exception, e: except Exception, e:
print "Saving failed for",key+":",str(e) print "Saving failed for", key+":", str(e)
finally: finally:
del rci, rco del rci, rco
...@@ -592,10 +592,10 @@ class pronsole(cmd.Cmd): ...@@ -592,10 +592,10 @@ class pronsole(cmd.Cmd):
print "No port specified - connecting to %s at %dbps" % (port, baud) print "No port specified - connecting to %s at %dbps" % (port, baud)
if port != self.settings.port: if port != self.settings.port:
self.settings.port = port self.settings.port = port
self.save_in_rc("set port","set port %s" % port) self.save_in_rc("set port", "set port %s" % port)
if baud != self.settings.baudrate: if baud != self.settings.baudrate:
self.settings.baudrate = baud self.settings.baudrate = baud
self.save_in_rc("set baudrate","set baudrate %d" % baud) self.save_in_rc("set baudrate", "set baudrate %d" % baud)
self.p.connect(port, baud) self.p.connect(port, baud)
def help_connect(self): def help_connect(self):
...@@ -630,9 +630,9 @@ class pronsole(cmd.Cmd): ...@@ -630,9 +630,9 @@ class pronsole(cmd.Cmd):
if not(os.path.exists(l)): if not(os.path.exists(l)):
print "File not found!" print "File not found!"
return return
self.f=[i.replace("\n","").replace("\r","") for i in open(l)] self.f = [i.replace("\n", "").replace("\r", "") for i in open(l)]
self.filename = l self.filename = l
print "Loaded ",l,", ",len(self.f)," lines." print "Loaded ", l, ", ", len(self.f)," lines."
def complete_load(self, text, line, begidx, endidx): def complete_load(self, text, line, begidx, endidx):
s = line.split() s = line.split()
...@@ -658,16 +658,16 @@ class pronsole(cmd.Cmd): ...@@ -658,16 +658,16 @@ class pronsole(cmd.Cmd):
if not self.p.online: if not self.p.online:
print "Not connected to printer." print "Not connected to printer."
return return
self.f=[i.replace("\n","") for i in open(l.split()[0])] self.f = [i.replace("\n", "") for i in open(l.split()[0])]
self.filename = l.split()[0] self.filename = l.split()[0]
print "Loaded ",l,", ",len(self.f)," lines." print "Loaded ", l, ", ", len(self.f)," lines."
tname = "" tname = ""
if len(l.split())>1: if len(l.split())>1:
tname = l.split()[1] tname = l.split()[1]
else: else:
print "please enter target name in 8.3 format." print "please enter target name in 8.3 format."
return return
print "Uploading as ",tname print "Uploading as ", tname
print("Uploading "+self.filename) print("Uploading "+self.filename)
self.p.send_now("M28 "+tname) self.p.send_now("M28 "+tname)
print("Press Ctrl-C to interrupt upload.") print("Press Ctrl-C to interrupt upload.")
...@@ -684,11 +684,11 @@ class pronsole(cmd.Cmd): ...@@ -684,11 +684,11 @@ class pronsole(cmd.Cmd):
self.sleep(0.2) self.sleep(0.2)
self.p.clear = 1 self.p.clear = 1
self.listing = 0 self.listing = 0
self.sdfiles=[] self.sdfiles = []
self.recvlisteners+=[self.listfiles] self.recvlisteners+=[self.listfiles]
self.p.send_now("M20") self.p.send_now("M20")
time.sleep(0.5) time.sleep(0.5)
print "\b\b\b\b\b100%. Upload completed. ",tname," should now be on the card." print "\b\b\b\b\b100%. Upload completed. ", tname, " should now be on the card."
return return
except: except:
print "...interrupted!" print "...interrupted!"
...@@ -697,7 +697,7 @@ class pronsole(cmd.Cmd): ...@@ -697,7 +697,7 @@ class pronsole(cmd.Cmd):
time.sleep(0.2) time.sleep(0.2)
self.p.clear = 1 self.p.clear = 1
self.p.startprint([]) self.p.startprint([])
print "A partial file named ",tname," may have been written to the sd card." print "A partial file named ", tname, " may have been written to the sd card."
def complete_upload(self, text, line, begidx, endidx): def complete_upload(self, text, line, begidx, endidx):
...@@ -776,14 +776,14 @@ class pronsole(cmd.Cmd): ...@@ -776,14 +776,14 @@ class pronsole(cmd.Cmd):
self.listing = 0 self.listing = 0
self.recvlisteners.remove(self.listfiles) self.recvlisteners.remove(self.listfiles)
elif self.listing: elif self.listing:
self.sdfiles+=[line.replace("\n","").replace("\r","").lower()] self.sdfiles+=[line.replace("\n", "").replace("\r", "").lower()]
def do_ls(self, l): def do_ls(self, l):
if not self.p.online: if not self.p.online:
print "Printer is not online. Try connect to it first." print "Printer is not online. Try connect to it first."
return return
self.listing = 2 self.listing = 2
self.sdfiles=[] self.sdfiles = []
self.recvlisteners+=[self.listfiles] self.recvlisteners+=[self.listfiles]
self.p.send_now("M20") self.p.send_now("M20")
time.sleep(0.5) time.sleep(0.5)
...@@ -830,7 +830,7 @@ class pronsole(cmd.Cmd): ...@@ -830,7 +830,7 @@ class pronsole(cmd.Cmd):
print "Printer is not online. Try connect to it first." print "Printer is not online. Try connect to it first."
return return
self.listing = 2 self.listing = 2
self.sdfiles=[] self.sdfiles = []
self.recvlisteners+=[self.listfiles] self.recvlisteners+=[self.listfiles]
self.p.send_now("M20") self.p.send_now("M20")
time.sleep(0.5) time.sleep(0.5)
...@@ -894,7 +894,7 @@ class pronsole(cmd.Cmd): ...@@ -894,7 +894,7 @@ class pronsole(cmd.Cmd):
def tempcb(self, l): def tempcb(self, l):
if "T:" in l: if "T:" in l:
print l.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ","") print l.replace("\r", "").replace("T", "Hotend").replace("B", "Bed").replace("\n", "").replace("ok ", "")
def do_gettemp(self, l): def do_gettemp(self, l):
if self.p.online: if self.p.online:
...@@ -908,14 +908,14 @@ class pronsole(cmd.Cmd): ...@@ -908,14 +908,14 @@ class pronsole(cmd.Cmd):
def do_settemp(self, l): def do_settemp(self, l):
try: try:
l = l.lower().replace(",",".") l = l.lower().replace(", ",".")
for i in self.temps.keys(): for i in self.temps.keys():
l = l.replace(i, self.temps[i]) l = l.replace(i, self.temps[i])
f = float(l) f = float(l)
if f>=0: if f>=0:
if self.p.online: if self.p.online:
self.p.send_now("M104 S"+l) self.p.send_now("M104 S"+l)
print "Setting hotend temperature to ",f," degrees Celsius." print "Setting hotend temperature to ", f, " degrees Celsius."
else: else:
print "Printer is not online." print "Printer is not online."
else: else:
...@@ -934,14 +934,14 @@ class pronsole(cmd.Cmd): ...@@ -934,14 +934,14 @@ class pronsole(cmd.Cmd):
def do_bedtemp(self, l): def do_bedtemp(self, l):
try: try:
l = l.lower().replace(",",".") l = l.lower().replace(", ",".")
for i in self.bedtemps.keys(): for i in self.bedtemps.keys():
l = l.replace(i, self.bedtemps[i]) l = l.replace(i, self.bedtemps[i])
f = float(l) f = float(l)
if f>=0: if f>=0:
if self.p.online: if self.p.online:
self.p.send_now("M140 S"+l) self.p.send_now("M140 S"+l)
print "Setting bed temperature to ",f," degrees Celsius." print "Setting bed temperature to ", f, " degrees Celsius."
else: else:
print "Printer is not online." print "Printer is not online."
else: else:
...@@ -1000,14 +1000,14 @@ class pronsole(cmd.Cmd): ...@@ -1000,14 +1000,14 @@ class pronsole(cmd.Cmd):
def help_move(self): def help_move(self):
print "Move an axis. Specify the name of the axis and the amount. " print "Move an axis. Specify the name of the axis and the amount. "
print "move X 10 will move the X axis forward by 10mm at ",self.settings.xy_feedrate,"mm/min (default XY speed)" print "move X 10 will move the X axis forward by 10mm at ", self.settings.xy_feedrate, "mm/min (default XY speed)"
print "move Y 10 5000 will move the Y axis forward by 10mm at 5000mm/min" print "move Y 10 5000 will move the Y axis forward by 10mm at 5000mm/min"
print "move Z -1 will move the Z axis down by 1mm at ",self.settings.z_feedrate,"mm/min (default Z speed)" print "move Z -1 will move the Z axis down by 1mm at ", self.settings.z_feedrate, "mm/min (default Z speed)"
print "Common amounts are in the tabcomplete list." print "Common amounts are in the tabcomplete list."
def complete_move(self, text, line, begidx, endidx): def complete_move(self, text, line, begidx, endidx):
if (len(line.split()) == 2 and line[-1] != " ") or (len(line.split()) == 1 and line[-1]==" "): if (len(line.split()) == 2 and line[-1] != " ") or (len(line.split()) == 1 and line[-1]==" "):
return [i for i in ["X ","Y ","Z ","E "] if i.lower().startswith(text)] return [i for i in ["X ", "Y ", "Z ", "E "] if i.lower().startswith(text)]
elif(len(line.split()) == 3 or (len(line.split()) == 2 and line[-1]==" ")): elif(len(line.split()) == 3 or (len(line.split()) == 2 and line[-1]==" ")):
base = line.split()[-1] base = line.split()[-1]
rlen = 0 rlen = 0
...@@ -1015,11 +1015,11 @@ class pronsole(cmd.Cmd): ...@@ -1015,11 +1015,11 @@ class pronsole(cmd.Cmd):
rlen = 1 rlen = 1
if line[-1]==" ": if line[-1]==" ":
base = "" base = ""
return [i[rlen:] for i in ["-100","-10","-1","-0.1","100","10","1","0.1","-50","-5","-0.5","50","5","0.5","-200","-20","-2","-0.2","200","20","2","0.2"] if i.startswith(base)] return [i[rlen:] for i in ["-100", "-10", "-1", "-0.1", "100", "10", "1", "0.1", "-50", "-5", "-0.5", "50", "5", "0.5", "-200", "-20", "-2", "-0.2", "200", "20", "2", "0.2"] if i.startswith(base)]
else: else:
return [] return []
def do_extrude(self, l,override = None, overridefeed = 300): def do_extrude(self, l, override = None, overridefeed = 300):
length = 5#default extrusion length length = 5#default extrusion length
feed = self.settings.e_feedrate#default speed feed = self.settings.e_feedrate#default speed
if not self.p.online: if not self.p.online:
...@@ -1079,7 +1079,7 @@ class pronsole(cmd.Cmd): ...@@ -1079,7 +1079,7 @@ class pronsole(cmd.Cmd):
feed = int(ls[1]) feed = int(ls[1])
except: except:
print "Invalid speed given." print "Invalid speed given."
self.do_extrude("",length*-1.0, feed) self.do_extrude("", length*-1.0, feed)
def help_reverse(self): def help_reverse(self):
print "Reverses the extruder, 5mm by default, or the number of mm given as a parameter" print "Reverses the extruder, 5mm by default, or the number of mm given as a parameter"
...@@ -1116,12 +1116,12 @@ class pronsole(cmd.Cmd): ...@@ -1116,12 +1116,12 @@ class pronsole(cmd.Cmd):
if(self.sdprinting): if(self.sdprinting):
self.p.send_now("M27") self.p.send_now("M27")
time.sleep(interval) time.sleep(interval)
#print (self.tempreadings.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ","")) #print (self.tempreadings.replace("\r", "").replace("T", "Hotend").replace("B", "Bed").replace("\n", "").replace("ok ", ""))
if(self.p.printing): if(self.p.printing):
print "Print progress: ", 100*float(self.p.queueindex)/len(self.p.mainqueue), "%" print "Print progress: ", 100*float(self.p.queueindex)/len(self.p.mainqueue), "%"
if(self.sdprinting): if(self.sdprinting):
print "SD print progress: ", self.percentdone,"%" print "SD print progress: ", self.percentdone, "%"
except: except:
print "Done monitoring." print "Done monitoring."
...@@ -1134,7 +1134,7 @@ class pronsole(cmd.Cmd): ...@@ -1134,7 +1134,7 @@ class pronsole(cmd.Cmd):
print "monitor 2 - Reports temperature and SD print status (if SD printing) every 2 seconds" print "monitor 2 - Reports temperature and SD print status (if SD printing) every 2 seconds"
def expandcommand(self, c): def expandcommand(self, c):
return c.replace("$python",sys.executable) return c.replace("$python", sys.executable)
def do_skein(self, l): def do_skein(self, l):
l = l.split() l = l.split()
...@@ -1152,18 +1152,18 @@ class pronsole(cmd.Cmd): ...@@ -1152,18 +1152,18 @@ class pronsole(cmd.Cmd):
try: try:
import shlex import shlex
if(settings): if(settings):
param = self.expandcommand(self.settings.sliceoptscommand).replace("\\","\\\\").encode() param = self.expandcommand(self.settings.sliceoptscommand).replace("\\", "\\\\").encode()
print "Entering slicer settings: ",param print "Entering slicer settings: ", param
subprocess.call(shlex.split(param)) subprocess.call(shlex.split(param))
else: else:
param = self.expandcommand(self.settings.slicecommand).encode() param = self.expandcommand(self.settings.slicecommand).encode()
print "Slicing: ",param print "Slicing: ", param
params=[i.replace("$s",l[0]).replace("$o",l[0].replace(".stl","_export.gcode").replace(".STL","_export.gcode")).encode() for i in shlex.split(param.replace("\\","\\\\").encode())] params = [i.replace("$s", l[0]).replace("$o", l[0].replace(".stl", "_export.gcode").replace(".STL", "_export.gcode")).encode() for i in shlex.split(param.replace("\\", "\\\\").encode())]
subprocess.call(params) subprocess.call(params)
print "Loading sliced file." print "Loading sliced file."
self.do_load(l[0].replace(".stl","_export.gcode")) self.do_load(l[0].replace(".stl", "_export.gcode"))
except Exception, e: except Exception, e:
print "Skeinforge execution failed: ",e print "Skeinforge execution failed: ", e
def complete_skein(self, text, line, begidx, endidx): def complete_skein(self, text, line, begidx, endidx):
s = line.split() s = line.split()
...@@ -1211,18 +1211,18 @@ class pronsole(cmd.Cmd): ...@@ -1211,18 +1211,18 @@ class pronsole(cmd.Cmd):
def parse_cmdline(self, args): def parse_cmdline(self, args):
import getopt import getopt
opts, args = getopt.getopt(args, "c:e:hw", ["conf = ","config = ","help","web","web-config = ", "web-auth-config = "]) opts, args = getopt.getopt(args, "c:e:hw", ["conf = ", "config = ", "help", "web", "web-config = ", "web-auth-config = "])
for o, a in opts: for o, a in opts:
#print repr((o, a)) #print repr((o, a))
if o in ("-c","--conf","--config"): if o in ("-c", "--conf", "--config"):
self.load_rc(a) self.load_rc(a)
elif o in ("-w","--web"): elif o in ("-w", "--web"):
self.webrequested = True self.webrequested = True
elif o == "--web-config": elif o == "--web-config":
self.web_config = a self.web_config = a
elif o == "--web-auth-config": elif o == "--web-auth-config":
self.web_auth_config = a self.web_auth_config = a
elif o in ("-h","--help"): elif o in ("-h", "--help"):
print "Usage: "+sys.argv[0]+' [-c filename [-c filename2 ... ] ] [-e "command" ...]' print "Usage: "+sys.argv[0]+' [-c filename [-c filename2 ... ] ] [-e "command" ...]'
print " -c | --conf | --config - override startup .pronsolerc file" print " -c | --conf | --config - override startup .pronsolerc file"
print " may chain config files, settings auto-save will go into last file in the chain" print " may chain config files, settings auto-save will go into last file in the chain"
......
...@@ -99,14 +99,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -99,14 +99,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.helpdict["preview_grid_step2"] = _("Coarse Grid Spacing (default: 50)") self.helpdict["preview_grid_step2"] = _("Coarse Grid Spacing (default: 50)")
self.helpdict["bgcolor"] = _("Pronterface background color (default: #FFFFFF)") self.helpdict["bgcolor"] = _("Pronterface background color (default: #FFFFFF)")
self.filename = filename self.filename = filename
os.putenv("UBUNTU_MENUPROXY","0") os.putenv("UBUNTU_MENUPROXY", "0")
wx.Frame.__init__(self, None, title = _("Printer Interface"),size = size); wx.Frame.__init__(self, None, title = _("Printer Interface"), size = size);
self.SetIcon(wx.Icon(pixmapfile("P-face.ico"),wx.BITMAP_TYPE_ICO)) self.SetIcon(wx.Icon(pixmapfile("P-face.ico"), wx.BITMAP_TYPE_ICO))
self.panel = wx.Panel(self,-1, size = size) self.panel = wx.Panel(self,-1, size = size)
self.statuscheck = False self.statuscheck = False
self.status_thread = None self.status_thread = None
self.capture_skip={} self.capture_skip = {}
self.capture_skip_newline = False self.capture_skip_newline = False
self.tempreport = "" self.tempreport = ""
self.monitor = 0 self.monitor = 0
...@@ -118,28 +118,28 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -118,28 +118,28 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
xcol = (245, 245, 108) xcol = (245, 245, 108)
ycol = (180, 180, 255) ycol = (180, 180, 255)
zcol = (180, 255, 180) zcol = (180, 255, 180)
self.cpbuttons=[ self.cpbuttons = [
[_("Motors off"),("M84"),None,(250, 250, 250),0, _("Switch all motors off")], [_("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")], [_("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")], [_("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")], [_("Reverse"), ("reverse"), (5, 0), (225, 200, 200), (1, 2), _("Reverse extruder by set length")],
] ]
self.custombuttons=[] self.custombuttons = []
self.btndict={} self.btndict = {}
self.parse_cmdline(sys.argv[1:]) self.parse_cmdline(sys.argv[1:])
self.build_dimensions_list = self.get_build_dimensions(self.settings.build_dimensions) self.build_dimensions_list = self.get_build_dimensions(self.settings.build_dimensions)
self.panel.SetBackgroundColour(self.settings.bgcolor) self.panel.SetBackgroundColour(self.settings.bgcolor)
customdict={} customdict = {}
try: try:
execfile(configfile("custombtn.txt"),customdict) execfile(configfile("custombtn.txt"), customdict)
if len(customdict["btns"]): if len(customdict["btns"]):
if not len(self.custombuttons): if not len(self.custombuttons):
try: try:
self.custombuttons = customdict["btns"] self.custombuttons = customdict["btns"]
for n in xrange(len(self.custombuttons)): for n in xrange(len(self.custombuttons)):
self.cbutton_save(n, self.custombuttons[n]) self.cbutton_save(n, self.custombuttons[n])
os.rename("custombtn.txt","custombtn.old") os.rename("custombtn.txt", "custombtn.old")
rco = open("custombtn.txt","w") rco = open("custombtn.txt", "w")
rco.write(_("# I moved all your custom buttons into .pronsolerc.\n# Please don't add them here any more.\n# Backup of your old buttons is in custombtn.old\n")) rco.write(_("# I moved all your custom buttons into .pronsolerc.\n# Please don't add them here any more.\n# Backup of your old buttons is in custombtn.old\n"))
rco.close() rco.close()
except IOError, x: except IOError, x:
...@@ -189,7 +189,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -189,7 +189,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
print "Print Started at: " + format_time(self.starttime) print "Print Started at: " + format_time(self.starttime)
def endcb(self): def endcb(self):
if(self.p.queueindex == 0): if self.p.queueindex == 0:
print "Print ended at: " + format_time(time.time()) print "Print ended at: " + format_time(time.time())
print_duration = int(time.time () - self.starttime + self.extra_print_time) print_duration = int(time.time () - self.starttime + self.extra_print_time)
print "and took: " + format_duration(print_duration) print "and took: " + format_duration(print_duration)
...@@ -200,7 +200,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -200,7 +200,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
if not param: if not param:
return return
import shlex import shlex
pararray=[i.replace("$s",str(self.filename)).replace("$t", format_duration(print_duration)).encode() for i in shlex.split(param.replace("\\","\\\\").encode())] pararray = [i.replace("$s", str(self.filename)).replace("$t", format_duration(print_duration)).encode() for i in shlex.split(param.replace("\\", "\\\\").encode())]
self.finalp = subprocess.Popen(pararray, stderr = subprocess.STDOUT, stdout = subprocess.PIPE) self.finalp = subprocess.Popen(pararray, stderr = subprocess.STDOUT, stdout = subprocess.PIPE)
def online(self): def online(self):
...@@ -321,7 +321,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -321,7 +321,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
try: try:
if not l.__class__ in (str, unicode) or not len(l): if not l.__class__ in (str, unicode) or not len(l):
l = str(self.htemp.GetValue().split()[0]) l = str(self.htemp.GetValue().split()[0])
l = l.lower().replace(",", ".") l = l.lower().replace(", ", ".")
for i in self.temps.keys(): for i in self.temps.keys():
l = l.replace(i, self.temps[i]) l = l.replace(i, self.temps[i])
f = float(l) f = float(l)
...@@ -343,7 +343,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -343,7 +343,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
try: try:
if not l.__class__ in (str, unicode) or not len(l): if not l.__class__ in (str, unicode) or not len(l):
l = str(self.btemp.GetValue().split()[0]) l = str(self.btemp.GetValue().split()[0])
l = l.lower().replace(",", ".") l = l.lower().replace(", ", ".")
for i in self.bedtemps.keys(): for i in self.bedtemps.keys():
l = l.replace(i, self.bedtemps[i]) l = l.replace(i, self.bedtemps[i])
f = float(l) f = float(l)
...@@ -411,7 +411,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -411,7 +411,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
baselist = [] baselist = []
if os.name == "nt": if os.name == "nt":
try: try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM") key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM")
i = 0 i = 0
while True: while True:
baselist += [_winreg.EnumValue(key, i)[1]] baselist += [_winreg.EnumValue(key, i)[1]]
...@@ -445,7 +445,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -445,7 +445,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.macros_menu = wx.Menu() self.macros_menu = wx.Menu()
m.AppendSubMenu(self.macros_menu, _("&Macros")) m.AppendSubMenu(self.macros_menu, _("&Macros"))
self.Bind(wx.EVT_MENU, self.new_macro, self.macros_menu.Append(-1, _("<&New...>"))) self.Bind(wx.EVT_MENU, self.new_macro, self.macros_menu.Append(-1, _("<&New...>")))
self.Bind(wx.EVT_MENU, lambda *e:options(self), m.Append(-1, _("&Options"),_(" Options dialog"))) self.Bind(wx.EVT_MENU, lambda *e:options(self), m.Append(-1, _("&Options"), _(" Options dialog")))
self.Bind(wx.EVT_MENU, lambda x: threading.Thread(target = lambda:self.do_skein("set")).start(), m.Append(-1, _("Slicing Settings"), _(" Adjust slicing settings"))) self.Bind(wx.EVT_MENU, lambda x: threading.Thread(target = lambda:self.do_skein("set")).start(), m.Append(-1, _("Slicing Settings"), _(" Adjust slicing settings")))
...@@ -491,12 +491,12 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -491,12 +491,12 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
if macro == "": return self.new_macro() if macro == "": return self.new_macro()
if self.macros.has_key(macro): if self.macros.has_key(macro):
old_def = self.macros[macro] old_def = self.macros[macro]
elif len([c for c in macro.encode("ascii","replace") if not c.isalnum() and c != "_"]): elif len([c for c in macro.encode("ascii", "replace") if not c.isalnum() and c != "_"]):
print _("Macro name may contain only ASCII alphanumeric symbols and underscores") print _("Macro name may contain only ASCII alphanumeric symbols and underscores")
if self.webInterface: if self.webInterface:
self.webInterface.AddLog("Macro name may contain only alphanumeric symbols and underscores") self.webInterface.AddLog("Macro name may contain only alphanumeric symbols and underscores")
return return
elif hasattr(self.__class__,"do_"+macro): elif hasattr(self.__class__, "do_"+macro):
print _("Name '%s' is being used by built-in command") % macro print _("Name '%s' is being used by built-in command") % macro
return return
else: else:
...@@ -505,7 +505,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -505,7 +505,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
return macro return macro
def update_macros_menu(self): def update_macros_menu(self):
if not hasattr(self,"macros_menu"): if not hasattr(self, "macros_menu"):
return # too early, menu not yet built return # too early, menu not yet built
try: try:
while True: while True:
...@@ -545,7 +545,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -545,7 +545,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
#lower section contains the rest of the window - manual controls, console, visualizations #lower section contains the rest of the window - manual controls, console, visualizations
#TOP ROW: #TOP ROW:
uts = self.uppertopsizer = wx.BoxSizer(wx.HORIZONTAL) uts = self.uppertopsizer = wx.BoxSizer(wx.HORIZONTAL)
self.rescanbtn = wx.Button(self.panel,-1, _("Port"),size = buttonSize) self.rescanbtn = wx.Button(self.panel,-1, _("Port"), size = buttonSize)
self.rescanbtn.SetToolTip(wx.ToolTip("Communication Settings\nClick to rescan ports")) self.rescanbtn.SetToolTip(wx.ToolTip("Communication Settings\nClick to rescan ports"))
self.rescanbtn.Bind(wx.EVT_BUTTON, self.rescanports) self.rescanbtn.Bind(wx.EVT_BUTTON, self.rescanports)
...@@ -556,9 +556,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -556,9 +556,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to")) self.serialport.SetToolTip(wx.ToolTip("Select Port Printer is connected to"))
self.rescanports() self.rescanports()
uts.Add(self.serialport) uts.Add(self.serialport)
uts.Add(wx.StaticText(self.panel,-1,"@"),0, wx.RIGHT|wx.ALIGN_CENTER, 0) uts.Add(wx.StaticText(self.panel,-1, "@"), 0, wx.RIGHT|wx.ALIGN_CENTER, 0)
self.baud = wx.ComboBox(self.panel, -1, self.baud = wx.ComboBox(self.panel, -1,
choices=["2400", "9600", "19200", "38400", "57600", "115200", "250000"], choices = ["2400", "9600", "19200", "38400", "57600", "115200", "250000"],
style = wx.CB_DROPDOWN, size = (100, 25)) style = wx.CB_DROPDOWN, size = (100, 25))
self.baud.SetToolTip(wx.ToolTip("Select Baud rate for printer communication")) self.baud.SetToolTip(wx.ToolTip("Select Baud rate for printer communication"))
try: try:
...@@ -571,31 +571,31 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -571,31 +571,31 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
uts.Add(self.connectbtn) uts.Add(self.connectbtn)
self.connectbtn.SetToolTip(wx.ToolTip("Connect to the printer")) self.connectbtn.SetToolTip(wx.ToolTip("Connect to the printer"))
self.connectbtn.Bind(wx.EVT_BUTTON, self.connect) 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 = wx.Button(self.panel,-1, _("Reset"), style = wx.BU_EXACTFIT, size = (-1, buttonSize[1]))
self.resetbtn.Bind(wx.EVT_BUTTON, self.reset) self.resetbtn.Bind(wx.EVT_BUTTON, self.reset)
self.resetbtn.SetToolTip(wx.ToolTip("Reset the printer")) self.resetbtn.SetToolTip(wx.ToolTip("Reset the printer"))
uts.Add(self.resetbtn) uts.Add(self.resetbtn)
#self.minibtn = wx.Button(self.panel,-1, _("Mini mode"),style = wx.BU_EXACTFIT) #self.minibtn = wx.Button(self.panel,-1, _("Mini mode"), style = wx.BU_EXACTFIT)
#self.minibtn.Bind(wx.EVT_BUTTON, self.toggleview) #self.minibtn.Bind(wx.EVT_BUTTON, self.toggleview)
#uts.Add((25,-1)) #uts.Add((25,-1))
#uts.Add((15,-1),flag = wx.EXPAND) #uts.Add((15,-1), flag = wx.EXPAND)
#uts.Add(self.minibtn, 0, wx.ALIGN_CENTER) #uts.Add(self.minibtn, 0, wx.ALIGN_CENTER)
#SECOND ROW #SECOND ROW
ubs = self.upperbottomsizer = uts#wx.BoxSizer(wx.HORIZONTAL) ubs = self.upperbottomsizer = uts#wx.BoxSizer(wx.HORIZONTAL)
self.loadbtn = wx.Button(self.panel,-1, _("Load file"),style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) 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.Bind(wx.EVT_BUTTON, self.loadfile)
self.loadbtn.SetToolTip(wx.ToolTip("Load a 3D model file")) self.loadbtn.SetToolTip(wx.ToolTip("Load a 3D model file"))
ubs.Add(self.loadbtn) ubs.Add(self.loadbtn)
self.platebtn = wx.Button(self.panel,-1, _("Compose"),style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) 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.Bind(wx.EVT_BUTTON, self.plate)
self.platebtn.SetToolTip(wx.ToolTip("Simple Plater System")) self.platebtn.SetToolTip(wx.ToolTip("Simple Plater System"))
#self.printerControls.append(self.uploadbtn) #self.printerControls.append(self.uploadbtn)
ubs.Add(self.platebtn) ubs.Add(self.platebtn)
self.sdbtn = wx.Button(self.panel,-1, _("SD"),style = wx.BU_EXACTFIT, size = (-1, buttonSize[1])) 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.Bind(wx.EVT_BUTTON, self.sdmenu)
self.sdbtn.SetToolTip(wx.ToolTip("SD Card Printing")) self.sdbtn.SetToolTip(wx.ToolTip("SD Card Printing"))
self.printerControls.append(self.sdbtn) self.printerControls.append(self.sdbtn)
...@@ -623,11 +623,11 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -623,11 +623,11 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.commandbox.SetToolTip(wx.ToolTip("Send commands to printer\n(Type 'help' for simple\nhelp function)")) 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.commandbox.Bind(wx.EVT_TEXT_ENTER, self.sendline)
self.commandbox.Bind(wx.EVT_CHAR, self.cbkey) self.commandbox.Bind(wx.EVT_CHAR, self.cbkey)
self.commandbox.history=[u""] self.commandbox.history = [u""]
self.commandbox.histindex = 1 self.commandbox.histindex = 1
#self.printerControls.append(self.commandbox) #self.printerControls.append(self.commandbox)
lbrs.Add(self.commandbox, 1) lbrs.Add(self.commandbox, 1)
self.sendbtn = wx.Button(self.panel,-1, _("Send"),style = wx.BU_EXACTFIT) self.sendbtn = wx.Button(self.panel,-1, _("Send"), style = wx.BU_EXACTFIT)
self.sendbtn.SetToolTip(wx.ToolTip("Send Command to Printer")) self.sendbtn.SetToolTip(wx.ToolTip("Send Command to Printer"))
self.sendbtn.Bind(wx.EVT_BUTTON, self.sendline) self.sendbtn.Bind(wx.EVT_BUTTON, self.sendline)
#self.printerControls.append(self.sendbtn) #self.printerControls.append(self.sendbtn)
...@@ -637,22 +637,22 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -637,22 +637,22 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
#left pane #left pane
lls = self.lowerlsizer = wx.GridBagSizer() lls = self.lowerlsizer = wx.GridBagSizer()
llts = wx.BoxSizer(wx.HORIZONTAL) llts = wx.BoxSizer(wx.HORIZONTAL)
#lls.Add(wx.StaticText(self.panel,-1, _("mm/min")),pos = (0, 4),span = (1, 4)) #lls.Add(wx.StaticText(self.panel,-1, _("mm/min")), pos = (0, 4), span = (1, 4))
lls.Add(llts, pos = (0, 0),span = (1, 9)) lls.Add(llts, pos = (0, 0), span = (1, 9))
#lls.Add((200, 375)) #lls.Add((200, 375))
szbuttons = wx.GridBagSizer() szbuttons = wx.GridBagSizer()
self.xyb = XYButtons(self.panel, self.moveXY, self.homeButtonClicked, self.spacebarAction, self.settings.bgcolor) self.xyb = XYButtons(self.panel, self.moveXY, self.homeButtonClicked, self.spacebarAction, self.settings.bgcolor)
szbuttons.Add(self.xyb, pos = (0, 1),flag = wx.ALIGN_CENTER) szbuttons.Add(self.xyb, pos = (0, 1), flag = wx.ALIGN_CENTER)
self.zb = ZButtons(self.panel, self.moveZ, self.settings.bgcolor) self.zb = ZButtons(self.panel, self.moveZ, self.settings.bgcolor)
szbuttons.Add(self.zb, pos = (0, 2),flag = wx.ALIGN_CENTER) szbuttons.Add(self.zb, pos = (0, 2), flag = wx.ALIGN_CENTER)
#lls.Add(self.zb, pos = (2, 6), span = (1, 1), flag = wx.ALIGN_CENTER) #lls.Add(self.zb, pos = (2, 6), span = (1, 1), flag = wx.ALIGN_CENTER)
wx.CallAfter(self.xyb.SetFocus) wx.CallAfter(self.xyb.SetFocus)
lls.Add(szbuttons, pos = (1, 0), span = (1, 8), flag = wx.ALIGN_CENTER) lls.Add(szbuttons, pos = (1, 0), span = (1, 8), flag = wx.ALIGN_CENTER)
for i in self.cpbuttons: 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.SetToolTip(wx.ToolTip(i[5]))
btn.SetBackgroundColour(i[3]) btn.SetBackgroundColour(i[3])
btn.SetForegroundColour("black") btn.SetForegroundColour("black")
...@@ -660,18 +660,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -660,18 +660,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
btn.Bind(wx.EVT_BUTTON, self.procbutton) btn.Bind(wx.EVT_BUTTON, self.procbutton)
self.btndict[i[1]]=btn self.btndict[i[1]]=btn
self.printerControls.append(btn) self.printerControls.append(btn)
if(i[2]==None): if i[2] == None:
if(i[4]==0): if i[4] == 0:
llts.Add(btn) llts.Add(btn)
else: else:
lls.Add(btn, pos = i[2],span = i[4]) 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 = 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)")) 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(wx.StaticText(self.panel,-1, _("XY:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
llts.Add(self.xyfeedc) llts.Add(self.xyfeedc)
llts.Add(wx.StaticText(self.panel,-1, _("mm/min Z:")), flag = wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL) 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 = 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)")) self.zfeedc.SetToolTip(wx.ToolTip("Set Maximum Speed for Z axis (mm/min)"))
llts.Add(self.zfeedc,) llts.Add(self.zfeedc,)
...@@ -680,14 +680,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -680,14 +680,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
lls.Add(self.monitorbox, pos = (2, 6)) lls.Add(self.monitorbox, pos = (2, 6))
self.monitorbox.Bind(wx.EVT_CHECKBOX, self.setmonitor) self.monitorbox.Bind(wx.EVT_CHECKBOX, self.setmonitor)
lls.Add(wx.StaticText(self.panel,-1, _("Heat:")),pos = (2, 0),span = (1, 1),flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) lls.Add(wx.StaticText(self.panel,-1, _("Heat:")), pos = (2, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
htemp_choices=[self.temps[i]+" ("+i+")" for i in sorted(self.temps.keys(),key = lambda x:self.temps[x])] 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 = wx.Button(self.panel,-1, _("Off"), size = (36,-1), style = wx.BU_EXACTFIT)
self.settoff.SetToolTip(wx.ToolTip("Switch Hotend Off")) self.settoff.SetToolTip(wx.ToolTip("Switch Hotend Off"))
self.settoff.Bind(wx.EVT_BUTTON, lambda e:self.do_settemp("off")) self.settoff.Bind(wx.EVT_BUTTON, lambda e:self.do_settemp("off"))
self.printerControls.append(self.settoff) self.printerControls.append(self.settoff)
lls.Add(self.settoff, pos = (2, 1),span = (1, 1)) lls.Add(self.settoff, pos = (2, 1), span = (1, 1))
if self.settings.last_temperature not in map(float, self.temps.values()): if self.settings.last_temperature not in map(float, self.temps.values()):
htemp_choices = [str(self.settings.last_temperature)] + htemp_choices htemp_choices = [str(self.settings.last_temperature)] + htemp_choices
...@@ -696,21 +696,21 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -696,21 +696,21 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.htemp.SetToolTip(wx.ToolTip("Select Temperature for Hotend")) self.htemp.SetToolTip(wx.ToolTip("Select Temperature for Hotend"))
self.htemp.Bind(wx.EVT_COMBOBOX, self.htemp_change) self.htemp.Bind(wx.EVT_COMBOBOX, self.htemp_change)
lls.Add(self.htemp, pos = (2, 2),span = (1, 2)) 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 = wx.Button(self.panel,-1, _("Set"), size = (38,-1), style = wx.BU_EXACTFIT)
self.settbtn.SetToolTip(wx.ToolTip("Switch Hotend On")) self.settbtn.SetToolTip(wx.ToolTip("Switch Hotend On"))
self.settbtn.Bind(wx.EVT_BUTTON, self.do_settemp) self.settbtn.Bind(wx.EVT_BUTTON, self.do_settemp)
self.printerControls.append(self.settbtn) self.printerControls.append(self.settbtn)
lls.Add(self.settbtn, pos = (2, 4),span = (1, 1)) lls.Add(self.settbtn, pos = (2, 4), span = (1, 1))
lls.Add(wx.StaticText(self.panel,-1, _("Bed:")),pos = (3, 0),span = (1, 1),flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT) lls.Add(wx.StaticText(self.panel,-1, _("Bed:")), pos = (3, 0), span = (1, 1), flag = wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT)
btemp_choices=[self.bedtemps[i]+" ("+i+")" for i in sorted(self.bedtemps.keys(),key = lambda x:self.temps[x])] 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 = wx.Button(self.panel,-1, _("Off"), size = (36,-1), style = wx.BU_EXACTFIT)
self.setboff.SetToolTip(wx.ToolTip("Switch Heated Bed Off")) self.setboff.SetToolTip(wx.ToolTip("Switch Heated Bed Off"))
self.setboff.Bind(wx.EVT_BUTTON, lambda e:self.do_bedtemp("off")) self.setboff.Bind(wx.EVT_BUTTON, lambda e:self.do_bedtemp("off"))
self.printerControls.append(self.setboff) self.printerControls.append(self.setboff)
lls.Add(self.setboff, pos = (3, 1),span = (1, 1)) lls.Add(self.setboff, pos = (3, 1), span = (1, 1))
if self.settings.last_bed_temperature not in map(float, self.bedtemps.values()): if self.settings.last_bed_temperature not in map(float, self.bedtemps.values()):
btemp_choices = [str(self.settings.last_bed_temperature)] + btemp_choices btemp_choices = [str(self.settings.last_bed_temperature)] + btemp_choices
...@@ -718,13 +718,13 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -718,13 +718,13 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
choices = btemp_choices, style = wx.CB_DROPDOWN, size = (70,-1)) choices = btemp_choices, style = wx.CB_DROPDOWN, size = (70,-1))
self.btemp.SetToolTip(wx.ToolTip("Select Temperature for Heated Bed")) self.btemp.SetToolTip(wx.ToolTip("Select Temperature for Heated Bed"))
self.btemp.Bind(wx.EVT_COMBOBOX, self.btemp_change) self.btemp.Bind(wx.EVT_COMBOBOX, self.btemp_change)
lls.Add(self.btemp, pos = (3, 2),span = (1, 2)) 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 = wx.Button(self.panel,-1, _("Set"), size = (38,-1), style = wx.BU_EXACTFIT)
self.setbbtn.SetToolTip(wx.ToolTip("Switch Heated Bed On")) self.setbbtn.SetToolTip(wx.ToolTip("Switch Heated Bed On"))
self.setbbtn.Bind(wx.EVT_BUTTON, self.do_bedtemp) self.setbbtn.Bind(wx.EVT_BUTTON, self.do_bedtemp)
self.printerControls.append(self.setbbtn) self.printerControls.append(self.setbbtn)
lls.Add(self.setbbtn, pos = (3, 4),span = (1, 1)) lls.Add(self.setbbtn, pos = (3, 4), span = (1, 1))
self.btemp.SetValue(str(self.settings.last_bed_temperature)) self.btemp.SetValue(str(self.settings.last_bed_temperature))
self.htemp.SetValue(str(self.settings.last_temperature)) self.htemp.SetValue(str(self.settings.last_temperature))
...@@ -745,33 +745,33 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -745,33 +745,33 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
if( '(' not in self.htemp.Value): if( '(' not in self.htemp.Value):
self.htemp.SetValue(self.htemp.Value + ' (user)') self.htemp.SetValue(self.htemp.Value + ' (user)')
#lls.Add(self.btemp, pos = (4, 1),span = (1, 3)) #lls.Add(self.btemp, pos = (4, 1), span = (1, 3))
#lls.Add(self.setbbtn, pos = (4, 4),span = (1, 2)) #lls.Add(self.setbbtn, pos = (4, 4), span = (1, 2))
self.tempdisp = wx.StaticText(self.panel,-1,"") self.tempdisp = wx.StaticText(self.panel,-1, "")
self.edist = wx.SpinCtrl(self.panel,-1,"5",min = 0, max = 1000, size = (60,-1)) self.edist = wx.SpinCtrl(self.panel,-1, "5", min = 0, max = 1000, size = (60,-1))
self.edist.SetBackgroundColour((225, 200, 200)) self.edist.SetBackgroundColour((225, 200, 200))
self.edist.SetForegroundColour("black") self.edist.SetForegroundColour("black")
lls.Add(self.edist, pos = (4, 2),span = (1, 2)) lls.Add(self.edist, pos = (4, 2), span = (1, 2))
lls.Add(wx.StaticText(self.panel,-1, _("mm")),pos = (4, 4),span = (1, 1)) 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.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 = 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.SetToolTip(wx.ToolTip("Extrude / Retract speed (mm/min)"))
self.efeedc.SetBackgroundColour((225, 200, 200)) self.efeedc.SetBackgroundColour((225, 200, 200))
self.efeedc.SetForegroundColour("black") self.efeedc.SetForegroundColour("black")
self.efeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds) self.efeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds)
lls.Add(self.efeedc, pos = (5, 2),span = (1, 2)) lls.Add(self.efeedc, pos = (5, 2), span = (1, 2))
lls.Add(wx.StaticText(self.panel,-1, _("mm/\nmin")),pos = (5, 4),span = (1, 1)) lls.Add(wx.StaticText(self.panel,-1, _("mm/\nmin")), pos = (5, 4), span = (1, 1))
self.xyfeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds) self.xyfeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds)
self.zfeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds) self.zfeedc.Bind(wx.EVT_SPINCTRL, self.setfeeds)
self.zfeedc.SetBackgroundColour((180, 255, 180)) self.zfeedc.SetBackgroundColour((180, 255, 180))
self.zfeedc.SetForegroundColour("black") self.zfeedc.SetForegroundColour("black")
# lls.Add((10, 0),pos = (0, 11),span = (1, 1)) # lls.Add((10, 0), pos = (0, 11), span = (1, 1))
#self.hottgauge = TempGauge(self.panel, size = (200, 24),title = _("Heater:"),maxval = 230) #self.hottgauge = TempGauge(self.panel, size = (200, 24), title = _("Heater:"), maxval = 230)
#lls.Add(self.hottgauge, pos = (7, 0),span = (1, 4)) #lls.Add(self.hottgauge, pos = (7, 0), span = (1, 4))
#self.bedtgauge = TempGauge(self.panel, size = (200, 24),title = _("Bed:"),maxval = 130) #self.bedtgauge = TempGauge(self.panel, size = (200, 24), title = _("Bed:"), maxval = 130)
#lls.Add(self.bedtgauge, pos = (8, 0),span = (1, 4)) #lls.Add(self.bedtgauge, pos = (8, 0), span = (1, 4))
#def scroll_setpoint(e): #def scroll_setpoint(e):
# if e.GetWheelRotation()>0: # if e.GetWheelRotation()>0:
# self.do_settemp(str(self.hsetpoint+1)) # self.do_settemp(str(self.hsetpoint+1))
...@@ -781,9 +781,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -781,9 +781,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.graph = Graph(self.panel, wx.ID_ANY) self.graph = Graph(self.panel, wx.ID_ANY)
lls.Add(self.graph, pos = (3, 5), span = (3, 3)) lls.Add(self.graph, pos = (3, 5), span = (3, 3))
lls.Add(self.tempdisp, pos = (6, 0),span = (1, 1)) lls.Add(self.tempdisp, pos = (6, 0), span = (1, 1))
self.gviz = gviz.gviz(self.panel,(300, 300), self.gviz = gviz.gviz(self.panel, (300, 300),
build_dimensions = self.build_dimensions_list, build_dimensions = self.build_dimensions_list,
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)
...@@ -857,7 +857,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -857,7 +857,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
def plate(self, e): def plate(self, e):
import plater import plater
print "plate function activated" print "plate function activated"
plater.stlwin(size = (800, 580),callback = self.platecb, parent = self).Show() plater.stlwin(size = (800, 580), callback = self.platecb, parent = self).Show()
def platecb(self, name): def platecb(self, name):
print "plated: "+name print "plated: "+name
...@@ -893,15 +893,15 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -893,15 +893,15 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
def setfeeds(self, e): def setfeeds(self, e):
self.feedrates_changed = True self.feedrates_changed = True
try: try:
self.settings._set("e_feedrate",self.efeedc.GetValue()) self.settings._set("e_feedrate", self.efeedc.GetValue())
except: except:
pass pass
try: try:
self.settings._set("z_feedrate",self.zfeedc.GetValue()) self.settings._set("z_feedrate", self.zfeedc.GetValue())
except: except:
pass pass
try: try:
self.settings._set("xy_feedrate",self.xyfeedc.GetValue()) self.settings._set("xy_feedrate", self.xyfeedc.GetValue())
except: except:
pass pass
...@@ -933,7 +933,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -933,7 +933,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
for sizer, button in allcbs: for sizer, button in allcbs:
#sizer.Remove(button) #sizer.Remove(button)
button.Destroy() button.Destroy()
self.custombuttonbuttons=[] self.custombuttonbuttons = []
newbuttonbuttonindex = len(self.custombuttons) newbuttonbuttonindex = len(self.custombuttons)
while newbuttonbuttonindex>0 and self.custombuttons[newbuttonbuttonindex-1] is None: while newbuttonbuttonindex>0 and self.custombuttons[newbuttonbuttonindex-1] is None:
newbuttonbuttonindex -= 1 newbuttonbuttonindex -= 1
...@@ -942,7 +942,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -942,7 +942,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
for i in xrange(len(self.custombuttons)): for i in xrange(len(self.custombuttons)):
btndef = self.custombuttons[i] btndef = self.custombuttons[i]
try: try:
b = wx.Button(self.panel,-1, btndef[0],style = wx.BU_EXACTFIT) b = wx.Button(self.panel,-1, btndef[0], style = wx.BU_EXACTFIT)
b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef[1])) b.SetToolTip(wx.ToolTip(_("Execute command: ")+btndef[1]))
if len(btndef)>2: if len(btndef)>2:
b.SetBackgroundColour(btndef[2]) b.SetBackgroundColour(btndef[2])
...@@ -951,14 +951,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -951,14 +951,14 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
b.SetForegroundColour("#ffffff") b.SetForegroundColour("#ffffff")
except: except:
if i == newbuttonbuttonindex: if i == newbuttonbuttonindex:
self.newbuttonbutton = b = wx.Button(self.panel,-1,"+",size = (19, 18),style = wx.BU_EXACTFIT) self.newbuttonbutton = b = wx.Button(self.panel,-1, "+", size = (19, 18), style = wx.BU_EXACTFIT)
#b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)) #b.SetFont(wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
b.SetForegroundColour("#4444ff") b.SetForegroundColour("#4444ff")
b.SetToolTip(wx.ToolTip(_("click to add new custom button"))) b.SetToolTip(wx.ToolTip(_("click to add new custom button")))
b.Bind(wx.EVT_BUTTON, self.cbutton_edit) b.Bind(wx.EVT_BUTTON, self.cbutton_edit)
else: else:
b = wx.Button(self.panel,-1,".",size = (1, 1)) b = wx.Button(self.panel,-1, ".", size = (1, 1))
#b = wx.StaticText(self.panel,-1,"",size = (72, 22),style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER #b = wx.StaticText(self.panel,-1, "", size = (72, 22), style = wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE) #+wx.SIMPLE_BORDER
b.Disable() b.Disable()
#continue #continue
b.custombutton = i b.custombutton = i
...@@ -972,7 +972,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -972,7 +972,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
#if i<4: #if i<4:
# ubs.Add(b) # ubs.Add(b)
#else: #else:
cs.Add(b, pos = ((i)/4,(i)%4)) cs.Add(b, pos = ((i)/4, (i)%4))
self.topsizer.Layout() self.topsizer.Layout()
def help_button(self): def help_button(self):
...@@ -1022,15 +1022,15 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1022,15 +1022,15 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
elif len(bdef)>2: elif len(bdef)>2:
colour = bdef[2] colour = bdef[2]
if type(colour) not in (str, unicode): if type(colour) not in (str, unicode):
#print type(colour),map(type, colour) #print type(colour), map(type, colour)
if type(colour) == tuple and tuple(map(type, colour)) == (int, int, int): if type(colour) == tuple and tuple(map(type, colour)) == (int, int, int):
colour = map(lambda x:x%256, colour) colour = map(lambda x:x%256, colour)
colour = wx.Colour(*colour).GetAsString(wx.C2S_NAME|wx.C2S_HTML_SYNTAX) colour = wx.Colour(*colour).GetAsString(wx.C2S_NAME|wx.C2S_HTML_SYNTAX)
else: else:
colour = wx.Colour(colour).GetAsString(wx.C2S_NAME|wx.C2S_HTML_SYNTAX) colour = wx.Colour(colour).GetAsString(wx.C2S_NAME|wx.C2S_HTML_SYNTAX)
self.save_in_rc(("button %d" % n),'button %d "%s" /c "%s" %s' % (new_n, bdef[0],colour, bdef[1])) self.save_in_rc(("button %d" % n),'button %d "%s" /c "%s" %s' % (new_n, bdef[0], colour, bdef[1]))
else: else:
self.save_in_rc(("button %d" % n),'button %d "%s" %s' % (new_n, bdef[0],bdef[1])) self.save_in_rc(("button %d" % n),'button %d "%s" %s' % (new_n, bdef[0], bdef[1]))
def cbutton_edit(self, e, button = None): def cbutton_edit(self, e, button = None):
bedit = ButtonEdit(self) bedit = ButtonEdit(self)
...@@ -1055,7 +1055,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1055,7 +1055,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
if bedit.ShowModal() == wx.ID_OK: if bedit.ShowModal() == wx.ID_OK:
if n == len(self.custombuttons): if n == len(self.custombuttons):
self.custombuttons+=[None] self.custombuttons+=[None]
self.custombuttons[n]=[bedit.name.GetValue().strip(),bedit.command.GetValue().strip()] self.custombuttons[n]=[bedit.name.GetValue().strip(), bedit.command.GetValue().strip()]
if bedit.color.GetValue().strip()!="": if bedit.color.GetValue().strip()!="":
self.custombuttons[n]+=[bedit.color.GetValue()] self.custombuttons[n]+=[bedit.color.GetValue()]
self.cbutton_save(n, self.custombuttons[n]) self.cbutton_save(n, self.custombuttons[n])
...@@ -1077,7 +1077,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1077,7 +1077,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
if n+1 >= len(self.custombuttons): if n+1 >= len(self.custombuttons):
self.custombuttons+=[None] # pad self.custombuttons+=[None] # pad
# swap # swap
self.custombuttons[n],self.custombuttons[n+1] = self.custombuttons[n+1],self.custombuttons[n] self.custombuttons[n], self.custombuttons[n+1] = self.custombuttons[n+1], self.custombuttons[n]
self.cbutton_save(n, self.custombuttons[n]) self.cbutton_save(n, self.custombuttons[n])
self.cbutton_save(n+1, self.custombuttons[n+1]) self.cbutton_save(n+1, self.custombuttons[n+1])
#if self.custombuttons[-1] is None: #if self.custombuttons[-1] is None:
...@@ -1092,18 +1092,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1092,18 +1092,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
pos = e.GetPosition() pos = e.GetPosition()
popupmenu = wx.Menu() popupmenu = wx.Menu()
obj = e.GetEventObject() obj = e.GetEventObject()
if hasattr(obj,"custombutton"): if hasattr(obj, "custombutton"):
item = popupmenu.Append(-1, _("Edit custom button '%s'") % e.GetEventObject().GetLabelText()) item = popupmenu.Append(-1, _("Edit custom button '%s'") % e.GetEventObject().GetLabelText())
self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_edit(e, button),item) self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_edit(e, button), item)
item = popupmenu.Append(-1, _("Move left <<")) item = popupmenu.Append(-1, _("Move left <<"))
self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_order(e, button,-1),item) self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_order(e, button,-1), item)
if obj.custombutton == 0: item.Enable(False) if obj.custombutton == 0: item.Enable(False)
item = popupmenu.Append(-1, _("Move right >>")) item = popupmenu.Append(-1, _("Move right >>"))
self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_order(e, button, 1),item) self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_order(e, button, 1), item)
if obj.custombutton == 63: item.Enable(False) if obj.custombutton == 63: item.Enable(False)
pos = self.panel.ScreenToClient(e.GetEventObject().ClientToScreen(pos)) pos = self.panel.ScreenToClient(e.GetEventObject().ClientToScreen(pos))
item = popupmenu.Append(-1, _("Remove custom button '%s'") % e.GetEventObject().GetLabelText()) item = popupmenu.Append(-1, _("Remove custom button '%s'") % e.GetEventObject().GetLabelText())
self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_remove(e, button),item) self.Bind(wx.EVT_MENU, lambda e, button = e.GetEventObject():self.cbutton_remove(e, button), item)
else: else:
item = popupmenu.Append(-1, _("Add custom button")) item = popupmenu.Append(-1, _("Add custom button"))
self.Bind(wx.EVT_MENU, self.cbutton_edit, item) self.Bind(wx.EVT_MENU, self.cbutton_edit, item)
...@@ -1111,18 +1111,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1111,18 +1111,18 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
elif e.Dragging() and e.ButtonIsDown(wx.MOUSE_BTN_LEFT): elif e.Dragging() and e.ButtonIsDown(wx.MOUSE_BTN_LEFT):
obj = e.GetEventObject() obj = e.GetEventObject()
scrpos = obj.ClientToScreen(e.GetPosition()) scrpos = obj.ClientToScreen(e.GetPosition())
if not hasattr(self,"dragpos"): if not hasattr(self, "dragpos"):
self.dragpos = scrpos self.dragpos = scrpos
e.Skip() e.Skip()
return return
else: else:
dx, dy = self.dragpos[0]-scrpos[0],self.dragpos[1]-scrpos[1] dx, dy = self.dragpos[0]-scrpos[0], self.dragpos[1]-scrpos[1]
if dx*dx+dy*dy < 5*5: # threshold to detect dragging for jittery mice if dx*dx+dy*dy < 5*5: # threshold to detect dragging for jittery mice
e.Skip() e.Skip()
return return
if not hasattr(self,"dragging"): if not hasattr(self, "dragging"):
# init dragging of the custom button # init dragging of the custom button
if hasattr(obj,"custombutton") and obj.properties is not None: if hasattr(obj, "custombutton") and obj.properties is not None:
#self.newbuttonbutton.SetLabel("") #self.newbuttonbutton.SetLabel("")
#self.newbuttonbutton.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) #self.newbuttonbutton.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
#self.newbuttonbutton.SetForegroundColour("black") #self.newbuttonbutton.SetForegroundColour("black")
...@@ -1142,7 +1142,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1142,7 +1142,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.upperbottomsizer.SetItemMinSize(b, obj.GetSize()) self.upperbottomsizer.SetItemMinSize(b, obj.GetSize())
self.topsizer.Layout() self.topsizer.Layout()
# b.SetStyle(wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE+wx.SIMPLE_BORDER) # b.SetStyle(wx.ALIGN_CENTRE+wx.ST_NO_AUTORESIZE+wx.SIMPLE_BORDER)
self.dragging = wx.Button(self.panel,-1, obj.GetLabel(),style = wx.BU_EXACTFIT) self.dragging = wx.Button(self.panel,-1, obj.GetLabel(), style = wx.BU_EXACTFIT)
self.dragging.SetBackgroundColour(obj.GetBackgroundColour()) self.dragging.SetBackgroundColour(obj.GetBackgroundColour())
self.dragging.SetForegroundColour(obj.GetForegroundColour()) self.dragging.SetForegroundColour(obj.GetForegroundColour())
self.dragging.sourcebutton = obj self.dragging.sourcebutton = obj
...@@ -1201,7 +1201,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1201,7 +1201,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
src.SetForegroundColour(drg.fgc) src.SetForegroundColour(drg.fgc)
src.SetLabel(drg.label) src.SetLabel(drg.label)
self.last_drag_dest = dst self.last_drag_dest = dst
elif hasattr(self,"dragging") and not e.ButtonIsDown(wx.MOUSE_BTN_LEFT): elif hasattr(self, "dragging") and not e.ButtonIsDown(wx.MOUSE_BTN_LEFT):
# dragging finished # dragging finished
obj = e.GetEventObject() obj = e.GetEventObject()
scrpos = obj.ClientToScreen(e.GetPosition()) scrpos = obj.ClientToScreen(e.GetPosition())
...@@ -1215,7 +1215,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1215,7 +1215,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
if dst is not None: if dst is not None:
src_i = src.custombutton src_i = src.custombutton
dst_i = dst.custombutton dst_i = dst.custombutton
self.custombuttons[src_i],self.custombuttons[dst_i] = self.custombuttons[dst_i],self.custombuttons[src_i] self.custombuttons[src_i], self.custombuttons[dst_i] = self.custombuttons[dst_i], self.custombuttons[src_i]
self.cbutton_save(src_i, self.custombuttons[src_i]) self.cbutton_save(src_i, self.custombuttons[src_i])
self.cbutton_save(dst_i, self.custombuttons[dst_i]) self.cbutton_save(dst_i, self.custombuttons[dst_i])
while self.custombuttons[-1] is None: while self.custombuttons[-1] is None:
...@@ -1280,10 +1280,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1280,10 +1280,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.status_thread = None self.status_thread = None
self.p.recvcb = None self.p.recvcb = None
self.p.disconnect() self.p.disconnect()
if hasattr(self,"feedrates_changed"): if hasattr(self, "feedrates_changed"):
self.save_in_rc("set xy_feedrate","set xy_feedrate %d" % self.settings.xy_feedrate) self.save_in_rc("set xy_feedrate", "set xy_feedrate %d" % self.settings.xy_feedrate)
self.save_in_rc("set z_feedrate","set z_feedrate %d" % self.settings.z_feedrate) self.save_in_rc("set z_feedrate", "set z_feedrate %d" % self.settings.z_feedrate)
self.save_in_rc("set e_feedrate","set e_feedrate %d" % self.settings.e_feedrate) self.save_in_rc("set e_feedrate", "set e_feedrate %d" % self.settings.e_feedrate)
try: try:
self.gwindow.Destroy() self.gwindow.Destroy()
except: except:
...@@ -1327,7 +1327,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1327,7 +1327,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
command = self.commandbox.GetValue() command = self.commandbox.GetValue()
if not len(command): if not len(command):
return return
wx.CallAfter(self.logbox.AppendText,">>>"+command+"\n") wx.CallAfter(self.logbox.AppendText, ">>>"+command+"\n")
if self.webInterface: if self.webInterface:
self.webInterface.AppendLog(">>>"+command+"\n") self.webInterface.AppendLog(">>>"+command+"\n")
self.onecmd(str(command)) self.onecmd(str(command))
...@@ -1341,7 +1341,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1341,7 +1341,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
def statuschecker(self): def statuschecker(self):
while self.statuscheck: while self.statuscheck:
string = "" string = ""
wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ","")) wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", ""))
try: try:
#self.hottgauge.SetValue(parse_temperature_report(self.tempreport, "T:")) #self.hottgauge.SetValue(parse_temperature_report(self.tempreport, "T:"))
wx.CallAfter(self.graph.SetExtruder0Temperature, parse_temperature_report(self.tempreport, "T:")) wx.CallAfter(self.graph.SetExtruder0Temperature, parse_temperature_report(self.tempreport, "T:"))
...@@ -1369,7 +1369,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1369,7 +1369,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
if(self.monitor and self.p.online): if(self.monitor and self.p.online):
if self.sdprinting: if self.sdprinting:
self.p.send_now("M27") self.p.send_now("M27")
if not hasattr(self,"auto_monitor_pattern"): if not hasattr(self, "auto_monitor_pattern"):
self.auto_monitor_pattern = re.compile(r"(ok\s+)?T:[\d\.]+(\s+B:[\d\.]+)?(\s+@:[\d\.]+)?\s*") self.auto_monitor_pattern = re.compile(r"(ok\s+)?T:[\d\.]+(\s+B:[\d\.]+)?(\s+@:[\d\.]+)?\s*")
self.capture_skip[self.auto_monitor_pattern] = self.capture_skip.setdefault(self.auto_monitor_pattern, 0) + 1 self.capture_skip[self.auto_monitor_pattern] = self.capture_skip.setdefault(self.auto_monitor_pattern, 0) + 1
self.p.send_now("M105") self.p.send_now("M105")
...@@ -1408,7 +1408,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1408,7 +1408,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
def recvcb(self, l): def recvcb(self, l):
if "T:" in l: if "T:" in l:
self.tempreport = l self.tempreport = l
wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ","")) wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", ""))
try: try:
#self.hottgauge.SetValue(parse_temperature_report(self.tempreport, "T:")) #self.hottgauge.SetValue(parse_temperature_report(self.tempreport, "T:"))
wx.CallAfter(self.graph.SetExtruder0Temperature, parse_temperature_report(self.tempreport, "T:")) wx.CallAfter(self.graph.SetExtruder0Temperature, parse_temperature_report(self.tempreport, "T:"))
...@@ -1432,7 +1432,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1432,7 +1432,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.recvlisteners.remove(self.listfiles) self.recvlisteners.remove(self.listfiles)
wx.CallAfter(self.filesloaded) wx.CallAfter(self.filesloaded)
elif self.listing: elif self.listing:
self.sdfiles+=[line.replace("\n","").replace("\r","").lower()] self.sdfiles+=[line.replace("\n", "").replace("\r", "").lower()]
def waitforsdresponse(self, l): def waitforsdresponse(self, l):
if "file.open failed" in l: if "file.open failed" in l:
...@@ -1473,10 +1473,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1473,10 +1473,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
def getfiles(self): def getfiles(self):
if not self.p.online: if not self.p.online:
self.sdfiles=[] self.sdfiles = []
return return
self.listing = 0 self.listing = 0
self.sdfiles=[] self.sdfiles = []
self.recvlisteners+=[self.listfiles] self.recvlisteners+=[self.listfiles]
self.p.send_now("M21") self.p.send_now("M21")
self.p.send_now("M20") self.p.send_now("M20")
...@@ -1485,10 +1485,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1485,10 +1485,10 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
try: try:
import shlex import shlex
param = self.expandcommand(self.settings.slicecommand).encode() param = self.expandcommand(self.settings.slicecommand).encode()
print "Slicing: ",param print "Slicing: ", param
if self.webInterface: if self.webInterface:
self.webInterface.AddLog("Slicing: "+param) self.webInterface.AddLog("Slicing: "+param)
pararray=[i.replace("$s",self.filename).replace("$o",self.filename.replace(".stl","_export.gcode").replace(".STL","_export.gcode")).encode() for i in shlex.split(param.replace("\\","\\\\").encode())] pararray = [i.replace("$s", self.filename).replace("$o", self.filename.replace(".stl", "_export.gcode").replace(".STL", "_export.gcode")).encode() for i in shlex.split(param.replace("\\", "\\\\").encode())]
#print pararray #print pararray
self.skeinp = subprocess.Popen(pararray, stderr = subprocess.STDOUT, stdout = subprocess.PIPE) self.skeinp = subprocess.Popen(pararray, stderr = subprocess.STDOUT, stdout = subprocess.PIPE)
while True: while True:
...@@ -1513,9 +1513,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1513,9 +1513,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
time.sleep(0.1) time.sleep(0.1)
fn = self.filename fn = self.filename
try: try:
self.filename = self.filename.replace(".stl","_export.gcode").replace(".STL","_export.gcode").replace(".obj","_export.gcode").replace(".OBJ","_export.gcode") self.filename = self.filename.replace(".stl", "_export.gcode").replace(".STL", "_export.gcode").replace(".obj", "_export.gcode").replace(".OBJ", "_export.gcode")
of = open(self.filename) of = open(self.filename)
self.f=[i.replace("\n","").replace("\r","") for i in of] self.f = [i.replace("\n", "").replace("\r", "") for i in of]
of.close() of.close()
if self.p.online: if self.p.online:
wx.CallAfter(self.printbtn.Enable) wx.CallAfter(self.printbtn.Enable)
...@@ -1552,7 +1552,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1552,7 +1552,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
basedir = os.path.split(self.filename)[0] basedir = os.path.split(self.filename)[0]
except: except:
pass pass
dlg = wx.FileDialog(self, _("Open file to print"),basedir, style = wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) 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.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 or dlg.ShowModal() == wx.ID_OK):
if filename is not None: if filename is not None:
...@@ -1564,7 +1564,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1564,7 +1564,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
return return
path = os.path.split(name)[0] path = os.path.split(name)[0]
if path != self.settings.last_file_path: if path != self.settings.last_file_path:
self.set("last_file_path",path) self.set("last_file_path", path)
if name.lower().endswith(".stl"): if name.lower().endswith(".stl"):
self.skein(name) self.skein(name)
elif name.lower().endswith(".obj"): elif name.lower().endswith(".obj"):
...@@ -1572,7 +1572,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1572,7 +1572,7 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
else: else:
self.filename = name self.filename = name
of = open(self.filename) of = open(self.filename)
self.f=[i.replace("\n","").replace("\r","") for i in of] self.f = [i.replace("\n", "").replace("\r", "") for i in of]
of.close() of.close()
self.status.SetStatusText(_("Loaded %s, %d lines") % (name, len(self.f))) self.status.SetStatusText(_("Loaded %s, %d lines") % (name, len(self.f)))
wx.CallAfter(self.printbtn.SetLabel, _("Print")) wx.CallAfter(self.printbtn.SetLabel, _("Print"))
...@@ -1709,9 +1709,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1709,9 +1709,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
self.p.connect(port, baud) self.p.connect(port, baud)
self.statuscheck = True self.statuscheck = True
if port != self.settings.port: if port != self.settings.port:
self.set("port",port) self.set("port", port)
if baud != self.settings.baudrate: if baud != self.settings.baudrate:
self.set("baudrate",str(baud)) self.set("baudrate", str(baud))
self.status_thread = threading.Thread(target = self.statuschecker) self.status_thread = threading.Thread(target = self.statuschecker)
self.status_thread.start() self.status_thread.start()
if self.predisconnect_mainqueue: if self.predisconnect_mainqueue:
...@@ -1786,9 +1786,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole): ...@@ -1786,9 +1786,9 @@ class PronterWindow(wx.Frame, pronsole.pronsole):
# a string containing up to six numbers delimited by almost anything # a string containing up to six numbers delimited by almost anything
# first 0-3 numbers specify the build volume, no sign, always positive # first 0-3 numbers specify the build volume, no sign, always positive
# remaining 0-3 numbers specify the coordinates of the "southwest" corner of the build platform # remaining 0-3 numbers specify the coordinates of the "southwest" corner of the build platform
# "XXX,YYY" # "XXX, YYY"
# "XXXxYYY+xxx-yyy" # "XXXxYYY+xxx-yyy"
# "XXX,YYY,ZZZ+xxx+yyy-zzz" # "XXX, YYY, ZZZ+xxx+yyy-zzz"
# etc # etc
bdl = re.match( bdl = re.match(
"[^\d+-]*(\d+)?" + # X build size "[^\d+-]*(\d+)?" + # X build size
......
...@@ -145,7 +145,7 @@ setup ( ...@@ -145,7 +145,7 @@ setup (
license = "GPLv3", license = "GPLv3",
data_files = data_files, data_files = data_files,
packages = ["printrun", "printrun.svg"], packages = ["printrun", "printrun.svg"],
scripts = ["pronsole.py", "pronterface.py", "plater.py","printcore.py"], scripts = ["pronsole.py", "pronterface.py", "plater.py", "printcore.py"],
cmdclass = {"uninstall" : uninstall, cmdclass = {"uninstall" : uninstall,
"install" : install, "install" : install,
"install_data" : install_data} "install_data" : install_data}
......
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