Semi-automated coding style cleanup
parent
cbd8cc0636
commit
77eb2440e3
|
@ -0,0 +1,18 @@
|
|||
Some cleanup commands :
|
||||
|
||||
To add a space after each comma :
|
||||
sed -e "s/\(\w\),\(\w\)/\1, \2/g" -i *.py printrun/*.py printrun/svg/*.py
|
||||
|
||||
To add spaces around each = :
|
||||
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
|
||||
|
||||
To add spaces around each == :
|
||||
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/\()\)==\((\)/\1 == \2/g" -i *.py printrun/*.py printrun/svg/*.py
|
||||
|
||||
Obviously this is not a perfect solution, it WILL break the code. Juste check the diff and fix what's wrong before commiting.
|
46
plater.py
46
plater.py
|
@ -46,7 +46,7 @@ def evalme(s):
|
|||
|
||||
|
||||
class stlwrap:
|
||||
def __init__(self, obj, name=None):
|
||||
def __init__(self, obj, name = None):
|
||||
self.obj = obj
|
||||
self.name = name
|
||||
if name is None:
|
||||
|
@ -58,7 +58,7 @@ class stlwrap:
|
|||
|
||||
class showstl(wx.Window):
|
||||
def __init__(self, parent, size, pos):
|
||||
wx.Window.__init__(self, parent, size=size, pos=pos)
|
||||
wx.Window.__init__(self, parent, size = size, pos = pos)
|
||||
#self.SetBackgroundColour((0, 0, 0))
|
||||
#wx.FutureCall(200, self.paint)
|
||||
self.i = 0
|
||||
|
@ -141,7 +141,7 @@ class showstl(wx.Window):
|
|||
self.i += angle
|
||||
if not self.triggered:
|
||||
self.triggered = 1
|
||||
threading.Thread(target=self.cr).start()
|
||||
threading.Thread(target = self.cr).start()
|
||||
|
||||
def keypress(self, event):
|
||||
"""gets keypress events and moves/rotates acive shape"""
|
||||
|
@ -200,9 +200,9 @@ class showstl(wx.Window):
|
|||
|
||||
def repaint(self, event):
|
||||
dc = wx.PaintDC(self)
|
||||
self.paint(dc=dc)
|
||||
self.paint(dc = dc)
|
||||
|
||||
def paint(self, coord1="x", coord2="y", dc=None):
|
||||
def paint(self, coord1 = "x", coord2 = "y", dc = None):
|
||||
coords = {"x": 0, "y": 1, "z": 2}
|
||||
if dc is None:
|
||||
dc = wx.ClientDC(self)
|
||||
|
@ -231,7 +231,7 @@ class showstl(wx.Window):
|
|||
bm = wx.BitmapFromImage(im)
|
||||
dcs.SelectObject(bm)
|
||||
bsz = bm.GetSize()
|
||||
dc.Blit(scale * m.offsets[0] - bsz[0] / 2, 400 - (scale * m.offsets[1] + bsz[1] / 2), bsz[0], bsz[1], dcs, 0, 0, useMask=1)
|
||||
dc.Blit(scale * m.offsets[0] - bsz[0] / 2, 400 - (scale * m.offsets[1] + bsz[1] / 2), bsz[0], bsz[1], dcs, 0, 0, useMask = 1)
|
||||
#for i in m.facets:#random.sample(m.facets, min(100000, len(m.facets))):
|
||||
# dc.DrawPolygon([wx.Point(offset[0]+scale*m.offsets[0]+scale*p[0], 400-(offset[1]+scale*m.offsets[1]+scale*p[1])) for p in i[1]])
|
||||
#if(time.time()-t)>5:
|
||||
|
@ -242,29 +242,29 @@ class showstl(wx.Window):
|
|||
|
||||
|
||||
class stlwin(wx.Frame):
|
||||
def __init__(self, size=(800, 580), callback=None, parent=None):
|
||||
wx.Frame.__init__(self, parent, title=_("Plate building tool"), size=size)
|
||||
def __init__(self, size = (800, 580), callback = None, parent = None):
|
||||
wx.Frame.__init__(self, parent, title = _("Plate building tool"), size = size)
|
||||
self.SetIcon(wx.Icon(pixmapfile("plater.ico"), wx.BITMAP_TYPE_ICO))
|
||||
self.mainsizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.panel = wx.Panel(self, -1, size=(150, 600), pos=(0, 0))
|
||||
self.panel = wx.Panel(self, -1, size = (150, 600), pos = (0, 0))
|
||||
#self.panel.SetBackgroundColour((10, 10, 10))
|
||||
self.l = wx.ListBox(self.panel, size=(300, 180), pos=(0, 30))
|
||||
self.cl = wx.Button(self.panel, label=_("Clear"), pos=(0, 205))
|
||||
self.lb = wx.Button(self.panel, label=_("Load"), pos=(0, 0))
|
||||
self.l = wx.ListBox(self.panel, size = (300, 180), pos = (0, 30))
|
||||
self.cl = wx.Button(self.panel, label = _("Clear"), pos = (0, 205))
|
||||
self.lb = wx.Button(self.panel, label = _("Load"), pos = (0, 0))
|
||||
if(callback is None):
|
||||
self.eb = wx.Button(self.panel, label=_("Export"), pos=(100, 0))
|
||||
self.eb = wx.Button(self.panel, label = _("Export"), pos = (100, 0))
|
||||
self.eb.Bind(wx.EVT_BUTTON, self.export)
|
||||
else:
|
||||
self.eb = wx.Button(self.panel, label=_("Export"), pos=(200, 205))
|
||||
self.eb = wx.Button(self.panel, label = _("Export"), pos = (200, 205))
|
||||
self.eb.Bind(wx.EVT_BUTTON, self.export)
|
||||
self.edb = wx.Button(self.panel, label=_("Done"), pos=(100, 0))
|
||||
self.edb = wx.Button(self.panel, label = _("Done"), pos = (100, 0))
|
||||
self.edb.Bind(wx.EVT_BUTTON, lambda e: self.done(e, callback))
|
||||
self.eb = wx.Button(self.panel, label=_("Cancel"), pos=(200, 0))
|
||||
self.eb = wx.Button(self.panel, label = _("Cancel"), pos = (200, 0))
|
||||
self.eb.Bind(wx.EVT_BUTTON, lambda e: self.Destroy())
|
||||
self.sb = wx.Button(self.panel, label=_("Snap to Z = 0"), pos=(00, 255))
|
||||
self.cb = wx.Button(self.panel, label=_("Put at 100, 100"), pos=(0, 280))
|
||||
self.db = wx.Button(self.panel, label=_("Delete"), pos=(0, 305))
|
||||
self.ab = wx.Button(self.panel, label=_("Auto"), pos=(0, 330))
|
||||
self.sb = wx.Button(self.panel, label = _("Snap to Z = 0"), pos = (00, 255))
|
||||
self.cb = wx.Button(self.panel, label = _("Put at 100, 100"), pos = (0, 280))
|
||||
self.db = wx.Button(self.panel, label = _("Delete"), pos = (0, 305))
|
||||
self.ab = wx.Button(self.panel, label = _("Auto"), pos = (0, 330))
|
||||
self.cl.Bind(wx.EVT_BUTTON, self.clear)
|
||||
self.lb.Bind(wx.EVT_BUTTON, self.right)
|
||||
self.sb.Bind(wx.EVT_BUTTON, self.snap)
|
||||
|
@ -368,7 +368,7 @@ class stlwin(wx.Frame):
|
|||
self.Destroy()
|
||||
|
||||
def export(self, event):
|
||||
dlg = wx.FileDialog(self, _("Pick file to save to"), self.basedir, style=wx.FD_SAVE)
|
||||
dlg = wx.FileDialog(self, _("Pick file to save to"), self.basedir, style = wx.FD_SAVE)
|
||||
dlg.SetWildcard(_("STL files (;*.stl;*.STL;)"))
|
||||
if(dlg.ShowModal() == wx.ID_OK):
|
||||
name = dlg.GetPath()
|
||||
|
@ -393,7 +393,7 @@ class stlwin(wx.Frame):
|
|||
print _("wrote %s") % name
|
||||
|
||||
def right(self, event):
|
||||
dlg = wx.FileDialog(self, _("Pick file to load"), self.basedir, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||
dlg = wx.FileDialog(self, _("Pick file to load"), self.basedir, style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||
dlg.SetWildcard(_("STL files (;*.stl;*.STL;)|*.stl|OpenSCAD files (;*.scad;)|*.scad"))
|
||||
if(dlg.ShowModal() == wx.ID_OK):
|
||||
name = dlg.GetPath()
|
||||
|
@ -443,7 +443,7 @@ class stlwin(wx.Frame):
|
|||
self.Refresh()
|
||||
#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]
|
||||
c = 1
|
||||
while newname in self.models:
|
||||
|
|
10
printcore.py
10
printcore.py
|
@ -83,7 +83,7 @@ class printcore():
|
|||
self.online = False
|
||||
self.printing = False
|
||||
|
||||
def connect(self,port=None,baud=None):
|
||||
def connect(self, port = None, baud = None):
|
||||
"""Set port and baudrate if given, then connect to printer
|
||||
"""
|
||||
if self.printer:
|
||||
|
@ -96,7 +96,7 @@ class printcore():
|
|||
disable_hup(self.port)
|
||||
self.printer = Serial(port = self.port, baudrate = self.baud, timeout = 0.25)
|
||||
self.stop_read_thread = False
|
||||
self.read_thread = Thread(target=self._listen)
|
||||
self.read_thread = Thread(target = self._listen)
|
||||
self.read_thread.start()
|
||||
|
||||
def reset(self):
|
||||
|
@ -183,7 +183,7 @@ class printcore():
|
|||
self.clear = True
|
||||
|
||||
def _checksum(self, command):
|
||||
return reduce(lambda x,y:x^y, map(ord, command))
|
||||
return reduce(lambda x, y:x^y, map(ord, command))
|
||||
|
||||
def startprint(self, data, startindex = 0):
|
||||
"""Start a print, data is an array of gcode commands.
|
||||
|
@ -289,7 +289,7 @@ class printcore():
|
|||
self.clear = True
|
||||
return
|
||||
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
|
||||
return
|
||||
self.resendfrom = -1
|
||||
|
@ -369,7 +369,7 @@ if __name__ == '__main__':
|
|||
|
||||
try:
|
||||
if statusreport:
|
||||
p.loud=False
|
||||
p.loud = False
|
||||
sys.stdout.write("Progress: 00.0%")
|
||||
sys.stdout.flush()
|
||||
while p.printing:
|
||||
|
|
|
@ -35,7 +35,7 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
|
|||
'speed':['Main Feed Rate (mm/s):','Main Flow Rate (scaler):','Perimeter Feed Rate (mm/s):','Perimeter Flow Rate (scaler):','Travel Feed Rate (mm/s):']
|
||||
}
|
||||
|
||||
self.scrollbarPanel = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL)
|
||||
self.scrollbarPanel = wx.ScrolledWindow(self, -1, style = wx.TAB_TRAVERSAL)
|
||||
self.settingsSizer = self.getProfileSettings()
|
||||
self.scrollbarPanel.SetSizer(self.settingsSizer)
|
||||
|
||||
|
@ -67,7 +67,7 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
|
|||
self.Layout()
|
||||
|
||||
def getProfileSettings(self):
|
||||
settingsSizer = wx.GridBagSizer(hgap=2, vgap=1)
|
||||
settingsSizer = wx.GridBagSizer(hgap = 2, vgap = 1)
|
||||
settingsRow = 0
|
||||
|
||||
for craftName in sorted(self.moduleSettingsMap.keys()):
|
||||
|
@ -86,28 +86,28 @@ class SkeinforgeQuickEditDialog(wx.Dialog):
|
|||
for setting in settings.getReadRepository(repo).preferences:
|
||||
if setting.name in self.moduleSettingsMap[craftName]:
|
||||
|
||||
settingSizer = wx.GridBagSizer(hgap=2, vgap=2)
|
||||
settingSizer = wx.GridBagSizer(hgap = 2, vgap = 2)
|
||||
settingSizer.AddGrowableCol(0)
|
||||
settingRow = 0
|
||||
settingLabel = wx.StaticText(self.scrollbarPanel, -1, setting.name)
|
||||
settingLabel.Wrap(400)
|
||||
settingSizer.Add(settingLabel, pos=(settingRow, 0))
|
||||
settingSizer.Add(settingLabel, pos = (settingRow, 0))
|
||||
|
||||
if (isinstance(setting.value, bool)):
|
||||
checkbox = wx.CheckBox(self.scrollbarPanel)
|
||||
checkbox.SetName(craftName + '.' + setting.name)
|
||||
checkbox.SetValue(setting.value)
|
||||
settingSizer.Add(checkbox, pos=(settingRow, 1))
|
||||
settingSizer.AddSpacer((25, -1), pos=(settingRow, 2))
|
||||
settingSizer.Add(checkbox, pos = (settingRow, 1))
|
||||
settingSizer.AddSpacer((25, -1), pos = (settingRow, 2))
|
||||
else:
|
||||
textCtrl = wx.TextCtrl(self.scrollbarPanel, value=str(setting.value), size=(50, -1))
|
||||
textCtrl = wx.TextCtrl(self.scrollbarPanel, value = str(setting.value), size = (50, -1))
|
||||
textCtrl.SetName(craftName + '.' + setting.name)
|
||||
settingSizer.Add(textCtrl, pos=(settingRow, 1))
|
||||
settingSizer.Add(textCtrl, pos = (settingRow, 1))
|
||||
|
||||
craftStaticBoxSizer.Add(settingSizer, 1, wx.EXPAND, 0)
|
||||
settingRow += 1
|
||||
col = settingsRow % 2
|
||||
settingsSizer.Add(craftStaticBoxSizer, pos=(settingsRow - col, col))
|
||||
settingsSizer.Add(craftStaticBoxSizer, pos = (settingsRow - col, col))
|
||||
settingsRow += 1
|
||||
|
||||
return settingsSizer
|
||||
|
|
|
@ -11,7 +11,7 @@ import shutil
|
|||
|
||||
class MyFrame(wx.Frame):
|
||||
def __init__(self, parent, mysize):
|
||||
wx.Frame.__init__(self, parent, wx.ID_ANY, size=mysize)
|
||||
wx.Frame.__init__(self, parent, wx.ID_ANY, size = mysize)
|
||||
self.SetBackgroundColour('black')
|
||||
|
||||
# milliseconds per frame
|
||||
|
@ -49,7 +49,7 @@ class MyFrame(wx.Frame):
|
|||
if self.mytmpdir:
|
||||
shutil.rmtree(self.mytmpdir)
|
||||
|
||||
def onPaint(self, event=None):
|
||||
def onPaint(self, event = None):
|
||||
# this is the wxPython drawing surface/canvas
|
||||
dc = wx.PaintDC(self)
|
||||
while self.loops:
|
||||
|
@ -59,7 +59,7 @@ class MyFrame(wx.Frame):
|
|||
w, h = bmp.GetSize()
|
||||
info = "%s %dx%d" % (self.name_list[ix], w, h)
|
||||
self.SetTitle(info)
|
||||
#self.SetSize((w,h))
|
||||
#self.SetSize((w, h))
|
||||
# draw the image
|
||||
dc.DrawBitmap(bmp, 0, 0, True)
|
||||
wx.MilliSleep(self.delay)
|
||||
|
|
|
@ -66,10 +66,10 @@ class BufferedCanvas(wx.Panel):
|
|||
def __init__(self,
|
||||
parent,
|
||||
ID=-1,
|
||||
pos=wx.DefaultPosition,
|
||||
size=wx.DefaultSize,
|
||||
style=wx.NO_FULL_REPAINT_ON_RESIZE|wx.WANTS_CHARS):
|
||||
wx.Panel.__init__(self,parent,ID,pos,size,style)
|
||||
pos = wx.DefaultPosition,
|
||||
size = wx.DefaultSize,
|
||||
style = wx.NO_FULL_REPAINT_ON_RESIZE|wx.WANTS_CHARS):
|
||||
wx.Panel.__init__(self, parent, ID, pos, size, style)
|
||||
|
||||
# Bind events
|
||||
self.Bind(wx.EVT_PAINT, self.onPaint)
|
||||
|
@ -83,7 +83,7 @@ class BufferedCanvas(wx.Panel):
|
|||
## General methods
|
||||
##
|
||||
|
||||
def draw(self,dc):
|
||||
def draw(self, dc):
|
||||
"""
|
||||
Stub: called when the canvas needs to be re-drawn.
|
||||
"""
|
||||
|
@ -96,7 +96,7 @@ class BufferedCanvas(wx.Panel):
|
|||
self.Refresh()
|
||||
|
||||
def getWidthHeight(self):
|
||||
width,height = self.GetClientSizeTuple()
|
||||
width, height = self.GetClientSizeTuple()
|
||||
if width == 0:
|
||||
width = 1
|
||||
if height == 0:
|
||||
|
|
|
@ -2,36 +2,36 @@
|
|||
#Interactive RepRap e axis calibration program
|
||||
#(C) Nathan Zadoks 2011
|
||||
#Licensed under CC-BY-SA or GPLv2 and higher - Pick your poison.
|
||||
s=300 #Extrusion speed (mm/min)
|
||||
n=100 #Default length to extrude
|
||||
s = 300 #Extrusion speed (mm/min)
|
||||
n = 100 #Default length to extrude
|
||||
m= 0 #User-entered measured extrusion length
|
||||
k=300 #Default amount of steps per mm
|
||||
k = 300 #Default amount of steps per mm
|
||||
port='/dev/ttyUSB0' #Default serial port to connect to printer
|
||||
temp=210 #Default extrusion temperature
|
||||
temp = 210 #Default extrusion temperature
|
||||
|
||||
tempmax=250 #Maximum extrusion temperature
|
||||
tempmax = 250 #Maximum extrusion temperature
|
||||
|
||||
t=int(n*60)/s #Time to wait for extrusion
|
||||
t = int(n*60)/s #Time to wait for extrusion
|
||||
|
||||
try:
|
||||
from printdummy import printcore
|
||||
except ImportError:
|
||||
from printcore import printcore
|
||||
import time,getopt,sys,os
|
||||
import time, getopt, sys, os
|
||||
|
||||
def float_input(prompt=''):
|
||||
import sys
|
||||
f=None
|
||||
while f==None:
|
||||
s=raw_input(prompt)
|
||||
f = None
|
||||
while f == None:
|
||||
s = raw_input(prompt)
|
||||
try:
|
||||
f=float(s)
|
||||
f = float(s)
|
||||
except ValueError:
|
||||
sys.stderr.write("Not a valid floating-point number.\n")
|
||||
sys.stderr.flush()
|
||||
return f
|
||||
def wait(t,m=''):
|
||||
import time,sys
|
||||
def wait(t, m=''):
|
||||
import time, sys
|
||||
sys.stdout.write(m+'['+(' '*t)+']\r'+m+'[')
|
||||
sys.stdout.flush()
|
||||
for i in range(t):
|
||||
|
@ -45,19 +45,19 @@ def w(s):
|
|||
sys.stdout.flush()
|
||||
|
||||
|
||||
def heatup(p,temp,s=0):
|
||||
curtemp=gettemp(p)
|
||||
def heatup(p, temp, s = 0):
|
||||
curtemp = gettemp(p)
|
||||
p.send_now('M109 S%03d'%temp)
|
||||
p.temp=0
|
||||
p.temp = 0
|
||||
if not s: w("Heating extruder up..")
|
||||
f=False
|
||||
f = False
|
||||
while curtemp<=(temp-1):
|
||||
p.send_now('M105')
|
||||
time.sleep(0.5)
|
||||
if not f:
|
||||
time.sleep(1.5)
|
||||
f=True
|
||||
curtemp=gettemp(p)
|
||||
f = True
|
||||
curtemp = gettemp(p)
|
||||
if curtemp: w(u"\rHeating extruder up.. %3d \xb0C"%curtemp)
|
||||
if s: print
|
||||
else: print "\nReady."
|
||||
|
@ -67,47 +67,47 @@ def gettemp(p):
|
|||
except: setattr(p,'logl',0)
|
||||
try: p.temp
|
||||
except: setattr(p,'temp',0)
|
||||
for n in range(p.logl,len(p.log)):
|
||||
line=p.log[n]
|
||||
for n in range(p.logl, len(p.log)):
|
||||
line = p.log[n]
|
||||
if 'T:' in line:
|
||||
try:
|
||||
setattr(p,'temp',int(line.split('T:')[1].split()[0]))
|
||||
except: print line
|
||||
p.logl=len(p.log)
|
||||
p.logl = len(p.log)
|
||||
return p.temp
|
||||
if not os.path.exists(port):
|
||||
port=0
|
||||
port = 0
|
||||
|
||||
#Parse options
|
||||
help=u"""
|
||||
help = u"""
|
||||
%s [ -l DISTANCE ] [ -s STEPS ] [ -t TEMP ] [ -p PORT ]
|
||||
-l --length Length of filament to extrude for each calibration step (default: %d mm)
|
||||
-s --steps Initial amount of steps to use (default: %d steps)
|
||||
-t --temp Extrusion temperature in degrees Celsius (default: %d \xb0C, max %d \xb0C)
|
||||
-p --port Serial port the printer is connected to (default: %s)
|
||||
-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:
|
||||
opts,args=getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help","length=","steps=","temp=","port="])
|
||||
except getopt.GetoptError,err:
|
||||
opts, args = getopt.getopt(sys.argv[1:],"hl:s:t:p:",["help","length = ","steps = ","temp = ","port = "])
|
||||
except getopt.GetoptError, err:
|
||||
print str(err)
|
||||
print help
|
||||
sys.exit(2)
|
||||
for o,a in opts:
|
||||
for o, a in opts:
|
||||
if o in ('-h','--help'):
|
||||
print help
|
||||
sys.exit()
|
||||
elif o in ('-l','--length'):
|
||||
n=float(a)
|
||||
n = float(a)
|
||||
elif o in ('-s','--steps'):
|
||||
k=int(a)
|
||||
k = int(a)
|
||||
elif o in ('-t','--temp'):
|
||||
temp=int(a)
|
||||
temp = int(a)
|
||||
if temp>=tempmax:
|
||||
print (u'%d \xb0C? Are you insane?'.encode('utf-8')%temp)+(" That's over nine thousand!" if temp>9000 else '')
|
||||
sys.exit(255)
|
||||
elif o in ('-p','--port'):
|
||||
port=a
|
||||
port = a
|
||||
|
||||
#Show initial parameters
|
||||
print "Initial parameters"
|
||||
|
@ -116,12 +116,12 @@ print "Length extruded: %3d mm"%n
|
|||
print
|
||||
print "Serial port: %s"%(port if port else 'auto')
|
||||
|
||||
p=None
|
||||
p = None
|
||||
try:
|
||||
#Connect to printer
|
||||
w("Connecting to printer..")
|
||||
try:
|
||||
p=printcore(port,115200)
|
||||
p = printcore(port, 115200)
|
||||
except:
|
||||
print 'Error.'
|
||||
raise
|
||||
|
@ -130,18 +130,18 @@ try:
|
|||
w('.')
|
||||
print " connected."
|
||||
|
||||
heatup(p,temp)
|
||||
heatup(p, temp)
|
||||
|
||||
#Calibration loop
|
||||
while n!=m:
|
||||
heatup(p,temp,True)
|
||||
heatup(p, temp, True)
|
||||
p.send_now("G92 E0") #Reset e axis
|
||||
p.send_now("G1 E%d F%d"%(n,s)) #Extrude length of filament
|
||||
p.send_now("G1 E%d F%d"%(n, s)) #Extrude length of filament
|
||||
wait(t,'Extruding.. ')
|
||||
m=float_input("How many millimeters of filament were extruded? ")
|
||||
if m==0: continue
|
||||
m = float_input("How many millimeters of filament were extruded? ")
|
||||
if m == 0: continue
|
||||
if n!=m:
|
||||
k=(n/m)*k
|
||||
k = (n/m)*k
|
||||
p.send_now("M92 E%d"%int(round(k))) #Set new step count
|
||||
print "Steps per mm: %3d steps"%k #Tell user
|
||||
print 'Calibration completed.' #Yay!
|
||||
|
|
|
@ -19,8 +19,8 @@ import threading
|
|||
class GLPanel(wx.Panel):
|
||||
'''A simple class for using OpenGL with wxPython.'''
|
||||
|
||||
def __init__(self, parent, id, pos=wx.DefaultPosition,
|
||||
size=wx.DefaultSize, style=0):
|
||||
def __init__(self, parent, id, pos = wx.DefaultPosition,
|
||||
size = wx.DefaultSize, style = 0):
|
||||
# Forcing a no full repaint to stop flickering
|
||||
style = style | wx.NO_FULL_REPAINT_ON_RESIZE
|
||||
#call super function
|
||||
|
@ -33,7 +33,7 @@ class GLPanel(wx.Panel):
|
|||
glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit
|
||||
# Create the canvas
|
||||
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.canvas = glcanvas.GLCanvas(self, attribList=attribList)
|
||||
self.canvas = glcanvas.GLCanvas(self, attribList = attribList)
|
||||
self.sizer.Add(self.canvas, 1, wx.EXPAND)
|
||||
self.SetSizer(self.sizer)
|
||||
#self.sizer.Fit(self)
|
||||
|
@ -200,7 +200,7 @@ def _dist(dist):
|
|||
class gcpoint(object):
|
||||
"""gcode point
|
||||
stub for first line"""
|
||||
def __init__(self, x=0,y=0,z=0,e=0):
|
||||
def __init__(self, x = 0, y = 0, z = 0, e = 0):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
|
@ -210,10 +210,10 @@ class gcpoint(object):
|
|||
|
||||
class gcline(object):
|
||||
"""gcode move line
|
||||
Once initialised,it knows its position, length and extrusion ratio
|
||||
Once initialised, it knows its position, length and extrusion ratio
|
||||
Returns lines into gcview batch()
|
||||
"""
|
||||
def __init__(self, x=None, y=None, z=None, e=None, f=None, prev_gcline=None, orgline = False):
|
||||
def __init__(self, x = None, y = None, z = None, e = None, f = None, prev_gcline = None, orgline = False):
|
||||
if prev_gcline is None:
|
||||
self.prev_gcline = gcpoint()
|
||||
else:
|
||||
|
@ -255,7 +255,7 @@ class gcline(object):
|
|||
self.orgline,
|
||||
)
|
||||
|
||||
def calc_delta(self, prev_gcline=None):
|
||||
def calc_delta(self, prev_gcline = None):
|
||||
if prev_gcline is None:
|
||||
prev_gcline = self.prev_gcline
|
||||
if self.prev_gcline is not None:
|
||||
|
@ -290,7 +290,7 @@ class gcline(object):
|
|||
]
|
||||
def glcolor(self, upper_limit = None, lower_limit = 0, max_feedrate = 0):
|
||||
if self.extrusion_ratio == 0:
|
||||
return [255,255,255,0,0,0]
|
||||
return [255, 255, 255, 0,0, 0]
|
||||
else:
|
||||
blue_color = 0
|
||||
green_color = 0
|
||||
|
@ -312,7 +312,7 @@ class gcline(object):
|
|||
blue_color = 255
|
||||
if blue_color < 0:
|
||||
blue_color = 0
|
||||
return[255,green_color,blue_color,128,green_color,blue_color/4]
|
||||
return[255, green_color, blue_color, 128, green_color, blue_color/4]
|
||||
|
||||
|
||||
def float_from_line(axe, line):
|
||||
|
@ -340,7 +340,7 @@ class gcview(object):
|
|||
"""gcode visualiser
|
||||
Holds opengl objects for all layers
|
||||
"""
|
||||
def __init__(self, lines, batch, w=0.5, h=0.5):
|
||||
def __init__(self, lines, batch, w = 0.5, h = 0.5):
|
||||
if len(lines) == 0:
|
||||
return
|
||||
print "Loading %s lines" % (len(lines))
|
||||
|
@ -430,7 +430,7 @@ class gcview(object):
|
|||
else:
|
||||
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
|
||||
return r
|
||||
return None
|
||||
|
@ -524,7 +524,7 @@ def mulquat(q1, rq):
|
|||
|
||||
class TestGlPanel(GLPanel):
|
||||
|
||||
def __init__(self, parent, size, id=wx.ID_ANY):
|
||||
def __init__(self, parent, size, id = wx.ID_ANY):
|
||||
super(TestGlPanel, self).__init__(parent, id, wx.DefaultPosition, size, 0)
|
||||
self.batches = []
|
||||
self.rot = 0
|
||||
|
@ -553,7 +553,7 @@ class TestGlPanel(GLPanel):
|
|||
def forceresize(self):
|
||||
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] + 1))
|
||||
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] - 1))
|
||||
threading.Thread(target=self.update).start()
|
||||
threading.Thread(target = self.update).start()
|
||||
self.initialized = 0
|
||||
|
||||
def move_shape(self, delta):
|
||||
|
@ -605,7 +605,7 @@ class TestGlPanel(GLPanel):
|
|||
p1y = -(float(p1[1]) - sz[1] / 2) / (sz[1] / 2)
|
||||
p2x = (float(p2[0]) - sz[0] / 2) / (sz[0] / 2)
|
||||
p2y = -(float(p2[1]) - sz[1] / 2) / (sz[1] / 2)
|
||||
#print p1x,p1y,p2x,p2y
|
||||
#print p1x, p1y, p2x, p2y
|
||||
quat = trackball(p1x, p1y, p2x, p2y, -self.transv[2] / 250.0)
|
||||
if self.rot:
|
||||
self.basequat = mulquat(self.basequat, quat)
|
||||
|
@ -768,7 +768,7 @@ class TestGlPanel(GLPanel):
|
|||
|
||||
def drawmodel(self, m, n):
|
||||
batch = pyglet.graphics.Batch()
|
||||
stl = stlview(m.facets, batch=batch)
|
||||
stl = stlview(m.facets, batch = batch)
|
||||
m.batch = batch
|
||||
m.animoffset = 300
|
||||
#print m
|
||||
|
@ -907,8 +907,8 @@ class TestGlPanel(GLPanel):
|
|||
class GCFrame(wx.Frame):
|
||||
'''A simple class for using OpenGL with wxPython.'''
|
||||
|
||||
def __init__(self, parent, ID, title, pos=wx.DefaultPosition,
|
||||
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
|
||||
def __init__(self, parent, ID, title, pos = wx.DefaultPosition,
|
||||
size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE):
|
||||
super(GCFrame, self).__init__(parent, ID, title, pos, (size[0] + 150, size[1]), style)
|
||||
|
||||
class d:
|
||||
|
@ -921,7 +921,7 @@ class GCFrame(wx.Frame):
|
|||
m.curlayer = -1
|
||||
m.scale = [1.0, 1.0, 1.0]
|
||||
m.batch = pyglet.graphics.Batch()
|
||||
m.gc = gcview([], batch=m.batch)
|
||||
m.gc = gcview([], batch = m.batch)
|
||||
self.models = {"GCODE": m}
|
||||
self.l = d()
|
||||
self.modelindex = 0
|
||||
|
@ -929,14 +929,14 @@ class GCFrame(wx.Frame):
|
|||
|
||||
def addfile(self, gcode=[]):
|
||||
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)
|
||||
|
||||
def clear(self):
|
||||
self.models["GCODE"].gc.delete()
|
||||
self.models["GCODE"].gc = gcview([], batch=self.models["GCODE"].batch)
|
||||
self.models["GCODE"].gc = gcview([], batch = self.models["GCODE"].batch)
|
||||
|
||||
def Show(self, arg=True):
|
||||
def Show(self, arg = True):
|
||||
wx.Frame.Show(self, arg)
|
||||
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] + 1))
|
||||
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] - 1))
|
||||
|
@ -975,8 +975,8 @@ class GCFrame(wx.Frame):
|
|||
|
||||
|
||||
def main():
|
||||
app = wx.App(redirect=False)
|
||||
frame = GCFrame(None, wx.ID_ANY, 'Gcode view, shift to move view, mousewheel to set layer', size=(400, 400))
|
||||
app = wx.App(redirect = False)
|
||||
frame = GCFrame(None, wx.ID_ANY, 'Gcode view, shift to move view, mousewheel to set layer', size = (400, 400))
|
||||
import sys
|
||||
for filename in sys.argv:
|
||||
if ".gcode" in filename:
|
||||
|
@ -985,8 +985,8 @@ def main():
|
|||
#TODO: add stl here
|
||||
pass
|
||||
|
||||
#frame = wx.Frame(None, -1, "GL Window", size=(400, 400))
|
||||
#panel = TestGlPanel(frame, size=(300,300))
|
||||
#frame = wx.Frame(None, -1, "GL Window", size = (400, 400))
|
||||
#panel = TestGlPanel(frame, size = (300, 300))
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
||||
app.Destroy()
|
||||
|
|
|
@ -22,8 +22,8 @@ from bufferedcanvas import *
|
|||
class Graph(BufferedCanvas):
|
||||
'''A class to show a Graph with Pronterface.'''
|
||||
|
||||
def __init__(self, parent, id, pos=wx.DefaultPosition,
|
||||
size=wx.DefaultSize, style=0):
|
||||
def __init__(self, parent, id, pos = wx.DefaultPosition,
|
||||
size = wx.DefaultSize, style = 0):
|
||||
# Forcing a no full repaint to stop flickering
|
||||
style = style | wx.NO_FULL_REPAINT_ON_RESIZE
|
||||
#call super function
|
||||
|
@ -53,7 +53,7 @@ class Graph(BufferedCanvas):
|
|||
|
||||
|
||||
#self.sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
#self.sizer.Add(wx.Button(self, -1, "Button1", (0,0)))
|
||||
#self.sizer.Add(wx.Button(self, -1, "Button1", (0, 0)))
|
||||
#self.SetSizer(self.sizer)
|
||||
|
||||
|
||||
|
@ -78,23 +78,23 @@ class Graph(BufferedCanvas):
|
|||
|
||||
|
||||
def drawgrid(self, dc, gc):
|
||||
#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)
|
||||
#col2 = wx.Colour(255,255,255, 128)
|
||||
#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)
|
||||
#col2 = wx.Colour(255, 255, 255, 128)
|
||||
|
||||
#b = gc.CreateLinearGradientBrush(0, 0, w, h, col1, col2)
|
||||
|
||||
gc.SetPen(wx.Pen(wx.Colour(255,0,0,0), 4))
|
||||
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(245,245,255,252))))
|
||||
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(b)
|
||||
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.SetPen(wx.Pen(wx.Colour(255,0,0,0), 4))
|
||||
#gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0,0, 255))))
|
||||
#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))
|
||||
|
||||
#path = gc.CreatePath()
|
||||
#path.MoveToPoint(0.0, 0.0)
|
||||
|
@ -107,34 +107,34 @@ class Graph(BufferedCanvas):
|
|||
|
||||
|
||||
font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)
|
||||
gc.SetFont(font, wx.Colour(23,44,44))
|
||||
gc.SetFont(font, wx.Colour(23, 44, 44))
|
||||
|
||||
dc.SetPen(wx.Pen(wx.Colour(225,225,225), 1))
|
||||
dc.SetPen(wx.Pen(wx.Colour(225, 225, 225), 1))
|
||||
for x in range(self.xbars):
|
||||
dc.DrawLine(x*(float(self.width)/self.xbars), 0, x*(float(self.width)/self.xbars), self.height)
|
||||
|
||||
dc.SetPen(wx.Pen(wx.Colour(225,225,225), 1))
|
||||
dc.SetPen(wx.Pen(wx.Colour(225, 225, 225), 1))
|
||||
for y in range(self.ybars):
|
||||
y_pos = y*(float(self.height)/self.ybars)
|
||||
dc.DrawLine(0,y_pos, self.width,y_pos)
|
||||
dc.DrawLine(0, y_pos, self.width, y_pos)
|
||||
gc.DrawText(unicode(int(self.maxyvalue - (y * (self.maxyvalue/self.ybars)))), 1, y_pos - (font.GetPointSize() / 2))
|
||||
|
||||
if self.timer.IsRunning() == False:
|
||||
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))
|
||||
|
||||
#dc.DrawCircle(50,50, 1)
|
||||
#dc.DrawCircle(50, 50, 1)
|
||||
|
||||
#gc.SetPen(wx.Pen(wx.Colour(255,0,0,0), 1))
|
||||
#gc.DrawLines([[20,30], [10,53]])
|
||||
#dc.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]])
|
||||
#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):
|
||||
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:
|
||||
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_pos = float(0.0)
|
||||
|
@ -143,7 +143,7 @@ class Graph(BufferedCanvas):
|
|||
for temperature in (temperature_list):
|
||||
y_pos = int((float(self.height-self.y_offset)/self.maxyvalue)*temperature) + self.y_offset
|
||||
if (x_pos > 0.0): # One need 2 points to draw a line.
|
||||
dc.DrawLine(lastxvalue,self.height-self._lastyvalue, x_pos, self.height-y_pos)
|
||||
dc.DrawLine(lastxvalue, self.height-self._lastyvalue, x_pos, self.height-y_pos)
|
||||
|
||||
lastxvalue = x_pos
|
||||
x_pos = float(x_pos) + x_add
|
||||
|
@ -153,9 +153,9 @@ class Graph(BufferedCanvas):
|
|||
font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD)
|
||||
#font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
|
||||
if self.timer.IsRunning() == False:
|
||||
gc.SetFont(font, wx.Colour(128,128,128))
|
||||
gc.SetFont(font, wx.Colour(128, 128, 128))
|
||||
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, 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):
|
|||
|
||||
|
||||
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):
|
||||
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):
|
||||
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):
|
||||
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):
|
||||
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):
|
||||
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):
|
||||
|
|
244
printrun/gviz.py
244
printrun/gviz.py
|
@ -12,45 +12,45 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
|
||||
import wx,time
|
||||
import wx, time
|
||||
|
||||
from printrun_utils import imagefile
|
||||
|
||||
ID_ABOUT = 101
|
||||
ID_EXIT = 110
|
||||
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):
|
||||
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)
|
||||
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]))
|
||||
self.p = gviz(self, size = size, build_dimensions = build_dimensions, grid = grid, extrusion_width = extrusion_width)
|
||||
|
||||
vbox = wx.BoxSizer(wx.VERTICAL)
|
||||
toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
|
||||
toolbar = wx.ToolBar(self, -1, style = wx.TB_HORIZONTAL | wx.NO_BORDER)
|
||||
toolbar.AddSimpleTool(1, wx.Image(imagefile('zoom_in.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Zoom In [+]', '')
|
||||
toolbar.AddSimpleTool(2, wx.Image(imagefile('zoom_out.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Zoom Out [-]', '')
|
||||
toolbar.AddSeparator()
|
||||
toolbar.AddSimpleTool(3, wx.Image(imagefile('arrow_up.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Move Up a Layer [U]', '')
|
||||
toolbar.AddSimpleTool(4, wx.Image(imagefile('arrow_down.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Move Down a Layer [D]', '')
|
||||
toolbar.AddSimpleTool(5, wx.EmptyBitmap(16,16), 'Reset view', '')
|
||||
toolbar.AddSimpleTool(5, wx.EmptyBitmap(16, 16), 'Reset view', '')
|
||||
toolbar.AddSeparator()
|
||||
#toolbar.AddSimpleTool(5, wx.Image('./images/inject.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'Insert Code at start of this layer', '')
|
||||
toolbar.Realize()
|
||||
vbox.Add(toolbar, 0, border=5)
|
||||
vbox.Add(toolbar, 0, border = 5)
|
||||
self.SetSizer(vbox)
|
||||
self.Bind(wx.EVT_TOOL, lambda x:self.p.zoom(200,200,1.2), id=1)
|
||||
self.Bind(wx.EVT_TOOL, lambda x:self.p.zoom(200,200,1/1.2), id=2)
|
||||
self.Bind(wx.EVT_TOOL, lambda x:self.p.layerup(), id=3)
|
||||
self.Bind(wx.EVT_TOOL, lambda x:self.p.layerdown(), id=4)
|
||||
self.Bind(wx.EVT_TOOL, self.resetview, id=5)
|
||||
#self.Bind(wx.EVT_TOOL, lambda x:self.p.inject(), id=5)
|
||||
self.Bind(wx.EVT_TOOL, lambda x:self.p.zoom(200, 200, 1.2), id = 1)
|
||||
self.Bind(wx.EVT_TOOL, lambda x:self.p.zoom(200, 200, 1/1.2), id = 2)
|
||||
self.Bind(wx.EVT_TOOL, lambda x:self.p.layerup(), id = 3)
|
||||
self.Bind(wx.EVT_TOOL, lambda x:self.p.layerdown(), id = 4)
|
||||
self.Bind(wx.EVT_TOOL, self.resetview, id = 5)
|
||||
#self.Bind(wx.EVT_TOOL, lambda x:self.p.inject(), id = 5)
|
||||
|
||||
|
||||
self.CreateStatusBar(1);
|
||||
self.SetStatusText("Layer number and Z position show here when you scroll");
|
||||
#self.bu=wx.Button(self.p,-1,"U",pos=(0,100),size=(40,140))
|
||||
#self.bd=wx.Button(self.p,-1,"D",pos=(0,140),size=(40,140))
|
||||
#self.bi=wx.Button(self.p,-1,"+",pos=(40,100),size=(40,140))
|
||||
#self.bo=wx.Button(self.p,-1,"-",pos=(40,140),size=(40,140))
|
||||
#self.bs=wx.Button(self.p, -1, "Inject", pos=(85, 103), size=(50, 20))
|
||||
#self.bu = wx.Button(self.p,-1,"U",pos = (0, 100),size = (40, 140))
|
||||
#self.bd = wx.Button(self.p,-1,"D",pos = (0, 140),size = (40, 140))
|
||||
#self.bi = wx.Button(self.p,-1,"+",pos = (40, 100),size = (40, 140))
|
||||
#self.bo = wx.Button(self.p,-1,"-",pos = (40, 140),size = (40, 140))
|
||||
#self.bs = wx.Button(self.p, -1, "Inject", pos = (85, 103), size = (50, 20))
|
||||
|
||||
#self.bu.SetToolTip(wx.ToolTip("Move up one layer"))
|
||||
#self.bd.SetToolTip(wx.ToolTip("Move down one layer"))
|
||||
|
@ -58,41 +58,41 @@ class window(wx.Frame):
|
|||
#self.bo.SetToolTip(wx.ToolTip("Zoom view out"))
|
||||
#self.bs.SetToolTip(wx.ToolTip("Insert Code at start of this layer"))
|
||||
|
||||
#self.bu.Bind(wx.EVT_BUTTON,lambda x:self.p.layerup())
|
||||
#self.bd.Bind(wx.EVT_BUTTON,lambda x:self.p.layerdown())
|
||||
#self.bi.Bind(wx.EVT_BUTTON,lambda x:self.p.zoom(200,200,1.2))
|
||||
#self.bo.Bind(wx.EVT_BUTTON,lambda x:self.p.zoom(200,200,1/1.2))
|
||||
#self.bs.Bind(wx.EVT_BUTTON,lambda x:self.p.inject())
|
||||
#self.bu.Bind(wx.EVT_BUTTON, lambda x:self.p.layerup())
|
||||
#self.bd.Bind(wx.EVT_BUTTON, lambda x:self.p.layerdown())
|
||||
#self.bi.Bind(wx.EVT_BUTTON, lambda x:self.p.zoom(200, 200, 1.2))
|
||||
#self.bo.Bind(wx.EVT_BUTTON, lambda x:self.p.zoom(200, 200, 1/1.2))
|
||||
#self.bs.Bind(wx.EVT_BUTTON, lambda x:self.p.inject())
|
||||
|
||||
s=time.time()
|
||||
s = time.time()
|
||||
#print time.time()-s
|
||||
self.initpos=[0,0]
|
||||
self.p.Bind(wx.EVT_KEY_DOWN,self.key)
|
||||
#self.bu.Bind(wx.EVT_KEY_DOWN,self.key)
|
||||
#self.bd.Bind(wx.EVT_KEY_DOWN,self.key)
|
||||
#self.bi.Bind(wx.EVT_KEY_DOWN,self.key)
|
||||
#self.bo.Bind(wx.EVT_KEY_DOWN,self.key)
|
||||
self.Bind(wx.EVT_KEY_DOWN,self.key)
|
||||
self.p.Bind(wx.EVT_MOUSEWHEEL,self.zoom)
|
||||
self.Bind(wx.EVT_MOUSEWHEEL,self.zoom)
|
||||
self.p.Bind(wx.EVT_MOUSE_EVENTS,self.mouse)
|
||||
self.Bind(wx.EVT_MOUSE_EVENTS,self.mouse)
|
||||
self.initpos=[0, 0]
|
||||
self.p.Bind(wx.EVT_KEY_DOWN, self.key)
|
||||
#self.bu.Bind(wx.EVT_KEY_DOWN, self.key)
|
||||
#self.bd.Bind(wx.EVT_KEY_DOWN, self.key)
|
||||
#self.bi.Bind(wx.EVT_KEY_DOWN, self.key)
|
||||
#self.bo.Bind(wx.EVT_KEY_DOWN, self.key)
|
||||
self.Bind(wx.EVT_KEY_DOWN, self.key)
|
||||
self.p.Bind(wx.EVT_MOUSEWHEEL, self.zoom)
|
||||
self.Bind(wx.EVT_MOUSEWHEEL, self.zoom)
|
||||
self.p.Bind(wx.EVT_MOUSE_EVENTS, self.mouse)
|
||||
self.Bind(wx.EVT_MOUSE_EVENTS, self.mouse)
|
||||
|
||||
def resetview(self,event):
|
||||
self.p.translate=[0.0,0.0]
|
||||
self.p.scale=self.p.basescale
|
||||
self.p.zoom(0,0,1.0)
|
||||
def resetview(self, event):
|
||||
self.p.translate=[0.0, 0.0]
|
||||
self.p.scale = self.p.basescale
|
||||
self.p.zoom(0, 0,1.0)
|
||||
|
||||
def mouse(self,event):
|
||||
def mouse(self, event):
|
||||
if event.ButtonUp(wx.MOUSE_BTN_LEFT):
|
||||
if(self.initpos is not None):
|
||||
self.initpos=None
|
||||
self.initpos = None
|
||||
elif event.Dragging():
|
||||
e=event.GetPositionTuple()
|
||||
e = event.GetPositionTuple()
|
||||
if self.initpos is None or not hasattr(self,"basetrans"):
|
||||
self.initpos=e
|
||||
self.basetrans=self.p.translate
|
||||
#print self.p.translate,e,self.initpos
|
||||
self.initpos = e
|
||||
self.basetrans = self.p.translate
|
||||
#print self.p.translate, e,self.initpos
|
||||
self.p.translate = [ self.basetrans[0]+(e[0]-self.initpos[0]),
|
||||
self.basetrans[1]+(e[1]-self.initpos[1]) ]
|
||||
self.p.repaint()
|
||||
|
@ -107,31 +107,31 @@ class window(wx.Frame):
|
|||
kdo=[68, 317] # Down Keys
|
||||
kzi=[388, 316, 61] # Zoom In Keys
|
||||
kzo=[390, 314, 45] # Zoom Out Keys
|
||||
x=event.GetKeyCode()
|
||||
x = event.GetKeyCode()
|
||||
#print "Key event - "+str(x)
|
||||
#if event.ShiftDown():
|
||||
cx,cy=self.p.translate
|
||||
# if x==wx.WXK_UP:
|
||||
# self.p.zoom(cx,cy,1.2)
|
||||
# if x==wx.WXK_DOWN:
|
||||
# self.p.zoom(cx,cy,1/1.2)
|
||||
cx, cy = self.p.translate
|
||||
# if x == wx.WXK_UP:
|
||||
# self.p.zoom(cx, cy, 1.2)
|
||||
# if x == wx.WXK_DOWN:
|
||||
# self.p.zoom(cx, cy, 1/1.2)
|
||||
#else:
|
||||
# if x==wx.WXK_UP:
|
||||
# if x == wx.WXK_UP:
|
||||
# self.p.layerup()
|
||||
# if x==wx.WXK_DOWN:
|
||||
# if x == wx.WXK_DOWN:
|
||||
# self.p.layerdown()
|
||||
if x in kup:
|
||||
self.p.layerup()
|
||||
if x in kdo:
|
||||
self.p.layerdown()
|
||||
if x in kzi:
|
||||
self.p.zoom(cx,cy,1.2)
|
||||
self.p.zoom(cx, cy, 1.2)
|
||||
if x in kzo:
|
||||
self.p.zoom(cx, cy, 1/1.2)
|
||||
|
||||
#print p.lines.keys()
|
||||
def zoom(self, event):
|
||||
z=event.GetWheelRotation()
|
||||
z = event.GetWheelRotation()
|
||||
if event.ShiftDown():
|
||||
if z > 0: self.p.layerdown()
|
||||
elif z < 0: self.p.layerup()
|
||||
|
@ -140,38 +140,38 @@ class window(wx.Frame):
|
|||
elif z < 0: self.p.zoom(event.GetX(),event.GetY(),1/1.2)
|
||||
|
||||
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):
|
||||
wx.Panel.__init__(self,parent,-1,size=(size[0],size[1]))
|
||||
self.parent=parent
|
||||
self.size=size
|
||||
self.build_dimensions=build_dimensions
|
||||
self.grid=grid
|
||||
self.lastpos=[0,0,0,0,0,0,0]
|
||||
self.hilightpos=self.lastpos[:]
|
||||
self.Bind(wx.EVT_PAINT,self.paint)
|
||||
self.Bind(wx.EVT_SIZE,self.resize)
|
||||
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]))
|
||||
self.parent = parent
|
||||
self.size = size
|
||||
self.build_dimensions = build_dimensions
|
||||
self.grid = grid
|
||||
self.lastpos=[0, 0,0, 0,0, 0,0]
|
||||
self.hilightpos = self.lastpos[:]
|
||||
self.Bind(wx.EVT_PAINT, self.paint)
|
||||
self.Bind(wx.EVT_SIZE, self.resize)
|
||||
self.lines={}
|
||||
self.pens={}
|
||||
self.arcs={}
|
||||
self.arcpens={}
|
||||
self.layers=[]
|
||||
self.layerindex=0
|
||||
self.filament_width=extrusion_width # set it to 0 to disable scaling lines with zoom
|
||||
self.layerindex = 0
|
||||
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.scale=self.basescale
|
||||
penwidth = max(1.0,self.filament_width*((self.scale[0]+self.scale[1])/2.0))
|
||||
self.translate=[0.0,0.0]
|
||||
self.mainpen=wx.Pen(wx.Colour(0,0,0),penwidth)
|
||||
self.arcpen=wx.Pen(wx.Colour(255,0,0),penwidth)
|
||||
self.travelpen=wx.Pen(wx.Colour(10,80,80),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.penslist=[self.mainpen,self.travelpen,self.hlpen]+self.fades
|
||||
self.showall=0
|
||||
self.scale = self.basescale
|
||||
penwidth = max(1.0, self.filament_width*((self.scale[0]+self.scale[1])/2.0))
|
||||
self.translate=[0.0, 0.0]
|
||||
self.mainpen = wx.Pen(wx.Colour(0, 0,0),penwidth)
|
||||
self.arcpen = wx.Pen(wx.Colour(255, 0,0),penwidth)
|
||||
self.travelpen = wx.Pen(wx.Colour(10, 80, 80),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.penslist=[self.mainpen, self.travelpen, self.hlpen]+self.fades
|
||||
self.showall = 0
|
||||
self.hilight=[]
|
||||
self.hilightarcs=[]
|
||||
self.dirty=1
|
||||
self.blitmap=wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1)
|
||||
self.dirty = 1
|
||||
self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1)
|
||||
|
||||
def inject(self):
|
||||
#import pdb; pdb.set_trace()
|
||||
|
@ -179,7 +179,7 @@ class gviz(wx.Panel):
|
|||
print "Layer "+str(self.layerindex +1)+" - Z = "+str(self.layers[self.layerindex])+" mm"
|
||||
|
||||
def clear(self):
|
||||
self.lastpos=[0,0,0,0,0,0,0]
|
||||
self.lastpos=[0, 0,0, 0,0, 0,0]
|
||||
self.lines={}
|
||||
self.pens={}
|
||||
self.arcs={}
|
||||
|
@ -187,9 +187,9 @@ class gviz(wx.Panel):
|
|||
self.layers=[]
|
||||
self.hilight=[]
|
||||
self.hilightarcs=[]
|
||||
self.layerindex=0
|
||||
self.showall=0
|
||||
self.dirty=1
|
||||
self.layerindex = 0
|
||||
self.showall = 0
|
||||
self.dirty = 1
|
||||
#self.repaint()
|
||||
def layerup(self):
|
||||
if(self.layerindex+1<len(self.layers)):
|
||||
|
@ -207,67 +207,67 @@ class gviz(wx.Panel):
|
|||
self.repaint()
|
||||
self.Refresh()
|
||||
|
||||
def setlayer(self,layer):
|
||||
def setlayer(self, layer):
|
||||
try:
|
||||
self.layerindex=self.layers.index(layer)
|
||||
self.layerindex = self.layers.index(layer)
|
||||
self.repaint()
|
||||
wx.CallAfter(self.Refresh)
|
||||
self.showall=0
|
||||
self.showall = 0
|
||||
except:
|
||||
pass
|
||||
|
||||
def resize(self,event):
|
||||
size=self.GetClientSize()
|
||||
newsize=min(float(size[0])/self.size[0],float(size[1])/self.size[1])
|
||||
self.size=self.GetClientSize()
|
||||
wx.CallAfter(self.zoom,0,0,newsize)
|
||||
def resize(self, event):
|
||||
size = self.GetClientSize()
|
||||
newsize = min(float(size[0])/self.size[0],float(size[1])/self.size[1])
|
||||
self.size = self.GetClientSize()
|
||||
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.translate = [ x - (x-self.translate[0]) * factor,
|
||||
y - (y-self.translate[1]) * factor]
|
||||
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))
|
||||
for pen in self.penslist:
|
||||
pen.SetWidth(penwidth)
|
||||
#self.dirty=1
|
||||
#self.dirty = 1
|
||||
self.repaint()
|
||||
self.Refresh()
|
||||
|
||||
|
||||
def repaint(self):
|
||||
self.blitmap=wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1)
|
||||
dc=wx.MemoryDC()
|
||||
self.blitmap = wx.EmptyBitmap(self.GetClientSize()[0],self.GetClientSize()[1],-1)
|
||||
dc = wx.MemoryDC()
|
||||
dc.SelectObject(self.blitmap)
|
||||
dc.SetBackground(wx.Brush((250,250,200)))
|
||||
dc.SetBackground(wx.Brush((250, 250, 200)))
|
||||
dc.Clear()
|
||||
dc.SetPen(wx.Pen(wx.Colour(180,180,150)))
|
||||
dc.SetPen(wx.Pen(wx.Colour(180, 180, 150)))
|
||||
for grid_unit in self.grid:
|
||||
if grid_unit > 0:
|
||||
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):
|
||||
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.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)))
|
||||
if not self.showall:
|
||||
self.size = self.GetSize()
|
||||
dc.SetBrush(wx.Brush((43,144,255)))
|
||||
dc.DrawRectangle(self.size[0]-15,0,15,self.size[1])
|
||||
dc.SetBrush(wx.Brush((0,255,0)))
|
||||
dc.SetBrush(wx.Brush((43, 144, 255)))
|
||||
dc.DrawRectangle(self.size[0]-15, 0,15, self.size[1])
|
||||
dc.SetBrush(wx.Brush((0, 255, 0)))
|
||||
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):
|
||||
return (self.scale[0]*x[0]+self.translate[0],
|
||||
self.scale[1]*x[1]+self.translate[1],
|
||||
self.scale[0]*x[2]+self.translate[0],
|
||||
self.scale[1]*x[3]+self.translate[1],)
|
||||
scaled_lines = map(_scaler,lines)
|
||||
scaled_lines = map(_scaler, lines)
|
||||
dc.DrawLineList(scaled_lines, pens)
|
||||
|
||||
def _drawarcs(arcs,pens):
|
||||
def _drawarcs(arcs, pens):
|
||||
def _scaler(x):
|
||||
return (self.scale[0]*x[0]+self.translate[0],
|
||||
self.scale[1]*x[1]+self.translate[1],
|
||||
|
@ -275,7 +275,7 @@ class gviz(wx.Panel):
|
|||
self.scale[1]*x[3]+self.translate[1],
|
||||
self.scale[0]*x[4]+self.translate[0],
|
||||
self.scale[1]*x[5]+self.translate[1],)
|
||||
scaled_arcs = map(_scaler,arcs)
|
||||
scaled_arcs = map(_scaler, arcs)
|
||||
for i in range(len(scaled_arcs)):
|
||||
dc.SetPen(pens[i] if type(pens).__name__ == 'list' else pens)
|
||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
|
@ -284,12 +284,12 @@ class gviz(wx.Panel):
|
|||
if self.showall:
|
||||
l=[]
|
||||
for i in self.layers:
|
||||
dc.DrawLineList(l,self.fades[0])
|
||||
dc.DrawLineList(l, self.fades[0])
|
||||
_drawlines(self.lines[i], self.pens[i])
|
||||
_drawarcs(self.arcs[i], self.arcpens[i])
|
||||
return
|
||||
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
|
||||
_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])
|
||||
|
@ -301,23 +301,23 @@ class gviz(wx.Panel):
|
|||
|
||||
dc.SelectObject(wx.NullBitmap)
|
||||
|
||||
def paint(self,event):
|
||||
dc=wx.PaintDC(self)
|
||||
def paint(self, event):
|
||||
dc = wx.PaintDC(self)
|
||||
if(self.dirty):
|
||||
self.repaint()
|
||||
self.dirty=0
|
||||
sz=self.GetClientSize()
|
||||
dc.DrawBitmap(self.blitmap,0,0)
|
||||
self.dirty = 0
|
||||
sz = self.GetClientSize()
|
||||
dc.DrawBitmap(self.blitmap, 0,0)
|
||||
del dc
|
||||
|
||||
def addfile(self,gcodes=[]):
|
||||
def addfile(self, gcodes=[]):
|
||||
self.clear()
|
||||
for i in gcodes:
|
||||
self.addgcode(i)
|
||||
|
||||
def addgcode(self,gcode="M105",hilight=0):
|
||||
gcode=gcode.split("*")[0]
|
||||
gcode=gcode.split(";")[0]
|
||||
def addgcode(self, gcode = "M105",hilight = 0):
|
||||
gcode = gcode.split("*")[0]
|
||||
gcode = gcode.split(";")[0]
|
||||
gcode = gcode.lower().strip().split()
|
||||
if len(gcode) == 0:
|
||||
return
|
||||
|
@ -325,11 +325,11 @@ class gviz(wx.Panel):
|
|||
gcode.pop(0)
|
||||
|
||||
def _readgcode():
|
||||
target=self.lastpos[:]
|
||||
target = self.lastpos[:]
|
||||
target[5]=0.0
|
||||
target[6]=0.0
|
||||
if hilight:
|
||||
target=self.hilightpos[:]
|
||||
target = self.hilightpos[:]
|
||||
for i in gcode:
|
||||
if i[0]=="x":
|
||||
target[0]=float(i[1:])
|
||||
|
|
|
@ -5,11 +5,11 @@ import gettext
|
|||
# searching for installed locales on /usr/share; uses relative folder if not found (windows)
|
||||
def install_locale(domain):
|
||||
if os.path.exists('/usr/share/pronterface/locale'):
|
||||
gettext.install(domain, '/usr/share/pronterface/locale', unicode=1)
|
||||
gettext.install(domain, '/usr/share/pronterface/locale', unicode = 1)
|
||||
elif os.path.exists('/usr/local/share/pronterface/locale'):
|
||||
gettext.install(domain, '/usr/local/share/pronterface/locale', unicode=1)
|
||||
gettext.install(domain, '/usr/local/share/pronterface/locale', unicode = 1)
|
||||
else:
|
||||
gettext.install(domain, './locale', unicode=1)
|
||||
gettext.install(domain, './locale', unicode = 1)
|
||||
|
||||
def imagefile(filename):
|
||||
for prefix in ['/usr/local/share/pronterface/images', '/usr/share/pronterface/images']:
|
||||
|
|
|
@ -23,8 +23,8 @@ import svg.document as wxpsvgdocument
|
|||
import imghdr
|
||||
|
||||
class dispframe(wx.Frame):
|
||||
def __init__(self, parent, title, res=(800, 600), printer=None):
|
||||
wx.Frame.__init__(self, parent=parent, title=title)
|
||||
def __init__(self, parent, title, res = (800, 600), printer = None):
|
||||
wx.Frame.__init__(self, parent = parent, title = title)
|
||||
self.p = printer
|
||||
self.pic = wx.StaticBitmap(self)
|
||||
self.bitmap = wx.EmptyBitmap(*res)
|
||||
|
@ -101,7 +101,7 @@ class dispframe(wx.Frame):
|
|||
wx.CallAfter(self.ShowFullScreen, 0)
|
||||
wx.CallAfter(self.timer.Stop)
|
||||
|
||||
def present(self, layers, interval=0.5, pause=0.2, thickness=0.4, scale=20, size=(800, 600), offset=(0, 0)):
|
||||
def present(self, layers, interval = 0.5, pause = 0.2, thickness = 0.4, scale = 20, size = (800, 600), offset = (0, 0)):
|
||||
wx.CallAfter(self.pic.Hide)
|
||||
wx.CallAfter(self.Refresh)
|
||||
self.layers = layers
|
||||
|
@ -118,47 +118,47 @@ class dispframe(wx.Frame):
|
|||
|
||||
class setframe(wx.Frame):
|
||||
|
||||
def __init__(self, parent, printer=None):
|
||||
wx.Frame.__init__(self, parent, title="Projector setup")
|
||||
self.f = dispframe(None, "", printer=printer)
|
||||
def __init__(self, parent, printer = None):
|
||||
wx.Frame.__init__(self, parent, title = "Projector setup")
|
||||
self.f = dispframe(None, "", printer = printer)
|
||||
self.panel = wx.Panel(self)
|
||||
self.panel.SetBackgroundColour("orange")
|
||||
self.bload = wx.Button(self.panel, -1, "Load", pos=(0, 0))
|
||||
self.bload = wx.Button(self.panel, -1, "Load", pos = (0, 0))
|
||||
self.bload.Bind(wx.EVT_BUTTON, self.loadfile)
|
||||
|
||||
wx.StaticText(self.panel, -1, "Layer:", pos=(0, 30))
|
||||
wx.StaticText(self.panel, -1, "mm", pos=(130, 30))
|
||||
self.thickness = wx.TextCtrl(self.panel, -1, "0.5", pos=(50, 30))
|
||||
wx.StaticText(self.panel, -1, "Layer:", pos = (0, 30))
|
||||
wx.StaticText(self.panel, -1, "mm", pos = (130, 30))
|
||||
self.thickness = wx.TextCtrl(self.panel, -1, "0.5", pos = (50, 30))
|
||||
|
||||
wx.StaticText(self.panel, -1, "Exposure:", pos=(0, 60))
|
||||
wx.StaticText(self.panel, -1, "s", pos=(130, 60))
|
||||
self.interval = wx.TextCtrl(self.panel, -1, "0.5", pos=(50, 60))
|
||||
wx.StaticText(self.panel, -1, "Exposure:", pos = (0, 60))
|
||||
wx.StaticText(self.panel, -1, "s", pos = (130, 60))
|
||||
self.interval = wx.TextCtrl(self.panel, -1, "0.5", pos = (50, 60))
|
||||
|
||||
wx.StaticText(self.panel, -1, "Blank:", pos=(0, 90))
|
||||
wx.StaticText(self.panel, -1, "s", pos=(130, 90))
|
||||
self.delay = wx.TextCtrl(self.panel, -1, "0.5", pos=(50, 90))
|
||||
wx.StaticText(self.panel, -1, "Blank:", pos = (0, 90))
|
||||
wx.StaticText(self.panel, -1, "s", pos = (130, 90))
|
||||
self.delay = wx.TextCtrl(self.panel, -1, "0.5", pos = (50, 90))
|
||||
|
||||
wx.StaticText(self.panel, -1, "Scale:", pos=(0, 120))
|
||||
wx.StaticText(self.panel, -1, "x", pos=(130, 120))
|
||||
self.scale = wx.TextCtrl(self.panel, -1, "5", pos=(50, 120))
|
||||
wx.StaticText(self.panel, -1, "Scale:", pos = (0, 120))
|
||||
wx.StaticText(self.panel, -1, "x", pos = (130, 120))
|
||||
self.scale = wx.TextCtrl(self.panel, -1, "5", pos = (50, 120))
|
||||
|
||||
wx.StaticText(self.panel, -1, "X:", pos=(160, 30))
|
||||
self.X = wx.TextCtrl(self.panel, -1, "1024", pos=(210, 30))
|
||||
wx.StaticText(self.panel, -1, "X:", pos = (160, 30))
|
||||
self.X = wx.TextCtrl(self.panel, -1, "1024", pos = (210, 30))
|
||||
|
||||
wx.StaticText(self.panel, -1, "Y:", pos=(160, 60))
|
||||
self.Y = wx.TextCtrl(self.panel, -1, "768", pos=(210, 60))
|
||||
wx.StaticText(self.panel, -1, "Y:", pos = (160, 60))
|
||||
self.Y = wx.TextCtrl(self.panel, -1, "768", pos = (210, 60))
|
||||
|
||||
wx.StaticText(self.panel, -1, "OffsetX:", pos=(160, 90))
|
||||
self.offsetX = wx.TextCtrl(self.panel, -1, "50", pos=(210, 90))
|
||||
wx.StaticText(self.panel, -1, "OffsetX:", pos = (160, 90))
|
||||
self.offsetX = wx.TextCtrl(self.panel, -1, "50", pos = (210, 90))
|
||||
|
||||
wx.StaticText(self.panel, -1, "OffsetY:", pos=(160, 120))
|
||||
self.offsetY = wx.TextCtrl(self.panel, -1, "50", pos=(210, 120))
|
||||
wx.StaticText(self.panel, -1, "OffsetY:", pos = (160, 120))
|
||||
self.offsetY = wx.TextCtrl(self.panel, -1, "50", pos = (210, 120))
|
||||
|
||||
self.bload = wx.Button(self.panel, -1, "Present", pos=(0, 150))
|
||||
self.bload = wx.Button(self.panel, -1, "Present", pos = (0, 150))
|
||||
self.bload.Bind(wx.EVT_BUTTON, self.startdisplay)
|
||||
|
||||
wx.StaticText(self.panel, -1, "Fullscreen:", pos=(160, 150))
|
||||
self.fullscreen = wx.CheckBox(self.panel, -1, pos=(220, 150))
|
||||
wx.StaticText(self.panel, -1, "Fullscreen:", pos = (160, 150))
|
||||
self.fullscreen = wx.CheckBox(self.panel, -1, pos = (220, 150))
|
||||
self.fullscreen.SetValue(True)
|
||||
|
||||
self.Show()
|
||||
|
@ -168,7 +168,7 @@ class setframe(wx.Frame):
|
|||
shutil.rmtree(self.image_dir)
|
||||
|
||||
def parsesvg(self, name):
|
||||
et = xml.etree.ElementTree.ElementTree(file=name)
|
||||
et = xml.etree.ElementTree.ElementTree(file = name)
|
||||
#xml.etree.ElementTree.dump(et)
|
||||
slicer = 'Slic3r' if et.getroot().find('{http://www.w3.org/2000/svg}metadata') == None else 'Skeinforge'
|
||||
zlast = 0
|
||||
|
@ -214,7 +214,7 @@ class setframe(wx.Frame):
|
|||
return ol, -1, "bitmap"
|
||||
|
||||
def loadfile(self, event):
|
||||
dlg = wx.FileDialog(self, ("Open file to print"), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||
dlg = wx.FileDialog(self, ("Open file to print"), style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||
dlg.SetWildcard(("Slic3r or Skeinforge svg files (;*.svg;*.SVG;);3DLP Zip (;*.3dlp.zip;)"))
|
||||
if(dlg.ShowModal() == wx.ID_OK):
|
||||
name = dlg.GetPath()
|
||||
|
@ -240,12 +240,12 @@ class setframe(wx.Frame):
|
|||
self.f.ShowFullScreen(1)
|
||||
l = self.layers[0][:]
|
||||
self.f.present(l,
|
||||
thickness=float(self.thickness.GetValue()),
|
||||
interval=float(self.interval.GetValue()),
|
||||
scale=float(self.scale.GetValue()),
|
||||
pause=float(self.delay.GetValue()),
|
||||
size=(float(self.X.GetValue()), float(self.Y.GetValue())),
|
||||
offset=(float(self.offsetX.GetValue()), float(self.offsetY.GetValue())))
|
||||
thickness = float(self.thickness.GetValue()),
|
||||
interval = float(self.interval.GetValue()),
|
||||
scale = float(self.scale.GetValue()),
|
||||
pause = float(self.delay.GetValue()),
|
||||
size = (float(self.X.GetValue()), float(self.Y.GetValue())),
|
||||
offset = (float(self.offsetX.GetValue()), float(self.offsetY.GetValue())))
|
||||
|
||||
if __name__ == "__main__":
|
||||
a = wx.App()
|
||||
|
|
|
@ -18,49 +18,49 @@ import wx
|
|||
class macroed(wx.Dialog):
|
||||
"""Really simple editor to edit macro definitions"""
|
||||
|
||||
def __init__(self,macro_name,definition,callback,gcode=False):
|
||||
def __init__(self, macro_name, definition, callback, gcode = False):
|
||||
self.indent_chars = " "
|
||||
title=" macro %s"
|
||||
title = " macro %s"
|
||||
if gcode:
|
||||
title=" %s"
|
||||
self.gcode=gcode
|
||||
wx.Dialog.__init__(self,None,title=title % macro_name,style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
|
||||
title = " %s"
|
||||
self.gcode = gcode
|
||||
wx.Dialog.__init__(self, None, title = title % macro_name, style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
|
||||
self.callback = callback
|
||||
self.panel=wx.Panel(self,-1)
|
||||
titlesizer=wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.panel = wx.Panel(self,-1)
|
||||
titlesizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
titletext = wx.StaticText(self.panel,-1," _") #title%macro_name)
|
||||
#title.SetFont(wx.Font(11,wx.NORMAL,wx.NORMAL,wx.BOLD))
|
||||
titlesizer.Add(titletext,1)
|
||||
self.findb = wx.Button(self.panel, -1, _("Find"),style=wx.BU_EXACTFIT) #New button for "Find" (Jezmy)
|
||||
#title.SetFont(wx.Font(11, wx.NORMAL, wx.NORMAL, wx.BOLD))
|
||||
titlesizer.Add(titletext, 1)
|
||||
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.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.Bind(wx.EVT_CLOSE, self.close)
|
||||
titlesizer.Add(self.findb)
|
||||
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)
|
||||
titlesizer.Add(self.cancelb)
|
||||
topsizer=wx.BoxSizer(wx.VERTICAL)
|
||||
topsizer.Add(titlesizer,0,wx.EXPAND)
|
||||
self.e=wx.TextCtrl(self.panel,style=wx.TE_MULTILINE+wx.HSCROLL,size=(400,400))
|
||||
topsizer = wx.BoxSizer(wx.VERTICAL)
|
||||
topsizer.Add(titlesizer, 0,wx.EXPAND)
|
||||
self.e = wx.TextCtrl(self.panel, style = wx.TE_MULTILINE+wx.HSCROLL, size = (400, 400))
|
||||
if not self.gcode:
|
||||
self.e.SetValue(self.unindent(definition))
|
||||
else:
|
||||
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)
|
||||
topsizer.Layout()
|
||||
topsizer.Fit(self)
|
||||
self.Show()
|
||||
self.e.SetFocus()
|
||||
|
||||
def find(self,ev):
|
||||
def find(self, ev):
|
||||
# Ask user what to look for, find it and point at it ... (Jezmy)
|
||||
S = self.e.GetStringSelection()
|
||||
if not S :
|
||||
S = "Z"
|
||||
FindValue = wx.GetTextFromUser('Please enter a search string:', caption="Search", default_value=S, parent=None)
|
||||
FindValue = wx.GetTextFromUser('Please enter a search string:', caption = "Search", default_value = S, parent = None)
|
||||
somecode = self.e.GetValue()
|
||||
numLines = len(somecode)
|
||||
position = somecode.find(FindValue, self.e.GetInsertionPoint())
|
||||
|
@ -70,7 +70,7 @@ class macroed(wx.Dialog):
|
|||
else:
|
||||
# self.title.SetValue("Position : "+str(position))
|
||||
|
||||
titletext = wx.TextCtrl(self.panel,-1,str(position))
|
||||
titletext = wx.TextCtrl(self.panel,-1, str(position))
|
||||
|
||||
# ananswer = wx.MessageBox(str(numLines)+" Lines detected in file\n"+str(position), "OK")
|
||||
self.e.SetFocus()
|
||||
|
@ -84,20 +84,20 @@ class macroed(wx.Dialog):
|
|||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
def save(self,ev):
|
||||
def save(self, ev):
|
||||
self.Destroy()
|
||||
if not self.gcode:
|
||||
self.callback(self.reindent(self.e.GetValue()))
|
||||
else:
|
||||
self.callback(self.e.GetValue().split("\n"))
|
||||
def close(self,ev):
|
||||
def close(self, ev):
|
||||
self.Destroy()
|
||||
if self.webInterface:
|
||||
webinterface.KillWebInterfaceThread()
|
||||
def unindent(self,text):
|
||||
def unindent(self, text):
|
||||
self.indent_chars = text[:len(text)-len(text.lstrip())]
|
||||
if len(self.indent_chars)==0:
|
||||
self.indent_chars=" "
|
||||
if len(self.indent_chars) == 0:
|
||||
self.indent_chars = " "
|
||||
unindented = ""
|
||||
lines = re.split(r"(?:\r\n?|\n)",text)
|
||||
#print lines
|
||||
|
@ -109,7 +109,7 @@ class macroed(wx.Dialog):
|
|||
else:
|
||||
unindented += line + "\n"
|
||||
return unindented
|
||||
def reindent(self,text):
|
||||
def reindent(self, text):
|
||||
lines = re.split(r"(?:\r\n?|\n)",text)
|
||||
if len(lines) <= 1:
|
||||
return text
|
||||
|
@ -121,64 +121,64 @@ class macroed(wx.Dialog):
|
|||
|
||||
class options(wx.Dialog):
|
||||
"""Options editor"""
|
||||
def __init__(self,pronterface):
|
||||
wx.Dialog.__init__(self, None, title=_("Edit settings"), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
|
||||
topsizer=wx.BoxSizer(wx.VERTICAL)
|
||||
vbox=wx.StaticBoxSizer(wx.StaticBox(self, label=_("Defaults")) ,wx.VERTICAL)
|
||||
topsizer.Add(vbox,1,wx.ALL+wx.EXPAND)
|
||||
grid=wx.FlexGridSizer(rows=0,cols=2,hgap=8,vgap=2)
|
||||
def __init__(self, pronterface):
|
||||
wx.Dialog.__init__(self, None, title = _("Edit settings"), style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
|
||||
topsizer = wx.BoxSizer(wx.VERTICAL)
|
||||
vbox = wx.StaticBoxSizer(wx.StaticBox(self, label = _("Defaults")) ,wx.VERTICAL)
|
||||
topsizer.Add(vbox, 1,wx.ALL+wx.EXPAND)
|
||||
grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 8, vgap = 2)
|
||||
grid.SetFlexibleDirection( wx.BOTH )
|
||||
grid.AddGrowableCol( 1 )
|
||||
grid.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
|
||||
vbox.Add(grid,0,wx.EXPAND)
|
||||
vbox.Add(grid, 0,wx.EXPAND)
|
||||
ctrls = {}
|
||||
for k,v in sorted(pronterface.settings._all_settings().items()):
|
||||
ctrls[k,0] = wx.StaticText(self,-1,k)
|
||||
ctrls[k,1] = wx.TextCtrl(self,-1,str(v))
|
||||
for k, v in sorted(pronterface.settings._all_settings().items()):
|
||||
ctrls[k, 0] = wx.StaticText(self,-1, k)
|
||||
ctrls[k, 1] = wx.TextCtrl(self,-1, str(v))
|
||||
if k in pronterface.helpdict:
|
||||
ctrls[k,0].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,1],1,wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND)
|
||||
topsizer.Add(self.CreateSeparatedButtonSizer(wx.OK+wx.CANCEL),0,wx.EXPAND)
|
||||
ctrls[k, 0].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, 1],1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND)
|
||||
topsizer.Add(self.CreateSeparatedButtonSizer(wx.OK+wx.CANCEL),0, wx.EXPAND)
|
||||
self.SetSizer(topsizer)
|
||||
topsizer.Layout()
|
||||
topsizer.Fit(self)
|
||||
if self.ShowModal()==wx.ID_OK:
|
||||
for k,v in pronterface.settings._all_settings().items():
|
||||
if ctrls[k,1].GetValue() != str(v):
|
||||
pronterface.set(k,str(ctrls[k,1].GetValue()))
|
||||
if self.ShowModal() == wx.ID_OK:
|
||||
for k, v in pronterface.settings._all_settings().items():
|
||||
if ctrls[k, 1].GetValue() != str(v):
|
||||
pronterface.set(k, str(ctrls[k, 1].GetValue()))
|
||||
self.Destroy()
|
||||
|
||||
class ButtonEdit(wx.Dialog):
|
||||
"""Custom button edit dialog"""
|
||||
def __init__(self,pronterface):
|
||||
wx.Dialog.__init__(self, None, title=_("Custom button"),style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
|
||||
self.pronterface=pronterface
|
||||
topsizer=wx.BoxSizer(wx.VERTICAL)
|
||||
grid=wx.FlexGridSizer(rows=0,cols=2,hgap=4,vgap=2)
|
||||
grid.AddGrowableCol(1,1)
|
||||
def __init__(self, pronterface):
|
||||
wx.Dialog.__init__(self, None, title = _("Custom button"),style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
|
||||
self.pronterface = pronterface
|
||||
topsizer = wx.BoxSizer(wx.VERTICAL)
|
||||
grid = wx.FlexGridSizer(rows = 0, cols = 2, hgap = 4, vgap = 2)
|
||||
grid.AddGrowableCol(1, 1)
|
||||
grid.Add(wx.StaticText(self,-1, _("Button title")), 0, wx.BOTTOM|wx.RIGHT)
|
||||
self.name=wx.TextCtrl(self,-1,"")
|
||||
grid.Add(self.name,1,wx.EXPAND)
|
||||
self.name = wx.TextCtrl(self,-1,"")
|
||||
grid.Add(self.name, 1,wx.EXPAND)
|
||||
grid.Add(wx.StaticText(self, -1, _("Command")), 0, wx.BOTTOM|wx.RIGHT)
|
||||
self.command=wx.TextCtrl(self,-1,"")
|
||||
xbox=wx.BoxSizer(wx.HORIZONTAL)
|
||||
xbox.Add(self.command,1,wx.EXPAND)
|
||||
self.command.Bind(wx.EVT_TEXT,self.macrob_enabler)
|
||||
self.macrob=wx.Button(self,-1,"..",style=wx.BU_EXACTFIT)
|
||||
self.macrob.Bind(wx.EVT_BUTTON,self.macrob_handler)
|
||||
xbox.Add(self.macrob,0)
|
||||
grid.Add(xbox,1,wx.EXPAND)
|
||||
grid.Add(wx.StaticText(self,-1, _("Color")),0,wx.BOTTOM|wx.RIGHT)
|
||||
self.color=wx.TextCtrl(self,-1,"")
|
||||
grid.Add(self.color,1,wx.EXPAND)
|
||||
topsizer.Add(grid,0,wx.EXPAND)
|
||||
topsizer.Add( (0,0),1)
|
||||
topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL),0,wx.ALIGN_CENTER)
|
||||
self.command = wx.TextCtrl(self,-1,"")
|
||||
xbox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
xbox.Add(self.command, 1,wx.EXPAND)
|
||||
self.command.Bind(wx.EVT_TEXT, self.macrob_enabler)
|
||||
self.macrob = wx.Button(self,-1,"..",style = wx.BU_EXACTFIT)
|
||||
self.macrob.Bind(wx.EVT_BUTTON, self.macrob_handler)
|
||||
xbox.Add(self.macrob, 0)
|
||||
grid.Add(xbox, 1,wx.EXPAND)
|
||||
grid.Add(wx.StaticText(self,-1, _("Color")),0, wx.BOTTOM|wx.RIGHT)
|
||||
self.color = wx.TextCtrl(self,-1,"")
|
||||
grid.Add(self.color, 1,wx.EXPAND)
|
||||
topsizer.Add(grid, 0,wx.EXPAND)
|
||||
topsizer.Add( (0, 0),1)
|
||||
topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL),0, wx.ALIGN_CENTER)
|
||||
self.SetSizer(topsizer)
|
||||
|
||||
def macrob_enabler(self,e):
|
||||
def macrob_enabler(self, e):
|
||||
macro = self.command.GetValue()
|
||||
valid = False
|
||||
try:
|
||||
|
@ -186,7 +186,7 @@ class ButtonEdit(wx.Dialog):
|
|||
valid = True
|
||||
elif self.pronterface.macros.has_key(macro):
|
||||
valid = True
|
||||
elif hasattr(self.pronterface.__class__,u"do_"+macro):
|
||||
elif hasattr(self.pronterface.__class__, u"do_"+macro):
|
||||
valid = False
|
||||
elif len([c for c in macro if not c.isalnum() and c != "_"]):
|
||||
valid = False
|
||||
|
@ -203,7 +203,7 @@ class ButtonEdit(wx.Dialog):
|
|||
valid = True
|
||||
self.macrob.Enable(valid)
|
||||
|
||||
def macrob_handler(self,e):
|
||||
def macrob_handler(self, e):
|
||||
macro = self.command.GetValue()
|
||||
macro = self.pronterface.edit_macro(macro)
|
||||
self.command.SetValue(macro)
|
||||
|
@ -212,106 +212,106 @@ class ButtonEdit(wx.Dialog):
|
|||
|
||||
class TempGauge(wx.Panel):
|
||||
|
||||
def __init__(self,parent,size=(200,22),title="",maxval=240,gaugeColour=None):
|
||||
wx.Panel.__init__(self,parent,-1,size=size)
|
||||
self.Bind(wx.EVT_PAINT,self.paint)
|
||||
def __init__(self, parent, size = (200, 22),title = "",maxval = 240, gaugeColour = None):
|
||||
wx.Panel.__init__(self, parent,-1, size = size)
|
||||
self.Bind(wx.EVT_PAINT, self.paint)
|
||||
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
|
||||
self.width,self.height=size
|
||||
self.title=title
|
||||
self.max=maxval
|
||||
self.gaugeColour=gaugeColour
|
||||
self.value=0
|
||||
self.setpoint=0
|
||||
self.width, self.height = size
|
||||
self.title = title
|
||||
self.max = maxval
|
||||
self.gaugeColour = gaugeColour
|
||||
self.value = 0
|
||||
self.setpoint = 0
|
||||
self.recalc()
|
||||
|
||||
def recalc(self):
|
||||
mmax=max(int(self.setpoint*1.05),self.max)
|
||||
self.scale=float(self.width-2)/float(mmax)
|
||||
self.ypt=max(16,int(self.scale*max(self.setpoint,self.max/6)))
|
||||
mmax = max(int(self.setpoint*1.05),self.max)
|
||||
self.scale = float(self.width-2)/float(mmax)
|
||||
self.ypt = max(16, int(self.scale*max(self.setpoint, self.max/6)))
|
||||
|
||||
def SetValue(self,value):
|
||||
self.value=value
|
||||
def SetValue(self, value):
|
||||
self.value = value
|
||||
wx.CallAfter(self.Refresh)
|
||||
|
||||
def SetTarget(self,value):
|
||||
self.setpoint=value
|
||||
def SetTarget(self, value):
|
||||
self.setpoint = value
|
||||
self.recalc()
|
||||
wx.CallAfter(self.Refresh)
|
||||
|
||||
def interpolatedColour(self,val,vmin,vmid,vmax,cmin,cmid,cmax):
|
||||
def interpolatedColour(self, val, vmin, vmid, vmax, cmin, cmid, cmax):
|
||||
if val < vmin: return cmin
|
||||
if val > vmax: return cmax
|
||||
if val <= vmid:
|
||||
lo,hi,val,valhi = cmin,cmid,val-vmin,vmid-vmin
|
||||
lo, hi, val, valhi = cmin, cmid, val-vmin, vmid-vmin
|
||||
else:
|
||||
lo,hi,val,valhi = cmid,cmax,val-vmid,vmax-vmid
|
||||
lo, hi, val, valhi = cmid, cmax, val-vmid, vmax-vmid
|
||||
vv = float(val)/valhi
|
||||
rgb=lo.Red()+(hi.Red()-lo.Red())*vv,lo.Green()+(hi.Green()-lo.Green())*vv,lo.Blue()+(hi.Blue()-lo.Blue())*vv
|
||||
rgb=map(lambda x:x*0.8,rgb)
|
||||
return wx.Colour(*map(int,rgb))
|
||||
rgb = lo.Red()+(hi.Red()-lo.Red())*vv, lo.Green()+(hi.Green()-lo.Green())*vv, lo.Blue()+(hi.Blue()-lo.Blue())*vv
|
||||
rgb = map(lambda x:x*0.8, rgb)
|
||||
return wx.Colour(*map(int, rgb))
|
||||
|
||||
def paint(self,ev):
|
||||
x0,y0,x1,y1,xE,yE = 1,1,self.ypt+1,1,self.width+1-2,20
|
||||
dc=wx.PaintDC(self)
|
||||
dc.SetBackground(wx.Brush((255,255,255)))
|
||||
def paint(self, ev):
|
||||
x0, y0, x1, y1, xE, yE = 1, 1,self.ypt+1, 1,self.width+1-2, 20
|
||||
dc = wx.PaintDC(self)
|
||||
dc.SetBackground(wx.Brush((255, 255, 255)))
|
||||
dc.Clear()
|
||||
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))
|
||||
shadow1,shadow2 = wx.Colour(110,110,110),wx.Colour(255,255,255)
|
||||
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))
|
||||
shadow1, shadow2 = wx.Colour(110, 110, 110),wx.Colour(255, 255, 255)
|
||||
gc = wx.GraphicsContext.Create(dc)
|
||||
# draw shadow first
|
||||
# corners
|
||||
gc.SetBrush(gc.CreateRadialGradientBrush(xE-7,9,xE-7,9,8,shadow1,shadow2))
|
||||
gc.DrawRectangle(xE-7,1,8,8)
|
||||
gc.SetBrush(gc.CreateRadialGradientBrush(xE-7,17,xE-7,17,8,shadow1,shadow2))
|
||||
gc.DrawRectangle(xE-7,17,8,8)
|
||||
gc.SetBrush(gc.CreateRadialGradientBrush(x0+6,17,x0+6,17,8,shadow1,shadow2))
|
||||
gc.DrawRectangle(0,17,x0+6,8)
|
||||
gc.SetBrush(gc.CreateRadialGradientBrush(xE-7, 9,xE-7, 9,8, shadow1, shadow2))
|
||||
gc.DrawRectangle(xE-7, 1,8, 8)
|
||||
gc.SetBrush(gc.CreateRadialGradientBrush(xE-7, 17, xE-7, 17, 8,shadow1, shadow2))
|
||||
gc.DrawRectangle(xE-7, 17, 8,8)
|
||||
gc.SetBrush(gc.CreateRadialGradientBrush(x0+6, 17, x0+6, 17, 8,shadow1, shadow2))
|
||||
gc.DrawRectangle(0, 17, x0+6, 8)
|
||||
# edges
|
||||
gc.SetBrush(gc.CreateLinearGradientBrush(xE-13,0,xE-6,0,shadow1,shadow2))
|
||||
gc.DrawRectangle(xE-6,9,10,8)
|
||||
gc.SetBrush(gc.CreateLinearGradientBrush(x0,yE-2,x0,yE+5,shadow1,shadow2))
|
||||
gc.DrawRectangle(x0+6,yE-2,xE-12,7)
|
||||
gc.SetBrush(gc.CreateLinearGradientBrush(xE-13, 0,xE-6, 0,shadow1, shadow2))
|
||||
gc.DrawRectangle(xE-6, 9,10, 8)
|
||||
gc.SetBrush(gc.CreateLinearGradientBrush(x0, yE-2, x0, yE+5, shadow1, shadow2))
|
||||
gc.DrawRectangle(x0+6, yE-2, xE-12, 7)
|
||||
# draw gauge background
|
||||
gc.SetBrush(gc.CreateLinearGradientBrush(x0,y0,x1+1,y1,cold,medium))
|
||||
gc.DrawRoundedRectangle(x0,y0,x1+4,yE,6)
|
||||
gc.SetBrush(gc.CreateLinearGradientBrush(x1-2,y1,xE,y1,medium,hot))
|
||||
gc.DrawRoundedRectangle(x1-2,y1,xE-x1,yE,6)
|
||||
gc.SetBrush(gc.CreateLinearGradientBrush(x0, y0, x1+1, y1, cold, medium))
|
||||
gc.DrawRoundedRectangle(x0, y0, x1+4, yE, 6)
|
||||
gc.SetBrush(gc.CreateLinearGradientBrush(x1-2, y1, xE, y1, medium, hot))
|
||||
gc.DrawRoundedRectangle(x1-2, y1, xE-x1, yE, 6)
|
||||
# draw gauge
|
||||
width=12
|
||||
w1=y0+9-width/2
|
||||
w2=w1+width
|
||||
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(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)))
|
||||
width = 12
|
||||
w1 = y0+9-width/2
|
||||
w2 = w1+width
|
||||
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(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)))
|
||||
val_path = gc.CreatePath()
|
||||
val_path.MoveToPoint(x0,w1)
|
||||
val_path.AddLineToPoint(value,w1)
|
||||
val_path.AddLineToPoint(value+2,w1+width/4)
|
||||
val_path.AddLineToPoint(value+2,w2-width/4)
|
||||
val_path.AddLineToPoint(value,w2)
|
||||
#val_path.AddLineToPoint(value-4,10)
|
||||
val_path.AddLineToPoint(x0,w2)
|
||||
val_path.MoveToPoint(x0, w1)
|
||||
val_path.AddLineToPoint(value, w1)
|
||||
val_path.AddLineToPoint(value+2, w1+width/4)
|
||||
val_path.AddLineToPoint(value+2, w2-width/4)
|
||||
val_path.AddLineToPoint(value, w2)
|
||||
#val_path.AddLineToPoint(value-4, 10)
|
||||
val_path.AddLineToPoint(x0, w2)
|
||||
gc.DrawPath(val_path)
|
||||
# draw setpoint markers
|
||||
setpoint=x0+max(10,int(self.setpoint*self.scale))
|
||||
gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0,0,0))))
|
||||
setpoint = x0+max(10, int(self.setpoint*self.scale))
|
||||
gc.SetBrush(gc.CreateBrush(wx.Brush(wx.Colour(0, 0,0))))
|
||||
setp_path = gc.CreatePath()
|
||||
setp_path.MoveToPoint(setpoint-4,y0)
|
||||
setp_path.AddLineToPoint(setpoint+4,y0)
|
||||
setp_path.AddLineToPoint(setpoint,y0+5)
|
||||
setp_path.MoveToPoint(setpoint-4,yE)
|
||||
setp_path.AddLineToPoint(setpoint+4,yE)
|
||||
setp_path.AddLineToPoint(setpoint,yE-5)
|
||||
setp_path.MoveToPoint(setpoint-4, y0)
|
||||
setp_path.AddLineToPoint(setpoint+4, y0)
|
||||
setp_path.AddLineToPoint(setpoint, y0+5)
|
||||
setp_path.MoveToPoint(setpoint-4, yE)
|
||||
setp_path.AddLineToPoint(setpoint+4, yE)
|
||||
setp_path.AddLineToPoint(setpoint, yE-5)
|
||||
gc.DrawPath(setp_path)
|
||||
# draw readout
|
||||
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.DrawText(text,29,-2)
|
||||
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(text, x0+119,y0+4)
|
||||
gc.SetFont(gc.CreateFont(wx.Font(10,wx.FONTFAMILY_DEFAULT,wx.FONTSTYLE_NORMAL,wx.FONTWEIGHT_BOLD)))
|
||||
gc.DrawText(self.title,x0+18,y0+3)
|
||||
gc.DrawText(text, x0+118,y0+3)
|
||||
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.DrawText(text, 29,-2)
|
||||
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(text, x0+119, y0+4)
|
||||
gc.SetFont(gc.CreateFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)))
|
||||
gc.DrawText(self.title, x0+18, y0+3)
|
||||
gc.DrawText(text, x0+118, y0+3)
|
||||
|
|
|
@ -15,56 +15,56 @@
|
|||
|
||||
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]]
|
||||
|
||||
def genfacet(v):
|
||||
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]]
|
||||
vecx=cross(veca,vecb)
|
||||
vlen=math.sqrt(sum(map(lambda x:x*x,vecx)))
|
||||
if vlen==0:
|
||||
vlen=1
|
||||
normal=map(lambda x:x/vlen, vecx)
|
||||
return [normal,v]
|
||||
vecx = cross(veca, vecb)
|
||||
vlen = math.sqrt(sum(map(lambda x:x*x, vecx)))
|
||||
if vlen == 0:
|
||||
vlen = 1
|
||||
normal = map(lambda x:x/vlen, vecx)
|
||||
return [normal, v]
|
||||
|
||||
I=[
|
||||
[1,0,0,0],
|
||||
[0,1,0,0],
|
||||
[0,0,1,0],
|
||||
[0,0,0,1]
|
||||
[1, 0,0, 0],
|
||||
[0, 1,0, 0],
|
||||
[0, 0,1, 0],
|
||||
[0, 0,0, 1]
|
||||
]
|
||||
|
||||
def transpose(matrix):
|
||||
return zip(*matrix)
|
||||
#return [[v[i] for v in matrix] for i in xrange(len(matrix[0]))]
|
||||
|
||||
def multmatrix(vector,matrix):
|
||||
def multmatrix(vector, matrix):
|
||||
return map(sum, transpose(map(lambda x:[x[0]*p for p in x[1]], zip(vector, transpose(matrix)))))
|
||||
|
||||
def applymatrix(facet,matrix=I):
|
||||
def applymatrix(facet, matrix = I):
|
||||
#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]))
|
||||
|
||||
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=[
|
||||
[1,0,0,0],
|
||||
[0,1,0,0],
|
||||
[0,0,1,1],
|
||||
[0,0,0,1]
|
||||
[1, 0,0, 0],
|
||||
[0, 1,0, 0],
|
||||
[0, 0,1, 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:
|
||||
return
|
||||
if binary:
|
||||
f=open(filename,"wb")
|
||||
buf="".join(["\0"]*80)
|
||||
f = open(filename,"wb")
|
||||
buf = "".join(["\0"]*80)
|
||||
buf+=struct.pack("<I",len(facets))
|
||||
facetformat=struct.Struct("<ffffffffffffH")
|
||||
facetformat = struct.Struct("<ffffffffffffH")
|
||||
for i in facets:
|
||||
l=list(i[0][:])
|
||||
l = list(i[0][:])
|
||||
for j in i[1]:
|
||||
l+=j[:]
|
||||
l+=[0]
|
||||
|
@ -75,12 +75,12 @@ def emitstl(filename,facets=[],objname="stltool_export",binary=1):
|
|||
return
|
||||
|
||||
|
||||
f=open(filename,"w")
|
||||
f = open(filename,"w")
|
||||
f.write("solid "+objname+"\n")
|
||||
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")
|
||||
for j in i[1]:
|
||||
f.write(" vertex "+" ".join(map(str,j))+"\n")
|
||||
f.write(" vertex "+" ".join(map(str, j))+"\n")
|
||||
f.write(" endloop"+"\n")
|
||||
f.write(" endfacet"+"\n")
|
||||
f.write("endsolid "+objname+"\n")
|
||||
|
@ -89,43 +89,43 @@ def emitstl(filename,facets=[],objname="stltool_export",binary=1):
|
|||
|
||||
|
||||
class stl:
|
||||
def __init__(self, filename=None):
|
||||
self.facet=[[0,0,0],[[0,0,0],[0,0,0],[0,0,0]]]
|
||||
def __init__(self, filename = None):
|
||||
self.facet=[[0, 0,0],[[0, 0,0],[0, 0,0],[0, 0,0]]]
|
||||
self.facets=[]
|
||||
self.facetsminz=[]
|
||||
self.facetsmaxz=[]
|
||||
|
||||
self.name=""
|
||||
self.insolid=0
|
||||
self.infacet=0
|
||||
self.inloop=0
|
||||
self.facetloc=0
|
||||
self.name = ""
|
||||
self.insolid = 0
|
||||
self.infacet = 0
|
||||
self.inloop = 0
|
||||
self.facetloc = 0
|
||||
if filename is None:
|
||||
return
|
||||
self.f=list(open(filename))
|
||||
self.f = list(open(filename))
|
||||
if not self.f[0].startswith("solid"):
|
||||
print "Not an ascii stl solid - attempting to parse as binary"
|
||||
f=open(filename,"rb")
|
||||
buf=f.read(84)
|
||||
f = open(filename,"rb")
|
||||
buf = f.read(84)
|
||||
while(len(buf)<84):
|
||||
newdata=f.read(84-len(buf))
|
||||
newdata = f.read(84-len(buf))
|
||||
if not len(newdata):
|
||||
break
|
||||
buf+=newdata
|
||||
facetcount=struct.unpack_from("<I",buf,80)
|
||||
facetformat=struct.Struct("<ffffffffffffH")
|
||||
facetcount = struct.unpack_from("<I",buf, 80)
|
||||
facetformat = struct.Struct("<ffffffffffffH")
|
||||
for i in xrange(facetcount[0]):
|
||||
buf=f.read(50)
|
||||
buf = f.read(50)
|
||||
while(len(buf)<50):
|
||||
newdata=f.read(50-len(buf))
|
||||
newdata = f.read(50-len(buf))
|
||||
if not len(newdata):
|
||||
break
|
||||
buf+=newdata
|
||||
fd=list(facetformat.unpack(buf))
|
||||
self.name="binary soloid"
|
||||
fd = list(facetformat.unpack(buf))
|
||||
self.name = "binary soloid"
|
||||
self.facet=[fd[:3],[fd[3:6],fd[6:9],fd[9:12]]]
|
||||
self.facets+=[self.facet]
|
||||
facet=self.facet
|
||||
facet = self.facet
|
||||
self.facetsminz+=[(min(map(lambda x:x[2], facet[1])),facet)]
|
||||
self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])),facet)]
|
||||
f.close()
|
||||
|
@ -134,106 +134,106 @@ class stl:
|
|||
if not self.parseline(i):
|
||||
return
|
||||
|
||||
def translate(self,v=[0,0,0]):
|
||||
def translate(self, v=[0, 0,0]):
|
||||
matrix=[
|
||||
[1,0,0,v[0]],
|
||||
[0,1,0,v[1]],
|
||||
[0,0,1,v[2]],
|
||||
[0,0,0,1]
|
||||
[1, 0,0, v[0]],
|
||||
[0, 1,0, v[1]],
|
||||
[0, 0,1, v[2]],
|
||||
[0, 0,0, 1]
|
||||
]
|
||||
return self.transform(matrix)
|
||||
|
||||
def rotate(self,v=[0,0,0]):
|
||||
def rotate(self, v=[0, 0,0]):
|
||||
import math
|
||||
z=v[2]
|
||||
z = v[2]
|
||||
matrix1=[
|
||||
[math.cos(math.radians(z)),-math.sin(math.radians(z)),0,0],
|
||||
[math.sin(math.radians(z)),math.cos(math.radians(z)),0,0],
|
||||
[0,0,1,0],
|
||||
[0,0,0,1]
|
||||
[math.cos(math.radians(z)),-math.sin(math.radians(z)),0, 0],
|
||||
[math.sin(math.radians(z)),math.cos(math.radians(z)),0, 0],
|
||||
[0, 0,1, 0],
|
||||
[0, 0,0, 1]
|
||||
]
|
||||
y=v[0]
|
||||
y = v[0]
|
||||
matrix2=[
|
||||
[1,0,0,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,0,0,1]
|
||||
[1, 0,0, 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, 0,0, 1]
|
||||
]
|
||||
x=v[1]
|
||||
x = v[1]
|
||||
matrix3=[
|
||||
[math.cos(math.radians(x)),0,-math.sin(math.radians(x)),0],
|
||||
[0,1,0,0],
|
||||
[math.sin(math.radians(x)),0,math.cos(math.radians(x)),0],
|
||||
[0,0,0,1]
|
||||
[0, 1,0, 0],
|
||||
[math.sin(math.radians(x)),0, math.cos(math.radians(x)),0],
|
||||
[0, 0,0, 1]
|
||||
]
|
||||
return self.transform(matrix1).transform(matrix2).transform(matrix3)
|
||||
|
||||
def scale(self,v=[0,0,0]):
|
||||
def scale(self, v=[0, 0,0]):
|
||||
matrix=[
|
||||
[v[0],0,0,0],
|
||||
[0,v[1],0,0],
|
||||
[0,0,v[2],0],
|
||||
[0,0,0,1]
|
||||
[v[0],0, 0,0],
|
||||
[0, v[1],0, 0],
|
||||
[0, 0,v[2],0],
|
||||
[0, 0,0, 1]
|
||||
]
|
||||
return self.transform(matrix)
|
||||
|
||||
|
||||
def transform(self,m=I):
|
||||
s=stl()
|
||||
s.facets=[applymatrix(i,m) for i in self.facets]
|
||||
s.insolid=0
|
||||
s.infacet=0
|
||||
s.inloop=0
|
||||
s.facetloc=0
|
||||
s.name=self.name
|
||||
def transform(self, m = I):
|
||||
s = stl()
|
||||
s.facets=[applymatrix(i, m) for i in self.facets]
|
||||
s.insolid = 0
|
||||
s.infacet = 0
|
||||
s.inloop = 0
|
||||
s.facetloc = 0
|
||||
s.name = self.name
|
||||
for facet in s.facets:
|
||||
s.facetsminz+=[(min(map(lambda x:x[2], facet[1])),facet)]
|
||||
s.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])),facet)]
|
||||
return s
|
||||
|
||||
def export(self,f=sys.stdout):
|
||||
def export(self, f = sys.stdout):
|
||||
f.write("solid "+self.name+"\n")
|
||||
for i in self.facets:
|
||||
f.write(" facet normal "+" ".join(map(str,i[0]))+"\n")
|
||||
f.write(" facet normal "+" ".join(map(str, i[0]))+"\n")
|
||||
f.write(" outer loop"+"\n")
|
||||
for j in i[1]:
|
||||
f.write(" vertex "+" ".join(map(str,j))+"\n")
|
||||
f.write(" vertex "+" ".join(map(str, j))+"\n")
|
||||
f.write(" endloop"+"\n")
|
||||
f.write(" endfacet"+"\n")
|
||||
f.write("endsolid "+self.name+"\n")
|
||||
f.flush()
|
||||
|
||||
def parseline(self,l):
|
||||
l=l.strip()
|
||||
def parseline(self, l):
|
||||
l = l.strip()
|
||||
if l.startswith("solid"):
|
||||
self.insolid=1
|
||||
self.name=l[6:]
|
||||
self.insolid = 1
|
||||
self.name = l[6:]
|
||||
#print self.name
|
||||
|
||||
elif l.startswith("endsolid"):
|
||||
self.insolid=0
|
||||
self.insolid = 0
|
||||
return 0
|
||||
elif l.startswith("facet normal"):
|
||||
l=l.replace(",",".")
|
||||
self.infacet=11
|
||||
self.facetloc=0
|
||||
self.facet=[[0,0,0],[[0,0,0],[0,0,0],[0,0,0]]]
|
||||
self.facet[0]=map(float,l.split()[2:])
|
||||
l = l.replace(",",".")
|
||||
self.infacet = 11
|
||||
self.facetloc = 0
|
||||
self.facet=[[0, 0,0],[[0, 0,0],[0, 0,0],[0, 0,0]]]
|
||||
self.facet[0]=map(float, l.split()[2:])
|
||||
elif l.startswith("endfacet"):
|
||||
self.infacet=0
|
||||
self.infacet = 0
|
||||
self.facets+=[self.facet]
|
||||
facet=self.facet
|
||||
facet = self.facet
|
||||
self.facetsminz+=[(min(map(lambda x:x[2], facet[1])),facet)]
|
||||
self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])),facet)]
|
||||
elif l.startswith("vertex"):
|
||||
l=l.replace(",",".")
|
||||
self.facet[1][self.facetloc]=map(float,l.split()[1:])
|
||||
l = l.replace(",",".")
|
||||
self.facet[1][self.facetloc]=map(float, l.split()[1:])
|
||||
self.facetloc+=1
|
||||
return 1
|
||||
if __name__=="__main__":
|
||||
s=stl("../../Downloads/frame-vertex-neo-foot-x4.stl")
|
||||
for i in xrange(11,11):
|
||||
working=s.facets[:]
|
||||
if __name__ == "__main__":
|
||||
s = stl("../../Downloads/frame-vertex-neo-foot-x4.stl")
|
||||
for i in xrange(11, 11):
|
||||
working = s.facets[:]
|
||||
for j in reversed(sorted(s.facetsminz)):
|
||||
if(j[0]>i):
|
||||
working.remove(j[1])
|
||||
|
@ -245,6 +245,6 @@ if __name__=="__main__":
|
|||
else:
|
||||
break
|
||||
|
||||
print i,len(working)
|
||||
print i, len(working)
|
||||
emitstl("../../Downloads/frame-vertex-neo-foot-x4-a.stl",s.facets,"emitted_object")
|
||||
#stl("../prusamendel/stl/mendelplate.stl")
|
||||
|
|
|
@ -32,8 +32,8 @@ from pyglet.gl import *
|
|||
class GLPanel(wx.Panel):
|
||||
'''A simple class for using OpenGL with wxPython.'''
|
||||
|
||||
def __init__(self, parent, id, pos=wx.DefaultPosition,
|
||||
size=wx.DefaultSize, style=0):
|
||||
def __init__(self, parent, id, pos = wx.DefaultPosition,
|
||||
size = wx.DefaultSize, style = 0):
|
||||
# Forcing a no full repaint to stop flickering
|
||||
style = style | wx.NO_FULL_REPAINT_ON_RESIZE
|
||||
#call super function
|
||||
|
@ -46,7 +46,7 @@ class GLPanel(wx.Panel):
|
|||
glcanvas.WX_GL_DEPTH_SIZE, 24) # 24 bit
|
||||
# Create the canvas
|
||||
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.canvas = glcanvas.GLCanvas(self, attribList=attribList)
|
||||
self.canvas = glcanvas.GLCanvas(self, attribList = attribList)
|
||||
self.sizer.Add(self.canvas, 1, wx.EXPAND)
|
||||
self.SetSizer(self.sizer)
|
||||
#self.sizer.Fit(self)
|
||||
|
@ -215,7 +215,7 @@ class stlview(object):
|
|||
normals.extend(i[0])
|
||||
|
||||
# Create a list of triangle indices.
|
||||
indices = range(3 * len(facets)) # [[3*i,3*i+1,3*i+2] for i in xrange(len(facets))]
|
||||
indices = range(3 * len(facets)) # [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
|
||||
#print indices[:10]
|
||||
self.vertex_list = batch.add_indexed(len(vertices) // 3,
|
||||
GL_TRIANGLES,
|
||||
|
@ -233,7 +233,7 @@ def vdiff(v, o):
|
|||
|
||||
|
||||
class gcview(object):
|
||||
def __init__(self, lines, batch, w=0.5, h=0.5):
|
||||
def __init__(self, lines, batch, w = 0.5, h = 0.5):
|
||||
# Create the vertex and normal arrays.
|
||||
vertices = []
|
||||
normals = []
|
||||
|
@ -258,7 +258,7 @@ class gcview(object):
|
|||
if lasth is not None:
|
||||
self.layers[lasth] = pyglet.graphics.Batch()
|
||||
lt = layertemp[lasth][0]
|
||||
indices = range(len(layertemp[lasth][0]) // 3) # [[3*i,3*i+1,3*i+2] for i in xrange(len(facets))]
|
||||
indices = range(len(layertemp[lasth][0]) // 3) # [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
|
||||
self.vlists.append(self.layers[lasth].add_indexed(len(layertemp[lasth][0]) // 3,
|
||||
GL_TRIANGLES,
|
||||
None, # group,
|
||||
|
@ -296,7 +296,7 @@ class gcview(object):
|
|||
t0 = time.time()
|
||||
|
||||
# Create a list of triangle indices.
|
||||
indices = range(3 * 16 * len(lines)) # [[3*i,3*i+1,3*i+2] for i in xrange(len(facets))]
|
||||
indices = range(3 * 16 * len(lines)) # [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
|
||||
self.vlists.append(batch.add_indexed(len(vertices) // 3,
|
||||
GL_TRIANGLES,
|
||||
None, # group,
|
||||
|
@ -305,7 +305,7 @@ class gcview(object):
|
|||
('n3f/static', normals)))
|
||||
if lasth is not None:
|
||||
self.layers[lasth] = pyglet.graphics.Batch()
|
||||
indices = range(len(layertemp[lasth][0])) # [[3*i,3*i+1,3*i+2] for i in xrange(len(facets))]
|
||||
indices = range(len(layertemp[lasth][0])) # [[3*i, 3*i+1, 3*i+2] for i in xrange(len(facets))]
|
||||
self.vlists.append(self.layers[lasth].add_indexed(len(layertemp[lasth][0]) // 3,
|
||||
GL_TRIANGLES,
|
||||
None, # group,
|
||||
|
@ -466,7 +466,7 @@ def mulquat(q1, rq):
|
|||
|
||||
class TestGlPanel(GLPanel):
|
||||
|
||||
def __init__(self, parent, size, id=wx.ID_ANY):
|
||||
def __init__(self, parent, size, id = wx.ID_ANY):
|
||||
super(TestGlPanel, self).__init__(parent, id, wx.DefaultPosition, size, 0)
|
||||
self.batches = []
|
||||
self.rot = 0
|
||||
|
@ -495,7 +495,7 @@ class TestGlPanel(GLPanel):
|
|||
def forceresize(self):
|
||||
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] + 1))
|
||||
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] - 1))
|
||||
threading.Thread(target=self.update).start()
|
||||
threading.Thread(target = self.update).start()
|
||||
self.initialized = 0
|
||||
|
||||
def move_shape(self, delta):
|
||||
|
@ -547,7 +547,7 @@ class TestGlPanel(GLPanel):
|
|||
p1y = -(float(p1[1]) - sz[1] / 2) / (sz[1] / 2)
|
||||
p2x = (float(p2[0]) - sz[0] / 2) / (sz[0] / 2)
|
||||
p2y = -(float(p2[1]) - sz[1] / 2) / (sz[1] / 2)
|
||||
#print p1x,p1y,p2x,p2y
|
||||
#print p1x, p1y, p2x, p2y
|
||||
quat = trackball(p1x, p1y, p2x, p2y, -self.transv[2] / 250.0)
|
||||
if self.rot:
|
||||
self.basequat = mulquat(self.basequat, quat)
|
||||
|
@ -710,7 +710,7 @@ class TestGlPanel(GLPanel):
|
|||
|
||||
def drawmodel(self, m, n):
|
||||
batch = pyglet.graphics.Batch()
|
||||
stl = stlview(m.facets, batch=batch)
|
||||
stl = stlview(m.facets, batch = batch)
|
||||
m.batch = batch
|
||||
m.animoffset = 300
|
||||
#print m
|
||||
|
@ -819,8 +819,8 @@ class TestGlPanel(GLPanel):
|
|||
class GCFrame(wx.Frame):
|
||||
'''A simple class for using OpenGL with wxPython.'''
|
||||
|
||||
def __init__(self, parent, ID, title, pos=wx.DefaultPosition,
|
||||
size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
|
||||
def __init__(self, parent, ID, title, pos = wx.DefaultPosition,
|
||||
size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE):
|
||||
super(GCFrame, self).__init__(parent, ID, title, pos, (size[0] + 150, size[1]), style)
|
||||
|
||||
class d:
|
||||
|
@ -833,7 +833,7 @@ class GCFrame(wx.Frame):
|
|||
m.curlayer = 0.0
|
||||
m.scale = [1.0, 1.0, 1.0]
|
||||
m.batch = pyglet.graphics.Batch()
|
||||
m.gc = gcview([], batch=m.batch)
|
||||
m.gc = gcview([], batch = m.batch)
|
||||
self.models = {"": m}
|
||||
self.l = d()
|
||||
self.modelindex = 0
|
||||
|
@ -841,13 +841,13 @@ class GCFrame(wx.Frame):
|
|||
|
||||
def addfile(self, gcode=[]):
|
||||
self.models[""].gc.delete()
|
||||
self.models[""].gc = gcview(gcode, batch=self.models[""].batch)
|
||||
self.models[""].gc = gcview(gcode, batch = self.models[""].batch)
|
||||
|
||||
def clear(self):
|
||||
self.models[""].gc.delete()
|
||||
self.models[""].gc = gcview([], batch=self.models[""].batch)
|
||||
self.models[""].gc = gcview([], batch = self.models[""].batch)
|
||||
|
||||
def Show(self, arg=True):
|
||||
def Show(self, arg = True):
|
||||
wx.Frame.Show(self, arg)
|
||||
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] + 1))
|
||||
self.SetClientSize((self.GetClientSize()[0], self.GetClientSize()[1] - 1))
|
||||
|
@ -868,10 +868,10 @@ class GCFrame(wx.Frame):
|
|||
|
||||
|
||||
def main():
|
||||
app = wx.App(redirect=False)
|
||||
frame = GCFrame(None, wx.ID_ANY, 'Gcode view, shift to move view, mousewheel to set layer', size=(400, 400))
|
||||
app = wx.App(redirect = False)
|
||||
frame = GCFrame(None, wx.ID_ANY, 'Gcode view, shift to move view, mousewheel to set layer', size = (400, 400))
|
||||
frame.addfile(list(open("carriage dump_export.gcode")))
|
||||
#frame = wx.Frame(None, -1, "GL Window", size=(400, 400))
|
||||
#frame = wx.Frame(None, -1, "GL Window", size = (400, 400))
|
||||
#panel = TestGlPanel(frame)
|
||||
#frame.Show(True)
|
||||
#app.MainLoop()
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
import wx
|
||||
|
||||
def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise=False):
|
||||
""" Draws an arc of an ellipse within bounding rect (x,y,w,h)
|
||||
def AddEllipticalArc(self, x, y, w, h, startAngle, endAngle, clockwise = False):
|
||||
""" 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)"""
|
||||
|
||||
if True:
|
||||
|
|
|
@ -22,7 +22,7 @@ colorDeclaration = none | currentColor | colourValue
|
|||
|
||||
urlEnd = (
|
||||
Literal(")").suppress() +
|
||||
Optional(Group(colorDeclaration), default=()) +
|
||||
Optional(Group(colorDeclaration), default = ()) +
|
||||
StringEnd()
|
||||
)
|
||||
|
||||
|
@ -30,12 +30,12 @@ url = (
|
|||
CaselessLiteral("URL")
|
||||
+
|
||||
Literal("(").suppress()+
|
||||
Group(SkipTo(urlEnd, include=True).setParseAction(parsePossibleURL))
|
||||
Group(SkipTo(urlEnd, include = True).setParseAction(parsePossibleURL))
|
||||
)
|
||||
|
||||
#paint value will parse into a (type, details) 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))
|
||||
#The url tuple will be as returned by urlparse.urlsplit, and can be
|
||||
#an empty tuple if the parser has an error
|
||||
|
|
|
@ -14,22 +14,22 @@ from svg.css.colour import colourValue
|
|||
from svg.css import values
|
||||
from attributes import paintValue
|
||||
|
||||
document = """<?xml version="1.0" standalone="no"?>
|
||||
document = """<?xml version = "1.0" standalone = "no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="4cm" height="4cm" viewBox="0 0 400 400"
|
||||
xmlns="http://www.w3.org/2000/svg" version="1.1">
|
||||
<svg width = "4cm" height = "4cm" viewBox = "0 0 400 400"
|
||||
xmlns = "http://www.w3.org/2000/svg" version = "1.1">
|
||||
<title>Example triangle01- simple example of a 'path'</title>
|
||||
<desc>A path that draws a triangle</desc>
|
||||
<rect x="1" y="1" width="398" height="398"
|
||||
fill="none" stroke="blue" />
|
||||
<path d="M 100 100 L 300 100 L 200 300 z"
|
||||
fill="red" stroke="blue" stroke-width="3" />
|
||||
<rect x = "1" y = "1" width = "398" height = "398"
|
||||
fill = "none" stroke = "blue" />
|
||||
<path d = "M 100 100 L 300 100 L 200 300 z"
|
||||
fill = "red" stroke = "blue" stroke-width = "3" />
|
||||
</svg>"""
|
||||
|
||||
makePath = lambda: wx.GraphicsRenderer_GetDefaultRenderer().CreatePath()
|
||||
|
||||
def attrAsFloat(node, attr, defaultValue="0"):
|
||||
def attrAsFloat(node, attr, defaultValue = "0"):
|
||||
val = node.get(attr, defaultValue)
|
||||
#TODO: process stuff like "inherit" by walking back up the nodes
|
||||
#fast path optimization - if it's a valid float, don't
|
||||
|
@ -39,7 +39,7 @@ def attrAsFloat(node, attr, defaultValue="0"):
|
|||
except ValueError:
|
||||
return valueToPixels(val)
|
||||
|
||||
def valueToPixels(val, defaultUnits="px"):
|
||||
def valueToPixels(val, defaultUnits = "px"):
|
||||
#TODO manage default units
|
||||
from pyparsing import ParseException
|
||||
try:
|
||||
|
@ -175,14 +175,14 @@ class SVGDocument(object):
|
|||
)
|
||||
if transform == 'skewX':
|
||||
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(
|
||||
(wx.GraphicsContext.ConcatTransform, (matrix,))
|
||||
)
|
||||
if transform == 'skewY':
|
||||
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(
|
||||
(wx.GraphicsContext.ConcatTransform, (matrix,))
|
||||
|
@ -231,7 +231,7 @@ class SVGDocument(object):
|
|||
def addTextToDocument(self, node):
|
||||
x, y = [attrAsFloat(node, attr) for attr in ('x', 'y')]
|
||||
|
||||
def DoDrawText(context, text, x, y, brush=wx.NullGraphicsBrush):
|
||||
def DoDrawText(context, text, x, y, brush = wx.NullGraphicsBrush):
|
||||
#SVG spec appears to originate text from the bottom
|
||||
#rather than the top as with our API. This function
|
||||
#will measure and then re-orient the text as needed.
|
||||
|
@ -259,7 +259,7 @@ class SVGDocument(object):
|
|||
rx = node.get('rx')
|
||||
ry = node.get('ry')
|
||||
if not (w and h):
|
||||
path.MoveToPoint(x,y) #keep the current point correct
|
||||
path.MoveToPoint(x, y) #keep the current point correct
|
||||
return
|
||||
if rx or ry:
|
||||
if rx and ry:
|
||||
|
@ -449,7 +449,7 @@ class SVGDocument(object):
|
|||
pen.SetJoin(joinmap.get(self.state.get('stroke-linejoin', None), wx.JOIN_MITER))
|
||||
return wx.GraphicsRenderer_GetDefaultRenderer().CreatePen(pen)
|
||||
|
||||
def getBrushFromState(self, path=None):
|
||||
def getBrushFromState(self, path = None):
|
||||
brushcolour = self.state.get('fill', 'black').strip()
|
||||
type, details = paintValue.parseString(brushcolour)
|
||||
if type == "URL":
|
||||
|
@ -465,29 +465,29 @@ class SVGDocument(object):
|
|||
box = path.GetBox()
|
||||
x, y, w, h = box.Get()
|
||||
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':
|
||||
box = path.GetBox()
|
||||
x, y, w, h = box.Get()
|
||||
#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)
|
||||
fx, fy = cx, cy
|
||||
return wx.GraphicsRenderer.GetDefaultRenderer().CreateRadialGradientBrush(
|
||||
cx,cy,
|
||||
fx,fy,
|
||||
(max(w,h))/2,
|
||||
wx.Colour(0,0,255,128), wx.RED
|
||||
cx, cy,
|
||||
fx, fy,
|
||||
(max(w, h))/2,
|
||||
wx.Colour(0, 0,255, 128), wx.RED
|
||||
)
|
||||
else:
|
||||
#invlid gradient specified
|
||||
return wx.NullBrush
|
||||
r,g,b = 0,0,0
|
||||
r, g,b = 0, 0,0
|
||||
if type == 'CURRENTCOLOR':
|
||||
type, details = paintValue.parseString(self.state.get('color', 'none'))
|
||||
if type == 'RGB':
|
||||
r,g,b = details
|
||||
r, g,b = details
|
||||
elif type == "NONE":
|
||||
return wx.NullBrush
|
||||
opacity = self.state.get('fill-opacity', self.state.get('opacity', '1'))
|
||||
|
@ -499,9 +499,9 @@ class SVGDocument(object):
|
|||
#be created every time anyway in order to pass them,
|
||||
#defeating the purpose of the cache
|
||||
try:
|
||||
return SVGDocument.brushCache[(r,g,b,a)]
|
||||
return SVGDocument.brushCache[(r, g,b, a)]
|
||||
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):
|
||||
|
@ -571,7 +571,7 @@ class SVGDocument(object):
|
|||
#~ cp = path.GetCurrentPoint()
|
||||
#~ path.AddCircle(c1x, c1y, 5)
|
||||
#~ path.AddCircle(c2x, c2y, 3)
|
||||
#~ path.AddCircle(x,y, 7)
|
||||
#~ path.AddCircle(x, y, 7)
|
||||
#~ path.MoveToPoint(cp)
|
||||
#~ print "C", control1, control2, endpoint
|
||||
|
||||
|
@ -592,7 +592,7 @@ class SVGDocument(object):
|
|||
endpoint
|
||||
)
|
||||
elif type == "Q":
|
||||
(cx, cy), (x,y) = map(normalizePoint, arg)
|
||||
(cx, cy), (x, y) = map(normalizePoint, arg)
|
||||
self.lastControlQ = (cx, cy)
|
||||
path.AddQuadCurveToPoint(cx, cy, x, y)
|
||||
elif type == "T":
|
||||
|
@ -607,12 +607,12 @@ class SVGDocument(object):
|
|||
elif type == "V":
|
||||
_, y = normalizePoint((0, arg))
|
||||
x, _ = path.GetCurrentPoint()
|
||||
path.AddLineToPoint(x,y)
|
||||
path.AddLineToPoint(x, y)
|
||||
|
||||
elif type == "H":
|
||||
x, _ = normalizePoint((arg, 0))
|
||||
_, y = path.GetCurrentPoint()
|
||||
path.AddLineToPoint(x,y)
|
||||
path.AddLineToPoint(x, y)
|
||||
|
||||
elif type == "A":
|
||||
#wxGC currently only supports circular arcs,
|
||||
|
@ -625,14 +625,14 @@ class SVGDocument(object):
|
|||
(x, y) #endpoint on the arc
|
||||
) = arg
|
||||
|
||||
x, y = normalizePoint((x,y))
|
||||
x, y = normalizePoint((x, y))
|
||||
cx, cy = path.GetCurrentPoint()
|
||||
if (cx, cy) == (x, y):
|
||||
return #noop
|
||||
|
||||
if (rx == 0 or ry == 0):
|
||||
#no radius is effectively a line
|
||||
path.AddLineToPoint(x,y)
|
||||
path.AddLineToPoint(x, y)
|
||||
return
|
||||
|
||||
#find the center point for the ellipse
|
||||
|
@ -685,7 +685,7 @@ class SVGDocument(object):
|
|||
path.MoveToPoint(x, y)
|
||||
#~ npath = makePath()
|
||||
#~ npath.AddEllipticalArc(cnx-rx, cny-ry, rx*2, ry*2, firstArc, lastArc, False)
|
||||
#~ npath.MoveToPoint(x,y)
|
||||
#~ npath.MoveToPoint(x, y)
|
||||
#~ path.AddPath(npath)
|
||||
|
||||
elif type == 'Z':
|
||||
|
|
|
@ -27,12 +27,12 @@ class CaselessPreservingLiteral(CaselessLiteral):
|
|||
instead of as defined.
|
||||
"""
|
||||
def __init__( self, matchString ):
|
||||
super(CaselessPreservingLiteral,self).__init__( matchString.upper() )
|
||||
super(CaselessPreservingLiteral, self).__init__( matchString.upper() )
|
||||
self.name = "'%s'" % matchString
|
||||
self.errmsg = "Expected " + self.name
|
||||
self.myException.msg = self.errmsg
|
||||
|
||||
def parseImpl( self, instring, loc, doActions=True ):
|
||||
def parseImpl( self, instring, loc, doActions = True ):
|
||||
test = instring[ loc:loc+self.matchLen ]
|
||||
if test.upper() == self.match:
|
||||
return loc+self.matchLen, test
|
||||
|
@ -117,7 +117,7 @@ ellipticalArcArgument = Group(
|
|||
arcRadius + maybeComma + #rx, ry
|
||||
number + maybeComma +#rotation
|
||||
arcFlags + #large-arc-flag, sweep-flag
|
||||
coordinatePair #(x,y)
|
||||
coordinatePair #(x, y)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ from printrun.printrun_utils import configfile, imagefile, sharedfile
|
|||
users = {}
|
||||
|
||||
def PrintHeader():
|
||||
return '<html>\n<head>\n<title>Pronterface-Web</title>\n<link rel="stylesheet" type="text/css" href="/css/style.css" type="text/css"></link>\n</head>\n<body>\n'
|
||||
return '<html>\n<head>\n<title>Pronterface-Web</title>\n<link rel = "stylesheet" type = "text/css" href = "/css/style.css" type = "text/css"></link>\n</head>\n<body>\n'
|
||||
|
||||
def PrintMenu():
|
||||
return '<div id="mainmenu"><ul><li><a href="/">home</a></li><li><a href="/settings">settings</a></li><li><a href="/console">console</a></li><li><a href="/status">status (XML)</a></li></ul></div>'
|
||||
return '<div id = "mainmenu"><ul><li><a href = "/">home</a></li><li><a href = "/settings">settings</a></li><li><a href = "/console">console</a></li><li><a href = "/status">status (XML)</a></li></ul></div>'
|
||||
|
||||
def PrintFooter():
|
||||
return "</body></html>"
|
||||
|
@ -30,41 +30,41 @@ gWeblog = ""
|
|||
gLogRefresh =5
|
||||
class SettingsPage(object):
|
||||
def __init__(self):
|
||||
self.name="<div id='title'>Pronterface Settings</div>"
|
||||
self.name = "<div id='title'>Pronterface Settings</div>"
|
||||
|
||||
def index(self):
|
||||
pageText=PrintHeader()+self.name+PrintMenu()
|
||||
pageText=pageText+"<div id='settings'><table>\n<tr><th>setting</th><th>value</th>"
|
||||
pageText=pageText+"<tr>\n <td><b>Build Dimenstions</b></td><td>"+str(gPronterPtr.settings.build_dimensions)+"</td>\n</tr>"
|
||||
pageText=pageText+" <tr>\n <td><b>Last Bed Temp</b></td><td>"+str(gPronterPtr.settings.last_bed_temperature)+"</td>\n</tr>"
|
||||
pageText=pageText+" <tr>\n <td><b>Last File Path</b></td><td>"+gPronterPtr.settings.last_file_path+"</td>\n</tr>"
|
||||
pageText=pageText+" <tr>\n <td><b>Last Temperature</b></td><td>"+str(gPronterPtr.settings.last_temperature)+"</td>\n</tr>"
|
||||
pageText=pageText+" <tr>\n <td><b>Preview Extrusion Width</b></td><td>"+str(gPronterPtr.settings.preview_extrusion_width)+"</td>\n</tr>"
|
||||
pageText=pageText+" <tr>\n <td><b>Filename</b></td><td>"+str(gPronterPtr.filename)+"</td></tr></div>"
|
||||
pageText=pageText+PrintFooter()
|
||||
pageText = PrintHeader()+self.name+PrintMenu()
|
||||
pageText = pageText+"<div id='settings'><table>\n<tr><th>setting</th><th>value</th>"
|
||||
pageText = pageText+"<tr>\n <td><b>Build Dimenstions</b></td><td>"+str(gPronterPtr.settings.build_dimensions)+"</td>\n</tr>"
|
||||
pageText = pageText+" <tr>\n <td><b>Last Bed Temp</b></td><td>"+str(gPronterPtr.settings.last_bed_temperature)+"</td>\n</tr>"
|
||||
pageText = pageText+" <tr>\n <td><b>Last File Path</b></td><td>"+gPronterPtr.settings.last_file_path+"</td>\n</tr>"
|
||||
pageText = pageText+" <tr>\n <td><b>Last Temperature</b></td><td>"+str(gPronterPtr.settings.last_temperature)+"</td>\n</tr>"
|
||||
pageText = pageText+" <tr>\n <td><b>Preview Extrusion Width</b></td><td>"+str(gPronterPtr.settings.preview_extrusion_width)+"</td>\n</tr>"
|
||||
pageText = pageText+" <tr>\n <td><b>Filename</b></td><td>"+str(gPronterPtr.filename)+"</td></tr></div>"
|
||||
pageText = pageText+PrintFooter()
|
||||
return pageText
|
||||
index.exposed = True
|
||||
|
||||
class LogPage(object):
|
||||
def __init__(self):
|
||||
self.name="<div id='title'>Pronterface Console</div>"
|
||||
self.name = "<div id='title'>Pronterface Console</div>"
|
||||
|
||||
def index(self):
|
||||
pageText="<html><head><meta http-equiv='refresh' content='"+str(gLogRefresh)+"'></head><body>"
|
||||
pageText = "<html><head><meta http-equiv='refresh' content='"+str(gLogRefresh)+"'></head><body>"
|
||||
pageText+="<div id='status'>"
|
||||
pageText+=gPronterPtr.status.GetStatusText()
|
||||
pageText+="</div>"
|
||||
pageText=pageText+"<div id='console'>"+gWeblog+"</div>"
|
||||
pageText=pageText+"</body></html>"
|
||||
pageText = pageText+"<div id='console'>"+gWeblog+"</div>"
|
||||
pageText = pageText+"</body></html>"
|
||||
return pageText
|
||||
index.exposed = True
|
||||
|
||||
class ConsolePage(object):
|
||||
def __init__(self):
|
||||
self.name="<div id='title'>Pronterface Settings</div>"
|
||||
self.name = "<div id='title'>Pronterface Settings</div>"
|
||||
|
||||
def index(self):
|
||||
pageText=PrintHeader()+self.name+PrintMenu()
|
||||
pageText = PrintHeader()+self.name+PrintMenu()
|
||||
pageText+="<div id='logframe'><iframe src='/logpage' width='100%' height='100%'>iFraming Not Supported?? No log for you.</iframe></div>"
|
||||
pageText+=PrintFooter()
|
||||
return pageText
|
||||
|
@ -129,7 +129,7 @@ class MoveButton(object):
|
|||
def axis(self, *args):
|
||||
if not args:
|
||||
raise cherrypy.HTTPError(400, "No Move Command Provided!")
|
||||
margs=list(args)
|
||||
margs = list(args)
|
||||
axis = margs.pop(0)
|
||||
if(margs and axis == "x"):
|
||||
distance = margs.pop(0)
|
||||
|
@ -154,7 +154,7 @@ class CustomButton(object):
|
|||
def button(self, *args):
|
||||
if not args:
|
||||
raise cherrypy.HTTPError(400, "No Custom Command Provided!")
|
||||
margs=list(args)
|
||||
margs = list(args)
|
||||
command = margs.pop(0)
|
||||
if(command):
|
||||
gPronterPtr.onecmd(command)
|
||||
|
@ -169,7 +169,7 @@ class HomeButton(object):
|
|||
def axis(self, *args):
|
||||
if not args:
|
||||
raise cherrypy.HTTPError(400, "No Axis Provided!")
|
||||
margs=list(args)
|
||||
margs = list(args)
|
||||
taxis = margs.pop(0)
|
||||
if(taxis == "x"):
|
||||
gPronterPtr.onecmd('home X')
|
||||
|
@ -193,31 +193,31 @@ class HomeButton(object):
|
|||
class XMLstatus(object):
|
||||
def index(self):
|
||||
#handle connect push, then reload page
|
||||
txt='<?xml version="1.0"?>\n<pronterface>\n'
|
||||
state="Offline"
|
||||
txt='<?xml version = "1.0"?>\n<pronterface>\n'
|
||||
state = "Offline"
|
||||
if gPronterPtr.statuscheck or gPronterPtr.p.online:
|
||||
state="Idle"
|
||||
state = "Idle"
|
||||
if gPronterPtr.sdprinting:
|
||||
state="SDPrinting"
|
||||
state = "SDPrinting"
|
||||
if gPronterPtr.p.printing:
|
||||
state="Printing"
|
||||
state = "Printing"
|
||||
if gPronterPtr.paused:
|
||||
state="Paused"
|
||||
state = "Paused"
|
||||
|
||||
txt=txt+'<state>'+state+'</state>\n'
|
||||
txt=txt+'<file>'+str(gPronterPtr.filename)+'</file>\n'
|
||||
txt=txt+'<status>'+str(gPronterPtr.status.GetStatusText())+'</status>\n'
|
||||
txt = txt+'<state>'+state+'</state>\n'
|
||||
txt = txt+'<file>'+str(gPronterPtr.filename)+'</file>\n'
|
||||
txt = txt+'<status>'+str(gPronterPtr.status.GetStatusText())+'</status>\n'
|
||||
try:
|
||||
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:
|
||||
txt=txt+'<hotend>NA</hotend>\n'
|
||||
txt = txt+'<hotend>NA</hotend>\n'
|
||||
pass
|
||||
try:
|
||||
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:
|
||||
txt=txt+'<bed>NA</bed>\n'
|
||||
txt = txt+'<bed>NA</bed>\n'
|
||||
pass
|
||||
if gPronterPtr.sdprinting:
|
||||
fractioncomplete = float(gPronterPtr.percentdone/100.0)
|
||||
|
@ -238,7 +238,7 @@ class WebInterface(object):
|
|||
def __init__(self, pface):
|
||||
if (sys.version_info[1] > 6):
|
||||
# 'allow_no_value' wasn't added until 2.7
|
||||
config = ConfigParser.SafeConfigParser(allow_no_value=True)
|
||||
config = ConfigParser.SafeConfigParser(allow_no_value = True)
|
||||
else:
|
||||
config = ConfigParser.SafeConfigParser()
|
||||
config.read(configfile(pface.web_auth_config or 'auth.config'))
|
||||
|
@ -246,7 +246,7 @@ class WebInterface(object):
|
|||
self.pface = pface
|
||||
global gPronterPtr
|
||||
global gWeblog
|
||||
self.name="<div id='title'>Pronterface Web-Interface</div>"
|
||||
self.name = "<div id='title'>Pronterface Web-Interface</div>"
|
||||
gWeblog = ""
|
||||
gPronterPtr = self.pface
|
||||
|
||||
|
@ -266,7 +266,7 @@ class WebInterface(object):
|
|||
custom =CustomButton()
|
||||
|
||||
def index(self):
|
||||
pageText=PrintHeader()+self.name+PrintMenu()
|
||||
pageText = PrintHeader()+self.name+PrintMenu()
|
||||
pageText+="<div id='content'>\n"
|
||||
pageText+="<div id='controls'>\n"
|
||||
pageText+="<ul><li><a href='/connect'>Connect</a></li>\n"
|
||||
|
@ -286,40 +286,40 @@ class WebInterface(object):
|
|||
pageText+="<div id='gui'>\n"
|
||||
pageText+="<div id='control_xy'>"
|
||||
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="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="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="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="106,83,138,107" href="/move/axis/y/.1" alt="Y .1" title="Y .1" />'
|
||||
pageText+='<area shape="rect" coords="110,135,142,159" href="/move/axis/y/-.1" alt="Y -.1" title="Y -.1" />'
|
||||
pageText+='<area shape="rect" coords="81,157,169,181" href="/move/axis/y/-1" alt="Y -1" title="Y -1" />'
|
||||
pageText+='<area shape="rect" coords="69,180,178,206" href="/move/axis/y/-10" alt="Y -10" title="Y -10" />'
|
||||
pageText+='<area shape="rect" coords="60,205,186,231" href="/move/axis/y/-100" alt="Y -100" title="Y -100" />'
|
||||
pageText+='<area shape="rect" coords="11,53,37,179" href="/move/axis/x/-100" alt="X -100" title="X -100" />'
|
||||
pageText+='<area shape="rect" coords="210,59,236,185" href="/move/axis/x/100" alt="X 100" title="X 100" />'
|
||||
pageText+='<area shape="rect" coords="38,60,64,172" href="/move/axis/x/-10" alt="X -10" title="X -10" />'
|
||||
pageText+='<area shape="rect" coords="185,66,211,178" href="/move/axis/x/10" alt="X 10" title="X 10" />'
|
||||
pageText+='<area shape="rect" coords="62,84,83,157" href="/move/axis/x/-1" alt="X -1" title="X -1" />'
|
||||
pageText+='<area shape="rect" coords="163,87,187,160" href="/move/axis/x/1" alt="X 1" title="X 1" />'
|
||||
pageText+='<area shape="rect" coords="82,104,110,139" href="/move/axis/x/-.1" alt="X -.1" title="X -.1" />'
|
||||
pageText+='<area shape="rect" coords="137,105,165,140" href="/move/axis/x/.1" alt="X .1" title="X .1" />'
|
||||
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 = "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 = "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 = "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 = "110, 135, 142, 159" href = "/move/axis/y/-.1" alt = "Y -.1" title = "Y -.1" />'
|
||||
pageText+='<area shape = "rect" coords = "81, 157, 169, 181" href = "/move/axis/y/-1" alt = "Y -1" title = "Y -1" />'
|
||||
pageText+='<area shape = "rect" coords = "69, 180, 178, 206" href = "/move/axis/y/-10" alt = "Y -10" title = "Y -10" />'
|
||||
pageText+='<area shape = "rect" coords = "60, 205, 186, 231" href = "/move/axis/y/-100" alt = "Y -100" title = "Y -100" />'
|
||||
pageText+='<area shape = "rect" coords = "11, 53, 37, 179" href = "/move/axis/x/-100" alt = "X -100" title = "X -100" />'
|
||||
pageText+='<area shape = "rect" coords = "210, 59, 236, 185" href = "/move/axis/x/100" alt = "X 100" title = "X 100" />'
|
||||
pageText+='<area shape = "rect" coords = "38, 60, 64, 172" href = "/move/axis/x/-10" alt = "X -10" title = "X -10" />'
|
||||
pageText+='<area shape = "rect" coords = "185, 66, 211, 178" href = "/move/axis/x/10" alt = "X 10" title = "X 10" />'
|
||||
pageText+='<area shape = "rect" coords = "62, 84, 83, 157" href = "/move/axis/x/-1" alt = "X -1" title = "X -1" />'
|
||||
pageText+='<area shape = "rect" coords = "163, 87, 187, 160" href = "/move/axis/x/1" alt = "X 1" title = "X 1" />'
|
||||
pageText+='<area shape = "rect" coords = "82, 104, 110, 139" href = "/move/axis/x/-.1" alt = "X -.1" title = "X -.1" />'
|
||||
pageText+='<area shape = "rect" coords = "137, 105, 165, 140" href = "/move/axis/x/.1" alt = "X .1" title = "X .1" />'
|
||||
|
||||
pageText+="</map>"
|
||||
pageText+="</div>\n" #endxy
|
||||
pageText+="<div id='control_z'>"
|
||||
pageText+="<img src='/images/control_z.png' usemap='#zmap'/>"
|
||||
pageText+='<map name="zmap">'
|
||||
pageText+='<area shape="rect" coords="4,35,54,64" href="/move/axis/z/10" alt="Z 10" title="Z 10" />'
|
||||
pageText+='<area shape="rect" coords="4,60,54,89" href="/move/axis/z/1" alt="Z 1" title="Z 1" />'
|
||||
pageText+='<area shape="rect" coords="4,87,54,116" href="/move/axis/z/.1" alt="Z .1" title="Z .1" />'
|
||||
pageText+='<area shape="rect" coords="4,121,54,150" href="/move/axis/z/-.1" alt="Z -.1" title="Z -.1" />'
|
||||
pageText+='<area shape="rect" coords="4,147,54,176" href="/move/axis/z/-1" alt="Z -1" title="Z -1" />'
|
||||
pageText+='<area shape="rect" coords="4,173,54,202" href="/move/axis/z/-10" alt="Z -10" title="Z -10" />'
|
||||
pageText+='<map name = "zmap">'
|
||||
pageText+='<area shape = "rect" coords = "4, 35, 54, 64" href = "/move/axis/z/10" alt = "Z 10" title = "Z 10" />'
|
||||
pageText+='<area shape = "rect" coords = "4, 60, 54, 89" href = "/move/axis/z/1" alt = "Z 1" title = "Z 1" />'
|
||||
pageText+='<area shape = "rect" coords = "4, 87, 54, 116" href = "/move/axis/z/.1" alt = "Z .1" title = "Z .1" />'
|
||||
pageText+='<area shape = "rect" coords = "4, 121, 54, 150" href = "/move/axis/z/-.1" alt = "Z -.1" title = "Z -.1" />'
|
||||
pageText+='<area shape = "rect" coords = "4, 147, 54, 176" href = "/move/axis/z/-1" alt = "Z -1" title = "Z -1" />'
|
||||
pageText+='<area shape = "rect" coords = "4, 173, 54, 202" href = "/move/axis/z/-10" alt = "Z -10" title = "Z -10" />'
|
||||
pageText+="</map>"
|
||||
#TODO Map Z Moves
|
||||
pageText+="</div>\n" #endz
|
||||
|
@ -337,17 +337,17 @@ class WebInterface(object):
|
|||
# pageText+="</div>"
|
||||
# pageText+="</div>"
|
||||
|
||||
pageText=pageText+"<div id='file'>File Loaded: <i>"+str(gPronterPtr.filename)+"</i></div>"
|
||||
pageText = pageText+"<div id='file'>File Loaded: <i>"+str(gPronterPtr.filename)+"</i></div>"
|
||||
pageText+="<div id='logframe'><iframe src='/logpage' width='100%' height='100%'>iFraming Not Supported?? No log for you.</iframe></div>"
|
||||
pageText+=PrintFooter()
|
||||
return pageText
|
||||
|
||||
def AddLog(self, log):
|
||||
global gWeblog
|
||||
gWeblog=gWeblog+"</br>"+log
|
||||
gWeblog = gWeblog+"</br>"+log
|
||||
def AppendLog(self, log):
|
||||
global gWeblog
|
||||
gWeblog=re.sub("\n", "</br>", gWeblog)+log
|
||||
gWeblog = re.sub("\n", "</br>", gWeblog)+log
|
||||
index.exposed = True
|
||||
|
||||
class WebInterfaceStub(object):
|
||||
|
@ -372,7 +372,7 @@ def StartWebInterfaceThread(webInterface):
|
|||
'tools.staticfile.filename': imagefile('control_z.png'),
|
||||
}}
|
||||
cherrypy.config.update(configfile(webInterface.pface.web_config or "http.config"))
|
||||
cherrypy.quickstart(webInterface, '/', config=conf)
|
||||
cherrypy.quickstart(webInterface, '/', config = conf)
|
||||
|
||||
if __name__ == '__main__':
|
||||
cherrypy.config.update(configfile("http.config"))
|
||||
|
|
|
@ -41,7 +41,7 @@ class XYButtons(BufferedCanvas):
|
|||
center = (124, 121)
|
||||
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.keypad_bmp = wx.Image(imagefile("arrow_keys.png"),wx.BITMAP_TYPE_PNG).ConvertToBitmap()
|
||||
self.keypad_idx = -1
|
||||
|
@ -181,7 +181,7 @@ class XYButtons(BufferedCanvas):
|
|||
|
||||
self.drawPartialPie(gc, center, r1-inner_ring_radius, r2-inner_ring_radius, a1+fudge, a2-fudge)
|
||||
|
||||
def drawCorner(self, gc, x, y, angle=0.0):
|
||||
def drawCorner(self, gc, x, y, angle = 0.0):
|
||||
w, h = XYButtons.corner_size
|
||||
|
||||
gc.PushState()
|
||||
|
@ -197,7 +197,7 @@ class XYButtons(BufferedCanvas):
|
|||
gc.DrawPath(path)
|
||||
gc.PopState()
|
||||
|
||||
def highlightCorner(self, gc, corner=0):
|
||||
def highlightCorner(self, gc, corner = 0):
|
||||
w, h = XYButtons.corner_size
|
||||
cx, cy = XYButtons.center
|
||||
ww, wh = self.GetSizeTuple()
|
||||
|
@ -229,8 +229,8 @@ class XYButtons(BufferedCanvas):
|
|||
|
||||
if self.enabled:
|
||||
# Brush and pen for grey overlay when mouse hovers over
|
||||
gc.SetPen(wx.Pen(wx.Colour(100,100,100,172), 4))
|
||||
gc.SetBrush(wx.Brush(wx.Colour(0,0,0,128)))
|
||||
gc.SetPen(wx.Pen(wx.Colour(100, 100, 100, 172), 4))
|
||||
gc.SetBrush(wx.Brush(wx.Colour(0, 0,0, 128)))
|
||||
|
||||
if self.concentric != None:
|
||||
if self.concentric < len(XYButtons.concentric_circle_radii):
|
||||
|
@ -246,8 +246,8 @@ class XYButtons(BufferedCanvas):
|
|||
gc.DrawBitmap(self.keypad_bmp, pos[0], pos[1], padw, padh)
|
||||
|
||||
# Draw label overlays
|
||||
gc.SetPen(wx.Pen(wx.Colour(255,255,255,128), 1))
|
||||
gc.SetBrush(wx.Brush(wx.Colour(255,255,255,128+64)))
|
||||
gc.SetPen(wx.Pen(wx.Colour(255, 255, 255, 128), 1))
|
||||
gc.SetBrush(wx.Brush(wx.Colour(255, 255, 255, 128+64)))
|
||||
for idx, kpos in XYButtons.label_overlay_positions.items():
|
||||
if idx != self.concentric:
|
||||
r = kpos[2]
|
||||
|
|
|
@ -32,7 +32,7 @@ class ZButtons(BufferedCanvas):
|
|||
3: None
|
||||
}
|
||||
|
||||
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.range = None
|
||||
self.direction = None
|
||||
|
@ -108,16 +108,16 @@ class ZButtons(BufferedCanvas):
|
|||
|
||||
if self.enabled:
|
||||
# Draw label overlays
|
||||
gc.SetPen(wx.Pen(wx.Colour(255,255,255,128), 1))
|
||||
gc.SetBrush(wx.Brush(wx.Colour(255,255,255,128+64)))
|
||||
gc.SetPen(wx.Pen(wx.Colour(255, 255, 255, 128), 1))
|
||||
gc.SetBrush(wx.Brush(wx.Colour(255, 255, 255, 128+64)))
|
||||
for idx, kpos in ZButtons.label_overlay_positions.items():
|
||||
if kpos and idx != self.range:
|
||||
r = kpos[2]
|
||||
gc.DrawEllipse(ZButtons.center[0]-kpos[0]-r, ZButtons.center[1]-kpos[1]-r, r*2, r*2)
|
||||
|
||||
# Top 'layer' is the mouse-over highlights
|
||||
gc.SetPen(wx.Pen(wx.Colour(100,100,100,172), 4))
|
||||
gc.SetBrush(wx.Brush(wx.Colour(0,0,0,128)))
|
||||
gc.SetPen(wx.Pen(wx.Colour(100, 100, 100, 172), 4))
|
||||
gc.SetBrush(wx.Brush(wx.Colour(0, 0,0, 128)))
|
||||
if self.range != None and self.direction != None:
|
||||
self.highlight(gc, self.range, self.direction)
|
||||
else:
|
||||
|
|
|
@ -13,63 +13,63 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import wx,math
|
||||
import wx, math
|
||||
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):
|
||||
o=stl(None)
|
||||
datal=len(data)
|
||||
datah=len(data[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)
|
||||
datal = len(data)
|
||||
datah = len(data[0])
|
||||
#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
|
||||
for i in zip(range(datal+1)[:-1],range(datal+1)[1:])[:-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],[[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+=[[[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+=[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([[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]])]
|
||||
#print o.facets[-1]
|
||||
pass
|
||||
#print o.facets[-4:]
|
||||
for i in zip(range(datah+1)[:-1],range(datah+1)[1:])[:-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[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+=[[[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+=[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
|
||||
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]])]
|
||||
pass
|
||||
for i in xrange(datah-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+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, 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]])]
|
||||
#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
|
||||
def zimage(name,out):
|
||||
i=wx.Image(name)
|
||||
s=i.GetSize()
|
||||
print len(map(ord,i.GetData()[::3]))
|
||||
b=map(ord,i.GetData()[::3])
|
||||
def zimage(name, out):
|
||||
i = wx.Image(name)
|
||||
s = i.GetSize()
|
||||
print len(map(ord, i.GetData()[::3]))
|
||||
b = map(ord, i.GetData()[::3])
|
||||
data=[]
|
||||
for i in xrange(s[0]):
|
||||
data+=[b[i*s[1]:(i+1)*s[1]]]
|
||||
#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):
|
||||
def __init__(self,size=(400,530)):
|
||||
wx.Frame.__init__(self,None,title="Right-click to load an image",size=size)
|
||||
def __init__(self, size = (400, 530)):
|
||||
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.SetClientSize(size)
|
||||
self.panel=wx.Panel(self,size=size)
|
||||
self.panel = wx.Panel(self, size = size)
|
||||
|
||||
|
||||
"""
|
||||
|
|
468
pronsole.py
468
pronsole.py
File diff suppressed because it is too large
Load Diff
852
pronterface.py
852
pronterface.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue