Moved profile read/write functions to newui. Better seperation of Skeinforge and NewUI. Moved all the defaults to profile.py, instead of all over the place.

master
Daid 2012-03-17 12:03:38 +01:00
parent ff7782fa14
commit 2fcd59bfb6
8 changed files with 211 additions and 139 deletions

View File

@ -7,30 +7,30 @@ from __future__ import absolute_import
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
import __init__
import ConfigParser
import os, sys
import types, math
from newui import profile
from fabmetheus_utilities import archive
def DEFSET(setting):
return setting.value
def storedSetting(name):
return lambda setting: getProfileSetting(name, setting.value)
return lambda setting: profile.getProfileSetting(name)
def ifSettingAboveZero(name):
return lambda setting: float(getProfileSetting(name, '0.0')) > 0
return lambda setting: float(profile.getProfileSetting(name)) > 0
def ifSettingIs(name, value, default):
return lambda setting: getProfileSetting(name, default) == value
def ifSettingIs(name, value):
return lambda setting: profile.getProfileSetting(name) == value
def storedPercentSetting(name):
return lambda setting: float(getProfileSetting(name, setting.value * 100)) / 100
return lambda setting: float(profile.getProfileSetting(name)) / 100
def calculateEdgeWidth(setting):
wallThickness = float(getProfileSetting('wall_thickness'))
nozzleSize = float(getProfileSetting('nozzle_size'))
wallThickness = float(profile.getProfileSetting('wall_thickness'))
nozzleSize = float(profile.getProfileSetting('nozzle_size'))
if wallThickness < nozzleSize:
return wallThickness
@ -43,13 +43,13 @@ def calculateEdgeWidth(setting):
return lineWidth
def calculateShells(setting):
return calculateShellsImp(float(getProfileSetting('wall_thickness')))
return calculateShellsImp(float(profile.getProfileSetting('wall_thickness')))
def calculateShellsBase(setting):
return calculateShellsImp(float(getProfileSetting('wall_thickness')) + float(getProfileSetting('extra_base_wall_thickness', '0')))
return calculateShellsImp(float(profile.getProfileSetting('wall_thickness')) + float(profile.getProfileSetting('extra_base_wall_thickness')))
def calculateShellsImp(wallThickness):
nozzleSize = float(getProfileSetting('nozzle_size'))
nozzleSize = float(profile.getProfileSetting('nozzle_size'))
if wallThickness < nozzleSize:
return 0
@ -62,19 +62,19 @@ def calculateShellsImp(wallThickness):
return lineCount - 1
def calculateSolidLayerCount(setting):
layerHeight = float(getProfileSetting('layer_height'))
solidThickness = float(getProfileSetting('solid_layer_thickness'))
layerHeight = float(profile.getProfileSetting('layer_height'))
solidThickness = float(profile.getProfileSetting('solid_layer_thickness'))
ret = int(math.ceil(solidThickness / layerHeight - 0.0001))
return ret
def firstLayerSpeedRatio(setting):
bottomSpeed = float(getProfileSetting('bottom_layer_speed'))
speed = float(getProfileSetting('print_speed'))
bottomSpeed = float(profile.getProfileSetting('bottom_layer_speed'))
speed = float(profile.getProfileSetting('print_speed'))
return bottomSpeed/speed
def calcSupportDistanceRatio(setting):
edgeWidth = calculateEdgeWidth(setting)
distance = float(getProfileSetting('support_distance', '0.5'))
distance = float(profile.getProfileSetting('support_distance'))
return distance / edgeWidth
def getSkeinPyPyProfileInformation():
@ -139,10 +139,10 @@ def getSkeinPyPyProfileInformation():
'Infill_Begin_Rotation_degrees': DEFSET,
'Infill_Begin_Rotation_Repeat_layers': DEFSET,
'Infill_Odd_Layer_Extra_Rotation_degrees': DEFSET,
'Grid_Circular': ifSettingIs('infill_type', 'Grid Circular', 'Line'),
'Grid_Hexagonal': ifSettingIs('infill_type', 'Grid Hexagonal', 'Line'),
'Grid_Rectangular': ifSettingIs('infill_type', 'Grid Rectangular', 'Line'),
'Line': ifSettingIs('infill_type', 'Line', 'Line'),
'Grid_Circular': ifSettingIs('infill_type', 'Grid Circular'),
'Grid_Hexagonal': ifSettingIs('infill_type', 'Grid Hexagonal'),
'Grid_Rectangular': ifSettingIs('infill_type', 'Grid Rectangular'),
'Line': ifSettingIs('infill_type', 'Line'),
'Infill_Perimeter_Overlap_ratio': storedPercentSetting('fill_overlap'),
'Infill_Solidity_ratio': storedPercentSetting('fill_density'),
'Infill_Width': storedSetting("nozzle_size"),
@ -380,69 +380,6 @@ def getSkeinPyPyProfileInformation():
}
}
def loadGlobalProfile(filename):
"Read a configuration file as global config"
global globalProfileParser
globalProfileParser = ConfigParser.ConfigParser()
globalProfileParser.read(filename)
def saveGlobalProfile(filename):
globalProfileParser.write(open(filename, 'w'))
def getProfileSetting(name, default = "ERR", section = 'profile'):
#Check if we have a configuration file loaded, else load the default.
if not globals().has_key('globalProfileParser'):
loadGlobalProfile(getDefaultProfilePath())
if not globalProfileParser.has_option(section, name):
if not globalProfileParser.has_section(section):
globalProfileParser.add_section(section)
globalProfileParser.set(section, name, str(default))
print name + " not found in profile, so using default: " + str(default)
return default
return globalProfileParser.get(section, name)
def putProfileSetting(name, value, section = 'profile'):
#Check if we have a configuration file loaded, else load the default.
if not globals().has_key('globalProfileParser'):
loadGlobalProfile(getDefaultProfilePath())
if not globalProfileParser.has_section(section):
globalProfileParser.add_section(section)
globalProfileParser.set(section, name, str(value))
global globalPreferenceParser
globalPreferenceParser = None
def getPreferencePath():
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../preferences.ini"))
def getPreference(name, default = "ERR"):
global globalPreferenceParser
if globalPreferenceParser == None:
globalPreferenceParser = ConfigParser.ConfigParser()
globalPreferenceParser.read(getPreferencePath())
if not globalPreferenceParser.has_option('preference', name):
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
globalPreferenceParser.set('preference', name, str(default))
print name + " not found in preferences, so using default: " + str(default)
return default
return globalPreferenceParser.get('preference', name)
def putPreference(name, value):
#Check if we have a configuration file loaded, else load the default.
global globalPreferenceParser
if globalPreferenceParser == None:
globalPreferenceParser = ConfigParser.ConfigParser()
globalPreferenceParser.read(getPreferencePath())
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
globalPreferenceParser.set('preference', name, str(value))
globalPreferenceParser.write(open(getPreferencePath(), 'w'))
def getDefaultProfilePath():
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../current_profile.ini"))
def safeConfigName(name):
return name.replace("=", "").replace(":", "").replace(" ", "_").replace("(", "").replace(")", "")
@ -491,10 +428,10 @@ def getAlterationFile(fileName, allowMagicPrefix = True):
if fileName == 'start.gcode':
#For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.
#We also set our steps per E here, if configured.
eSteps = float(getPreference('steps_per_e', '0'))
eSteps = float(profile.getPreference('steps_per_e'))
if eSteps > 0:
prefix += 'M92 E'+str(eSteps)+'\n'
temp = float(getProfileSetting('print_temperature', '0'))
temp = float(profile.getProfileSetting('print_temperature'))
if temp > 0:
prefix += 'M109 S'+str(temp)+'\n'
elif fileName == 'replace.csv':

