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):
......
This diff is collapsed.
This diff is collapsed.
...@@ -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
This diff is collapsed.
This diff is collapsed.
...@@ -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