chiark / gitweb /
Merge branch 'master' into SteamEngine
authordaid303 <daid303@gmail.com>
Thu, 21 Mar 2013 08:43:23 +0000 (09:43 +0100)
committerdaid303 <daid303@gmail.com>
Thu, 21 Mar 2013 08:43:23 +0000 (09:43 +0100)
16 files changed:
Cura/cura.py
Cura/gui/configBase.py
Cura/gui/expertConfig.py
Cura/gui/mainWindow.py
Cura/gui/preferencesDialog.py
Cura/gui/projectPlanner.py
Cura/gui/simpleMode.py
Cura/gui/sliceProgressPanel.py
Cura/resources/images/UltimakerRobot.png
Cura/slice/__main__.py
Cura/util/gcodeInterpreter.py
Cura/util/mesh.py
Cura/util/meshLoader.py
Cura/util/profile.py
Cura/util/sliceRun.py
Cura/util/validators.py

index 8474a661fdded4430d4b03b069f7bb71a55d4de7..3c07d642c44815fbbce9c5106e88ae208a5750ad 100644 (file)
@@ -54,10 +54,13 @@ def main():
                help="Slice the given files instead of opening them in Cura")
        (options, args) = parser.parse_args()
 
+       profile.loadPreferences(profile.getPreferencePath())
        if options.profile is not None:
-               profile.loadGlobalProfileFromString(options.profile)
-       if options.profileini is not None:
-               profile.loadGlobalProfile(options.profileini)
+               profile.loadProfileFromString(options.profile)
+       elif options.profileini is not None:
+               profile.loadProfile(options.profileini)
+       else:
+               profile.loadProfile(profile.getDefaultProfilePath())
 
        if options.printfile is not None:
                from Cura.gui import printWindow
index 43c5a784621d7db6f49540358b98a558595a8f1b..6b20cbe6331ec2dd7d74bd9a670e800951b508d1 100644 (file)
@@ -90,9 +90,9 @@ class configPanelBase(wx.Panel):
        def UpdatePopup(self, setting):
                if self.popup.setting == setting:
                        if setting.validationMsg != '':
-                               self.popup.text.SetLabel(setting.validationMsg + '\n\n' + setting.helpText)
+                               self.popup.text.SetLabel(setting.validationMsg + '\n\n' + setting.setting.getTooltip())
                        else:
-                               self.popup.text.SetLabel(setting.helpText)
+                               self.popup.text.SetLabel(setting.setting.getTooltip())
                        self.popup.text.Wrap(350)
                        self.popup.Fit()
                        x, y = setting.ctrl.ClientToScreenXY(0, 0)
@@ -107,10 +107,7 @@ class configPanelBase(wx.Panel):
        def updateProfileToControls(self):
                "Update the configuration wx controls to show the new configuration settings"
                for setting in self.settingControlList:
-                       if setting.type == 'profile':
-                               setting.SetValue(profile.getProfileSetting(setting.configName))
-                       else:
-                               setting.SetValue(profile.getPreference(setting.configName))
+                       setting.SetValue(setting.setting.getValue())
                self.Update()
 
        def getLabelColumnWidth(self, panel):
@@ -132,69 +129,56 @@ class TitleRow():
                "Add a title row to the configuration panel"
                sizer = panel.GetSizer()
                x = sizer.GetRows()
-               self.title = wx.StaticText(panel, -1, name)
+               self.title = wx.StaticText(panel, -1, name.replace('&', '&&'))
                self.title.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
                sizer.Add(self.title, (x,0), (1,3), flag=wx.EXPAND|wx.TOP|wx.LEFT, border=10)
                sizer.Add(wx.StaticLine(panel), (x+1,0), (1,3), flag=wx.EXPAND|wx.LEFT,border=10)
                sizer.SetRows(x + 2)
 
 class SettingRow():
-       def __init__(self, panel, label, configName, defaultValue = '', helpText = 'Help: TODO', type = 'profile'):
+       def __init__(self, panel, configName, valueOverride = None):
                "Add a setting to the configuration panel"
                sizer = panel.GetSizer()
                x = sizer.GetRows()
                y = 0
                flag = 0
-               
-               self.validators = []
+
+               self.setting = profile.settingsDictionary[configName]
                self.validationMsg = ''
-               self.helpText = helpText
-               self.configName = configName
                self.panel = panel
-               self.type = type
 
-               self.label = wx.lib.stattext.GenStaticText(panel, -1, label)
+               self.label = wx.lib.stattext.GenStaticText(panel, -1, self.setting.getLabel())
                self.label.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
                self.label.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseExit)
 
-               getSettingFunc = profile.getPreference
-               if self.type == 'profile':
-                       getSettingFunc = profile.getProfileSetting
-               if isinstance(defaultValue, types.StringTypes):
-                       self.ctrl = wx.TextCtrl(panel, -1, getSettingFunc(configName))
-                       self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange)
-                       flag = wx.EXPAND
-               elif isinstance(defaultValue, types.FloatType):
+               if self.setting.getType() is types.FloatType and False:
                        digits = 0
                        while 1 / pow(10, digits) > defaultValue:
                                digits += 1
                        self.ctrl = floatspin.FloatSpin(panel, -1, value=float(getSettingFunc(configName)), increment=defaultValue, digits=digits, min_val=0.0)
                        self.ctrl.Bind(floatspin.EVT_FLOATSPIN, self.OnSettingChange)
                        flag = wx.EXPAND
-               elif isinstance(defaultValue, types.BooleanType):
+               elif self.setting.getType() is types.BooleanType:
                        self.ctrl = wx.CheckBox(panel, -1, style=wx.ALIGN_RIGHT)
-                       self.SetValue(getSettingFunc(configName))
+                       self.SetValue(self.setting.getValue())
                        self.ctrl.Bind(wx.EVT_CHECKBOX, self.OnSettingChange)
-               elif isinstance(defaultValue, wx.Colour):
+               elif self.setting.getType() is wx.Colour:
                        self.ctrl = wx.ColourPickerCtrl(panel, -1)
-                       self.SetValue(getSettingFunc(configName))
+                       self.SetValue(self.setting.getValue())
                        self.ctrl.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnSettingChange)
-               else:
-                       self.ctrl = wx.ComboBox(panel, -1, getSettingFunc(configName), choices=defaultValue, style=wx.CB_DROPDOWN|wx.CB_READONLY)
+               elif type(self.setting.getType()) is list or valueOverride is not None:
+                       if valueOverride is not None:
+                               self.ctrl = wx.ComboBox(panel, -1, self.setting.getValue(), choices=valueOverride, style=wx.CB_DROPDOWN|wx.CB_READONLY)
+                       else:
+                               self.ctrl = wx.ComboBox(panel, -1, self.setting.getValue(), choices=self.setting.getType(), style=wx.CB_DROPDOWN|wx.CB_READONLY)
                        self.ctrl.Bind(wx.EVT_COMBOBOX, self.OnSettingChange)
                        self.ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnMouseExit)
                        flag = wx.EXPAND
+               else:
+                       self.ctrl = wx.TextCtrl(panel, -1, self.setting.getValue())
+                       self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange)
+                       flag = wx.EXPAND
 
-               # Set the minimum size of control to something other than the humungous default
-               minSize = self.ctrl.GetMinSize()
-               
-               ##if platform.system() == "Darwin":
-               ##      # Under MacOS, it appears that the minSize is used for the actual size, so give the field a bit more room...
-               ##      minSize[0] = 150
-               ##else:
-               ##      minSize[0] = 50
-               ##self.ctrl.SetMinSize(minSize)
-               
                sizer.Add(self.label, (x,y), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=10)
                sizer.Add(self.ctrl, (x,y+1), flag=wx.ALIGN_BOTTOM|flag)
                sizer.SetRows(x+1)
@@ -218,20 +202,9 @@ class SettingRow():
                e.Skip()
 
        def OnSettingChange(self, e):
-               if self.type == 'profile':
-                       profile.putProfileSetting(self.configName, self.GetValue())
-               else:
-                       profile.putPreference(self.configName, self.GetValue())
-               result = validators.SUCCESS
-               msgs = []
-               for validator in self.validators:
-                       res, err = validator.validate()
-                       if res == validators.ERROR:
-                               result = res
-                       elif res == validators.WARNING and result != validators.ERROR:
-                               result = res
-                       if res != validators.SUCCESS:
-                               msgs.append(err)
+               self.setting.setValue(self.GetValue())
+               result, msg = self.setting.validate()
+
                ctrl = self.ctrl
                if isinstance(ctrl, floatspin.FloatSpin):
                        ctrl = ctrl.GetTextCtrl()
@@ -243,7 +216,7 @@ class SettingRow():
                        ctrl.SetBackgroundColour(self.defaultBGColour)
                ctrl.Refresh()
 
-               self.validationMsg = '\n'.join(msgs)
+               self.validationMsg = msg
                self.panel.main.UpdatePopup(self)
 
        def GetValue(self):
index b8ef30459def1b70d3239551550e07f8883990b0..903dbdff5575754c020e4be2419887555eafc15d 100644 (file)
@@ -3,10 +3,24 @@ from __future__ import absolute_import
 import wx
 
 from Cura.gui import configBase
-from Cura.util import validators
+from Cura.util import profile
 
 class expertConfigWindow(wx.Frame):
        "Expert configuration window"
+       def _addSettingsToPanels(self, category, left, right):
+               count = len(profile.getSubCategoriesFor(category)) + len(profile.getSettingsForCategory(category))
+
+               p = left
+               n = 0
+               for title in profile.getSubCategoriesFor(category):
+                       n += 1 + len(profile.getSettingsForCategory(category, title))
+                       if n > count / 2:
+                               p = right
+                       configBase.TitleRow(p, title)
+                       for s in profile.getSettingsForCategory(category, title):
+                               if s.checkConditions():
+                                       configBase.SettingRow(p, s.getName())
+
        def __init__(self):
                super(expertConfigWindow, self).__init__(None, title='Expert config', style=wx.DEFAULT_DIALOG_STYLE)
 
@@ -14,58 +28,8 @@ class expertConfigWindow(wx.Frame):
                self.panel = configBase.configPanelBase(self)
 
                left, right, main = self.panel.CreateConfigPanel(self)
+               self._addSettingsToPanels('expert', left, right)
                