View File

@ -4,8 +4,6 @@ import __init__
import wx, os, platform, types
import ConfigParser
from fabmetheus_utilities import settings
from newui import configBase
from newui import preview3d
from newui import sliceProgessPanel

View File

@ -3,9 +3,8 @@ import __init__
import wx, os, sys, platform, types
from fabmetheus_utilities import settings
from newui import validators
from newui import profile
def main():
app = wx.App(False)
@ -82,9 +81,9 @@ class configWindowBase(wx.Frame):
"Update the configuration wx controls to show the new configuration settings"
for setting in self.settingControlList:
if setting.type == 'profile':
setting.SetValue(settings.getProfileSetting(setting.configName))
setting.SetValue(profile.getProfileSetting(setting.configName))
else:
setting.SetValue(settings.getPreference(setting.configName))
setting.SetValue(profile.getPreference(setting.configName))
class TitleRow():
def __init__(self, panel, name):
@ -112,18 +111,18 @@ class SettingRow():
self.type = type
self.label = wx.StaticText(panel, -1, label)
getSettingFunc = settings.getPreference
getSettingFunc = profile.getPreference
if self.type == 'profile':
getSettingFunc = settings.getProfileSetting
getSettingFunc = profile.getProfileSetting
if isinstance(defaultValue, types.StringTypes):
self.ctrl = wx.TextCtrl(panel, -1, getSettingFunc(configName, defaultValue))
self.ctrl = wx.TextCtrl(panel, -1, getSettingFunc(configName))
self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange)
elif isinstance(defaultValue, types.BooleanType):
self.ctrl = wx.CheckBox(panel, -1, style=wx.ALIGN_RIGHT)
self.SetValue(getSettingFunc(configName, defaultValue))
self.SetValue(getSettingFunc(configName))
self.ctrl.Bind(wx.EVT_CHECKBOX, self.OnSettingChange)
else:
self.ctrl = wx.ComboBox(panel, -1, getSettingFunc(configName, defaultValue[0]), choices=defaultValue, style=wx.CB_DROPDOWN|wx.CB_READONLY)
self.ctrl = wx.ComboBox(panel, -1, getSettingFunc(configName), choices=defaultValue, style=wx.CB_DROPDOWN|wx.CB_READONLY)
self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange)
sizer.Add(self.label, (x,y), flag=wx.ALIGN_CENTER_VERTICAL)
@ -149,9 +148,9 @@ class SettingRow():
def OnSettingChange(self, e):
if self.type == 'profile':
settings.putProfileSetting(self.configName, self.GetValue())
profile.putProfileSetting(self.configName, self.GetValue())
else:
settings.putPreference(self.configName, self.GetValue())
profile.putPreference(self.configName, self.GetValue())
result = validators.SUCCESS
msgs = []
for validator in self.validators:

