#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
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
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():
'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"),
}
}
-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(")", "")
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':
import wx, os, platform, types
import ConfigParser
-from fabmetheus_utilities import settings
-
from newui import configBase
from newui import preview3d
from newui import sliceProgessPanel
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)
"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):
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)
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:
import wx, os, platform, types, webbrowser, threading, time, re\r
import wx.wizard\r
\r
-from fabmetheus_utilities import settings\r
from newui import machineCom\r
+from newui import profile\r
\r
class InfoPage(wx.wizard.WizardPageSimple):\r
def __init__(self, parent, title):\r
\r
def StoreData(self):\r
if self.UltimakerRadio.GetValue():\r
- settings.putPreference('machine_width', '205')\r
- settings.putPreference('machine_depth', '205')\r
- settings.putPreference('machine_height', '200')\r
- settings.putProfileSetting('nozzle_size', '0.4')\r
- settings.putProfileSetting('machine_center_x', '100')\r
- settings.putProfileSetting('machine_center_y', '100')\r
+ profile.putPreference('machine_width', '205')\r
+ profile.putPreference('machine_depth', '205')\r
+ profile.putPreference('machine_height', '200')\r
+ profile.putProfileSetting('nozzle_size', '0.4')\r
+ profile.putProfileSetting('machine_center_x', '100')\r
+ profile.putProfileSetting('machine_center_y', '100')\r
else:\r
- settings.putPreference('machine_width', '80')\r
- settings.putPreference('machine_depth', '80')\r
- settings.putPreference('machine_height', '60')\r
- settings.putProfileSetting('nozzle_size', '0.5')\r
- settings.putProfileSetting('machine_center_x', '40')\r
- settings.putProfileSetting('machine_center_y', '40')\r
+ profile.putPreference('machine_width', '80')\r
+ profile.putPreference('machine_depth', '80')\r
+ profile.putPreference('machine_height', '60')\r
+ profile.putProfileSetting('nozzle_size', '0.5')\r
+ profile.putProfileSetting('machine_center_x', '40')\r
+ profile.putProfileSetting('machine_center_y', '40')\r
+ profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2)\r
\r
class FirmwareUpgradePage(InfoPage):\r
def __init__(self, parent):\r
self.AddText("The better you have calibrated these values, the better your prints\nwill become.");\r
self.AddSeperator()\r
self.AddText("First we need the diameter of your filament:");\r
- self.filamentDiameter = wx.TextCtrl(self, -1, settings.getProfileSetting('filament_diameter', '2.89'))\r
+ self.filamentDiameter = wx.TextCtrl(self, -1, profile.getProfileSetting('filament_diameter'))\r
self.GetSizer().Add(self.filamentDiameter, 0, wx.LEFT, 5)\r
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.");\r
self.AddText("Note: This value can be changed later at any time.");\r
\r
def StoreData(self):\r
- settings.putProfileSetting('filament_diameter', self.filamentDiameter.GetValue())\r
+ profile.putProfileSetting('filament_diameter', self.filamentDiameter.GetValue())\r
\r
class UltimakerCalibrateStepsPerEPage(InfoPage):\r
def __init__(self, parent):\r
p.GetSizer().Add(self.saveLengthButton, 0)\r
self.GetSizer().Add(p, 0, wx.LEFT, 5)\r
self.AddText("This results in the following steps per E:")\r
- self.stepsPerEInput = wx.TextCtrl(self, -1, settings.getPreference('steps_per_e', '865.888'))\r
+ self.stepsPerEInput = wx.TextCtrl(self, -1, profile.getPreference('steps_per_e'))\r
self.GetSizer().Add(self.stepsPerEInput, 0, wx.LEFT, 5)\r
self.AddText("You can repeat these steps to get better calibration.")\r
self.AddSeperator()\r
break\r
\r
def StoreData(self):\r
- settings.putPreference('steps_per_e', self.stepsPerEInput.GetValue())\r
+ profile.putPreference('steps_per_e', self.stepsPerEInput.GetValue())\r
\r
class configWizard(wx.wizard.Wizard):\r
def __init__(self):\r
import wx, os, platform, types, webbrowser
-from fabmetheus_utilities import settings
-
from newui import configBase
from newui import advancedConfig
from newui import preview3d
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()
self.SetMenuBar(menubar)
self.lastPath = ""
- self.filename = settings.getPreference('lastFile', "None")
+ self.filename = profile.getPreference('lastFile')
self.progressPanelList = []
#Preview window
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()
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):
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)
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()
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]
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)
self.Close()
def OnClose(self, e):
- settings.saveGlobalProfile(settings.getDefaultProfilePath())
+ profile.saveGlobalProfile(profile.getDefaultProfilePath())
self.Destroy()
print "Failed to find PyOpenGL: http://pyopengl.sourceforge.net/"\r
hasOpenGLlibs = False\r
\r
-from fabmetheus_utilities import settings\r
+from newui import profile\r
from newui import gcodeInterpreter\r
from newui import util3d\r
\r
+from fabmetheus_utilities import settings\r
from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret\r
from fabmetheus_utilities.vector3 import Vector3\r
\r
self.init = 0\r
self.triangleMesh = None\r
self.gcode = None\r
- self.machineSize = Vector3(float(settings.getPreference('machine_width', '205')), float(settings.getPreference('machine_depth', '205')), float(settings.getPreference('machine_height', '200')))\r
+ self.machineSize = Vector3(float(profile.getPreference('machine_width')), float(profile.getPreference('machine_depth')), float(profile.getPreference('machine_height')))\r
self.machineCenter = Vector3(0, 0, 0)\r
\r
self.toolbar = wx.ToolBar( self, -1 )\r
self.glCanvas.Refresh()\r
\r
def updateWallLineWidth(self, setting):\r
+ #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)\r
self.glCanvas.lineWidth = settings.calculateEdgeWidth(setting)\r
\r
def updateInfillLineWidth(self, setting):\r
- self.glCanvas.infillLineWidth = settings.getProfileSetting('nozzle_size')\r
+ #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)\r
+ self.glCanvas.infillLineWidth = profile.getProfileSetting('nozzle_size')\r
\r
def loadModelFile(self, filename):\r
self.modelFilename = filename\r
scale = 1.0\r
rotate = 0.0\r
try:\r
- scale = float(settings.getProfileSetting('model_scale', '1.0'))\r
- rotate = float(settings.getProfileSetting('model_rotate_base', '0.0')) / 180 * math.pi\r
+ scale = float(profile.getProfileSetting('model_scale'))\r
+ rotate = float(profile.getProfileSetting('model_rotate_base')) / 180 * math.pi\r
except:\r
pass\r
scaleX = scale\r
scaleY = scale\r
scaleZ = scale\r
- if settings.getProfileSetting('flip_x') == 'True':\r
+ if profile.getProfileSetting('flip_x') == 'True':\r
scaleX = -scaleX\r
- if settings.getProfileSetting('flip_y') == 'True':\r
+ if profile.getProfileSetting('flip_y') == 'True':\r
scaleY = -scaleY\r
- if settings.getProfileSetting('flip_z') == 'True':\r
+ if profile.getProfileSetting('flip_z') == 'True':\r
scaleZ = -scaleZ\r
mat00 = math.cos(rotate) * scaleX\r
mat01 =-math.sin(rotate) * scaleY\r
self.modelDisplayList = glGenLists(1);\r
if self.parent.modelDirty:\r
self.parent.modelDirty = False\r
- multiX = int(settings.getProfileSetting('model_multiply_x', '1'))\r
- multiY = int(settings.getProfileSetting('model_multiply_y', '1'))\r
+ multiX = int(profile.getProfileSetting('model_multiply_x'))\r
+ multiY = int(profile.getProfileSetting('model_multiply_y'))\r
modelSize = self.parent.triangleMesh.getCarveCornerMaximum() - self.parent.triangleMesh.getCarveCornerMinimum()\r
glNewList(self.modelDisplayList, GL_COMPILE)\r
glPushMatrix()\r
--- /dev/null
+from __future__ import absolute_import\r
+#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.\r
+import __init__\r
+\r
+import ConfigParser\r
+import os\r
+import traceback\r
+\r
+#Single place to store the defaults, so we have a consistent set of default settings.\r
+profileDefaultSettings = {\r
+ 'layer_height': '0.2',\r
+ 'wall_thickness': '0.8',\r
+ 'solid_layer_thickness': '0.6',\r
+ 'fill_density': '20',\r
+ 'skirt_line_count': '1',\r
+ 'skirt_gap': '6.0',\r
+ 'print_speed': '50',\r
+ 'print_temperature': '0',\r
+ 'support': 'None',\r
+ 'filament_diameter': '2.89',\r
+ 'filament_density': '1.00',\r
+ 'machine_center_x': '100',\r
+ 'machine_center_y': '100',\r
+ 'nozzle_size': '0.4',\r
+ 'retraction_min_travel': '5.0',\r
+ 'retraction_speed': '13.5',\r
+ 'retraction_amount': '0.0',\r
+ 'retraction_extra': '0.0',\r
+ 'travel_speed': '150',\r
+ 'max_z_speed': '1.0',\r
+ 'bottom_layer_speed': '25',\r
+ 'cool_min_layer_time': '10',\r
+ 'model_scale': '1.0',\r
+ 'flip_x': 'False',\r
+ 'flip_y': 'False',\r
+ 'flip_z': 'False',\r
+ 'model_rotate_base': '0',\r
+ 'model_multiply_x': '1',\r
+ 'model_multiply_y': '1',\r
+ 'extra_base_wall_thickness': '0.0',\r
+ 'sequence': 'Loops > Perimeter > Infill',\r
+ 'force_first_layer_sequence': 'True',\r
+ 'infill_type': 'Line',\r
+ 'solid_top': 'True',\r
+ 'fill_overlap': '15',\r
+ 'support_rate': '100',\r
+ 'support_distance': '0.5',\r
+ 'joris': 'False',\r
+}\r
+preferencesDefaultSettings = {\r
+ 'wizardDone': 'False',\r
+ 'lastFile': 'None',\r
+ 'machine_width': '205',\r
+ 'machine_depth': '205',\r
+ 'machine_height': '200',\r
+ 'steps_per_e': '0',\r
+ 'serial_port': 'AUTO',\r
+ 'serial_baud': '250000',\r
+}\r
+\r
+def getDefaultProfilePath():\r
+ return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../current_profile.ini"))\r
+\r
+def loadGlobalProfile(filename):\r
+ "Read a configuration file as global config"\r
+ global globalProfileParser\r
+ globalProfileParser = ConfigParser.ConfigParser()\r
+ globalProfileParser.read(filename)\r
+\r
+def saveGlobalProfile(filename):\r
+ globalProfileParser.write(open(filename, 'w'))\r
+\r
+def getProfileSetting(name):\r
+ if name in profileDefaultSettings:\r
+ default = profileDefaultSettings[name]\r
+ else:\r
+ print "Missing default setting for: '" + name + "'"\r
+ profileDefaultSettings[name] = ''\r
+ default = ''\r
+ \r
+ #Check if we have a configuration file loaded, else load the default.\r
+ if not globals().has_key('globalProfileParser'):\r
+ loadGlobalProfile(getDefaultProfilePath())\r
+ if not globalProfileParser.has_option('profile', name):\r
+ if not globalProfileParser.has_section('profile'):\r
+ globalProfileParser.add_section('profile')\r
+ globalProfileParser.set('profile', name, str(default))\r
+ print name + " not found in profile, so using default: " + str(default)\r
+ return default\r
+ return globalProfileParser.get('profile', name)\r
+\r
+def putProfileSetting(name, value):\r
+ #Check if we have a configuration file loaded, else load the default.\r
+ if not globals().has_key('globalProfileParser'):\r
+ loadGlobalProfile(getDefaultProfilePath())\r
+ if not globalProfileParser.has_section('profile'):\r
+ globalProfileParser.add_section('profile')\r
+ globalProfileParser.set('profile', name, str(value))\r
+\r
+global globalPreferenceParser\r
+globalPreferenceParser = None\r
+\r
+def getPreferencePath():\r
+ return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../preferences.ini"))\r
+\r
+def getPreference(name):\r
+ if name in preferencesDefaultSettings:\r
+ default = preferencesDefaultSettings[name]\r
+ else:\r
+ print "Missing default setting for: '" + name + "'"\r
+ preferencesDefaultSettings[name] = ''\r
+ default = ''\r
+\r
+ global globalPreferenceParser\r
+ if globalPreferenceParser == None:\r
+ globalPreferenceParser = ConfigParser.ConfigParser()\r
+ globalPreferenceParser.read(getPreferencePath())\r
+ if not globalPreferenceParser.has_option('preference', name):\r
+ if not globalPreferenceParser.has_section('preference'):\r
+ globalPreferenceParser.add_section('preference')\r
+ globalPreferenceParser.set('preference', name, str(default))\r
+ print name + " not found in preferences, so using default: " + str(default)\r
+ return default\r
+ return globalPreferenceParser.get('preference', name)\r
+\r
+def putPreference(name, value):\r
+ #Check if we have a configuration file loaded, else load the default.\r
+ global globalPreferenceParser\r
+ if globalPreferenceParser == None:\r
+ globalPreferenceParser = ConfigParser.ConfigParser()\r
+ globalPreferenceParser.read(getPreferencePath())\r
+ if not globalPreferenceParser.has_section('preference'):\r
+ globalPreferenceParser.add_section('preference')\r
+ globalPreferenceParser.set('preference', name, str(value))\r
+ globalPreferenceParser.write(open(getPreferencePath(), 'w'))\r
from __future__ import absolute_import
import __init__
-from fabmetheus_utilities import settings
+from newui import profile
SUCCESS = 0
WARNING = 1
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: