reformated plater.py

master
Václav 'Ax' Hůla 2012-01-02 15:53:12 +01:00
parent b631c3ba85
commit 95aaa81b3b
1 changed files with 233 additions and 232 deletions

View File

@ -1,9 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
import wx,time,random,threading,os,math import wx
import stltool import time
import random
import threading
import os
import math
import sys import sys
import stltool
glview = False glview = False
if "-nogl" not in sys.argv: if "-nogl" not in sys.argv:
@ -17,6 +21,7 @@ if "-nogl" not in sys.argv:
def evalme(s): def evalme(s):
return eval(s[s.find("(") + 1:s.find(")")]) return eval(s[s.find("(") + 1:s.find(")")])
class stlwrap: class stlwrap:
def __init__(self, obj, name=None): def __init__(self, obj, name=None):
self.obj = obj self.obj = obj
@ -63,7 +68,6 @@ class showstl(wx.Window):
dc.SelectObject(wx.NullBitmap) dc.SelectObject(wx.NullBitmap)
m.bitmap.SetMask(wx.Mask(m.bitmap, wx.Colour(0, 0, 0, 255))) m.bitmap.SetMask(wx.Mask(m.bitmap, wx.Colour(0, 0, 0, 255)))
def move_shape(self, delta): def move_shape(self, delta):
"""moves shape (selected in l, which is list ListBox of shapes) """moves shape (selected in l, which is list ListBox of shapes)
by an offset specified in tuple delta. by an offset specified in tuple delta.
@ -213,6 +217,7 @@ class showstl(wx.Window):
#print time.time()-t #print time.time()-t
#s.export() #s.export()
class stlwin(wx.Frame): class stlwin(wx.Frame):
def __init__(self, size=(800, 580), callback=None, parent=None): def __init__(self, size=(800, 580), callback=None, parent=None):
wx.Frame.__init__(self, parent, title="Plate building tool", size=size) wx.Frame.__init__(self, parent, title="Plate building tool", size=size)
@ -295,7 +300,6 @@ class stlwin(wx.Frame):
self.models[i].offsets[1] += centreoffset[1] self.models[i].offsets[1] += centreoffset[1]
self.Refresh() self.Refresh()
def clear(self, event): def clear(self, event):
result = wx.MessageBox('Are you sure you want to clear the grid? All unsaved changes will be lost.', 'Clear the grid?', result = wx.MessageBox('Are you sure you want to clear the grid? All unsaved changes will be lost.', 'Clear the grid?',
wx.YES_NO | wx.ICON_QUESTION) wx.YES_NO | wx.ICON_QUESTION)
@ -328,7 +332,6 @@ class stlwin(wx.Frame):
self.Refresh() self.Refresh()
def done(self, event, cb): def done(self, event, cb):
import os,time
try: try:
os.mkdir("tempstl") os.mkdir("tempstl")
except: except:
@ -339,7 +342,6 @@ class stlwin(wx.Frame):
cb(name) cb(name)
self.Destroy() self.Destroy()
def export(self, event): 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;)") dlg.SetWildcard("STL files (;*.stl;)")
@ -462,4 +464,3 @@ if __name__ == '__main__':
main = stlwin() main = stlwin()
main.Show() main.Show()
app.MainLoop() app.MainLoop()