View File

@ -4,8 +4,8 @@ import __init__
import wx, os, platform, types, webbrowser, threading, time, re
import wx.wizard
from fabmetheus_utilities import settings
from newui import machineCom
from newui import profile
class InfoPage(wx.wizard.WizardPageSimple):
def __init__(self, parent, title):
@ -94,19 +94,20 @@ class MachineSelectPage(InfoPage):
def StoreData(self):
if self.UltimakerRadio.GetValue():
settings.putPreference('machine_width', '205')
settings.putPreference('machine_depth', '205')
settings.putPreference('machine_height', '200')
settings.putProfileSetting('nozzle_size', '0.4')
settings.putProfileSetting('machine_center_x', '100')
settings.putProfileSetting('machine_center_y', '100')
profile.putPreference('machine_width', '205')
profile.putPreference('machine_depth', '205')
profile.putPreference('machine_height', '200')
profile.putProfileSetting('nozzle_size', '0.4')
profile.putProfileSetting('machine_center_x', '100')
profile.putProfileSetting('machine_center_y', '100')
else:
settings.putPreference('machine_width', '80')
settings.putPreference('machine_depth', '80')
settings.putPreference('machine_height', '60')
settings.putProfileSetting('nozzle_size', '0.5')
settings.putProfileSetting('machine_center_x', '40')
settings.putProfileSetting('machine_center_y', '40')
profile.putPreference('machine_width', '80')
profile.putPreference('machine_depth', '80')
profile.putPreference('machine_height', '60')
profile.putProfileSetting('nozzle_size', '0.5')
profile.putProfileSetting('machine_center_x', '40')
profile.putProfileSetting('machine_center_y', '40')
profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2)
class FirmwareUpgradePage(InfoPage):
def __init__(self, parent):
@ -299,13 +300,13 @@ class UltimakerCalibrationPage(InfoPage):
self.AddText("The better you have calibrated these values, the better your prints\nwill become.");
self.AddSeperator()
self.AddText("First we need the diameter of your filament:");
self.filamentDiameter = wx.TextCtrl(self, -1, settings.getProfileSetting('filament_diameter', '2.89'))
self.filamentDiameter = wx.TextCtrl(self, -1, profile.getProfileSetting('filament_diameter'))
self.GetSizer().Add(self.filamentDiameter, 0, wx.LEFT, 5)
self.AddText("If you do not own digital Calipers that can measure\nat least 2 digits then use 2.89mm.\nWhich is the average diameter of most filament.");
self.AddText("Note: This value can be changed later at any time.");
def StoreData(self):
settings.putProfileSetting('filament_diameter', self.filamentDiameter.GetValue())
profile.putProfileSetting('filament_diameter', self.filamentDiameter.GetValue())
class UltimakerCalibrateStepsPerEPage(InfoPage):
def __init__(self, parent):
@ -325,7 +326,7 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
p.GetSizer().Add(self.saveLengthButton, 0)
self.GetSizer().Add(p, 0, wx.LEFT, 5)
self.AddText("This results in the following steps per E:")
self.stepsPerEInput = wx.TextCtrl(self, -1, settings.getPreference('steps_per_e', '865.888'))
self.stepsPerEInput = wx.TextCtrl(self, -1, profile.getPreference('steps_per_e'))
self.GetSizer().Add(self.stepsPerEInput, 0, wx.LEFT, 5)
self.AddText("You can repeat these steps to get better calibration.")
self.AddSeperator()
@ -393,7 +394,7 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
break
def StoreData(self):
settings.putPreference('steps_per_e', self.stepsPerEInput.GetValue())
profile.putPreference('steps_per_e', self.stepsPerEInput.GetValue())
class configWizard(wx.wizard.Wizard):
def __init__(self):

