Renamed "config" to "profile"
This commit is contained in:
parent
5bcb8035e4
commit
7183ac0d4a
2 changed files with 35 additions and 32 deletions
|
@ -12,7 +12,7 @@ import os, sys
|
||||||
|
|
||||||
from fabmetheus_utilities import archive
|
from fabmetheus_utilities import archive
|
||||||
|
|
||||||
def getSkeinPyPyConfigInformation():
|
def getSkeinPyPyProfileInformation():
|
||||||
return {
|
return {
|
||||||
'carve': {
|
'carve': {
|
||||||
'Add_Layer_Template_to_SVG': 'ignore',
|
'Add_Layer_Template_to_SVG': 'ignore',
|
||||||
|
@ -305,17 +305,17 @@ def getSkeinPyPyConfigInformation():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def loadGlobalConfig(filename):
|
def loadGlobalProfile(filename):
|
||||||
"Read a configuration file as global config"
|
"Read a configuration file as global config"
|
||||||
global globalConfigParser
|
global globalProfileParser
|
||||||
globalConfigParser = ConfigParser.ConfigParser()
|
globalProfileParser = ConfigParser.ConfigParser()
|
||||||
globalConfigParser.read(filename)
|
globalProfileParser.read(filename)
|
||||||
|
|
||||||
def saveGlobalConfig(filename):
|
def saveGlobalProfile(filename):
|
||||||
globalConfigParser.write(open(filename, 'w'))
|
globalProfileParser.write(open(filename, 'w'))
|
||||||
|
|
||||||
def getDefaultConfigPath():
|
def getDefaultProfilePath():
|
||||||
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../current_config.ini"))
|
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../current_profile.ini"))
|
||||||
|
|
||||||
def safeConfigName(name):
|
def safeConfigName(name):
|
||||||
return name.replace("=", "").replace(":", "").replace(" ", "_").replace("(", "").replace(")", "")
|
return name.replace("=", "").replace(":", "").replace(" ", "_").replace("(", "").replace(")", "")
|
||||||
|
@ -324,10 +324,10 @@ def getReadRepository(repository):
|
||||||
"Read the configuration for this 'repository'"
|
"Read the configuration for this 'repository'"
|
||||||
|
|
||||||
#Check if we have a configuration file loaded, else load the default.
|
#Check if we have a configuration file loaded, else load the default.
|
||||||
if not globals().has_key('globalConfigParser'):
|
if not globals().has_key('globalProfileParser'):
|
||||||
loadGlobalConfig(getDefaultConfigPath())
|
loadGlobalProfile(getDefaultProfilePath())
|
||||||
|
|
||||||
info = getSkeinPyPyConfigInformation()
|
info = getSkeinPyPyProfileInformation()
|
||||||
if not info.has_key(repository.name):
|
if not info.has_key(repository.name):
|
||||||
print "Warning: Plugin: " + repository.name + " missing from SkeinPyPy info"
|
print "Warning: Plugin: " + repository.name + " missing from SkeinPyPy info"
|
||||||
return repository
|
return repository
|
||||||
|
@ -348,29 +348,29 @@ def getReadRepository(repository):
|
||||||
#Load this setting from another value.
|
#Load this setting from another value.
|
||||||
if info[name][0:4] == "use:":
|
if info[name][0:4] == "use:":
|
||||||
i = info[name][4:].split(':')
|
i = info[name][4:].split(':')
|
||||||
p.setValueToString(globalConfigParser.get(i[0], i[1]))
|
p.setValueToString(globalProfileParser.get(i[0], i[1]))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p.setValueToString(globalConfigParser.get(repository.name, name))
|
p.setValueToString(globalProfileParser.get(repository.name, name))
|
||||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||||
#Value not in configuration, add it.
|
#Value not in configuration, add it.
|
||||||
try:
|
try:
|
||||||
globalConfigParser.add_section(repository.name)
|
globalProfileParser.add_section(repository.name)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
globalConfigParser.set(repository.name, name, str(p.value))
|
globalProfileParser.set(repository.name, name, str(p.value))
|
||||||
#saveGlobalConfig(getDefaultConfigPath())
|
#saveGlobalProfile(getDefaultProfilePath())
|
||||||
#print "============" + str(p) + "|" + p.name + "|" + str(p.value) + "|" + str(type(p.value))
|
#print "============" + str(p) + "|" + p.name + "|" + str(p.value) + "|" + str(type(p.value))
|
||||||
return repository
|
return repository
|
||||||
|
|
||||||
def storeRepository(repository):
|
def storeRepository(repository):
|
||||||
"Store the configuration for this 'repository'"
|
"Store the configuration for this 'repository'"
|
||||||
#Check if we have a configuration file loaded, else load the default.
|
#Check if we have a configuration file loaded, else load the default.
|
||||||
if not globals().has_key('globalConfigParser'):
|
if not globals().has_key('globalProfileParser'):
|
||||||
loadGlobalConfig(getDefaultConfigPath())
|
loadGlobalProfile(getDefaultProfilePath())
|
||||||
|
|
||||||
info = getSkeinPyPyConfigInformation()
|
info = getSkeinPyPyProfileInformation()
|
||||||
if not info.has_key(repository.name):
|
if not info.has_key(repository.name):
|
||||||
print "Warning: Plugin: " + repository.name + " missing from SkeinPyPy info"
|
print "Warning: Plugin: " + repository.name + " missing from SkeinPyPy info"
|
||||||
return repository
|
return repository
|
||||||
|
@ -387,10 +387,10 @@ def storeRepository(repository):
|
||||||
|
|
||||||
if info[name] == "save":
|
if info[name] == "save":
|
||||||
try:
|
try:
|
||||||
globalConfigParser.add_section(repository.name)
|
globalProfileParser.add_section(repository.name)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
globalConfigParser.set(repository.name, name, str(p.value))
|
globalProfileParser.set(repository.name, name, str(p.value))
|
||||||
return repository
|
return repository
|
||||||
|
|
||||||
def printProgress(layerIndex, procedureName):
|
def printProgress(layerIndex, procedureName):
|
||||||
|
|
|
@ -43,7 +43,7 @@ class mainWindow(wx.Frame):
|
||||||
self.plugins[m] = archive.getModuleWithDirectoryPath(archive.getCraftPluginsDirectoryPath(), m).getNewRepository()
|
self.plugins[m] = archive.getModuleWithDirectoryPath(archive.getCraftPluginsDirectoryPath(), m).getNewRepository()
|
||||||
settings.getReadRepository(self.plugins[m])
|
settings.getReadRepository(self.plugins[m])
|
||||||
|
|
||||||
skeinPyPySettingInfo = settings.getSkeinPyPyConfigInformation()
|
skeinPyPySettingInfo = settings.getSkeinPyPyProfileInformation()
|
||||||
|
|
||||||
for pluginName in self.plugins.keys():
|
for pluginName in self.plugins.keys():
|
||||||
self.plugins[pluginName].preferencesDict = {}
|
self.plugins[pluginName].preferencesDict = {}
|
||||||
|
@ -67,6 +67,9 @@ class mainWindow(wx.Frame):
|
||||||
self.AddTitle(configPanel, "Skirt")
|
self.AddTitle(configPanel, "Skirt")
|
||||||
self.AddSetting(configPanel, "Line count", self.plugins['skirt'].preferencesDict['Skirt_line_count'])
|
self.AddSetting(configPanel, "Line count", self.plugins['skirt'].preferencesDict['Skirt_line_count'])
|
||||||
self.AddSetting(configPanel, "Start distance (mm)", self.plugins['skirt'].preferencesDict['Gap_Width_mm'])
|
self.AddSetting(configPanel, "Start distance (mm)", self.plugins['skirt'].preferencesDict['Gap_Width_mm'])
|
||||||
|
self.AddTitle(configPanel, "Cool")
|
||||||
|
#self.AddSetting(configPanel, "Cool type", self.plugins['cool'].preferencesDict['Cool_Type'])
|
||||||
|
self.AddSetting(configPanel, "Minimal layer time", self.plugins['cool'].preferencesDict['Minimum_Layer_Time_seconds'])
|
||||||
self.AddTitle(configPanel, "Retraction")
|
self.AddTitle(configPanel, "Retraction")
|
||||||
self.AddSetting(configPanel, "Speed (mm/s)", self.plugins['dimension'].preferencesDict['Extruder_Retraction_Speed_mm/s'])
|
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, "Distance (mm)", self.plugins['dimension'].preferencesDict['Retraction_Distance_millimeters'])
|
||||||
|
@ -161,8 +164,8 @@ class mainWindow(wx.Frame):
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
profileFile = dlg.GetPath()
|
profileFile = dlg.GetPath()
|
||||||
self.lastPath = os.path.split(profileFile)[0]
|
self.lastPath = os.path.split(profileFile)[0]
|
||||||
settings.loadGlobalConfig(profileFile)
|
settings.loadGlobalProfile(profileFile)
|
||||||
self.updateConfigToControls()
|
self.updateProfileToControls()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
def OnSaveProfile(self, e):
|
def OnSaveProfile(self, e):
|
||||||
|
@ -171,8 +174,8 @@ class mainWindow(wx.Frame):
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
profileFile = dlg.GetPath()
|
profileFile = dlg.GetPath()
|
||||||
self.lastPath = os.path.split(profileFile)[0]
|
self.lastPath = os.path.split(profileFile)[0]
|
||||||
settings.saveGlobalConfig(profileFile)
|
settings.saveGlobalProfile(profileFile)
|
||||||
self.updateConfigFromControls()
|
self.updateProfileFromControls()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
def OnLoadSTL(self, e):
|
def OnLoadSTL(self, e):
|
||||||
|
@ -189,7 +192,7 @@ class mainWindow(wx.Frame):
|
||||||
def OnSlice(self, e):
|
def OnSlice(self, e):
|
||||||
if self.filename == None:
|
if self.filename == None:
|
||||||
return
|
return
|
||||||
self.updateConfigFromControls()
|
self.updateProfileFromControls()
|
||||||
|
|
||||||
#Create a progress panel and add it to the window. The progress panel will start the Skein operation.
|
#Create a progress panel and add it to the window. The progress panel will start the Skein operation.
|
||||||
spp = sliceProgessPanel.sliceProgessPanel(self, self.panel, self.filename)
|
spp = sliceProgessPanel.sliceProgessPanel(self, self.panel, self.filename)
|
||||||
|
@ -214,24 +217,24 @@ class mainWindow(wx.Frame):
|
||||||
i += 1
|
i += 1
|
||||||
self.sizer.Layout()
|
self.sizer.Layout()
|
||||||
|
|
||||||
def updateConfigToControls(self):
|
def updateProfileToControls(self):
|
||||||
"Update the configuration wx controls to show the new configuration settings"
|
"Update the configuration wx controls to show the new configuration settings"
|
||||||
for pluginName in self.plugins.keys():
|
for pluginName in self.plugins.keys():
|
||||||
settings.getReadRepository(self.plugins[pluginName])
|
settings.getReadRepository(self.plugins[pluginName])
|
||||||
settings.saveGlobalConfig(settings.getDefaultConfigPath())
|
settings.saveGlobalProfile(settings.getDefaultProfilePath())
|
||||||
for ctrl in self.controlList:
|
for ctrl in self.controlList:
|
||||||
if ctrl.setting.__class__ is settings.BooleanSetting:
|
if ctrl.setting.__class__ is settings.BooleanSetting:
|
||||||
ctrl.SetValue(ctrl.setting.value)
|
ctrl.SetValue(ctrl.setting.value)
|
||||||
else:
|
else:
|
||||||
ctrl.SetValue(str(ctrl.setting.value))
|
ctrl.SetValue(str(ctrl.setting.value))
|
||||||
|
|
||||||
def updateConfigFromControls(self):
|
def updateProfileFromControls(self):
|
||||||
"Update the configuration settings with values from the wx controls"
|
"Update the configuration settings with values from the wx controls"
|
||||||
for ctrl in self.controlList:
|
for ctrl in self.controlList:
|
||||||
ctrl.setting.setValueToString(ctrl.GetValue())
|
ctrl.setting.setValueToString(ctrl.GetValue())
|
||||||
for pluginName in self.plugins.keys():
|
for pluginName in self.plugins.keys():
|
||||||
settings.storeRepository(self.plugins[pluginName])
|
settings.storeRepository(self.plugins[pluginName])
|
||||||
settings.saveGlobalConfig(settings.getDefaultConfigPath())
|
settings.saveGlobalProfile(settings.getDefaultProfilePath())
|
||||||
|
|
||||||
def OnQuit(self, e):
|
def OnQuit(self, e):
|
||||||
self.Close()
|
self.Close()
|
||||||
|
|
Loading…
Reference in a new issue