-               configBase.TitleRow(left, "Accuracy")
-               c = configBase.SettingRow(left, "Extra Wall thickness for bottom/top (mm)", 'extra_base_wall_thickness', '0.0', 'Additional wall thickness of the bottom and top layers.')
-               validators.validFloat(c, 0.0)
-               
-               configBase.TitleRow(left, "Cool")
-               c = configBase.SettingRow(left, "Minimum feedrate (mm/s)", 'cool_min_feedrate', '5', 'The minimal layer time can cause the print to slow down so much it starts to ooze. The minimal feedrate protects against this. Even if a print gets slown down it will never be slower then this minimal feedrate.')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(left, "Fan on layer number", 'fan_layer', '0', 'The layer at which the fan is turned on. The first layer is layer 0. The first layer can stick better if you turn on the fan on, on the 2nd layer.')
-               validators.validInt(c, 0)
-               c = configBase.SettingRow(left, "Fan speed min (%)", 'fan_speed', '100', 'When the fan is turned on, it is enabled at this speed setting. If cool slows down the layer, the fan is adjusted between the min and max speed. Minimal fan speed is used if the layer is not slowed down due to cooling.')
-               validators.validInt(c, 0, 100)
-               c = configBase.SettingRow(left, "Fan speed max (%)", 'fan_speed_max', '100', 'When the fan is turned on, it is enabled at this speed setting. If cool slows down the layer, the fan is adjusted between the min and max speed. Maximal fan speed is used if the layer is slowed down due to cooling by more then 200%.')
-               validators.validInt(c, 0, 100)
-
-               configBase.TitleRow(left, "Raft (if enabled)")
-               c = configBase.SettingRow(left, "Extra margin (mm)", 'raft_margin', '3.0', 'If the raft is enabled, this is the extra raft area around the object which is also rafted. Increasing this margin will create a stronger raft.')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(left, "Base material amount (%)", 'raft_base_material_amount', '100', 'The base layer is the first layer put down as a raft. This layer has thick strong lines and is put firmly on the bed to prevent warping. This setting adjust the amount of material used for the base layer.')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(left, "Interface material amount (%)", 'raft_interface_material_amount', '100', 'The interface layer is a weak thin layer between the base layer and the printed object. It is designed to has little material to make it easy to break the base off the printed object. This setting adjusts the amount of material used for the interface layer.')
-               validators.validFloat(c, 0.0)
-
-               configBase.TitleRow(left, "Support")
-               c = configBase.SettingRow(left, "Material amount (%)", 'support_rate', '100', 'Amount of material used for support, less material gives a weaker support structure which is easier to remove.')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(left, "Distance from object (mm)", 'support_distance', '0.5', 'Distance between the support structure and the object. Empty gap in which no support structure is printed.')
-               validators.validFloat(c, 0.0)
-
-               configBase.TitleRow(right, "Infill")
-               c = configBase.SettingRow(right, "Infill pattern", 'infill_type', ['Line', 'Grid Circular', 'Grid Hexagonal', 'Grid Rectangular'], 'Pattern of the none-solid infill. Line is default, but grids can provide a strong print.')
-               c = configBase.SettingRow(right, "Solid infill top", 'solid_top', True, 'Create a solid top surface, if set to false the top is filled with the fill percentage. Useful for cups/vases.')
-               c = configBase.SettingRow(right, "Infill overlap (%)", 'fill_overlap', '15', 'Amount of overlap between the infill and the walls. There is a slight overlap with the walls and the infill so the walls connect firmly to the infill.')
-               validators.validFloat(c, 0.0)
-
-               configBase.TitleRow(right, "Bridge")
-               c = configBase.SettingRow(right, "Bridge speed (%)", 'bridge_speed', '100', 'Speed at which layers with bridges are printed, compared to normal printing speed.')
-               validators.validFloat(c, 0.0)
-               
-               configBase.TitleRow(right, "Sequence")
-               c = configBase.SettingRow(right, "Print order sequence", 'sequence', ['Loops > Perimeter > Infill', 'Loops > Infill > Perimeter', 'Infill > Loops > Perimeter', 'Infill > Perimeter > Loops', 'Perimeter > Infill > Loops', 'Perimeter > Loops > Infill'], 'Sequence of printing. The perimeter is the outer print edge, the loops are the insides of the walls, and the infill is the insides.');
-               c = configBase.SettingRow(right, "Force first layer sequence", 'force_first_layer_sequence', True, 'This setting forces the order of the first layer to be \'Perimeter > Loops > Infill\'')
-
-               configBase.TitleRow(right, "Joris")
-               c = configBase.SettingRow(right, "Joris the outer edge", 'joris', False, '[Joris] is a code name for smoothing out the Z move of the outer edge. This will create a steady Z increase over the whole print. It is intended to be used with a single walled wall thickness to make cups/vases.')
-
-               configBase.TitleRow(right, "Retraction")
-               c = configBase.SettingRow(right, "Retract on jumps only", 'retract_on_jumps_only', True, 'Only retract when we are making a move that is over a hole in the model, else retract on every move. This effects print quality in different ways.')
-
-               configBase.TitleRow(right, "Hop")
-               c = configBase.SettingRow(right, "Enable hop on move", 'hop_on_move', False, 'When moving from print position to print position, raise the printer head 0.2mm so it does not knock off the print (experimental).')
-
                main.Fit()
                self.Fit()
 
index 29b22fb35ee029a6cbf98079f424933013e946a5..678964797cd47f542dbadc431a899172e5a6fed2 100644 (file)
@@ -28,7 +28,7 @@ from Cura.util import meshLoader
 
 class mainWindow(wx.Frame):
        def __init__(self):
-               super(mainWindow, self).__init__(None, title='Cura - ' + version.getVersion())
+               super(mainWindow, self).__init__(None, title='Cura Steam Engine BETA - ' + version.getVersion())
 
                self.extruderCount = int(profile.getPreference('extruder_amount'))
 
@@ -322,7 +322,7 @@ class mainWindow(wx.Frame):
                isSimple = profile.getPreference('startMode') == 'Simple'
                if isSimple:
                        #save the current profile so we can put it back latter
-                       oldProfile = profile.getGlobalProfileString()
+                       oldProfile = profile.getProfileString()
                        self.simpleSettingsPanel.setupSlice()
                #Create a progress panel and add it to the window. The progress panel will start the Skein operation.
                spp = sliceProgressPanel.sliceProgressPanel(self, self, self.filelist)
@@ -334,7 +334,7 @@ class mainWindow(wx.Frame):
                        self.SetSize(newSize)
                self.progressPanelList.append(spp)
                if isSimple:
-                       profile.loadGlobalProfileFromString(oldProfile)
+                       profile.loadProfileFromString(oldProfile)
 
        def OnPrint(self, e):
                if len(self.filelist) < 1:
@@ -372,7 +372,7 @@ class mainWindow(wx.Frame):
                self.profileFileHistory.Save(self.config)
                self.config.Flush()
                # Load Profile  
-               profile.loadGlobalProfile(path)
+               profile.loadProfile(path)
                self.updateProfileToControls()
 
        def addToProfileMRU(self, file):
@@ -401,7 +401,7 @@ class mainWindow(wx.Frame):
                dlg.SetWildcard("ini files (*.ini)|*.ini")
                if dlg.ShowModal() == wx.ID_OK:
                        profileFile = dlg.GetPath()
-                       profile.loadGlobalProfile(profileFile)
+                       profile.loadProfile(profileFile)
                        self.updateProfileToControls()
 
                        # Update the Profile MRU
@@ -417,7 +417,7 @@ class mainWindow(wx.Frame):
                        hasProfile = False
                        for line in f:
                                if line.startswith(';CURA_PROFILE_STRING:'):
-                                       profile.loadGlobalProfileFromString(line[line.find(':')+1:].strip())
+                                       profile.loadProfileFromString(line[line.find(':')+1:].strip())
                                        hasProfile = True
                        if hasProfile:
                                self.updateProfileToControls()
@@ -430,7 +430,7 @@ class mainWindow(wx.Frame):
                dlg.SetWildcard("ini files (*.ini)|*.ini")
                if dlg.ShowModal() == wx.ID_OK:
                        profileFile = dlg.GetPath()
-                       profile.saveGlobalProfile(profileFile)
+                       profile.saveProfile(profileFile)
                dlg.Destroy()
 
        def OnResetProfile(self, e):
@@ -438,7 +438,7 @@ class mainWindow(wx.Frame):
                result = dlg.ShowModal() == wx.ID_YES
                dlg.Destroy()
                if result:
-                       profile.resetGlobalProfile()
+                       profile.resetProfile()
                        self.updateProfileToControls()
 
        def OnBatchRun(self, e):
@@ -459,7 +459,7 @@ class mainWindow(wx.Frame):
 
        def OnCustomFirmware(self, e):
                if profile.getPreference('machine_type') == 'ultimaker':