View File

@ -3,8 +3,6 @@ import __init__
import wx, os, platform, types, webbrowser
from fabmetheus_utilities import settings
from newui import configBase
from newui import advancedConfig
from newui import preview3d
@ -14,14 +12,15 @@ from newui import validators
from newui import preferencesDialog
from newui import configWizard
from newui import machineCom
from newui import profile
def main():
app = wx.App(False)
if settings.getPreference('wizardDone', 'False') == 'False':
if profile.getPreference('wizardDone') == 'False':
if os.name == 'darwin':
wx.MessageBox('The MacOS version of SkeinPyPy is experimental.\nThere are still UI/usability bugs. Check the issue list at:\nhttps://github.com/daid/SkeinPyPy/issues\nfor details.\nPlease report any extra issue you find.', 'MacOS Warning', wx.OK | wx.ICON_INFORMATION)
configWizard.configWizard()
settings.putPreference("wizardDone", "True")
profile.putPreference("wizardDone", "True")
mainWindow()
app.MainLoop()
@ -71,7 +70,7 @@ class mainWindow(configBase.configWindowBase):
self.SetMenuBar(menubar)
self.lastPath = ""
self.filename = settings.getPreference('lastFile', "None")
self.filename = profile.getPreference('lastFile')
self.progressPanelList = []
#Preview window
@ -223,7 +222,7 @@ class mainWindow(configBase.configWindowBase):
if dlg.ShowModal() == wx.ID_OK:
profileFile = dlg.GetPath()
self.lastPath = os.path.split(profileFile)[0]
settings.loadGlobalProfile(profileFile)
profile.loadGlobalProfile(profileFile)
self.updateProfileToControls()
dlg.Destroy()
@ -233,7 +232,7 @@ class mainWindow(configBase.configWindowBase):
if dlg.ShowModal() == wx.ID_OK:
profileFile = dlg.GetPath()
self.lastPath = os.path.split(profileFile)[0]
settings.saveGlobalProfile(profileFile)
profile.saveGlobalProfile(profileFile)
dlg.Destroy()
def OnPreferences(self, e):
@ -242,7 +241,7 @@ class mainWindow(configBase.configWindowBase):
prefDialog.Show(True)
def OnDefaultMarlinFirmware(self, e):
machineCom.InstallFirmware(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../firmware/default.hex"), settings.getPreference('serial_port', 'AUTO'))
machineCom.InstallFirmware(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../firmware/default.hex"), profile.getPreference('serial_port'))
def OnCustomFirmware(self, e):
dlg=wx.FileDialog(self, "Open firmware to upload", self.lastPath, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
@ -252,7 +251,7 @@ class mainWindow(configBase.configWindowBase):
if not(os.path.exists(filename)):
return
#For some reason my Ubuntu 10.10 crashes here.
machineCom.InstallFirmware(filename, settings.getPreference('serial_port', 'AUTO'))
machineCom.InstallFirmware(filename, profile.getPreference('serial_port'))
def OnFirstRunWizard(self, e):
configWizard.configWizard()
@ -263,7 +262,7 @@ class mainWindow(configBase.configWindowBase):
dlg.SetWildcard("STL files (*.stl)|*.stl")
if dlg.ShowModal() == wx.ID_OK:
self.filename=dlg.GetPath()
settings.putPreference('lastFile', self.filename)
profile.putPreference('lastFile', self.filename)
if not(os.path.exists(self.filename)):
return
self.lastPath = os.path.split(self.filename)[0]
@ -273,7 +272,7 @@ class mainWindow(configBase.configWindowBase):
def OnSlice(self, e):
if self.filename == None:
return
settings.saveGlobalProfile(settings.getDefaultProfilePath())
profile.saveGlobalProfile(profile.getDefaultProfilePath())
#Create a progress panel and add it to the window. The progress panel will start the Skein operation.
spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filename)
@ -308,5 +307,5 @@ class mainWindow(configBase.configWindowBase):
self.Close()
def OnClose(self, e):
settings.saveGlobalProfile(settings.getDefaultProfilePath())
profile.saveGlobalProfile(profile.getDefaultProfilePath())
self.Destroy()

View File

@ -14,10 +14,11 @@ except:
print "Failed to find PyOpenGL: http://pyopengl.sourceforge.net/"
hasOpenGLlibs = False
from fabmetheus_utilities import settings
from newui import profile
from newui import gcodeInterpreter
from newui import util3d
from fabmetheus_utilities import settings
from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
from fabmetheus_utilities.vector3 import Vector3
@ -32,7 +33,7 @@ class previewPanel(wx.Panel):
self.init = 0
self.triangleMesh = None
self.gcode = None
self.machineSize = Vector3(float(settings.getPreference('machine_width', '205')), float(settings.getPreference('machine_depth', '205')), float(settings.getPreference('machine_height', '200')))
self.machineSize = Vector3(float(profile.getPreference('machine_width')), float(profile.getPreference('machine_depth')), float(profile.getPreference('machine_height')))
self.machineCenter = Vector3(0, 0, 0)
self.toolbar = wx.ToolBar( self, -1 )
@ -93,10 +94,12 @@ class previewPanel(wx.Panel):
self.glCanvas.Refresh()
def updateWallLineWidth(self, setting):
#TODO: this shouldn't be needed, you can calculate the line width from the E values combined with the steps_per_E and the filament diameter (reverse volumatric)
self.glCanvas.lineWidth = settings.calculateEdgeWidth(setting)
def updateInfillLineWidth(self, setting):
self.glCanvas.infillLineWidth = settings.getProfileSetting('nozzle_size')
#TODO: this shouldn't be needed, you can calculate the line width from the E values combined with the steps_per_E and the filament diameter (reverse volumatric)
self.glCanvas.infillLineWidth = profile.getProfileSetting('nozzle_size')
def loadModelFile(self, filename):
self.modelFilename = filename
@ -158,18 +161,18 @@ class previewPanel(wx.Panel):
scale = 1.0
rotate = 0.0
try:
scale = float(settings.getProfileSetting('model_scale', '1.0'))
rotate = float(settings.getProfileSetting('model_rotate_base', '0.0')) / 180 * math.pi
scale = float(profile.getProfileSetting('model_scale'))
rotate = float(profile.getProfileSetting('model_rotate_base')) / 180 * math.pi
except:
pass
scaleX = scale
scaleY = scale
scaleZ = scale
if settings.getProfileSetting('flip_x') == 'True':
if profile.getProfileSetting('flip_x') == 'True':
scaleX = -scaleX
if settings.getProfileSetting('flip_y') == 'True':
if profile.getProfileSetting('flip_y') == 'True':
scaleY = -scaleY
if settings.getProfileSetting('flip_z') == 'True':
if profile.getProfileSetting('flip_z') == 'True':
scaleZ = -scaleZ
mat00 = math.cos(rotate) * scaleX
mat01 =-math.sin(rotate) * scaleY
@ -381,8 +384,8 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
self.modelDisplayList = glGenLists(1);
if self.parent.modelDirty:
self.parent.modelDirty = False
multiX = int(settings.getProfileSetting('model_multiply_x', '1'))
multiY = int(settings.getProfileSetting('model_multiply_y', '1'))
multiX = int(profile.getProfileSetting('model_multiply_x'))
multiY = int(profile.getProfileSetting('model_multiply_y'))
modelSize = self.parent.triangleMesh.getCarveCornerMaximum() - self.parent.triangleMesh.getCarveCornerMinimum()
glNewList(self.modelDisplayList, GL_COMPILE)
glPushMatrix()

135
SkeinPyPy/newui/profile.py Normal file
View File

@ -0,0 +1,135 @@
from __future__ import absolute_import
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
import __init__
import ConfigParser
import os
import traceback
#Single place to store the defaults, so we have a consistent set of default settings.
profileDefaultSettings = {
'layer_height': '0.2',
'wall_thickness': '0.8',
'solid_layer_thickness': '0.6',
'fill_density': '20',
'skirt_line_count': '1',
'skirt_gap': '6.0',
'print_speed': '50',
'print_temperature': '0',
'support': 'None',
'filament_diameter': '2.89',
'filament_density': '1.00',
'machine_center_x': '100',
'machine_center_y': '100',
'nozzle_size': '0.4',
'retraction_min_travel': '5.0',
'retraction_speed': '13.5',
'retraction_amount': '0.0',
'retraction_extra': '0.0',
'travel_speed': '150',
'max_z_speed': '1.0',
'bottom_layer_speed': '25',
'cool_min_layer_time': '10',
'model_scale': '1.0',
'flip_x': 'False',
'flip_y': 'False',
'flip_z': 'False',
'model_rotate_base': '0',
'model_multiply_x': '1',
'model_multiply_y': '1',
'extra_base_wall_thickness': '0.0',
'sequence': 'Loops > Perimeter > Infill',
'force_first_layer_sequence': 'True',
'infill_type': 'Line',
'solid_top': 'True',
'fill_overlap': '15',
'support_rate': '100',
'support_distance': '0.5',
'joris': 'False',
}
preferencesDefaultSettings = {
'wizardDone': 'False',
'lastFile': 'None',
'machine_width': '205',
'machine_depth': '205',
'machine_height': '200',
'steps_per_e': '0',
'serial_port': 'AUTO',
'serial_baud': '250000',
}
def getDefaultProfilePath():
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../current_profile.ini"))
def loadGlobalProfile(filename):
"Read a configuration file as global config"
global globalProfileParser
globalProfileParser = ConfigParser.ConfigParser()
globalProfileParser.read(filename)
def saveGlobalProfile(filename):
globalProfileParser.write(open(filename, 'w'))
def getProfileSetting(name):
if name in profileDefaultSettings:
default = profileDefaultSettings[name]
else:
print "Missing default setting for: '" + name + "'"
profileDefaultSettings[name] = ''
default = ''
#Check if we have a configuration file loaded, else load the default.
if not globals().has_key('globalProfileParser'):
loadGlobalProfile(getDefaultProfilePath())
if not globalProfileParser.has_option('profile', name):
if not globalProfileParser.has_section('profile'):
globalProfileParser.add_section('profile')
globalProfileParser.set('profile', name, str(default))
print name + " not found in profile, so using default: " + str(default)
return default
return globalProfileParser.get('profile', name)
def putProfileSetting(name, value):
#Check if we have a configuration file loaded, else load the default.
if not globals().has_key('globalProfileParser'):
loadGlobalProfile(getDefaultProfilePath())
if not globalProfileParser.has_section('profile'):
globalProfileParser.add_section('profile')
globalProfileParser.set('profile', name, str(value))
global globalPreferenceParser
globalPreferenceParser = None
def getPreferencePath():
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../preferences.ini"))
def getPreference(name):
if name in preferencesDefaultSettings:
default = preferencesDefaultSettings[name]
else:
print "Missing default setting for: '" + name + "'"
preferencesDefaultSettings[name] = ''
default = ''
global globalPreferenceParser
if globalPreferenceParser == None:
globalPreferenceParser = ConfigParser.ConfigParser()
globalPreferenceParser.read(getPreferencePath())
if not globalPreferenceParser.has_option('preference', name):
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
globalPreferenceParser.set('preference', name, str(default))
print name + " not found in preferences, so using default: " + str(default)
return default
return globalPreferenceParser.get('preference', name)
def putPreference(name, value):
#Check if we have a configuration file loaded, else load the default.
global globalPreferenceParser
if globalPreferenceParser == None:
globalPreferenceParser = ConfigParser.ConfigParser()
globalPreferenceParser.read(getPreferencePath())
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
globalPreferenceParser.set('preference', name, str(value))
globalPreferenceParser.write(open(getPreferencePath(), 'w'))

View File

@ -1,7 +1,7 @@
from __future__ import absolute_import
import __init__
from fabmetheus_utilities import settings
from newui import profile
SUCCESS = 0
WARNING = 1
@ -68,7 +68,7 @@ class wallThicknessValidator():
def validate(self):
try:
wallThickness = float(self.setting.GetValue())
nozzleSize = float(settings.getProfileSetting('nozzle_size'))
nozzleSize = float(profile.getProfileSetting('nozzle_size'))
if wallThickness <= nozzleSize * 0.5:
return ERROR, 'Trying to print walls thinner then the half of your nozzle size, this will not produce anything usable'
if wallThickness <= nozzleSize * 0.85: