2012-02-19 23:30:49 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
import __init__
|
|
|
|
|
2012-02-20 17:55:54 +00:00
|
|
|
import wx, os
|
2012-02-19 23:30:49 +00:00
|
|
|
|
2012-02-20 15:44:43 +00:00
|
|
|
from fabmetheus_utilities import archive
|
|
|
|
from fabmetheus_utilities import settings
|
|
|
|
from skeinforge_application.skeinforge_utilities import skeinforge_profile
|
2012-02-19 23:30:49 +00:00
|
|
|
|
2012-02-21 14:27:03 +00:00
|
|
|
from newui import preview3d
|
|
|
|
from newui import sliceProgessPanel
|
|
|
|
|
2012-02-19 23:30:49 +00:00
|
|
|
def main():
|
|
|
|
app = wx.App(False)
|
|
|
|
mainWindow()
|
|
|
|
app.MainLoop()
|
|
|
|
|
|
|
|
class mainWindow(wx.Frame):
|
|
|
|
"Main user interface window"
|
|
|
|
def __init__(self):
|
|
|
|
super(mainWindow, self).__init__(None, title='SkeinPyPy')
|
|
|
|
menubar = wx.MenuBar()
|
|
|
|
fileMenu = wx.Menu()
|
2012-02-20 17:55:54 +00:00
|
|
|
fitem = fileMenu.Append(-1, 'Open Profile...', 'Open Profile...')
|
|
|
|
fitem = fileMenu.Append(-1, 'Save Profile...', 'Save Profile...')
|
2012-02-20 22:27:34 +00:00
|
|
|
self.Bind(wx.EVT_MENU, self.OnSaveProfile, fitem)
|
2012-02-19 23:30:49 +00:00
|
|
|
fitem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')
|
2012-02-20 17:55:54 +00:00
|
|
|
self.Bind(wx.EVT_MENU, self.OnQuit, fitem)
|
2012-02-19 23:30:49 +00:00
|
|
|
menubar.Append(fileMenu, '&File')
|
|
|
|
menubar.Append(wx.Menu(), 'Expert')
|
|
|
|
self.SetMenuBar(menubar)
|
|
|
|
|
2012-02-21 14:27:03 +00:00
|
|
|
self.lastPath = ""
|
2012-02-20 22:27:34 +00:00
|
|
|
self.filename = None
|
|
|
|
self.controlList = []
|
|
|
|
self.plugins = {}
|
2012-02-20 15:44:43 +00:00
|
|
|
for m in skeinforge_profile.getCraftTypePluginModule().getCraftSequence():
|
2012-02-20 22:27:34 +00:00
|
|
|
self.plugins[m] = archive.getModuleWithDirectoryPath(archive.getCraftPluginsDirectoryPath(), m).getNewRepository()
|
|
|
|
settings.getReadRepository(self.plugins[m])
|
2012-02-20 15:44:43 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
skeinPyPySettingInfo = settings.getSkeinPyPyConfigInformation()
|
|
|
|
|
|
|
|
for pluginName in self.plugins.keys():
|
|
|
|
self.plugins[pluginName].preferencesDict = {}
|
|
|
|
for pref in self.plugins[pluginName].preferences:
|
|
|
|
if skeinPyPySettingInfo[pluginName][settings.safeConfigName(pref.name)] == 'save':
|
|
|
|
self.plugins[pluginName].preferencesDict[settings.safeConfigName(pref.name)] = pref
|
|
|
|
|
2012-02-19 23:30:49 +00:00
|
|
|
p = wx.Panel(self)
|
2012-02-20 15:44:43 +00:00
|
|
|
nb = wx.Notebook(p, size=(500,10))
|
2012-02-19 23:30:49 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
configPanel = wx.Panel(nb);
|
|
|
|
nb.AddPage(configPanel, "Print")
|
|
|
|
sizer = wx.GridBagSizer(2, 2)
|
|
|
|
configPanel.SetSizer(sizer)
|
|
|
|
|
|
|
|
self.AddTitle(configPanel, "Accuracy")
|
|
|
|
self.AddSetting(configPanel, "Layer height (mm)", self.plugins['carve'].preferencesDict['Layer_Height_mm'])
|
|
|
|
self.AddTitle(configPanel, "Skirt")
|
|
|
|
self.AddSetting(configPanel, "Enable skirt", self.plugins['skirt'].preferencesDict['Activate_Skirt'])
|
|
|
|
self.AddSetting(configPanel, "Skirt distance (mm)", self.plugins['skirt'].preferencesDict['Gap_over_Perimeter_Width_ratio'])
|
|
|
|
self.AddTitle(configPanel, "Fill")
|
|
|
|
self.AddSetting(configPanel, "Solid layers", self.plugins['fill'].preferencesDict['Solid_Surface_Thickness_layers'])
|
|
|
|
self.AddSetting(configPanel, "Fill Density", self.plugins['fill'].preferencesDict['Infill_Solidity_ratio'])
|
|
|
|
self.AddTitle(configPanel, "Retraction")
|
|
|
|
self.AddSetting(configPanel, "Speed (mm/s)", self.plugins['dimension'].preferencesDict['Extruder_Retraction_Speed_mm/s'])
|
|
|
|
self.AddSetting(configPanel, "Distance (mm)", self.plugins['dimension'].preferencesDict['Retraction_Distance_millimeters'])
|
|
|
|
self.AddSetting(configPanel, "Extra length on start (mm)", self.plugins['dimension'].preferencesDict['Restart_Extra_Distance_millimeters'])
|
2012-02-20 15:44:43 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
configPanel = wx.Panel(nb);
|
|
|
|
nb.AddPage(configPanel, "Machine")
|
2012-02-20 15:44:43 +00:00
|
|
|
sizer = wx.GridBagSizer(2, 2)
|
2012-02-20 22:27:34 +00:00
|
|
|
configPanel.SetSizer(sizer)
|
2012-02-20 17:55:54 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
self.AddTitle(configPanel, "Machine size")
|
|
|
|
self.AddSetting(configPanel, "Width (mm)", settings.IntSpin().getFromValue(10, "machine_width", None, 1000, 205))
|
|
|
|
self.AddSetting(configPanel, "Depth (mm)", settings.IntSpin().getFromValue(10, "machine_depth", None, 1000, 205))
|
|
|
|
self.AddSetting(configPanel, "Height (mm)", settings.IntSpin().getFromValue(10, "machine_height", None, 1000, 200))
|
2012-02-20 15:44:43 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
self.AddTitle(configPanel, "Machine nozzle")
|
|
|
|
self.AddSetting(configPanel, "Nozzle size (mm)", self.plugins['carve'].preferencesDict['Edge_Width_mm'])
|
2012-02-20 17:55:54 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
self.AddTitle(configPanel, "Speed")
|
|
|
|
self.AddSetting(configPanel, "Print speed (mm/s)", self.plugins['speed'].preferencesDict['Feed_Rate_mm/s'])
|
|
|
|
self.AddSetting(configPanel, "Travel speed (mm/s)", self.plugins['speed'].preferencesDict['Travel_Feed_Rate_mm/s'])
|
2012-02-20 15:44:43 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
self.AddTitle(configPanel, "Filament")
|
|
|
|
self.AddSetting(configPanel, "Diameter (mm)", self.plugins['dimension'].preferencesDict['Filament_Diameter_mm'])
|
|
|
|
self.AddSetting(configPanel, "Packing Density", self.plugins['dimension'].preferencesDict['Filament_Packing_Density_ratio'])
|
2012-02-20 15:44:43 +00:00
|
|
|
|
2012-02-19 23:30:49 +00:00
|
|
|
nb.AddPage(wx.Panel(nb), "Start/End-GCode")
|
|
|
|
|
2012-02-20 17:55:54 +00:00
|
|
|
#Preview window, load and slice buttons.
|
|
|
|
self.preview3d = preview3d.myGLCanvas(p)
|
2012-02-19 23:30:49 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
loadButton = wx.Button(p, -1, 'Load STL')
|
|
|
|
sliceButton = wx.Button(p, -1, 'Slice to GCode')
|
2012-02-20 17:55:54 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnLoadSTL, loadButton)
|
2012-02-20 22:27:34 +00:00
|
|
|
self.Bind(wx.EVT_BUTTON, self.OnSlice, sliceButton)
|
2012-02-19 23:30:49 +00:00
|
|
|
|
|
|
|
sizer = wx.GridBagSizer()
|
|
|
|
sizer.Add(nb, (0,0), span=(2,1), flag=wx.EXPAND)
|
2012-02-20 22:27:34 +00:00
|
|
|
sizer.Add(self.preview3d, (0,1), span=(1,3), flag=wx.EXPAND)
|
2012-02-19 23:30:49 +00:00
|
|
|
sizer.Add(loadButton, (1,1))
|
2012-02-20 22:27:34 +00:00
|
|
|
sizer.Add(sliceButton, (1,2))
|
|
|
|
sizer.AddGrowableCol(2)
|
2012-02-19 23:30:49 +00:00
|
|
|
sizer.AddGrowableRow(0)
|
|
|
|
p.SetSizer(sizer)
|
2012-02-21 14:27:03 +00:00
|
|
|
|
|
|
|
self.panel = p
|
|
|
|
self.sizer = sizer
|
|
|
|
self.sizer.SetRows(2)
|
|
|
|
|
2012-02-19 23:30:49 +00:00
|
|
|
self.SetSize((800, 400))
|
|
|
|
self.Centre()
|
|
|
|
self.Show(True)
|
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
def AddTitle(self, panel, name):
|
|
|
|
sizer = panel.GetSizer()
|
|
|
|
title = wx.StaticText(panel, -1, name)
|
|
|
|
title.SetFont(wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
|
|
|
|
sizer.Add(title, (sizer.GetRows(),1), (1,2), flag=wx.EXPAND)
|
|
|
|
sizer.Add(wx.StaticLine(panel), (sizer.GetRows()+1,1), (1,2), flag=wx.EXPAND)
|
|
|
|
sizer.SetRows(sizer.GetRows() + 2)
|
2012-02-20 15:44:43 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
def AddSetting(self, panel, name, setting):
|
2012-02-20 15:44:43 +00:00
|
|
|
sizer = panel.GetSizer()
|
2012-02-20 22:27:34 +00:00
|
|
|
sizer.Add(wx.StaticText(panel, -1, name), (sizer.GetRows(),1), flag=wx.ALIGN_CENTER_VERTICAL)
|
|
|
|
ctrl = None
|
|
|
|
if setting.__class__ is settings.FloatSpin:
|
|
|
|
ctrl = wx.TextCtrl(panel, -1, str(setting.value))
|
|
|
|
if setting.__class__ is settings.IntSpin:
|
|
|
|
ctrl = wx.TextCtrl(panel, -1, str(setting.value))
|
|
|
|
if setting.__class__ is settings.BooleanSetting:
|
|
|
|
ctrl = wx.CheckBox(panel, -1, '')
|
|
|
|
ctrl.SetValue(setting.value)
|
|
|
|
if ctrl == None:
|
|
|
|
print "No WX control for: " + str(setting), str(setting.__class__)
|
|
|
|
else:
|
|
|
|
ctrl.setting = setting
|
|
|
|
self.controlList.append(ctrl)
|
|
|
|
sizer.Add(ctrl, (sizer.GetRows(),2), flag=wx.ALIGN_BOTTOM|wx.EXPAND)
|
2012-02-20 15:44:43 +00:00
|
|
|
sizer.SetRows(sizer.GetRows()+1)
|
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
def OnSaveProfile(self, e):
|
2012-02-21 14:27:03 +00:00
|
|
|
dlg=wx.FileDialog(self, "Select profile file to save", self.lastPath, style=wx.FD_SAVE)
|
2012-02-20 22:27:34 +00:00
|
|
|
dlg.SetWildcard("ini files (*.ini)|*.ini")
|
|
|
|
if dlg.ShowModal() == wx.ID_OK:
|
|
|
|
profileFile = dlg.GetPath()
|
2012-02-21 14:27:03 +00:00
|
|
|
self.lastPath = os.path.split(profileFile)[0]
|
2012-02-20 22:27:34 +00:00
|
|
|
self.updateConfig()
|
|
|
|
settings.saveGlobalConfig(profileFile)
|
2012-02-21 14:27:03 +00:00
|
|
|
dlg.Destroy()
|
2012-02-20 22:27:34 +00:00
|
|
|
|
2012-02-20 17:55:54 +00:00
|
|
|
def OnLoadSTL(self, e):
|
2012-02-21 14:27:03 +00:00
|
|
|
dlg=wx.FileDialog(self, "Open file to print", self.lastPath, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
|
|
|
|
dlg.SetWildcard("OBJ, STL files (*.stl;*.obj)|*.stl;*.obj")
|
2012-02-20 17:55:54 +00:00
|
|
|
if dlg.ShowModal() == wx.ID_OK:
|
|
|
|
self.filename=dlg.GetPath()
|
|
|
|
if not(os.path.exists(self.filename)):
|
|
|
|
return
|
2012-02-21 14:27:03 +00:00
|
|
|
self.lastPath = os.path.split(self.filename)[0]
|
2012-02-20 17:55:54 +00:00
|
|
|
self.preview3d.loadFile(self.filename)
|
2012-02-21 14:27:03 +00:00
|
|
|
dlg.Destroy()
|
2012-02-20 17:55:54 +00:00
|
|
|
|
2012-02-20 22:27:34 +00:00
|
|
|
def OnSlice(self, e):
|
|
|
|
if self.filename == None:
|
|
|
|
return
|
|
|
|
for pluginName in self.plugins.keys():
|
|
|
|
settings.storeRepository(self.plugins[pluginName])
|
|
|
|
settings.saveGlobalConfig(settings.getDefaultConfigPath())
|
2012-02-21 14:27:03 +00:00
|
|
|
#skeinpypy.runSkein([self.filename])
|
|
|
|
spp = sliceProgessPanel.sliceProgessPanel(self.panel, self.filename)
|
|
|
|
self.sizer.Add(spp, (self.sizer.GetRows(),0), span=(1,4), flag=wx.EXPAND)
|
|
|
|
self.sizer.SetRows(self.sizer.GetRows()+1)
|
|
|
|
self.sizer.Layout()
|
2012-02-20 22:27:34 +00:00
|
|
|
|
|
|
|
def updateConfig(self):
|
|
|
|
for ctrl in self.controlList:
|
|
|
|
ctrl.setting.setValueToString(ctrl.GetValue())
|
|
|
|
for pluginName in self.plugins.keys():
|
|
|
|
settings.storeRepository(self.plugins[pluginName])
|
|
|
|
settings.saveGlobalConfig(settings.getDefaultConfigPath())
|
|
|
|
|
2012-02-19 23:30:49 +00:00
|
|
|
def OnQuit(self, e):
|
|
|
|
self.Close()
|
|
|
|
|