-                       wx.MessageBox('Warning: Installing a custom firmware does not garantee that you machine will function correctly, and could damage your machine.', 'Firmware update', wx.OK | wx.ICON_EXCLAMATION)
+                       wx.MessageBox('Warning: Installing a custom firmware does not guarantee that you machine will function correctly, and could damage your machine.', 'Firmware update', wx.OK | wx.ICON_EXCLAMATION)
                dlg=wx.FileDialog(self, "Open firmware to upload", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
                dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX")
                if dlg.ShowModal() == wx.ID_OK:
@@ -505,7 +505,7 @@ class mainWindow(wx.Frame):
                        wx.MessageBox('You are running the latest version of Cura!', 'Awesome!', wx.ICON_INFORMATION)
 
        def OnClose(self, e):
-               profile.saveGlobalProfile(profile.getDefaultProfilePath())
+               profile.saveProfile(profile.getDefaultProfilePath())
 
                # Save the window position, size & state from the preferences file
                profile.putPreference('window_maximized', self.IsMaximized())
@@ -532,6 +532,20 @@ class mainWindow(wx.Frame):
 
 class normalSettingsPanel(configBase.configPanelBase):
        "Main user interface window"
+       def _addSettingsToPanels(self, category, left, right):
+               count = len(profile.getSubCategoriesFor(category)) + len(profile.getSettingsForCategory(category))
+
+               p = left
+               n = 0
+               for title in profile.getSubCategoriesFor(category):
+                       n += 1 + len(profile.getSettingsForCategory(category, title))
+                       if n > count / 2:
+                               p = right
+                       configBase.TitleRow(p, title)
+                       for s in profile.getSettingsForCategory(category, title):
+                               if s.checkConditions():
+                                       configBase.SettingRow(p, s.getName())
+
        def __init__(self, parent):
                super(normalSettingsPanel, self).__init__(parent)
 
@@ -541,120 +555,11 @@ class normalSettingsPanel(configBase.configPanelBase):
                self.GetSizer().Add(self.nb, 1, wx.EXPAND)
 
                (left, right, self.printPanel) = self.CreateDynamicConfigTab(self.nb, 'Basic')
-
-               configBase.TitleRow(left, "Quality")
-               c = configBase.SettingRow(left, "Layer height (mm)", 'layer_height', '0.2', 'Layer height in millimeters.\n0.2 is a good value for quick prints.\n0.1 gives high quality prints.')
-               validators.validFloat(c, 0.0001)
-               validators.warningAbove(c, lambda : (float(profile.getProfileSetting('nozzle_size')) * 80.0 / 100.0), "Thicker layers then %.2fmm (80%% nozzle size) usually give bad results and are not recommended.")
-               c = configBase.SettingRow(left, "Wall thickness (mm)", 'wall_thickness', '0.8', 'Thickness of the walls.\nThis is used in combination with the nozzle size to define the number\nof perimeter lines and the thickness of those perimeter lines.')
-               validators.validFloat(c, 0.0001)
-               validators.wallThicknessValidator(c)
-               c = configBase.SettingRow(left, "Enable retraction", 'retraction_enable', False, 'Retract the filament when the nozzle is moving over a none-printed area. Details about the retraction can be configured in the advanced tab.')
-
-               configBase.TitleRow(left, "Fill")
-               c = configBase.SettingRow(left, "Bottom/Top thickness (mm)", 'solid_layer_thickness', '0.6', 'This controls the thickness of the bottom and top layers, the amount of solid layers put down is calculated by the layer thickness and this value.\nHaving this value a multiply of the layer thickness makes sense. And keep it near your wall thickness to make an evenly strong part.')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(left, "Fill Density (%)", 'fill_density', '20', 'This controls how densily filled the insides of your print will be. For a solid part use 100%, for an empty part use 0%. A value around 20% is usually enough')
-               validators.validFloat(c, 0.0, 100.0)
-
-               configBase.TitleRow(right, "Speed && Temperature")
-               c = configBase.SettingRow(right, "Print speed (mm/s)", 'print_speed', '50', 'Speed at which printing happens. A well adjusted Ultimaker can reach 150mm/s, but for good quality prints you want to print slower. Printing speed depends on a lot of factors. So you will be experimenting with optimal settings for this.')
-               validators.validFloat(c, 1.0)
-               validators.warningAbove(c, 150.0, "It is highly unlikely that your machine can achieve a printing speed above 150mm/s")
-               validators.printSpeedValidator(c)
-
-               #configBase.TitleRow(right, "Temperature")
-               c = configBase.SettingRow(right, "Printing temperature", 'print_temperature', '0', 'Temperature used for printing. Set at 0 to pre-heat yourself')
-               validators.validFloat(c, 0.0, 340.0)
-               validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
-               if int(profile.getPreference('extruder_amount')) > 1:
-                       c = configBase.SettingRow(right, "2nd nozzle temperature", 'print_temperature2', '0', 'Temperature used for printing with the 2nd nozzle. Set at 0 to use the same temperature as for nozzle 1')
-                       validators.validFloat(c, 0.0, 340.0)
-                       validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
-               if int(profile.getPreference('extruder_amount')) > 2:
-                       c = configBase.SettingRow(right, "3th nozzle temperature", 'print_temperature3', '0', 'Temperature used for printing with the 3th nozzle. Set at 0 to use the same temperature as for nozzle 1')
-                       validators.validFloat(c, 0.0, 340.0)
-                       validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
-               if int(profile.getPreference('extruder_amount')) > 3:
-                       c = configBase.SettingRow(right, "4th nozzle temperature", 'print_temperature4', '0', 'Temperature used for printing with the 4th nozzle. Set at 0 to use the same temperature as for nozzle 1')
-                       validators.validFloat(c, 0.0, 340.0)
-                       validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
-               if profile.getPreference('has_heated_bed') == 'True':
-                       c = configBase.SettingRow(right, "Bed temperature", 'print_bed_temperature', '0', 'Temperature used for the heated printer bed. Set at 0 to pre-heat yourself')
-                       validators.validFloat(c, 0.0, 340.0)
-
-               configBase.TitleRow(right, "Support structure")
-               c = configBase.SettingRow(right, "Support type", 'support', ['None', 'Exterior Only', 'Everywhere'], 'Type of support structure build.\n"Exterior only" is the most commonly used support setting.\n\nNone does not do any support.\nExterior only only creates support where the support structure will touch the build platform.\nEverywhere creates support even on the insides of the model.')
-               c = configBase.SettingRow(right, "Add raft", 'enable_raft', False, 'A raft is a few layers of lines below the bottom of the object. It prevents warping. Full raft settings can be found in the expert settings.\nFor PLA this is usually not required. But if you print with ABS it is almost required.')
-               if int(profile.getPreference('extruder_amount')) > 1:
-                       c = configBase.SettingRow(right, "Support dual extrusion", 'support_dual_extrusion', False, 'Print the support material with the 2nd extruder in a dual extrusion setup. The primary extruder will be used for normal material, while the second extruder is used to print support material.')
-
-               configBase.TitleRow(right, "Filament")
-               c = configBase.SettingRow(right, "Diameter (mm)", 'filament_diameter', '2.89', 'Diameter of your filament, as accurately as possible.\nIf you cannot measure this value you will have to calibrate it, a higher number means less extrusion, a smaller number generates more extrusion.')
-               validators.validFloat(c, 1.0)
-               validators.warningAbove(c, 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
-               if int(profile.getPreference('extruder_amount')) > 1:
-                       c = configBase.SettingRow(right, "Diameter (mm)", 'filament_diameter2', '2.89', 'Diameter of your filament for the 2nd nozzle, as accurately as possible.\nIf you cannot measure this value you will have to calibrate it, a higher number means less extrusion, a smaller number generates more extrusion. Use 0 to use the same diameter as for nozzle 1.')
-                       validators.validFloat(c, 0.0)
-                       validators.warningAbove(c, 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
-               if int(profile.getPreference('extruder_amount')) > 2:
-                       c = configBase.SettingRow(right, "Diameter (mm)", 'filament_diameter3', '2.89', 'Diameter of your filament for the 3th nozzle, as accurately as possible.\nIf you cannot measure this value you will have to calibrate it, a higher number means less extrusion, a smaller number generates more extrusion. Use 0 to use the same diameter as for nozzle 1.')
-                       validators.validFloat(c, 0.0)
-                       validators.warningAbove(c, 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
-               if int(profile.getPreference('extruder_amount')) > 3:
-                       c = configBase.SettingRow(right, "Diameter (mm)", 'filament_diameter4', '2.89', 'Diameter of your filament for the 4th nozzle, as accurately as possible.\nIf you cannot measure this value you will have to calibrate it, a higher number means less extrusion, a smaller number generates more extrusion. Use 0 to use the same diameter as for nozzle 1.')
-                       validators.validFloat(c, 0.0)
-                       validators.warningAbove(c, 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
-               c = configBase.SettingRow(right, "Packing Density", 'filament_density', '1.00', 'Packing density of your filament. This should be 1.00 for PLA and 0.85 for ABS')
-               validators.validFloat(c, 0.5, 1.5)
-
+               self._addSettingsToPanels('basic', left, right)
                self.SizeLabelWidths(left, right)
                
                (left, right, self.advancedPanel) = self.CreateDynamicConfigTab(self.nb, 'Advanced')
-               
-               configBase.TitleRow(left, "Machine size")
-               c = configBase.SettingRow(left, "Nozzle size (mm)", 'nozzle_size', '0.4', 'The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings.')
-               validators.validFloat(c, 0.1, 10.0)
-
-               configBase.TitleRow(left, "Skirt")
-               c = configBase.SettingRow(left, "Line count", 'skirt_line_count', '1', 'The skirt is a line drawn around the object at the first layer. This helps to prime your extruder, and to see if the object fits on your platform.\nSetting this to 0 will disable the skirt. Multiple skirt lines can help priming your extruder better for small objects.')
-               validators.validInt(c, 0, 10)
-               c = configBase.SettingRow(left, "Start distance (mm)", 'skirt_gap', '6.0', 'The distance between the skirt and the first layer.\nThis is the minimal distance, multiple skirt lines will be put outwards from this distance.')
-               validators.validFloat(c, 0.0)
-
-               configBase.TitleRow(left, "Retraction")
-               c = configBase.SettingRow(left, "Minimum travel (mm)", 'retraction_min_travel', '5.0', 'Minimum amount of travel needed for a retraction to happen at all. To make sure you do not get a lot of retractions in a small area')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(left, "Speed (mm/s)", 'retraction_speed', '40.0', 'Speed at which the filament is retracted, a higher retraction speed works better. But a very high retraction speed can lead to filament grinding.')
-               validators.validFloat(c, 0.1)
-               c = configBase.SettingRow(left, "Distance (mm)", 'retraction_amount', '0.0', 'Amount of retraction, set at 0 for no retraction at all. A value of 2.0mm seems to generate good results.')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(left, "Extra length on start (mm)", 'retraction_extra', '0.0', 'Extra extrusion amount when restarting after a retraction, to better "Prime" your extruder after retraction.')
-               validators.validFloat(c, 0.0)
-
-               configBase.TitleRow(right, "Speed")
-               c = configBase.SettingRow(right, "Travel speed (mm/s)", 'travel_speed', '150', 'Speed at which travel moves are done, a high quality build Ultimaker can reach speeds of 250mm/s. But some machines might miss steps then.')
-               validators.validFloat(c, 1.0)
-               validators.warningAbove(c, 300.0, "It is highly unlikely that your machine can achieve a travel speed above 300mm/s")
-               c = configBase.SettingRow(right, "Max Z speed (mm/s)", 'max_z_speed', '1.0', 'Speed at which Z moves are done. When you Z axis is properly lubercated you can increase this for less Z blob.')
-               validators.validFloat(c, 0.5)
-               c = configBase.SettingRow(right, "Bottom layer speed (mm/s)", 'bottom_layer_speed', '25', 'Print speed for the bottom layer, you want to print the first layer slower so it sticks better to the printer bed.')
-               validators.validFloat(c, 0.0)
-
-               configBase.TitleRow(right, "Cool")
-               c = configBase.SettingRow(right, "Minimal layer time (sec)", 'cool_min_layer_time', '10', 'Minimum time spend in a layer, gives the layer time to cool down before the next layer is put on top. If the layer will be placed down too fast the printer will slow down to make sure it has spend atleast this amount of seconds printing this layer.')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(right, "Enable cooling fan", 'fan_enabled', True, 'Enable the cooling fan during the print. The extra cooling from the cooling fan is essensial during faster prints.')
-
-               configBase.TitleRow(right, "Quality")
-               c = configBase.SettingRow(right, "Initial layer thickness (mm)", 'bottom_thickness', '0.0', 'Layer thickness of the bottom layer. A thicker bottom layer makes sticking to the bed easier. Set to 0.0 to have the bottom layer thickness the same as the other layers.')
-               validators.validFloat(c, 0.0)
-               validators.warningAbove(c, lambda : (float(profile.getProfileSetting('nozzle_size')) * 3.0 / 4.0), "A bottom layer of more then %.2fmm (3/4 nozzle size) usually give bad results and is not recommended.")
-               c = configBase.SettingRow(right, "Cut off object bottom (mm)", 'object_sink', 0.05, 'Sinks the object into the platform, this can be used for objects that do not have a flat bottom and thus create a too small first layer.')
-               validators.validFloat(c, 0.0)
-               configBase.settingNotify(c, lambda : self.GetParent().GetParent().GetParent().preview3d.Refresh())
-               c = configBase.SettingRow(right, "Duplicate outlines", 'enable_skin', False, 'Skin prints the outer lines of the prints twice, each time with half the thickness. This gives the illusion of a higher print quality.')
-
+               self._addSettingsToPanels('advanced', left, right)
                self.SizeLabelWidths(left, right)
 
                #Plugin page
index 5744dc0115a0a732bc440f1f7adbcd271856b017..baf103eb9448bcc6d32ddee1e8fb2c4c45353238 100644 (file)
@@ -20,55 +20,45 @@ class preferencesDialog(wx.Frame):
                
                left, right, main = self.panel.CreateConfigPanel(self)
                configBase.TitleRow(left, 'Machine settings')
-               c = configBase.SettingRow(left, 'Steps per E', 'steps_per_e', '0', 'Amount of steps per mm filament extrusion', type = 'preference')
-               validators.validFloat(c, 0.1)
-               c = configBase.SettingRow(left, 'Maximum width (mm)', 'machine_width', '205', 'Size of the machine in mm', type = 'preference')
-               validators.validFloat(c, 10.0)
-               c = configBase.SettingRow(left, 'Maximum depth (mm)', 'machine_depth', '205', 'Size of the machine in mm', type = 'preference')
-               validators.validFloat(c, 10.0)
-               c = configBase.SettingRow(left, 'Maximum height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference')
-               validators.validFloat(c, 10.0)
-               c = configBase.SettingRow(left, 'Extruder count', 'extruder_amount', ['1', '2', '3', '4'], 'Amount of extruders in your machine.', type = 'preference')
-               c = configBase.SettingRow(left, 'Heated bed', 'has_heated_bed', False, 'If you have an heated bed, this enabled heated bed settings', type = 'preference')
+               configBase.SettingRow(left, 'steps_per_e')
+               configBase.SettingRow(left, 'machine_width')
+               configBase.SettingRow(left, 'machine_depth')
+               configBase.SettingRow(left, 'machine_height')
+               configBase.SettingRow(left, 'extruder_amount')
+               configBase.SettingRow(left, 'has_heated_bed')
                
                for i in xrange(1, self.oldExtruderAmount):
                        configBase.TitleRow(left, 'Extruder %d' % (i+1))
-                       c = configBase.SettingRow(left, 'Offset X', 'extruder_offset_x%d' % (i), '0.0', 'The offset of your secondary extruder compared to the primary.', type = 'preference')
-                       validators.validFloat(c)
-                       c = configBase.SettingRow(left, 'Offset Y', 'extruder_offset_y%d' % (i), '0.0', 'The offset of your secondary extruder compared to the primary.', type = 'preference')
-                       validators.validFloat(c)
+                       configBase.SettingRow(left, 'extruder_offset_x%d' % (i))
+                       configBase.SettingRow(left, 'extruder_offset_y%d' % (i))
 
                configBase.TitleRow(left, 'Colours')
-               c = configBase.SettingRow(left, 'Model colour', 'model_colour', wx.Colour(0,0,0), '', type = 'preference')
+               configBase.SettingRow(left, 'model_colour')
                for i in xrange(1, self.oldExtruderAmount):
-                       c = configBase.SettingRow(left, 'Model colour (%d)' % (i+1), 'model_colour%d' % (i+1), wx.Colour(0,0,0), '', type = 'preference')
+                       configBase.SettingRow(left, 'model_colour%d' % (i+1))
 
                configBase.TitleRow(right, 'Filament settings')
-               c = configBase.SettingRow(right, 'Density (kg/m3)', 'filament_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference')
-               validators.validFloat(c, 500.0, 3000.0)
-               c = configBase.SettingRow(right, 'Cost (price/kg)', 'filament_cost_kg', '0', 'Cost of your filament per kg, to estimate the cost of the final print.', type = 'preference')
-               validators.validFloat(c, 0.0)
-               c = configBase.SettingRow(right, 'Cost (price/m)', 'filament_cost_meter', '0', 'Cost of your filament per meter, to estimate the cost of the final print.', type = 'preference')
-               validators.validFloat(c, 0.0)
-               
+               configBase.SettingRow(right, 'filament_physical_density')
+               configBase.SettingRow(right, 'filament_cost_kg')
+               configBase.SettingRow(right, 'filament_cost_meter')
+
                configBase.TitleRow(right, 'Communication settings')
-               c = configBase.SettingRow(right, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference')
-               c = configBase.SettingRow(right, 'Baudrate', 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference')
+               configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList())
+               configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()))
 
                configBase.TitleRow(right, 'Slicer settings')
-               #c = configBase.SettingRow(right, 'Slicer selection', 'slicer', ['Cura (Skeinforge based)', 'Slic3r'], 'Which slicer to use to slice objects. Usually the Cura engine produces the best results. But Slic3r is developing fast and is faster with slicing.', type = 'preference')
-               c = configBase.SettingRow(right, 'Save profile on slice', 'save_profile', False, 'When slicing save the profile as [stl_file]_profile.ini next to the model.', type = 'preference')
+               configBase.SettingRow(right, 'save_profile')
 
                configBase.TitleRow(right, 'SD Card settings')
                if len(profile.getSDcardDrives()) > 1:
-                       c = configBase.SettingRow(right, 'SD card drive', 'sdpath', profile.getSDcardDrives(), 'Location of your SD card, when using the copy to SD feature.', type = 'preference')
+                       configBase.SettingRow(right, 'sdpath', profile.getSDcardDrives())
                else:
-                       c = configBase.SettingRow(right, 'SD card path', 'sdpath', '', 'Location of your SD card, when using the copy to SD feature.', type = 'preference')
-               c = configBase.SettingRow(right, 'Copy to SD with 8.3 names', 'sdshortnames', False, 'Save the gcode files in short filenames, so they are properly shown on the UltiController', type = 'preference')
+                       configBase.SettingRow(right, 'sdpath')
+               configBase.SettingRow(right, 'sdshortnames')
 
                configBase.TitleRow(right, 'Cura settings')
-               c = configBase.SettingRow(right, 'Check for updates', 'check_for_updates', True, 'Check for newer versions of Cura on startup', type = 'preference')
-               c = configBase.SettingRow(right, 'Send usage statistics', 'submit_slice_information', True, 'Submit anonymous usage information to improve next versions of Cura', type = 'preference')
+               configBase.SettingRow(right, 'check_for_updates')
+               configBase.SettingRow(right, 'submit_slice_information')
 
                self.okButton = wx.Button(right, -1, 'Ok')
                right.GetSizer().Add(self.okButton, (right.GetSizer().GetRows(), 0), flag=wx.BOTTOM, border=5)
index f263ad530824519159d48ca7ff157333c58511e2..61f9143e27695eded5633ba300d65c9f956eec7f 100644 (file)
@@ -681,7 +681,7 @@ class projectPlanner(wx.Frame):
                dlg.Destroy()
 
                put = profile.setTempOverride
-               oldProfile = profile.getGlobalProfileString()
+               oldProfile = profile.getProfileString()
                
                if self.printMode == 0:
                        fileList = []
index 0b170e77eca7c15e085281e383880888ed6c4366..14d2a891c1b47b67f1d23152372473ff1f1d95cc 100644 (file)
@@ -19,6 +19,7 @@ class simpleModePanel(wx.Panel):
                self.printTypeNormal = wx.RadioButton(printTypePanel, -1, 'Normal quality print')
                self.printTypeLow = wx.RadioButton(printTypePanel, -1, 'Fast low quality print')
                self.printTypeJoris = wx.RadioButton(printTypePanel, -1, 'Thin walled cup or vase')
+               self.printTypeJoris.Hide()
 
                printMaterialPanel = wx.Panel(self)
                self.printMaterialPLA = wx.RadioButton(printMaterialPanel, -1, 'PLA', style=wx.RB_GROUP)
@@ -26,7 +27,8 @@ class simpleModePanel(wx.Panel):
                self.printMaterialDiameter = wx.TextCtrl(printMaterialPanel, -1, profile.getProfileSetting('filament_diameter'))
                
                self.printSupport = wx.CheckBox(self, -1, 'Print support structure')
-               
+               self.printSupport.Hide()
+
                sizer = wx.GridBagSizer()
                self.SetSizer(sizer)
 
@@ -50,10 +52,10 @@ class simpleModePanel(wx.Panel):
                printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
                sizer.Add(printMaterialPanel, (1,0), flag=wx.EXPAND)
 
-               sb = wx.StaticBox(self, label="Other:")
-               boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
-               boxsizer.Add(self.printSupport)
-               sizer.Add(boxsizer, (2,0), flag=wx.EXPAND)
+               #sb = wx.StaticBox(self, label="Other:")
+               #boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
+               #boxsizer.Add(self.printSupport)
+               #sizer.Add(boxsizer, (2,0), flag=wx.EXPAND)
 
                self.printTypeNormal.SetValue(True)
                self.printMaterialPLA.SetValue(True)
index 2ef571463b7d714d2eb9fb9ae29956e792ce1182..fbcee355516b7c1cecdc61dad37d84cac2d0f49b 100644 (file)
@@ -43,7 +43,7 @@ class sliceProgressPanel(wx.Panel):
                self.totalDoneFactor = 0.0
                self.startTime = time.time()
                if profile.getPreference('save_profile') == 'True':
-                       profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind('.')] + "_profile.ini")
+                       profile.saveProfile(self.filelist[0][: self.filelist[0].rfind('.')] + "_profile.ini")
                center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
                cmdList = [sliceRun.getSliceCommand(sliceRun.getExportFilename(self.filelist[0]), ['|'.join(self.filelist)], [center])]
                self.thread = WorkerThread(self, filelist, cmdList)
index 4cf6a53903d06e7321b48fce522c7855df1a3afc..d5acdeb423d3023b2972fbdff7d4daa3cdc1bb8b 100644 (file)
Binary files a/Cura/resources/images/UltimakerRobot.png and b/Cura/resources/images/UltimakerRobot.png differ
index 80a1489e1ce369147c9c6a360e211c7d109f42e8..a551e9ea087c73f468b65e9321d23ca2f5d8a684 100644 (file)
@@ -8,6 +8,7 @@ import urllib
 import urllib2
 import platform
 import hashlib
+import subprocess
 
 if not hasattr(sys, 'frozen'):
        cura_sf_path = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "./cura_sf/"))
@@ -34,9 +35,62 @@ def main():
                print 'Missing output filename'
                sys.exit(1)
        if options.profile is not None:
-               profile.loadGlobalProfileFromString(options.profile)
+               profile.loadProfileFromString(options.profile)
        options.output = fixUTF8(options.output)
 
+       steamEngineFilename = os.path.join(os.path.dirname(__file__), 'SteamEngine')
+       if platform.system() == "Windows":
+               steamEngineFilename += ".exe"
+               if os.path.isfile("C:\Software\Cura_SteamEngine\_bin\Release\Cura_SteamEngine.exe"):
+                       steamEngineFilename = "C:\Software\Cura_SteamEngine\_bin\Release\Cura_SteamEngine.exe"
+       if os.path.isfile(steamEngineFilename):
+               for idx in xrange(0, len(args), 2):
+                       position = map(float, args[idx].split(','))
+                       if len(position) < 9 + 2:
+                               position = position[0:2]
+                               position += [1,0,0]
+                               position += [0,1,0]
+                               position += [0,0,1]
+
+                       settings = {}
+                       settings['layerThickness'] = int(profile.getProfileSettingFloat('layer_height') * 1000)
+                       settings['initialLayerThickness'] = int(profile.getProfileSettingFloat('bottom_thickness') * 1000)
+                       settings['filamentDiameter'] = int(profile.getProfileSettingFloat('filament_diameter') * 1000)
+                       settings['extrusionWidth'] = int(profile.calculateEdgeWidth() * 1000)
+                       settings['insetCount'] = int(profile.calculateLineCount())
+                       settings['downSkinCount'] = int(profile.calculateSolidLayerCount())
+                       settings['upSkinCount'] = int(profile.calculateSolidLayerCount())
+                       if profile.getProfileSettingFloat('fill_density') > 0:
+                               settings['sparseInfillLineDistance'] = int(100 * 1000 * profile.calculateEdgeWidth() / profile.getProfileSettingFloat('fill_density'))
+                       else:
+                               settings['sparseInfillLineDistance'] = 9999999
+                       settings['skirtDistance'] = int(profile.getProfileSettingFloat('skirt_gap') * 1000)
+                       settings['skirtLineCount'] = int(profile.getProfileSettingFloat('skirt_line_count'))
+
+                       settings['initialSpeedupLayers'] = int(4)
+                       settings['initialLayerSpeed'] = int(profile.getProfileSettingFloat('bottom_layer_speed'))
+                       settings['printSpeed'] = int(profile.getProfileSettingFloat('print_speed'))
+                       settings['moveSpeed'] = int(profile.getProfileSettingFloat('travel_speed'))
+                       settings['fanOnLayerNr'] = int(profile.getProfileSettingFloat('fan_layer'))
+                       settings['supportAngle'] = int(60) if profile.getProfileSetting('support') != 'None' else int(-1)
+                       settings['supportEverywhere'] = int(1) if profile.getProfileSetting('support') == 'Everywhere' else int(0)
+                       settings['retractionAmount'] = int(0) if profile.getProfileSetting('retraction_enable') == 'False' else int(profile.getProfileSettingFloat('retraction_amount') * 1000)
+                       settings['retractionSpeed'] = int(profile.getProfileSettingFloat('retraction_speed'))
+                       settings['objectSink'] = int(profile.getProfileSettingFloat('object_sink') * 1000.0)
+
+                       cmdList = [steamEngineFilename, args[idx+1], '-o', options.output, '-m', ','.join(map(str, position[2:]))]
+                       for (key, value) in settings.items():
+                               cmdList += ['-s', str(key) + "=" + str(value)]
+                       kwargs = {}
+                       if subprocess.mswindows:
+                               su = subprocess.STARTUPINFO()
+                               su.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+                               su.wShowWindow = subprocess.SW_HIDE
+                               kwargs['startupinfo'] = su
+                       p = subprocess.Popen(cmdList, **kwargs)
+                       p.communicate()
+               return
+
        clearZ = 0
        resultFile = open(options.output, "w")
        for idx in xrange(0, len(args), 2):
@@ -111,7 +165,7 @@ def main():
                                'processor': platform.processor(),
                                'machine': platform.machine(),
                                'platform': platform.platform(),
-                               'profile': profile.getGlobalProfileString(),
+                               'profile': profile.getProfileString(),
                                'preferences': profile.getGlobalPreferencesString(),
                                'modelhash': m.hexdigest(),
                                'version': version.getVersion(),
index 19b68acec4d25b557c3e657eba4545c96cf029d7..6c7cebd10bf4fe6a58dc4d9b1265eb0b31fcf368 100644 (file)
@@ -37,7 +37,7 @@ class gcode(object):
                #Calculates the weight of the filament in kg
                radius = float(profile.getProfileSetting('filament_diameter')) / 2
                volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000)
-               return volumeM3 * profile.getPreferenceFloat('filament_density')
+               return volumeM3 * profile.getPreferenceFloat('filament_physical_density')
        
        def calculateCost(self):
                cost_kg = profile.getPreferenceFloat('filament_cost_kg')
index 76b8369ee240529c827683d2ca0c3f03a37ec8d2..6bbaeefdc7cdab75a32bb1083f36e71ede457ed8 100644 (file)
@@ -8,13 +8,50 @@ numpy.seterr(all='ignore')
 
 from Cura.util import util3d
 
+class printableObject(object):
+       def __init__(self):
+               self._meshList = []
+               self._position = [0.0, 0.0]
+               self._matrix = numpy.matrix([[1,0,0],[0,1,0],[0,0,1]], numpy.float64)
+
+       def _addMesh(self):
+               m = mesh()
+               self._meshList.append(m)
+               return m
+
+       def processMatrix(self):
+               self.transformedMin = numpy.array([999999999999,999999999999,999999999999], numpy.float64)
+               self.transformedMax = numpy.array([-999999999999,-999999999999,-999999999999], numpy.float64)
+               self.boundaryCircleSize = 0
+
+               for m in self._meshList:
+                       transformedVertexes = (numpy.matrix(m.vertexes, copy = False) * self.matrix).getA()
+                       transformedMin = transformedVertexes.min(0)
+                       transformedMax = transformedVertexes.max(0)
+                       for n in xrange(0, 3):
+                               self.transformedMin[n] = min(transformedMin[n], self.transformedMin[n])
+                               self.transformedMax[n] = min(transformedMax[n], self.transformedMax[n])
+
+                       #Calculate the boundary circle
+                       transformedSize = transformedMax - transformedMin
+                       center = transformedMin + transformedSize / 2.0
+                       boundaryCircleSize = round(math.sqrt(numpy.max(((transformedVertexes[::,0] - center[0]) * (transformedVertexes[::,0] - center[0])) + ((transformedVertexes[::,1] - center[1]) * (transformedVertexes[::,1] - center[1])) + ((transformedVertexes[::,2] - center[2]) * (transformedVertexes[::,2] - center[2])))), 3)
+                       self.boundaryCircleSize = max(self.boundaryCircleSize, boundaryCircleSize)
+               self.transformedSize = self.transformedMax - self.transformedMin
+
+       def getMaximum(self):
+               return self.transformedMax
+       def getMinimum(self):
+               return self.transformedMin
+       def getSize(self):
+               return self.transformedSize
+
 class mesh(object):
        def __init__(self):
                self.vertexes = None
-               self.matrix = numpy.matrix([[1,0,0], [0,1,0], [0,0,1]], numpy.float32);
                self.vertexCount = 0
 
-       def addVertex(self, x, y, z):
+       def _addVertex(self, x, y, z):
                n = self.vertexCount
                self.vertexes[n][0] = x
                self.vertexes[n][1] = y
@@ -31,23 +68,6 @@ class mesh(object):
                self.processMatrix()
                self._calculateNormals()
 
-       def processMatrix(self):
-               transformedVertexes = (numpy.matrix(self.vertexes, copy = False) * self.matrix).getA()
-               self.transformedMin = transformedVertexes.min(0)
-               self.transformedMax = transformedVertexes.max(0)
-               self.transformedSize = self.transformedMax - self.transformedMin
-
-               #Calculate the boundary circle
-               center = self.transformedMin + self.transformedSize / 2.0
-               self.boundaryCircleSize = round(math.sqrt(numpy.max(((transformedVertexes[::,0] - center[0]) * (transformedVertexes[::,0] - center[0])) + ((transformedVertexes[::,1] - center[1]) * (transformedVertexes[::,1] - center[1])) + ((transformedVertexes[::,2] - center[2]) * (transformedVertexes[::,2] - center[2])))), 3)
-
-       def getMaximum(self):
-               return self.transformedMax
-       def getMinimum(self):
-               return self.transformedMin
-       def getSize(self):
-               return self.transformedSize
-
        def _calculateNormals(self):
                #Calculate the normals
                tris = self.vertexes.reshape(self.vertexCount / 3, 3, 3)
@@ -148,4 +168,3 @@ class mesh(object):
                        if f1 not in doneSet:
                                todoList.append(f1)
                                doneSet.add(f1)
-
index 6bf2767dd8c8521277828bee1337295733db9b2a..2bfa5096d8c82ec87faaa5c84674a8dbbb2827c6 100644 (file)
@@ -24,4 +24,3 @@ def loadMesh(filename):
                return amf.amfModel().load(filename)
        print 'Error: Unknown model extension: %s' % (ext)
        return None
-
index b2aa0bca55d26c90fedf9eeb2b42f86cc938016c..36357eee85882ea72d0c5811464243bfb26f0721 100644 (file)
@@ -1,7 +1,7 @@
 from __future__ import absolute_import
 from __future__ import division
 
-import os, traceback, math, re, zlib, base64, time, sys, platform, glob, string, stat
+import os, traceback, math, re, zlib, base64, time, sys, platform, glob, string, stat, types
 import cPickle as pickle
 if sys.version_info[0] < 3:
        import ConfigParser
@@ -10,82 +10,166 @@ else:
 
 from Cura.util import resources
 from Cura.util import version
+from Cura.util import validators
+
+settingsDictionary = {}
+settingsList = []
+class setting(object):
+       def __init__(self, name, default, type, category, subcategory):
+               self._name = name
+               self._label = name
+               self._tooltip = ''
+               self._default = unicode(default)
+               self._value = self._default
+               self._type = type
+               self._category = category
+               self._subcategory = subcategory
+               self._validators = []
+               self._conditions = []
+
+               if type is types.FloatType:
+                       validators.validFloat(self)
+               elif type is types.IntType:
+                       validators.validInt(self)
+
+               global settingsDictionary
+               settingsDictionary[name] = self
+               global settingsList
+               settingsList.append(self)
+
+       def setLabel(self, label, tooltip = ''):
+               self._label = label
+               self._tooltip = tooltip
+               return self
+
+       def setRange(self, minValue = None, maxValue = None):
+               if len(self._validators) < 1:
+                       return
+               self._validators[0].minValue = minValue
+               self._validators[0].maxValue = maxValue
+               return self
+
+       def getLabel(self):
+               return self._label
+
+       def getTooltip(self):
+               return self._tooltip
+
+       def getCategory(self):
+               return self._category
+
+       def getSubCategory(self):
+               return self._subcategory
+
+       def isPreference(self):
+               return self._category == 'preference'
+
+       def isAlteration(self):
+               return self._category == 'alteration'
+
+       def isProfile(self):
+               return not self.isAlteration() and not self.isPreference()
+
+       def getName(self):
+               return self._name
+
+       def getType(self):
+               return self._type
+
+       def getValue(self):
+               return self._value
+
+       def getDefault(self):
+               return self._default
+
+       def setValue(self, value):
+               self._value = unicode(value)
+
+       def validate(self):
+               result = validators.SUCCESS
+               msgs = []
+               for validator in self._validators:
+                       res, err = validator.validate()
+                       if res == validators.ERROR:
+                               result = res
+                       elif res == validators.WARNING and result != validators.ERROR:
+                               result = res
+                       if res != validators.SUCCESS:
+                               msgs.append(err)
+               return result, '\n'.join(msgs)
+
+       def addCondition(self, conditionFunction):
+               self._conditions.append(conditionFunction)
+
+       def checkConditions(self):
+               for condition in self._conditions:
+                       if not condition():
+                               return False
+               return True
 
 #########################################################
-## Default settings when none are found.
+## Settings
 #########################################################
-
-#Single place to store the defaults, so we have a consistent set of default settings.
-profileDefaultSettings = {
-       'nozzle_size': '0.4',
-       'layer_height': '0.2',
-       'wall_thickness': '0.8',
-       'solid_layer_thickness': '0.6',
-       'fill_density': '20',
-       'skirt_line_count': '1',
-       'skirt_gap': '3.0',
-       'print_speed': '50',
-       'print_temperature': '220',
-       'print_temperature2': '0',
-       'print_temperature3': '0',
-       'print_temperature4': '0',
-       'print_bed_temperature': '70',
-       'support': 'None',
-       'filament_diameter': '2.89',
-       'filament_diameter2': '0',
-       'filament_diameter3': '0',
-       'filament_diameter4': '0',
-       'filament_density': '1.00',
-       'retraction_min_travel': '5.0',
-       'retraction_enable': 'False',
-       'retraction_speed': '40.0',
-       'retraction_amount': '4.5',
-       'retraction_extra': '0.0',
-       'retract_on_jumps_only': 'True',
-       'travel_speed': '150',
-       'max_z_speed': '3.0',
-       'bottom_layer_speed': '20',
-       'cool_min_layer_time': '5',
-       'fan_enabled': 'True',
-       'fan_layer': '1',
-       'fan_speed': '100',
-       'fan_speed_max': '100',
-       'model_matrix': '1,0,0,0,1,0,0,0,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': '50',
-       'support_distance': '0.5',
-       'support_dual_extrusion': 'False',
-       'joris': 'False',
-       'enable_skin': 'False',
-       'enable_raft': 'False',
-       'cool_min_feedrate': '10',
-       'bridge_speed': '100',
-       'raft_margin': '5',
-       'raft_base_material_amount': '100',
-       'raft_interface_material_amount': '100',
-       'bottom_thickness': '0.3',
-       'hop_on_move': 'False',
-       'plugin_config': '',
-       'object_center_x': '-1',
-       'object_center_y': '-1',
-       'object_sink': '0.0',
-       
-       'gcode_extension': 'gcode',
-       'alternative_center': '',
-       'clear_z': '0.0',
-       'extruder': '0',
-       'new_x': '0',
-       'new_y': '0',
-       'new_z': '0',
-}
-alterationDefault = {
-#######################################################################################
-       'start.gcode': """;Sliced {filename} at: {day} {date} {time}
+setting('layer_height',              0.2, float, 'basic',    'Quality').setRange(0.0001).setLabel('Layer height (mm)', 'Layer height in millimeters.\n0.2 is a good value for quick prints.\n0.1 gives high quality prints.\nDepending on your printer you can go as low as 0.02mm')
+setting('wall_thickness',            0.8, float, 'basic',    'Quality').setRange(0.0001).setLabel('Wall thickness (mm)', 'Thickness of the walls.\nThis is used in combination with the nozzle size to define the number\nof perimeter lines and the thickness of those perimeter lines.')
+setting('retraction_enable',       False, bool,  'basic',    'Quality').setLabel('Enable retraction', 'Retract the filament when the nozzle is moving over a none-printed area. Details about the retraction can be configured in the advanced tab.')
+setting('solid_layer_thickness',     0.6, float, 'basic',    'Fill').setRange(0).setLabel('Bottom/Top thickness (mm)', 'This controls the thickness of the bottom and top layers, the amount of solid layers put down is calculated by the layer thickness and this value.\nHaving this value a multiply of the layer thickness makes sense. And keep it near your wall thickness to make an evenly strong part.')
+setting('fill_density',               20, float, 'basic',    'Fill').setRange(0, 100).setLabel('Fill Density (%)', 'This controls how densely filled the insides of your print will be. For a solid part use 100%, for an empty part use 0%. A value around 20% is usually enough.\nThis won\'t effect the outside of the print and only adjusts how strong the part becomes.')
+setting('nozzle_size',               0.4, float, 'advanced', 'Machine').setRange(0.1,10).setLabel('Nozzle size (mm)', 'The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings.')
+setting('skirt_line_count',            1, int,   'advanced', 'Skirt').setRange(0).setLabel('Line count', 'The skirt is a line drawn around the object at the first layer. This helps to prime your extruder, and to see if the object fits on your platform.\nSetting this to 0 will disable the skirt. Multiple skirt lines can help priming your extruder better for small objects.')
+setting('skirt_gap',                 3.0, float, 'advanced', 'Skirt').setRange(0).setLabel('Start distance (mm)', 'The distance between the skirt and the first layer.\nThis is the minimal distance, multiple skirt lines will be put outwards from this distance.')
+setting('print_speed',                50, float, 'basic',    'Speed & Temperature').setRange(1).setLabel('Print speed (mm/s)', 'Speed at which printing happens. A well adjusted Ultimaker can reach 150mm/s, but for good quality prints you want to print slower. Printing speed depends on a lot of factors. So you will be experimenting with optimal settings for this.')
+setting('print_temperature',         220, int,   'basic',    'Speed & Temperature').setRange(0,340).setLabel('Printing temperature (C)', 'Temperature used for printing. Set at 0 to pre-heat yourself.\nFor PLA a value of 210C is usually used.\nFor ABS a value of 230C or higher is required.')
+setting('print_temperature2',          0, int,   'basic',    'Speed & Temperature').setRange(0,340).setLabel('2nd nozzle temperature (C)', 'Temperature used for printing. Set at 0 to pre-heat yourself.\nFor PLA a value of 210C is usually used.\nFor ABS a value of 230C or higher is required.')
+setting('print_temperature3',          0, int,   'basic',    'Speed & Temperature').setRange(0,340).setLabel('3th nozzle temperature (C)', 'Temperature used for printing. Set at 0 to pre-heat yourself.\nFor PLA a value of 210C is usually used.\nFor ABS a value of 230C or higher is required.')
+setting('print_temperature4',          0, int,   'basic',    'Speed & Temperature').setRange(0,340).setLabel('4th nozzle temperature (C)', 'Temperature used for printing. Set at 0 to pre-heat yourself.\nFor PLA a value of 210C is usually used.\nFor ABS a value of 230C or higher is required.')
+setting('print_bed_temperature',      70, int,   'basic',    'Speed & Temperature').setRange(0,340).setLabel('Bed temperature (C)', 'Temperature used for the heated printer bed. Set at 0 to pre-heat yourself.')
+setting('support',                'None', ['None', 'Touching buildplate', 'Everywhere'], 'Basic', 'Support structure').setLabel('Support type', 'Type of support structure build.\n"Exterior only" is the most commonly used support setting.\n\nNone does not do any support.\nTouching buildplate only creates support where the support structure will touch the build platform.\nEverywhere creates support even on top of parts of the model.')
+setting('enable_raft',             False, bool,  'basic',   'Support').setLabel('Enable raft', 'A raft is a few layers of lines below the bottom of the object. It prevents warping. Full raft settings can be found in the expert settings.\nFor PLA this is usually not required. But if you print with ABS it is almost required.')
+setting('support_dual_extrusion',  False, bool, 'basic', 'Support').setLabel('Support dual extrusion', 'Print the support material with the 2nd extruder in a dual extrusion setup. The primary extruder will be used for normal material, while the second extruder is used to print support material.')
+setting('filament_diameter',        2.89, float, 'basic',    'Filament').setRange(1).setLabel('Diameter (mm)', 'Diameter of your filament, as accurately as possible.\nIf you cannot measure this value you will have to calibrate it, a higher number means less extrusion, a smaller number generates more extrusion.')
+setting('filament_diameter2',          0, float, 'basic',    'Filament').setRange(0).setLabel('Diameter2 (mm)', 'Diameter of your filament for the 2nd nozzle. Use 0 to use the same diameter as for nozzle 1.')
+setting('filament_diameter3',          0, float, 'basic',    'Filament').setRange(0).setLabel('Diameter3 (mm)', 'Diameter of your filament for the 3th nozzle. Use 0 to use the same diameter as for nozzle 1.')
+setting('filament_diameter4',          0, float, 'basic',    'Filament').setRange(0).setLabel('Diameter4 (mm)', 'Diameter of your filament for the 4th nozzle. Use 0 to use the same diameter as for nozzle 1.')
+setting('filament_density',         1.00, float, 'basic',    'Filament').setRange(0.5,1.5).setLabel('Packing Density', 'Packing density of your filament. This should be 1.00 for PLA and 0.85 for ABS')
+setting('retraction_min_travel',     5.0, float, 'advanced', 'Retraction').setRange(0).setLabel('Minimum travel (mm)', 'Minimum amount of travel needed for a retraction to happen at all. To make sure you do not get a lot of retractions in a small area')
+setting('retraction_speed',         40.0, float, 'advanced', 'Retraction').setRange(0.1).setLabel('Speed (mm/s)', 'Speed at which the filament is retracted, a higher retraction speed works better. But a very high retraction speed can lead to filament grinding.')
+setting('retraction_amount',         4.5, float, 'advanced', 'Retraction').setRange(0).setLabel('Distance (mm)', 'Amount of retraction, set at 0 for no retraction at all. A value of 2.0mm seems to generate good results.')
+setting('retraction_extra',          0.0, float, 'advanced', 'Retraction').setRange(0).setLabel('Extra length on start (mm)', 'Extra extrusion amount when restarting after a retraction, to better "Prime" your extruder after retraction.')
+setting('bottom_thickness',          0.3, float, 'advanced', 'Quality').setRange(0).setLabel('Initial layer thickness (mm)', 'Layer thickness of the bottom layer. A thicker bottom layer makes sticking to the bed easier. Set to 0.0 to have the bottom layer thickness the same as the other layers.')
+setting('object_sink',               0.0, float, 'advanced', 'Quality').setLabel('Cut off object bottom (mm)', 'Sinks the object into the platform, this can be used for objects that do not have a flat bottom and thus create a too small first layer.')
+setting('enable_skin',             False, bool,  'advanced', 'Quality').setLabel('Duplicate outlines', 'Skin prints the outer lines of the prints twice, each time with half the thickness. This gives the illusion of a higher print quality.')
+setting('travel_speed',            150.0, float, 'advanced', 'Speed').setRange(0.1).setLabel('Travel speed (mm/s)', 'Speed at which travel moves are done, a high quality build Ultimaker can reach speeds of 250mm/s. But some machines might miss steps then.')
+setting('bottom_layer_speed',         20, float, 'advanced', 'Speed').setRange(0.1).setLabel('Bottom layer speed (mm/s)', 'Print speed for the bottom layer, you want to print the first layer slower so it sticks better to the printer bed.')
+#setting('cool_min_layer_time',         5, float, 'advanced', 'Cool').setRange(0).setLabel('Minimal layer time (sec)', 'Minimum time spend in a layer, gives the layer time to cool down before the next layer is put on top. If the layer will be placed down too fast the printer will slow down to make sure it has spend at least this amount of seconds printing this layer.')
+#setting('fan_enabled',              True, bool,  'advanced', 'Cool').setLabel('Enable cooling fan', 'Enable the cooling fan during the print. The extra cooling from the cooling fan is essensial during faster prints.')
+#setting('max_z_speed',               3.0, float, 'expert',   'Speed').setRange(0.1).setLabel('Max Z speed (mm/s)', 'Speed at which Z moves are done. When you Z axis is properly lubricated you can increase this for less Z blob.')
+#setting('retract_on_jumps_only',    True, bool,  'expert',   'Retraction').setLabel('Retract on jumps only', 'Only retract when we are making a move that is over a hole in the model, else retract on every move. This effects print quality in different ways.')
+setting('fan_layer',                   1, int,   'expert',   'Cool').setRange(0).setLabel('Fan on layer number', 'The layer at which the fan is turned on. The first layer is layer 0. The first layer can stick better if you turn on the fan on, on the 2nd layer.')
+#setting('fan_speed',                 100, int,   'expert',   'Cool').setRange(0,100).setLabel('Fan speed min (%)', 'When the fan is turned on, it is enabled at this speed setting. If cool slows down the layer, the fan is adjusted between the min and max speed. Minimal fan speed is used if the layer is not slowed down due to cooling.')
+#setting('fan_speed_max',             100, int,   'expert',   'Cool').setRange(0,100).setLabel('Fan speed max (%)', 'When the fan is turned on, it is enabled at this speed setting. If cool slows down the layer, the fan is adjusted between the min and max speed. Maximal fan speed is used if the layer is slowed down due to cooling by more then 200%.')
+#setting('cool_min_feedrate',          10, float, 'expert',   'Cool').setRange(0).setLabel('Minimum feedrate (mm/s)', 'The minimal layer time can cause the print to slow down so much it starts to ooze. The minimal feedrate protects against this. Even if a print gets slown down it will never be slower then this minimal feedrate.')
+#setting('extra_base_wall_thickness', 0.0, float, 'expert',   'Accuracy').setRange(0).setLabel('Extra Wall thickness for bottom/top (mm)', 'Additional wall thickness of the bottom and top layers.')
+#setting('sequence', 'Loops > Perimeter > Infill', ['Loops > Perimeter > Infill', 'Loops > Infill > Perimeter', 'Infill > Loops > Perimeter', 'Infill > Perimeter > Loops', 'Perimeter > Infill > Loops', 'Perimeter > Loops > Infill'], 'expert', 'Sequence')
+#setting('force_first_layer_sequence', True, bool, 'expert', 'Sequence').setLabel('Force first layer sequence', 'This setting forces the order of the first layer to be \'Perimeter > Loops > Infill\'')
+#setting('infill_type', 'Line', ['Line', 'Grid Circular', 'Grid Hexagonal', 'Grid Rectangular'], 'expert', 'Infill').setLabel('Infill pattern', 'Pattern of the none-solid infill. Line is default, but grids can provide a strong print.')
+#setting('solid_top', True, bool, 'expert', 'Infill').setLabel('Solid infill top', 'Create a solid top surface, if set to false the top is filled with the fill percentage. Useful for cups/vases.')
+#setting('fill_overlap', 15, int, 'expert', 'Infill').setRange(0,100).setLabel('Infill overlap (%)', 'Amount of overlap between the infill and the walls. There is a slight overlap with the walls and the infill so the walls connect firmly to the infill.')
+#setting('support_rate', 50, int, 'expert', 'Support').setRange(0,100).setLabel('Material amount (%)', 'Amount of material used for support, less material gives a weaker support structure which is easier to remove.')
+#setting('support_distance',  0.5, float, 'expert', 'Support').setRange(0).setLabel('Distance from object (mm)', 'Distance between the support structure and the object. Empty gap in which no support structure is printed.')
+#setting('joris', False, bool, 'expert', 'Joris').setLabel('Spiralize the outer contour', '[Joris] is a code name for smoothing out the Z move of the outer edge. This will create a steady Z increase over the whole print. It is intended to be used with a single walled wall thickness to make cups/vases.')
+#setting('bridge_speed', 100, int, 'expert', 'Bridge').setRange(0,100).setLabel('Bridge speed (%)', 'Speed at which layers with bridges are printed, compared to normal printing speed.')
+#setting('raft_margin', 5, float, 'expert', 'Raft').setRange(0).setLabel('Extra margin (mm)', 'If the raft is enabled, this is the extra raft area around the object which is also rafted. Increasing this margin will create a stronger raft.')
+#setting('raft_base_material_amount', 100, int, 'expert', 'Raft').setRange(0,100).setLabel('Base material amount (%)', 'The base layer is the first layer put down as a raft. This layer has thick strong lines and is put firmly on the bed to prevent warping. This setting adjust the amount of material used for the base layer.')
+#setting('raft_interface_material_amount', 100, int, 'expert', 'Raft').setRange(0,100).setLabel('Interface material amount (%)', 'The interface layer is a weak thin layer between the base layer and the printed object. It is designed to has little material to make it easy to break the base off the printed object. This setting adjusts the amount of material used for the interface layer.')
+#setting('hop_on_move', False, bool, 'expert', 'Hop').setLabel('Enable hop on move', 'When moving from print position to print position, raise the printer head 0.2mm so it does not knock off the print (experimental).')
+
+setting('model_matrix', '1,0,0,0,1,0,0,0,1', str, 'hidden', 'hidden')
+setting('plugin_config', '', str, 'hidden', 'hidden')
+setting('object_center_x', -1, float, 'hidden', 'hidden')
+setting('object_center_y', -1, float, 'hidden', 'hidden')
+
+setting('start.gcode', """;Sliced {filename} at: {day} {date} {time}
 ;Basic settings: Layer height: {layer_height} Walls: {wall_thickness} Fill: {fill_density}
 ;Print time: {print_time}
 ;Filament used: {filament_amount}m {filament_weight}g
@@ -104,9 +188,9 @@ G1 F200 E3              ;extrude 3mm of feed stock
 G92 E0                  ;zero the extruded length again
 G1 F{travel_speed}
 M117 Printing...
-""",
+""", str, 'alteration', 'alteration')
 #######################################################################################
-       'end.gcode': """;End GCode
+setting('end.gcode', """;End GCode
 M104 S0                     ;extruder heater off
 M140 S0                     ;heated bed heater off (if you have it)
 
@@ -117,15 +201,15 @@ G28 X0 Y0                              ;move X/Y to min endstops, so the head is
 
 M84                         ;steppers off
 G90                         ;absolute positioning
-""",
+""", str, 'alteration', 'alteration')
 #######################################################################################
-       'support_start.gcode': '',
-       'support_end.gcode': '',
-       'cool_start.gcode': '',
-       'cool_end.gcode': '',
-       'replace.csv': '',
+setting('support_start.gcode', '', str, 'alteration', 'alteration')
+setting('support_end.gcode', '', str, 'alteration', 'alteration')
+setting('cool_start.gcode', '', str, 'alteration', 'alteration')
+setting('cool_end.gcode', '', str, 'alteration', 'alteration')
+setting('replace.csv', '', str, 'alteration', 'alteration')
 #######################################################################################
-       'nextobject.gcode': """;Move to next object on the platform. clear_z is the minimal z height we need to make sure we do not hit any objects.
+setting('nextobject.gcode', """;Move to next object on the platform. clear_z is the minimal z height we need to make sure we do not hit any objects.
 G92 E0
 
 G91                                    ;relative positioning
@@ -138,9 +222,9 @@ G92 E0
 G1 X{object_center_x} Y{object_center_y} F{travel_speed}
 G1 F200 E6
 G92 E0
-""",
+""", str, 'alteration', 'alteration')
 #######################################################################################
-       'switchExtruder.gcode': """;Switch between the current extruder and the next extruder, when printing with multiple extruders.
+setting('switchExtruder.gcode', """;Switch between the current extruder and the next extruder, when printing with multiple extruders.
 G92 E0
 G1 E-36 F5000
 G92 E0
@@ -148,65 +232,104 @@ T{extruder}
 G1 X{new_x} Y{new_y} Z{new_z} F{travel_speed}
 G1 E36 F5000
 G92 E0
-""",
-}
-preferencesDefaultSettings = {
-       'startMode': 'Simple',
-       'lastFile': os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'resources', 'example', 'UltimakerRobot_support.stl')),
-       'machine_width': '205',
-       'machine_depth': '205',
-       'machine_height': '200',
-       'machine_type': 'unknown',
-       'machine_center_is_zero': 'False',
-       'ultimaker_extruder_upgrade': 'False',
-       'has_heated_bed': 'False',
-       'reprap_name': 'RepRap',
-       'extruder_amount': '1',
-       'extruder_offset_x1': '-22.0',
-       'extruder_offset_y1': '0.0',
-       'extruder_offset_x2': '0.0',
-       'extruder_offset_y2': '0.0',
-       'extruder_offset_x3': '0.0',
-       'extruder_offset_y3': '0.0',
-       'filament_density': '1300',
-       'steps_per_e': '0',
-       'serial_port': 'AUTO',
-       'serial_port_auto': '',
-       'serial_baud': 'AUTO',
-       'serial_baud_auto': '',
-       'slicer': 'Cura (Skeinforge based)',
-       'save_profile': 'False',
-       'filament_cost_kg': '0',
-       'filament_cost_meter': '0',
-       'sdpath': '',
-       'sdshortnames': 'False',
-       'check_for_updates': 'True',
-       'submit_slice_information': 'False',
-
-       'planner_always_autoplace': 'True',
-       'extruder_head_size_min_x': '75.0',
-       'extruder_head_size_min_y': '18.0',
-       'extruder_head_size_max_x': '18.0',
-       'extruder_head_size_max_y': '35.0',
-       'extruder_head_size_height': '60.0',
-       
-       'model_colour': '#7AB645',
-       'model_colour2': '#CB3030',
-       'model_colour3': '#DDD93C',
-       'model_colour4': '#4550D3',
-
-       'window_maximized': 'False',
-       'window_pos_x': '-1',
-       'window_pos_y': '-1',
-       'window_width': '-1',
-       'window_height': '-1',
-       'window_normal_sash': '320',
-}
+""", str, 'alteration', 'alteration')
+
+setting('startMode', 'Simple', ['Simple', 'Normal'], 'preference', 'hidden')
+setting('lastFile', os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'resources', 'example', 'UltimakerRobot_support.stl')), str, 'preference', 'hidden')
+setting('machine_width', '205', float, 'preference', 'hidden').setLabel('Maximum width (mm)', 'Size of the machine in mm')
+setting('machine_depth', '205', float, 'preference', 'hidden').setLabel('Maximum depth (mm)', 'Size of the machine in mm')
+setting('machine_height', '200', float, 'preference', 'hidden').setLabel('Maximum height (mm)', 'Size of the machine in mm')
+setting('machine_type', 'unknown', str, 'preference', 'hidden')
+setting('machine_center_is_zero', 'False', bool, 'preference', 'hidden')
+setting('ultimaker_extruder_upgrade', 'False', bool, 'preference', 'hidden')
+setting('has_heated_bed', 'False', bool, 'preference', 'hidden').setLabel('Heated bed', 'If you have an heated bed, this enabled heated bed settings (requires restart)')
+setting('reprap_name', 'RepRap', str, 'preference', 'hidden')
+setting('extruder_amount', '1', ['1','2','3','4'], 'preference', 'hidden').setLabel('Extruder count', 'Amount of extruders in your machine.')
+setting('extruder_offset_x1', '-21.6', float, 'preference', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_y1', '0.0', float, 'preference', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_x2', '0.0', float, 'preference', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_y2', '0.0', float, 'preference', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_x3', '0.0', float, 'preference', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_y3', '0.0', float, 'preference', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
+setting('filament_physical_density', '1300', float, 'preference', 'hidden').setRange(500.0, 3000.0).setLabel('Density (kg/m3)', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.')
+setting('steps_per_e', '0', float, 'preference', 'hidden').setRange(0).setLabel('E-Steps per 1mm filament', 'Amount of steps per mm filament extrusion')
+setting('serial_port', 'AUTO', str, 'preference', 'hidden').setLabel('Serial port', 'Serial port to use for communication with the printer')
+setting('serial_port_auto', '', str, 'preference', 'hidden')
+setting('serial_baud', 'AUTO', str, 'preference', 'hidden').setLabel('Baudrate', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600')
+setting('serial_baud_auto', '', int, 'preference', 'hidden')
+setting('save_profile', 'False', bool, 'preference', 'hidden').setLabel('Save profile on slice', 'When slicing save the profile as [stl_file]_profile.ini next to the model.')
+setting('filament_cost_kg', '0', float, 'preference', 'hidden').setLabel('Cost (price/kg)', 'Cost of your filament per kg, to estimate the cost of the final print.')
+setting('filament_cost_meter', '0', float, 'preference', 'hidden').setLabel('Cost (price/m)', 'Cost of your filament per meter, to estimate the cost of the final print.')
+setting('sdpath', '', str, 'preference', 'hidden').setLabel('SD card drive', 'Location of your SD card, when using the copy to SD feature.')
+setting('sdshortnames', 'False', bool, 'preference', 'hidden').setLabel('Copy to SD with 8.3 names', 'Save the gcode files in short filenames, so they are properly shown on the UltiController')
+setting('check_for_updates', 'True', bool, 'preference', 'hidden').setLabel('Check for updates', 'Check for newer versions of Cura on startup')
+setting('submit_slice_information', 'False', bool, 'preference', 'hidden').setLabel('Send usage statistics', 'Submit anonymous usage information to improve next versions of Cura')
+
+setting('planner_always_autoplace', 'True', bool, 'preference', 'hidden')
+setting('extruder_head_size_min_x', '75.0', float, 'preference', 'hidden')
+setting('extruder_head_size_min_y', '18.0', float, 'preference', 'hidden')
+setting('extruder_head_size_max_x', '18.0', float, 'preference', 'hidden')
+setting('extruder_head_size_max_y', '35.0', float, 'preference', 'hidden')
+setting('extruder_head_size_height', '60.0', float, 'preference', 'hidden')
+
+setting('model_colour', '#7AB645', str, 'preference', 'hidden').setLabel('Model colour')
+setting('model_colour2', '#CB3030', str, 'preference', 'hidden').setLabel('Model colour (2)')
+setting('model_colour3', '#DDD93C', str, 'preference', 'hidden').setLabel('Model colour (3)')
+setting('model_colour4', '#4550D3', str, 'preference', 'hidden').setLabel('Model colour (4)')
+
+setting('window_maximized', 'False', bool, 'preference', 'hidden')
+setting('window_pos_x', '-1', float, 'preference', 'hidden')
+setting('window_pos_y', '-1', float, 'preference', 'hidden')
+setting('window_width', '-1', float, 'preference', 'hidden')
+setting('window_height', '-1', float, 'preference', 'hidden')
+setting('window_normal_sash', '320', float, 'preference', 'hidden')
+
+validators.warningAbove(settingsDictionary['layer_height'], lambda : (float(getProfileSetting('nozzle_size')) * 80.0 / 100.0), "Thicker layers then %.2fmm (80%% nozzle size) usually give bad results and are not recommended.")
+validators.wallThicknessValidator(settingsDictionary['wall_thickness'])
+validators.warningAbove(settingsDictionary['print_speed'], 150.0, "It is highly unlikely that your machine can achieve a printing speed above 150mm/s")
+validators.printSpeedValidator(settingsDictionary['print_speed'])
+validators.warningAbove(settingsDictionary['print_temperature'], 260.0, "Temperatures above 260C could damage your machine, be careful!")
+validators.warningAbove(settingsDictionary['print_temperature2'], 260.0, "Temperatures above 260C could damage your machine, be careful!")
+validators.warningAbove(settingsDictionary['print_temperature3'], 260.0, "Temperatures above 260C could damage your machine, be careful!")
+validators.warningAbove(settingsDictionary['print_temperature4'], 260.0, "Temperatures above 260C could damage your machine, be careful!")
+validators.warningAbove(settingsDictionary['filament_diameter'], 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
+validators.warningAbove(settingsDictionary['filament_diameter2'], 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
+validators.warningAbove(settingsDictionary['filament_diameter3'], 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
+validators.warningAbove(settingsDictionary['filament_diameter4'], 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
+validators.warningAbove(settingsDictionary['travel_speed'], 300.0, "It is highly unlikely that your machine can achieve a travel speed above 300mm/s")
+validators.warningAbove(settingsDictionary['bottom_thickness'], lambda : (float(getProfileSetting('nozzle_size')) * 3.0 / 4.0), "A bottom layer of more then %.2fmm (3/4 nozzle size) usually give bad results and is not recommended.")
+
+#Conditions for multiple extruders
+settingsDictionary['print_temperature2'].addCondition(lambda : int(getPreference('extruder_amount')) > 1)
+settingsDictionary['print_temperature3'].addCondition(lambda : int(getPreference('extruder_amount')) > 2)
+settingsDictionary['print_temperature4'].addCondition(lambda : int(getPreference('extruder_amount')) > 3)
+settingsDictionary['filament_diameter2'].addCondition(lambda : int(getPreference('extruder_amount')) > 1)
+settingsDictionary['filament_diameter3'].addCondition(lambda : int(getPreference('extruder_amount')) > 2)
+settingsDictionary['filament_diameter4'].addCondition(lambda : int(getPreference('extruder_amount')) > 3)
+settingsDictionary['support_dual_extrusion'].addCondition(lambda : int(getPreference('extruder_amount')) > 1)
+#Heated bed
+settingsDictionary['print_bed_temperature'].addCondition(lambda : getPreference('has_heated_bed') == 'True')
 
 #########################################################
 ## Profile and preferences functions
 #########################################################
 
+def getSubCategoriesFor(category):
+       done = {}
+       ret = []
+       for s in settingsList:
+               if s.getCategory() == category and not s.getSubCategory() in done:
+                       done[s.getSubCategory()] = True
+                       ret.append(s.getSubCategory())
+       return ret
+
+def getSettingsForCategory(category, subCategory = None):
+       ret = []
+       for s in settingsList:
+               if s.getCategory() == category and (subCategory is None or s.getSubCategory() == subCategory):
+                       ret.append(s)
+       return ret
+
 ## Profile functions
 def getBasePath():
        if platform.system() == "Windows":
@@ -223,19 +346,46 @@ def getBasePath():
 def getDefaultProfilePath():
        return os.path.join(getBasePath(), 'current_profile.ini')
 
-def loadGlobalProfile(filename):
+def loadProfile(filename):
        #Read a configuration file as global config
-       global globalProfileParser
-       globalProfileParser = ConfigParser.ConfigParser()
+       profileParser = ConfigParser.ConfigParser()
        try:
-               globalProfileParser.read(filename)
+               profileParser.read(filename)
        except ConfigParser.ParsingError:
-               pass
+               return
+       global settingsList
+       for set in settingsList:
+               if set.isPreference():
+                       continue
+               section = 'profile'
+               if set.isAlteration():
+                       section = 'alterations'
+               if profileParser.has_option(section, set.getName()):
+                       set.setValue(unicode(profileParser.get(section, set.getName()), 'utf-8', 'replace'))
 
-def resetGlobalProfile():
+def saveProfile(filename):
+       #Save the current profile to an ini file
+       profileParser = ConfigParser.ConfigParser()
+       profileParser.add_section('profile')
+       profileParser.add_section('alterations')
+       global settingsList
+       for set in settingsList:
+               if set.isPreference():
+                       continue
+               if set.isAlteration():
+                       profileParser.set('alterations', set.getName(), set.getValue().encode('utf-8'))
+               else:
+                       profileParser.set('profile', set.getName(), set.getValue().encode('utf-8'))
+
+       profileParser.write(open(filename, 'w'))
+
+def resetProfile():
        #Read a configuration file as global config
-       global globalProfileParser
-       globalProfileParser = ConfigParser.ConfigParser()
+       global settingsList
+       for set in settingsList:
+               if set.isPreference():
+                       continue
+               set.setValue(set.getDefault())
 
        if getPreference('machine_type') == 'ultimaker':
                putProfileSetting('nozzle_size', '0.4')
@@ -244,69 +394,49 @@ def resetGlobalProfile():
        else:
                putProfileSetting('nozzle_size', '0.5')
 
-def saveGlobalProfile(filename):
-       #Save the current profile to an ini file
-       globalProfileParser.write(open(filename, 'w'))
-
-def loadGlobalProfileFromString(options):
-       global globalProfileParser
-       globalProfileParser = ConfigParser.ConfigParser()
-       globalProfileParser.add_section('profile')
-       globalProfileParser.add_section('alterations')
+def loadProfileFromString(options):
        options = base64.b64decode(options)
        options = zlib.decompress(options)
        (profileOpts, alt) = options.split('\f', 1)
+       global settingsDictionary
        for option in profileOpts.split('\b'):
                if len(option) > 0:
                        (key, value) = option.split('=', 1)
-                       globalProfileParser.set('profile', key, value)
+                       if key in settingsDictionary:
+                               if settingsDictionary[key].isProfile():
+                                       settingsDictionary[key].setValue(value)
        for option in alt.split('\b'):
                if len(option) > 0:
                        (key, value) = option.split('=', 1)
-                       globalProfileParser.set('alterations', key, value)
+                       if key in settingsDictionary:
+                               if settingsDictionary[key].isAlteration():
+                                       settingsDictionary[key].setValue(value)
 
-def getGlobalProfileString():
-       global globalProfileParser
-       if not globals().has_key('globalProfileParser'):
-               loadGlobalProfile(getDefaultProfilePath())
-       
+def getProfileString():
        p = []
        alt = []
-       tempDone = []
-       if globalProfileParser.has_section('profile'):
-               for key in globalProfileParser.options('profile'):
-                       if key in tempOverride:
-                               p.append(key + "=" + tempOverride[key])
-                               tempDone.append(key)
+       global settingsList
+       for set in settingsList:
+               if set.isProfile():
+                       if set.getName() in tempOverride:
+                               p.append(set.getName() + "=" + tempOverride[set.getName()])
                        else:
-                               p.append(key + "=" + globalProfileParser.get('profile', key))
-       if globalProfileParser.has_section('alterations'):
-               for key in globalProfileParser.options('alterations'):
-                       if key in tempOverride:
-                               p.append(key + "=" + tempOverride[key])
-                               tempDone.append(key)
+                               p.append(set.getName() + "=" + set.getValue())
+               if set.isAlteration():
+                       if set.getName() in tempOverride:
+                               alt.append(set.getName() + "=" + tempOverride[set.getName()])
                        else:
-                               alt.append(key + "=" + globalProfileParser.get('alterations', key))
-       for key in tempOverride:
-               if key not in tempDone:
-                       p.append(key + "=" + tempOverride[key])
+                               alt.append(set.getName() + "=" + set.getValue())
        ret = '\b'.join(p) + '\f' + '\b'.join(alt)
        ret = base64.b64encode(zlib.compress(ret, 9))
        return ret
 
 def getGlobalPreferencesString():
-       global globalPreferenceParser
-       if globalPreferenceParser is None:
-               globalPreferenceParser = ConfigParser.ConfigParser()
-               try:
-                       globalPreferenceParser.read(getPreferencePath())
-               except ConfigParser.ParsingError:
-                       pass
-
        p = []
-       if globalPreferenceParser.has_section('preference'):
-               for key in globalPreferenceParser.options('preference'):
-                       p.append(key + "=" + globalPreferenceParser.get('preference', key))
+       global settingsList
+       for set in settingsList:
+               if set.isPreference():
+                       p.append(set.getName() + "=" + set.getValue())
        ret = '\b'.join(p)
        ret = base64.b64encode(zlib.compress(ret, 9))
        return ret
@@ -314,23 +444,12 @@ def getGlobalPreferencesString():
 
 def getProfileSetting(name):
        if name in tempOverride:
-               return unicode(tempOverride[name], "utf-8")
-       #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 name in profileDefaultSettings:
-                       default = profileDefaultSettings[name]
-               else:
-                       print("Missing default setting for: '" + name + "'")
-                       profileDefaultSettings[name] = ''
-                       default = ''
-               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)
+               return tempOverride[name]
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isProfile():
+               return settingsDictionary[name].getValue()
+       print 'Error: "%s" not found in profile settings' % (name)
+       return ''
 
 def getProfileSettingFloat(name):
        try:
@@ -341,21 +460,17 @@ def getProfileSettingFloat(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 settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isProfile():
+               settingsDictionary[name].setValue(value)
 
 def isProfileSetting(name):
-       if name in profileDefaultSettings:
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isProfile():
                return True
        return False
 
 ## Preferences functions
-global globalPreferenceParser
-globalPreferenceParser = None
-
 def getPreferencePath():
        return os.path.join(getBasePath(), 'preferences.ini')
 
@@ -370,46 +485,48 @@ def getPreferenceColour(name):
        colorString = getPreference(name)
        return [float(int(colorString[1:3], 16)) / 255, float(int(colorString[3:5], 16)) / 255, float(int(colorString[5:7], 16)) / 255, 1.0]
 
+def loadPreferences(filename):
+       #Read a configuration file as global config
+       profileParser = ConfigParser.ConfigParser()
+       try:
+               profileParser.read(filename)
+       except ConfigParser.ParsingError:
+               return
+       global settingsList
+       for set in settingsList:
+               if set.isPreference():
+                       if profileParser.has_option('preferences', set.getName()):
+                               set.setValue(unicode(profileParser.get('preferences', set.getName()), 'utf-8', 'replace'))
+
+def savePreferences(filename):
+       #Save the current profile to an ini file
+       parser = ConfigParser.ConfigParser()
+       parser.add_section('preferences')
+       global settingsList
+       for set in settingsList:
+               if set.isPreference():
+                       parser.set('preferences', set.getName(), set.getValue().encode('utf-8'))
+       parser.write(open(filename, 'w'))
+
 def getPreference(name):
        if name in tempOverride:
-               return unicode(tempOverride[name])
-       global globalPreferenceParser
-       if globalPreferenceParser is None:
-               globalPreferenceParser = ConfigParser.ConfigParser()
-               try:
-                       globalPreferenceParser.read(getPreferencePath())
-               except ConfigParser.ParsingError:
-                       pass
-       if not globalPreferenceParser.has_option('preference', name):
-               if name in preferencesDefaultSettings:
-                       default = preferencesDefaultSettings[name]
-               else:
-                       print("Missing default setting for: '" + name + "'")
-                       preferencesDefaultSettings[name] = ''
-                       default = ''
-               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 unicode(globalPreferenceParser.get('preference', name), "utf-8")
+               return tempOverride[name]
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isPreference():
+               return settingsDictionary[name].getValue()
+       print 'Error: "%s" not found in profile settings' % (name)
+       return ''
 
 def putPreference(name, value):
        #Check if we have a configuration file loaded, else load the default.
-       global globalPreferenceParser
-       if globalPreferenceParser == None:
-               globalPreferenceParser = ConfigParser.ConfigParser()
-               try:
-                       globalPreferenceParser.read(getPreferencePath())
-               except ConfigParser.ParsingError:
-                       pass
-       if not globalPreferenceParser.has_section('preference'):
-               globalPreferenceParser.add_section('preference')
-       globalPreferenceParser.set('preference', name, unicode(value).encode("utf-8"))
-       globalPreferenceParser.write(open(getPreferencePath(), 'w'))
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isPreference():
+               settingsDictionary[name].setValue(value)
+       savePreferences(getPreferencePath())
 
 def isPreference(name):
-       if name in preferencesDefaultSettings:
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isPreference():
                return True
        return False
 
@@ -518,31 +635,20 @@ def replaceGCodeTags(filename, gcodeInt):
 
 ### Get aleration raw contents. (Used internally in Cura)
 def getAlterationFile(filename):
+       if filename in tempOverride:
+               return tempOverride[filename]
+       global settingsDictionary
+       if filename in settingsDictionary and settingsDictionary[filename].isAlteration():
+               return settingsDictionary[filename].getValue()
+       print 'Error: "%s" not found in profile settings' % (filename)
+       return ''
+
+def setAlterationFile(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_option('alterations', filename):
-               if filename in alterationDefault:
-                       default = alterationDefault[filename]
-               else:
-                       print("Missing default alteration for: '" + filename + "'")
-                       alterationDefault[filename] = ''
-                       default = ''
-               if not globalProfileParser.has_section('alterations'):
-                       globalProfileParser.add_section('alterations')
-               #print("Using default for: %s" % (filename))
-               globalProfileParser.set('alterations', filename, default)
-       return unicode(globalProfileParser.get('alterations', filename), "utf-8")
-
-def setAlterationFile(filename, 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('alterations'):
-               globalProfileParser.add_section('alterations')
-       globalProfileParser.set('alterations', filename, value.encode("utf-8"))
-       saveGlobalProfile(getDefaultProfilePath())
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isAlteration():
+               settingsDictionary[name].setValue(value)
+       saveProfile(getDefaultProfilePath())
 
 ### Get the alteration file for output. (Used by Skeinforge)
 def getAlterationFileContents(filename, extruderCount = 1):
@@ -581,7 +687,7 @@ def getAlterationFileContents(filename, extruderCount = 1):
                        prefix += 'M190 S%f\n' % (bedTemp)
        elif filename == 'end.gcode':
                #Append the profile string to the end of the GCode, so we can load it from the GCode file later.
-               postfix = ';CURA_PROFILE_STRING:%s\n' % (getGlobalProfileString())
+               postfix = ';CURA_PROFILE_STRING:%s\n' % (getProfileString())
        elif filename == 'replace.csv':
                #Always remove the extruder on/off M codes. These are no longer needed in 5D printing.
                prefix = 'M101\nM103\n'
index 094d8f6e1fc9f8a7ff1c6078abc144d4e35d013d..139e7c46a5514e2b96b88b9d2814519982a537da 100644 (file)
@@ -67,7 +67,7 @@ def getSliceCommand(outputfilename, filenames, positions):
        pypyExe = getPyPyExe()
        if pypyExe is None:
                pypyExe = sys.executable
-       cmd = [pypyExe, '-m', 'Cura.slice', '-p', profile.getGlobalProfileString(), '-o']
+       cmd = [pypyExe, '-m', 'Cura.slice', '-p', profile.getProfileString(), '-o']
        try:
                cmd.append(str(outputfilename))
        except UnicodeEncodeError:
index d226c6065d5afd8f4745f6481c7274025a6ee685..4decec0b55ab8bae019eea2f6604ff20d4795d5c 100644 (file)
@@ -4,8 +4,6 @@ from __future__ import division
 import types
 import math
 
-from Cura.util import profile
-
 SUCCESS = 0
 WARNING = 1
 ERROR   = 2
@@ -13,49 +11,49 @@ ERROR   = 2
 class validFloat(object):
        def __init__(self, setting, minValue = None, maxValue = None):
                self.setting = setting
-               self.setting.validators.append(self)
+               self.setting._validators.append(self)
                self.minValue = minValue
                self.maxValue = maxValue
        
        def validate(self):
                try:
-                       f = float(eval(self.setting.GetValue().replace(',','.'), {}, {}))
+                       f = float(eval(self.setting.getValue().replace(',','.'), {}, {}))
                        if self.minValue is not None and f < self.minValue:
-                               return ERROR, 'This setting should not be below ' + str(self.minValue)
-                       if self.maxValue != None and f > self.maxValue:
+                               return ERROR, 'This setting should not be below ' + str(round(self.minValue, 3))
+                       if self.maxValue is not None and f > self.maxValue:
                                return ERROR, 'This setting should not be above ' + str(self.maxValue)
                        return SUCCESS, ''
-               except (ValueError, SyntaxError, TypeError):
-                       return ERROR, '"' + str(self.setting.GetValue()) + '" is not a valid number or expression'
+               except (ValueError, SyntaxError, TypeError, NameError):
+                       return ERROR, '"' + str(self.setting.getValue()) + '" is not a valid number or expression'
 
 class validInt(object):
        def __init__(self, setting, minValue = None, maxValue = None):
                self.setting = setting
-               self.setting.validators.append(self)
+               self.setting._validators.append(self)
                self.minValue = minValue
                self.maxValue = maxValue
        
        def validate(self):
                try:
-                       f = int(eval(self.setting.GetValue(), {}, {}))
-                       if self.minValue != None and f < self.minValue:
+                       f = int(eval(self.setting.getValue(), {}, {}))
+                       if self.minValue is not None and f < self.minValue:
                                return ERROR, 'This setting should not be below ' + str(self.minValue)
-                       if self.maxValue != None and f > self.maxValue:
+                       if self.maxValue is not None and f > self.maxValue:
                                return ERROR, 'This setting should not be above ' + str(self.maxValue)
                        return SUCCESS, ''
-               except (ValueError, SyntaxError, TypeError):
-                       return ERROR, '"' + str(self.setting.GetValue()) + '" is not a valid whole number or expression'
+               except (ValueError, SyntaxError, TypeError, NameError):
+                       return ERROR, '"' + str(self.setting.getValue()) + '" is not a valid whole number or expression'
 
 class warningAbove(object):
        def __init__(self, setting, minValueForWarning, warningMessage):
                self.setting = setting
-               self.setting.validators.append(self)
+               self.setting._validators.append(self)
                self.minValueForWarning = minValueForWarning
                self.warningMessage = warningMessage
        
        def validate(self):
                try:
-                       f = float(eval(self.setting.GetValue().replace(',','.'), {}, {}))
+                       f = float(eval(self.setting.getValue().replace(',','.'), {}, {}))
                        if isinstance(self.minValueForWarning, types.FunctionType):
                                if f >= self.minValueForWarning():
                                        return WARNING, self.warningMessage % (self.minValueForWarning())
@@ -70,9 +68,10 @@ class warningAbove(object):
 class wallThicknessValidator(object):
        def __init__(self, setting):
                self.setting = setting
-               self.setting.validators.append(self)
+               self.setting._validators.append(self)
        
        def validate(self):
+               from Cura.util import profile
                try:
                        wallThickness = profile.getProfileSettingFloat('wall_thickness')
                        nozzleSize = profile.getProfileSettingFloat('nozzle_size')
@@ -96,9 +95,10 @@ class wallThicknessValidator(object):
 class printSpeedValidator(object):
        def __init__(self, setting):
                self.setting = setting
-               self.setting.validators.append(self)
+               self.setting._validators.append(self)
 
        def validate(self):
+               from Cura.util import profile
                try:
                        nozzleSize = profile.getProfileSettingFloat('nozzle_size')
                        layerHeight = profile.getProfileSettingFloat('layer_height')