chiark / gitweb /
Seperate the machine settings from the preference settings
authordaid <daid303@gmail.com>
Wed, 18 Sep 2013 08:05:57 +0000 (10:05 +0200)
committerdaid <daid303@gmail.com>
Wed, 18 Sep 2013 08:05:57 +0000 (10:05 +0200)
15 files changed:
Cura/gui/alterationPanel.py
Cura/gui/app.py
Cura/gui/configWizard.py
Cura/gui/firmwareInstall.py
Cura/gui/mainWindow.py
Cura/gui/preferencesDialog.py
Cura/gui/sceneView.py
Cura/gui/simpleMode.py
Cura/gui/util/opengl.py
Cura/gui/util/webcam.py
Cura/util/gcodeInterpreter.py
Cura/util/machineCom.py
Cura/util/profile.py
Cura/util/sliceEngine.py
Cura/util/svg.py

index 4e2b64f21f0cdc18af69af3bd96b1201c8d9b955..ec07bc1efeb3c9c394df4d51458cbc6f1f1c8dc7 100644 (file)
@@ -12,7 +12,7 @@ class alterationPanel(wx.Panel):
 
                self.callback = callback
                self.alterationFileList = ['start.gcode', 'end.gcode']#, 'nextobject.gcode', 'replace.csv'
-               if int(profile.getPreference('extruder_amount')) > 1:
+               if int(profile.getMachineSetting('extruder_amount')) > 1:
                        self.alterationFileList += ['start2.gcode', 'end2.gcode']
                self.currentFile = None
 
index 657c9601206fbc7a74182431825515af999ee6bb..681da39eac152b7981b30c5f278e473c3b8609b9 100644 (file)
@@ -48,17 +48,19 @@ class CuraApp(wx.App):
                resources.setupLocalization()  # it's important to set up localization at very beginning to install _
 
                #If we do not have preferences yet, try to load it from a previous Cura install
-               if profile.getPreference('machine_type') == 'unknown':
+               if profile.getMachineSetting('machine_type') == 'unknown':
                        try:
                                otherCuraInstalls = profile.getAlternativeBasePaths()
                                otherCuraInstalls.sort()
-                               profile.loadPreferences(os.path.join(otherCuraInstalls[-1], 'preferences.ini'))
-                               profile.loadProfile(os.path.join(otherCuraInstalls[-1], 'current_profile.ini'))
+                               if len(otherCuraInstalls) > 0:
+                                       profile.loadPreferences(os.path.join(otherCuraInstalls[-1], 'preferences.ini'))
+                                       profile.loadProfile(os.path.join(otherCuraInstalls[-1], 'current_profile.ini'))
                        except:
-                               print sys.exc_info()
+                               import traceback
+                               print traceback.print_exc()
 
                #If we haven't run it before, run the configuration wizard.
-               if profile.getPreference('machine_type') == 'unknown':
+               if profile.getMachineSetting('machine_type') == 'unknown':
                        if platform.system() == "Windows":
                                exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'UltimakerRobot_support.stl'))
                        else:
index f68f8d8c4d863aa3a3f25f8d29eef45cbe2bd43f..9f575fd5e38595a4be27fde122d2ee6639ab9370 100644 (file)
@@ -289,37 +289,37 @@ class MachineSelectPage(InfoPage):
 
        def StoreData(self):
                if self.Ultimaker2Radio.GetValue():
-                       profile.putPreference('machine_width', '230')
-                       profile.putPreference('machine_depth', '225')
-                       profile.putPreference('machine_height', '205')
-                       profile.putPreference('machine_type', 'ultimaker2')
-                       profile.putPreference('machine_center_is_zero', 'False')
-                       profile.putPreference('gcode_flavor', 'UltiGCode')
+                       profile.putMachineSetting('machine_width', '230')
+                       profile.putMachineSetting('machine_depth', '225')
+                       profile.putMachineSetting('machine_height', '205')
+                       profile.putMachineSetting('machine_type', 'ultimaker2')
+                       profile.putMachineSetting('machine_center_is_zero', 'False')
+                       profile.putMachineSetting('gcode_flavor', 'UltiGCode')
                        profile.putProfileSetting('nozzle_size', '0.4')
-                       profile.putPreference('extruder_head_size_min_x', '75.0')
-                       profile.putPreference('extruder_head_size_min_y', '18.0')
-                       profile.putPreference('extruder_head_size_max_x', '18.0')
-                       profile.putPreference('extruder_head_size_max_y', '35.0')
-                       profile.putPreference('extruder_head_size_height', '60.0')
+                       profile.putMachineSetting('extruder_head_size_min_x', '75.0')
+                       profile.putMachineSetting('extruder_head_size_min_y', '18.0')
+                       profile.putMachineSetting('extruder_head_size_max_x', '18.0')
+                       profile.putMachineSetting('extruder_head_size_max_y', '35.0')
+                       profile.putMachineSetting('extruder_head_size_height', '60.0')
                elif self.UltimakerRadio.GetValue():
-                       profile.putPreference('machine_width', '205')
-                       profile.putPreference('machine_depth', '205')
-                       profile.putPreference('machine_height', '200')
-                       profile.putPreference('machine_type', 'ultimaker')
-                       profile.putPreference('machine_center_is_zero', 'False')
-                       profile.putPreference('gcode_flavor', 'RepRap (Marlin/Sprinter)')
+                       profile.putMachineSetting('machine_width', '205')
+                       profile.putMachineSetting('machine_depth', '205')
+                       profile.putMachineSetting('machine_height', '200')
+                       profile.putMachineSetting('machine_type', 'ultimaker')
+                       profile.putMachineSetting('machine_center_is_zero', 'False')
+                       profile.putMachineSetting('gcode_flavor', 'RepRap (Marlin/Sprinter)')
                        profile.putProfileSetting('nozzle_size', '0.4')
-                       profile.putPreference('extruder_head_size_min_x', '75.0')
-                       profile.putPreference('extruder_head_size_min_y', '18.0')
-                       profile.putPreference('extruder_head_size_max_x', '18.0')
-                       profile.putPreference('extruder_head_size_max_y', '35.0')
-                       profile.putPreference('extruder_head_size_height', '60.0')
+                       profile.putMachineSetting('extruder_head_size_min_x', '75.0')
+                       profile.putMachineSetting('extruder_head_size_min_y', '18.0')
+                       profile.putMachineSetting('extruder_head_size_max_x', '18.0')
+                       profile.putMachineSetting('extruder_head_size_max_y', '35.0')
+                       profile.putMachineSetting('extruder_head_size_height', '60.0')
                else:
-                       profile.putPreference('machine_width', '80')
-                       profile.putPreference('machine_depth', '80')
-                       profile.putPreference('machine_height', '60')
-                       profile.putPreference('machine_type', 'reprap')
-                       profile.putPreference('gcode_flavor', 'RepRap (Marlin/Sprinter)')
+                       profile.putMachineSetting('machine_width', '80')
+                       profile.putMachineSetting('machine_depth', '80')
+                       profile.putMachineSetting('machine_height', '60')
+                       profile.putMachineSetting('machine_type', 'reprap')
+                       profile.putMachineSetting('gcode_flavor', 'RepRap (Marlin/Sprinter)')
                        profile.putPreference('startMode', 'Normal')
                        profile.putProfileSetting('nozzle_size', '0.5')
                profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2)
@@ -342,14 +342,14 @@ class SelectParts(InfoPage):
                self.springExtruder.SetValue(True)
 
        def StoreData(self):
-               profile.putPreference('ultimaker_extruder_upgrade', str(self.springExtruder.GetValue()))
-               profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue()))
+               profile.putMachineSetting('ultimaker_extruder_upgrade', str(self.springExtruder.GetValue()))
+               profile.putMachineSetting('has_heated_bed', str(self.heatedBed.GetValue()))
                if self.dualExtrusion.GetValue():
-                       profile.putPreference('extruder_amount', '2')
-                       profile.putPreference('machine_depth', '195')
+                       profile.putMachineSetting('extruder_amount', '2')
+                       profile.putMachineSetting('machine_depth', '195')
                else:
-                       profile.putPreference('extruder_amount', '1')
-               if profile.getPreference('ultimaker_extruder_upgrade') == 'True':
+                       profile.putMachineSetting('extruder_amount', '1')
+               if profile.getMachineSetting('ultimaker_extruder_upgrade') == 'True':
                        profile.putProfileSetting('retraction_enable', 'True')
                else:
                        profile.putProfileSetting('retraction_enable', 'False')
@@ -491,7 +491,7 @@ class UltimakerCheckupPage(InfoPage):
                        if temp[self.checkExtruderNr] > self.startTemp + 40:
                                self.comm.sendCommand('M104 S0 T%d' % (self.checkExtruderNr))
                                self.comm.sendCommand('M104 S0 T%d' % (self.checkExtruderNr))
-                               if self.checkExtruderNr < int(profile.getPreference('extruder_amount')):
+                               if self.checkExtruderNr < int(profile.getMachineSetting('extruder_amount')):
                                        self.checkExtruderNr = 0
                                        self.checkupState = 3
                                        wx.CallAfter(self.infoBox.SetAttention, _("Please make sure none of the endstops are pressed."))
@@ -638,8 +638,8 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
        def __init__(self, parent):
                super(UltimakerCalibrateStepsPerEPage, self).__init__(parent, "Ultimaker Calibration")
 
-               #if profile.getPreference('steps_per_e') == '0':
-               #       profile.putPreference('steps_per_e', '865.888')
+               #if profile.getMachineSetting('steps_per_e') == '0':
+               #       profile.putMachineSetting('steps_per_e', '865.888')
 
                self.AddText(_("Calibrating the Steps Per E requires some manual actions."))
                self.AddText(_("First remove any filament from your machine."))
@@ -649,7 +649,7 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
                self.AddText(_("Now measure the amount of extruded filament:\n(this can be more or less then 100mm)"))
                self.lengthInput, self.saveLengthButton = self.AddTextCtrlButton("100", _("Save"))
                self.AddText(_("This results in the following steps per E:"))
-               self.stepsPerEInput = self.AddTextCtrl(profile.getPreference('steps_per_e'))
+               self.stepsPerEInput = self.AddTextCtrl(profile.getMachineSetting('steps_per_e'))
                self.AddText(_("You can repeat these steps to get better calibration."))
                self.AddSeperator()
                self.AddText(
@@ -832,7 +832,7 @@ class bedLevelWizardMain(InfoPage):
                self._wizardState = 0
 
        def AllowNext(self):
-               if self.GetParent().headOffsetCalibration is not None and int(profile.getPreference('extruder_amount')) > 1:
+               if self.GetParent().headOffsetCalibration is not None and int(profile.getMachineSetting('extruder_amount')) > 1:
                        wx.wizard.WizardPageSimple.Chain(self, self.GetParent().headOffsetCalibration)
                return True
 
@@ -842,21 +842,21 @@ class bedLevelWizardMain(InfoPage):
                if self._wizardState == 2:
                        wx.CallAfter(self.infoBox.SetBusy, 'Moving head to back left corner...')
                        self.comm.sendCommand('G1 Z3 F%d' % (feedZ))
-                       self.comm.sendCommand('G1 X%d Y%d F%d' % (0, profile.getPreferenceFloat('machine_depth'), feedTravel))
+                       self.comm.sendCommand('G1 X%d Y%d F%d' % (0, profile.getMachineSettingFloat('machine_depth'), feedTravel))
                        self.comm.sendCommand('G1 Z0 F%d' % (feedZ))
                        self.comm.sendCommand('M400')
                        self._wizardState = 3
                elif self._wizardState == 4:
                        wx.CallAfter(self.infoBox.SetBusy, 'Moving head to back right corner...')
                        self.comm.sendCommand('G1 Z3 F%d' % (feedZ))
-                       self.comm.sendCommand('G1 X%d Y%d F%d' % (profile.getPreferenceFloat('machine_width') - 5.0, profile.getPreferenceFloat('machine_depth') - 25, feedTravel))
+                       self.comm.sendCommand('G1 X%d Y%d F%d' % (profile.getMachineSettingFloat('machine_width') - 5.0, profile.getMachineSettingFloat('machine_depth') - 25, feedTravel))
                        self.comm.sendCommand('G1 Z0 F%d' % (feedZ))
                        self.comm.sendCommand('M400')
                        self._wizardState = 5
                elif self._wizardState == 6:
                        wx.CallAfter(self.infoBox.SetBusy, 'Moving head to front right corner...')
                        self.comm.sendCommand('G1 Z3 F%d' % (feedZ))
-                       self.comm.sendCommand('G1 X%d Y%d F%d' % (profile.getPreferenceFloat('machine_width') - 5.0, 20, feedTravel))
+                       self.comm.sendCommand('G1 X%d Y%d F%d' % (profile.getMachineSettingFloat('machine_width') - 5.0, 20, feedTravel))
                        self.comm.sendCommand('G1 Z0 F%d' % (feedZ))
                        self.comm.sendCommand('M400')
                        self._wizardState = 7
@@ -872,8 +872,8 @@ class bedLevelWizardMain(InfoPage):
                        feedZ = profile.getProfileSettingFloat('print_speed') * 60
                        feedPrint = profile.getProfileSettingFloat('print_speed') * 60
                        feedTravel = profile.getProfileSettingFloat('travel_speed') * 60
-                       w = profile.getPreferenceFloat('machine_width')
-                       d = profile.getPreferenceFloat('machine_depth')
+                       w = profile.getMachineSettingFloat('machine_width')
+                       d = profile.getMachineSettingFloat('machine_depth')
                        filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2
                        filamentArea = math.pi * filamentRadius * filamentRadius
                        ePerMM = (profile.calculateEdgeWidth() * 0.3) / filamentArea
@@ -997,8 +997,8 @@ class headOffsetCalibrationPage(InfoPage):
                        self._wizardState = 3
                        wx.CallAfter(self.infoBox.SetBusy, 'Printing initial calibration cross')
 
-                       w = profile.getPreferenceFloat('machine_width')
-                       d = profile.getPreferenceFloat('machine_depth')
+                       w = profile.getMachineSettingFloat('machine_width')
+                       d = profile.getMachineSettingFloat('machine_depth')
 
                        gcode = gcodeGenerator.gcodeGenerator()
                        gcode.setExtrusionRate(profile.getProfileSettingFloat('nozzle_size') * 1.5, 0.2)
@@ -1058,8 +1058,8 @@ class headOffsetCalibrationPage(InfoPage):
                        self.textEntry.Enable(False)
                        self.resumeButton.Enable(False)
 
-                       x = profile.getPreferenceFloat('extruder_offset_x1')
-                       y = profile.getPreferenceFloat('extruder_offset_y1')
+                       x = profile.getMachineSettingFloat('extruder_offset_x1')
+                       y = profile.getMachineSettingFloat('extruder_offset_y1')
                        gcode = gcodeGenerator.gcodeGenerator()
                        gcode.setExtrusionRate(profile.getProfileSettingFloat('nozzle_size') * 1.5, 0.2)
                        gcode.setPrintSpeed(25)
@@ -1105,7 +1105,7 @@ class headOffsetCalibrationPage(InfoPage):
                                n = int(self.textEntry.GetValue()) - 1
                        except:
                                return
-                       x = profile.getPreferenceFloat('extruder_offset_x1')
+                       x = profile.getMachineSettingFloat('extruder_offset_x1')
                        x += -1.0 + n * 0.1
                        profile.putPreference('extruder_offset_x1', '%0.2f' % (x))
                        self.infoBox.SetAttention('Which horizontal line number lays perfect on top of each other? Front most line is zero.')
@@ -1116,10 +1116,10 @@ class headOffsetCalibrationPage(InfoPage):
                                n = int(self.textEntry.GetValue()) - 1
                        except:
                                return
-                       y = profile.getPreferenceFloat('extruder_offset_y1')
+                       y = profile.getMachineSettingFloat('extruder_offset_y1')
                        y += -1.0 + n * 0.1
                        profile.putPreference('extruder_offset_y1', '%0.2f' % (y))
-                       self.infoBox.SetInfo('Calibration finished. Offsets are: %s %s' % (profile.getPreferenceFloat('extruder_offset_x1'), profile.getPreferenceFloat('extruder_offset_y1')))
+                       self.infoBox.SetInfo('Calibration finished. Offsets are: %s %s' % (profile.getMachineSettingFloat('extruder_offset_x1'), profile.getMachineSettingFloat('extruder_offset_y1')))
                        self.infoBox.SetReadyIndicator()
                        self._wizardState = 8
                        self.comm.close()
index 2dc4ef74b303e1b10faac6de240c250b0ec21465..2892b06377fa77990e6f97dc926d0570fb6acd93 100644 (file)
@@ -12,12 +12,12 @@ from Cura.util import profile
 from Cura.util import resources
 
 def getDefaultFirmware():
-       if profile.getPreference('machine_type') == 'ultimaker':
-               if profile.getPreference('has_heated_bed') == 'True':
+       if profile.getMachineSetting('machine_type') == 'ultimaker':
+               if profile.getMachineSetting('has_heated_bed') == 'True':
                        return None
-               if profile.getPreferenceFloat('extruder_amount') > 2:
+               if profile.getMachineSettingFloat('extruder_amount') > 2:
                        return None
-               if profile.getPreferenceFloat('extruder_amount') > 1:
+               if profile.getMachineSettingFloat('extruder_amount') > 1:
                        if sys.platform.startswith('linux'):
                                return resources.getPathForFirmware("MarlinUltimaker-115200-dual.hex")
                        else:
@@ -32,7 +32,7 @@ class InstallFirmware(wx.Dialog):
        def __init__(self, filename = None, port = None):
                super(InstallFirmware, self).__init__(parent=None, title="Firmware install", size=(250, 100))
                if port is None:
-                       port = profile.getPreference('serial_port')
+                       port = profile.getMachineSetting('serial_port')
                if filename is None:
                        filename = getDefaultFirmware()
                if filename is None:
index 41cb1f0615b3f9ffd4b7575800c9eb6bce1f420d..cdfee11c2c5bca70d48788c8464709d6085f3f73 100644 (file)
@@ -27,7 +27,7 @@ class mainWindow(wx.Frame):
        def __init__(self):
                super(mainWindow, self).__init__(None, title='Cura - ' + version.getVersion())
 
-               self.extruderCount = int(profile.getPreference('extruder_amount'))
+               self.extruderCount = int(profile.getMachineSetting('extruder_amount'))
 
                wx.EVT_CLOSE(self, self.OnClose)
 
@@ -491,7 +491,7 @@ class normalSettingsPanel(configBase.configPanelBase):
                        self.pluginPanel.Show(False)
 
                #Alteration page
-               if profile.getPreference('gcode_flavor') == 'UltiGCode':
+               if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
                        self.alterationPanel = None
                else:
                        self.alterationPanel = alterationPanel.alterationPanel(self.nb, callback)
index 8f85503acebd4d4e83f91a244efcc240c8586d87..b14a55baab5b4d0f51d81b4d9c5fe4f33fec4f4a 100644 (file)
@@ -14,7 +14,7 @@ class preferencesDialog(wx.Dialog):
                wx.EVT_CLOSE(self, self.OnClose)
 
                self.parent = parent
-               self.oldExtruderAmount = int(profile.getPreference('extruder_amount'))
+               self.oldExtruderAmount = int(profile.getMachineSetting('extruder_amount'))
 
                self.panel = configBase.configPanelBase(self)
 
@@ -72,7 +72,7 @@ class preferencesDialog(wx.Dialog):
                self.Fit()
 
        def OnClose(self, e):
-               if self.oldExtruderAmount != int(profile.getPreference('extruder_amount')):
+               if self.oldExtruderAmount != int(profile.getMachineSetting('extruder_amount')):
                        wx.MessageBox(_("After changing the amount of extruders you need to restart Cura for full effect."), _("Extruder amount warning."), wx.OK | wx.ICON_INFORMATION)
                self.parent.updateProfileToControls()
                self.Destroy()
index 5023bdc51b64326ca81d3dd2b46ff08ab7e27ae7..3173e294a32699ffbfdfad2142c198dff4d9f01d 100644 (file)
@@ -51,7 +51,7 @@ class SceneView(openglGui.glGuiPanel):
                self._viewTarget = numpy.array([0,0,0], numpy.float32)
                self._animView = None
                self._animZoom = None
-               self._platformMesh = None
+               self._platformMesh = {}
                self._isSimpleMode = True
                self._usbPrintMonitor = printWindow.printProcessMonitor(lambda : self._queueRefresh())
 
@@ -524,14 +524,14 @@ class SceneView(openglGui.glGuiPanel):
                if self._isSimpleMode != oldSimpleMode:
                        self._scene.arrangeAll()
                        self.sceneUpdated()
-               self._machineSize = numpy.array([profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')])
+               self._machineSize = numpy.array([profile.getMachineSettingFloat('machine_width'), profile.getMachineSettingFloat('machine_depth'), profile.getMachineSettingFloat('machine_height')])
                self._objColors[0] = profile.getPreferenceColour('model_colour')
                self._objColors[1] = profile.getPreferenceColour('model_colour2')
                self._objColors[2] = profile.getPreferenceColour('model_colour3')
                self._objColors[3] = profile.getPreferenceColour('model_colour4')
                self._scene.setMachineSize(self._machineSize)
                self._scene.setSizeOffsets(numpy.array(profile.calculateObjectSizeOffsets(), numpy.float32))
-               self._scene.setHeadSize(profile.getPreferenceFloat('extruder_head_size_min_x'), profile.getPreferenceFloat('extruder_head_size_max_x'), profile.getPreferenceFloat('extruder_head_size_min_y'), profile.getPreferenceFloat('extruder_head_size_max_y'), profile.getPreferenceFloat('extruder_head_size_height'))
+               self._scene.setHeadSize(profile.getMachineSettingFloat('extruder_head_size_min_x'), profile.getMachineSettingFloat('extruder_head_size_max_x'), profile.getMachineSettingFloat('extruder_head_size_min_y'), profile.getMachineSettingFloat('extruder_head_size_max_y'), profile.getMachineSettingFloat('extruder_head_size_height'))
 
                if self._selectedObj is not None:
                        scale = self._selectedObj.getScale()
@@ -620,7 +620,7 @@ class SceneView(openglGui.glGuiPanel):
                                                self.Bind(wx.EVT_MENU, lambda e: self._deleteObject(self._focusObj), menu.Append(-1, _("Delete")))
                                                self.Bind(wx.EVT_MENU, self.OnMultiply, menu.Append(-1, _("Multiply")))
                                                self.Bind(wx.EVT_MENU, self.OnSplitObject, menu.Append(-1, _("Split")))
-                                       if ((self._selectedObj != self._focusObj and self._focusObj is not None and self._selectedObj is not None) or len(self._scene.objects()) == 2) and int(profile.getPreference('extruder_amount')) > 1:
+                                       if ((self._selectedObj != self._focusObj and self._focusObj is not None and self._selectedObj is not None) or len(self._scene.objects()) == 2) and int(profile.getMachineSetting('extruder_amount')) > 1:
                                                self.Bind(wx.EVT_MENU, self.OnMergeObjects, menu.Append(-1, _("Dual extrusion merge")))
                                        if len(self._scene.objects()) > 0:
                                                self.Bind(wx.EVT_MENU, self.OnDeleteAll, menu.Append(-1, _("Delete all")))
@@ -890,7 +890,7 @@ void main(void)
                                self._gcodeLoadThread.start()
                        if self._gcode is not None and self._gcode.layerList is not None:
                                glPushMatrix()
-                               if profile.getPreference('machine_center_is_zero') != 'True':
+                               if profile.getMachineSetting('machine_center_is_zero') != 'True':
                                        glTranslate(-self._machineSize[0] / 2, -self._machineSize[1] / 2, 0)
                                t = time.time()
                                drawUpTill = min(len(self._gcode.layerList), self.layerSelect.getValue() + 1)
@@ -1143,19 +1143,23 @@ void main(void)
                glEnable(GL_CULL_FACE)
                glEnable(GL_BLEND)
 
-               size = [profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')]
+               size = [profile.getMachineSettingFloat('machine_width'), profile.getMachineSettingFloat('machine_depth'), profile.getMachineSettingFloat('machine_height')]
 
-               if profile.getPreference('machine_type').startswith('ultimaker'):
-                       if self._platformMesh is None:
-                               if profile.getPreference('machine_type') == 'ultimaker2':
-                                       self._platformMesh = meshLoader.loadMeshes(resources.getPathForMesh('ultimaker2_platform.stl'))[0]
-                                       self._platformMesh._drawOffset = numpy.array([0,-37,145], numpy.float32)
+               machine = profile.getMachineSetting('machine_type')
+               if profile.getMachineSetting('machine_type').startswith('ultimaker'):
+                       if machine not in self._platformMesh:
+                               meshes = meshLoader.loadMeshes(resources.getPathForMesh(machine + '_platform.stl'))
+                               if len(meshes) > 0:
+                                       self._platformMesh[machine] = meshes[0]
                                else:
-                                       self._platformMesh = meshLoader.loadMeshes(resources.getPathForMesh('ultimaker_platform.stl'))[0]
-                                       self._platformMesh._drawOffset = numpy.array([0,0,2.5], numpy.float32)
+                                       self._platformMesh[machine] = None
+                               if profile.getMachineSetting('machine_type') == 'ultimaker2':
+                                       self._platformMesh[machine]._drawOffset = numpy.array([0,-37,145], numpy.float32)
+                               else:
+                                       self._platformMesh[machine]._drawOffset = numpy.array([0,0,2.5], numpy.float32)
                        glColor4f(1,1,1,0.5)
                        self._objectShader.bind()
-                       self._renderObject(self._platformMesh, False, False)
+                       self._renderObject(self._platformMesh[machine], False, False)
                        self._objectShader.unbind()
                else:
                        glColor4f(0,0,0,1)
@@ -1237,7 +1241,7 @@ void main(void)
        def _generateGCodeVBOs2(self, layer):
                filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2
                filamentArea = math.pi * filamentRadius * filamentRadius
-               useFilamentArea = profile.getPreference('gcode_flavor') == 'UltiGCode'
+               useFilamentArea = profile.getMachineSetting('gcode_flavor') == 'UltiGCode'
 
                ret = []
                for extrudeType in ['WALL-OUTER:0', 'WALL-OUTER:1', 'WALL-OUTER:2', 'WALL-OUTER:3', 'WALL-INNER', 'FILL', 'SUPPORT', 'SKIRT']:
index 13ea7a2280f02801ea622585a11327e3fd1a5c84..5171dde1a23fc0a4b99f7dc8329eb72e917e9a8e 100644 (file)
@@ -27,7 +27,7 @@ class simpleModePanel(wx.Panel):
                self.printMaterialPLA = wx.RadioButton(printMaterialPanel, -1, 'PLA', style=wx.RB_GROUP)
                self.printMaterialABS = wx.RadioButton(printMaterialPanel, -1, 'ABS')
                self.printMaterialDiameter = wx.TextCtrl(printMaterialPanel, -1, profile.getProfileSetting('filament_diameter'))
-               if profile.getPreference('gcode_flavor') == 'UltiGCode':
+               if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
                        printMaterialPanel.Show(False)
                
                self.printSupport = wx.CheckBox(self, -1, _("Print support structure"))
index c184584ea03f259a286c4658804326654f161623..0bde41bebea8e733599c00cc4600cf4345467b74 100644 (file)
@@ -194,142 +194,6 @@ class GLVBO(GLReferenceCounter):
                if self._buffer is not None and bool(glDeleteBuffers):
                        print "VBO was not properly released!"
 
-def DrawMachine(machineSize):
-       glDisable(GL_LIGHTING)
-       glDisable(GL_CULL_FACE)
-       glEnable(GL_BLEND)
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
-
-       sx = machineSize.x
-       sy = machineSize.y
-       for x in xrange(-int(sx/20)-1, int(sx / 20) + 1):
-               for y in xrange(-int(sx/20)-1, int(sy / 20) + 1):
-                       x1 = sx/2+x * 10
-                       x2 = x1 + 10
-                       y1 = sx/2+y * 10
-                       y2 = y1 + 10
-                       x1 = max(min(x1, sx), 0)
-                       y1 = max(min(y1, sy), 0)
-                       x2 = max(min(x2, sx), 0)
-                       y2 = max(min(y2, sy), 0)
-                       if (x & 1) == (y & 1):
-                               glColor4ub(5, 171, 231, 127)
-                       else:
-                               glColor4ub(5 * 8 / 10, 171 * 8 / 10, 231 * 8 / 10, 128)
-                       glBegin(GL_QUADS)
-                       glVertex3f(x1, y1, -0.02)
-                       glVertex3f(x2, y1, -0.02)
-                       glVertex3f(x2, y2, -0.02)
-                       glVertex3f(x1, y2, -0.02)
-                       glEnd()
-
-       glEnable(GL_CULL_FACE)
-
-       if profile.getPreference('machine_type') == 'ultimaker':
-               glPushMatrix()
-               glEnable(GL_LIGHTING)
-               glTranslate(100, 200, -1)
-               glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.8, 0.8, 0.8])
-               glLightfv(GL_LIGHT0, GL_AMBIENT, [0.5, 0.5, 0.5])
-               glEnable(GL_BLEND)
-               glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR)
-
-               global platformMesh
-               if platformMesh is None:
-                       try:
-                               platformMesh = meshLoader.loadMesh(getPathForMesh('ultimaker_platform.stl'))
-                       except:
-                               platformMesh = False
-
-               if platformMesh:
-                       DrawMesh(platformMesh)
-               glPopMatrix()
-               glDisable(GL_LIGHTING)
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
-
-       glColor4ub(5, 171, 231, 64)
-       glBegin(GL_QUADS)
-       glVertex3f(0, 0, machineSize.z)
-       glVertex3f(0, machineSize.y, machineSize.z)
-       glVertex3f(machineSize.x, machineSize.y, machineSize.z)
-       glVertex3f(machineSize.x, 0, machineSize.z)
-       glEnd()
-
-       glColor4ub(5, 171, 231, 96)
-       glBegin(GL_QUADS)
-       glVertex3f(0, 0, 0)
-       glVertex3f(0, 0, machineSize.z)
-       glVertex3f(machineSize.x, 0, machineSize.z)
-       glVertex3f(machineSize.x, 0, 0)
-
-       glVertex3f(0, machineSize.y, machineSize.z)
-       glVertex3f(0, machineSize.y, 0)
-       glVertex3f(machineSize.x, machineSize.y, 0)
-       glVertex3f(machineSize.x, machineSize.y, machineSize.z)
-       glEnd()
-
-       glColor4ub(5, 171, 231, 128)
-       glBegin(GL_QUADS)
-       glVertex3f(0, 0, machineSize.z)
-       glVertex3f(0, 0, 0)
-       glVertex3f(0, machineSize.y, 0)
-       glVertex3f(0, machineSize.y, machineSize.z)
-
-       glVertex3f(machineSize.x, 0, 0)
-       glVertex3f(machineSize.x, 0, machineSize.z)
-       glVertex3f(machineSize.x, machineSize.y, machineSize.z)
-       glVertex3f(machineSize.x, machineSize.y, 0)
-       glEnd()
-
-       glDisable(GL_BLEND)
-
-       #Draw the X/Y/Z indicator
-       glPushMatrix()
-       glTranslate(5, 5, 2)
-       glLineWidth(2)
-       glColor3f(0.5, 0, 0)
-       glBegin(GL_LINES)
-       glVertex3f(0, 0, 0)
-       glVertex3f(20, 0, 0)
-       glEnd()
-       glColor3f(0, 0.5, 0)
-       glBegin(GL_LINES)
-       glVertex3f(0, 0, 0)
-       glVertex3f(0, 20, 0)
-       glEnd()
-       glColor3f(0, 0, 0.5)
-       glBegin(GL_LINES)
-       glVertex3f(0, 0, 0)
-       glVertex3f(0, 0, 20)
-       glEnd()
-
-       glDisable(GL_DEPTH_TEST)
-       #X
-       glColor3f(1, 0, 0)
-       glPushMatrix()
-       glTranslate(20, 0, 0)
-       noZ = ResetMatrixRotationAndScale()
-       glDrawStringCenter("X")
-       glPopMatrix()
-
-       #Y
-       glColor3f(0, 1, 0)
-       glPushMatrix()
-       glTranslate(0, 20, 0)
-       glDrawStringCenter("Y")
-       glPopMatrix()
-
-       #Z
-       if not noZ:
-               glColor3f(0, 0, 1)
-               glPushMatrix()
-               glTranslate(0, 0, 20)
-               glDrawStringCenter("Z")
-               glPopMatrix()
-
-       glPopMatrix()
-       glEnable(GL_DEPTH_TEST)
-
 def glDrawStringCenter(s):
        glRasterPos2f(0, 0)
        glBitmap(0,0,0,0, -glGetStringSize(s)[0]/2, 0, None)
index 7aad233845d80fb35f12886d8b58b8170b9858db..f491b2cc9e8911171cc5b8d94848024aeaf2f93c 100644 (file)
@@ -146,7 +146,7 @@ class webcam(object):
                        dc = wx.MemoryDC()
                        dc.SelectObject(bitmap)
                        dc.DrawBitmap(self._overlayImage, bitmap.GetWidth() - self._overlayImage.GetWidth() - 5, 5, True)
-                       if profile.getPreference('machine_type') == 'ultimaker':
+                       if profile.getMachineSetting('machine_type').startswith('ultimaker'):
                                dc.DrawBitmap(self._overlayUltimaker, (bitmap.GetWidth() - self._overlayUltimaker.GetWidth()) / 2,
                                        bitmap.GetHeight() - self._overlayUltimaker.GetHeight() - 5, True)
                        dc.SelectObject(wx.NullBitmap)
index 03d2dd415b6a1bf45a0e88fa5778138a1064afa4..9551ee1218e4bc067f644873bb06ec12996f29ba 100644 (file)
@@ -117,12 +117,12 @@ class gcode(object):
                        T = getCodeInt(line, 'T')
                        if T is not None:
                                if currentExtruder > 0:
-                                       posOffset[0] -= profile.getPreferenceFloat('extruder_offset_x%d' % (currentExtruder))
-                                       posOffset[1] -= profile.getPreferenceFloat('extruder_offset_y%d' % (currentExtruder))
+                                       posOffset[0] -= profile.getMachineSettingFloat('extruder_offset_x%d' % (currentExtruder))
+                                       posOffset[1] -= profile.getMachineSettingFloat('extruder_offset_y%d' % (currentExtruder))
                                currentExtruder = T
                                if currentExtruder > 0:
-                                       posOffset[0] += profile.getPreferenceFloat('extruder_offset_x%d' % (currentExtruder))
-                                       posOffset[1] += profile.getPreferenceFloat('extruder_offset_y%d' % (currentExtruder))
+                                       posOffset[0] += profile.getMachineSettingFloat('extruder_offset_x%d' % (currentExtruder))
+                                       posOffset[1] += profile.getMachineSettingFloat('extruder_offset_y%d' % (currentExtruder))
                        
                        G = getCodeInt(line, 'G')
                        if G is not None:
index db9ed8c6ebf6e53b64d1dcab3d4a2fad91372d95..a39654a240a30d2ec9a88ee9042e699e2bdee0a9 100644 (file)
@@ -43,7 +43,7 @@ def serialList(forAutoDetect=False):
                baselist = filter(lambda s: not 'Bluetooth' in s, baselist)
        else:
                baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob("/dev/cu.*") + glob.glob("/dev/tty.usb*") + glob.glob("/dev/rfcomm*")
-       prev = profile.getPreference('serial_port_auto')
+       prev = profile.getMachineSetting('serial_port_auto')
        if prev in baselist:
                baselist.remove(prev)
                baselist.insert(0, prev)
@@ -53,9 +53,9 @@ def serialList(forAutoDetect=False):
 
 def machineIsConnected():
        #UltiGCode is designed for SD-Card printing, so never auto-detect the serial port.
-       port = profile.getPreference('serial_port')
+       port = profile.getMachineSetting('serial_port')
        if port == 'AUTO':
-               if profile.getPreference('gcode_flavor') == 'UltiGCode':
+               if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
                        return False
                return len(serialList(True)) > 0
        if platform.system() == "Windows":
@@ -64,8 +64,8 @@ def machineIsConnected():
 
 def baudrateList():
        ret = [250000, 230400, 115200, 57600, 38400, 19200, 9600]
-       if profile.getPreference('serial_baud_auto') != '':
-               prev = int(profile.getPreference('serial_baud_auto'))
+       if profile.getMachineSetting('serial_baud_auto') != '':
+               prev = int(profile.getMachineSetting('serial_baud_auto'))
                if prev in ret:
                        ret.remove(prev)
                        ret.insert(0, prev)
@@ -157,12 +157,12 @@ class MachineCom(object):
        
        def __init__(self, port = None, baudrate = None, callbackObject = None):
                if port is None:
-                       port = profile.getPreference('serial_port')
+                       port = profile.getMachineSetting('serial_port')
                if baudrate is None:
-                       if profile.getPreference('serial_baud') == 'AUTO':
+                       if profile.getMachineSetting('serial_baud') == 'AUTO':
                                baudrate = 0
                        else:
-                               baudrate = int(profile.getPreference('serial_baud'))
+                               baudrate = int(profile.getMachineSetting('serial_baud'))
                if callbackObject is None:
                        callbackObject = MachineComPrintCallback()
 
@@ -173,7 +173,7 @@ class MachineCom(object):
                self._serial = None
                self._baudrateDetectList = baudrateList()
                self._baudrateDetectRetry = 0
-               self._extruderCount = int(profile.getPreference('extruder_amount'))
+               self._extruderCount = int(profile.getMachineSetting('extruder_amount'))
                self._temperatureRequestExtruder = 0
                self._temp = [0] * self._extruderCount
                self._targetTemp = [0] * self._extruderCount
index 8ca2eb173448bbf98e1868233094c796b7d8b03d..2ed52c4945a8e2ba81edc7753817417d39a81d7d 100644 (file)
@@ -65,11 +65,14 @@ class setting(object):
        def isPreference(self):
                return self._category == 'preference'
 
+       def isMachineSetting(self):
+               return self._category == 'machine'
+
        def isAlteration(self):
                return self._category == 'alteration'
 
        def isProfile(self):
-               return not self.isAlteration() and not self.isPreference()
+               return not self.isAlteration() and not self.isPreference() and not self.isMachineSetting()
 
        def getName(self):
                return self._name
@@ -296,28 +299,6 @@ G92 E0
 
 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('machine_type', 'unknown', str, 'preference', 'hidden')
-setting('gcode_flavor', 'RepRap (Marlin/Sprinter)', ['RepRap (Marlin/Sprinter)', 'UltiGCode'], 'preference', 'hidden').setLabel('GCode Flavor', 'Flavor of generated GCode.\nRepRap...')
-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', '1240', float, 'preference', 'hidden').setRange(500.0, 3000.0).setLabel('Density (kg/m3)', 'Weight of the filament per m3. Around 1240 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').setLabel('E-Steps per 1mm filament', 'Amount of steps per mm filament extrusion. If set to 0 then this value is ignored and the value in your firmware is used.')
-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.')
@@ -325,12 +306,7 @@ setting('auto_detect_sd', 'True', bool, 'preference', 'hidden').setLabel('Auto d
 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('youmagine_token', '', str, 'preference', 'hidden')
-
-setting('extruder_head_size_min_x', '0.0', float, 'preference', 'hidden').setLabel('Head size towards X min (mm)', 'The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head. 75mm for an Ultimaker if the fan is on the left side.')
-setting('extruder_head_size_min_y', '0.0', float, 'preference', 'hidden').setLabel('Head size towards Y min (mm)', 'The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head. 18mm for an Ultimaker if the fan is on the left side.')
-setting('extruder_head_size_max_x', '0.0', float, 'preference', 'hidden').setLabel('Head size towards X max (mm)', 'The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head. 18mm for an Ultimaker if the fan is on the left side.')
-setting('extruder_head_size_max_y', '0.0', float, 'preference', 'hidden').setLabel('Head size towards Y max (mm)', 'The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head. 35mm for an Ultimaker if the fan is on the left side.')
-setting('extruder_head_size_height', '0.0', float, 'preference', 'hidden').setLabel('Printer gantry height (mm)', 'The height of the gantry holding up the printer head. If an object is higher then this then you cannot print multiple objects one for one. 60mm for an Ultimaker.')
+setting('filament_physical_density', '1240', float, 'preference', 'hidden').setRange(500.0, 3000.0).setLabel('Density (kg/m3)', 'Weight of the filament per m3. Around 1240 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.')
 
 setting('model_colour', '#FFC924', str, 'preference', 'hidden').setLabel('Model colour')
 setting('model_colour2', '#CB3030', str, 'preference', 'hidden').setLabel('Model colour (2)')
@@ -344,6 +320,33 @@ setting('window_width', '-1', float, 'preference', 'hidden')
 setting('window_height', '-1', float, 'preference', 'hidden')
 setting('window_normal_sash', '320', float, 'preference', 'hidden')
 
+setting('machine_width', '205', float, 'machine', 'hidden').setLabel('Maximum width (mm)', 'Size of the machine in mm')
+setting('machine_depth', '205', float, 'machine', 'hidden').setLabel('Maximum depth (mm)', 'Size of the machine in mm')
+setting('machine_height', '200', float, 'machine', 'hidden').setLabel('Maximum height (mm)', 'Size of the machine in mm')
+setting('machine_type', 'unknown', str, 'machine', 'hidden')
+setting('machine_center_is_zero', 'False', bool, 'machine', 'hidden')
+setting('ultimaker_extruder_upgrade', 'False', bool, 'machine', 'hidden')
+setting('has_heated_bed', 'False', bool, 'machine', 'hidden').setLabel('Heated bed', 'If you have an heated bed, this enabled heated bed settings (requires restart)')
+setting('gcode_flavor', 'RepRap (Marlin/Sprinter)', ['RepRap (Marlin/Sprinter)', 'UltiGCode'], 'machine', 'hidden').setLabel('GCode Flavor', 'Flavor of generated GCode.\nRepRap...')
+setting('extruder_amount', '1', ['1','2','3','4'], 'machine', 'hidden').setLabel('Extruder count', 'Amount of extruders in your machine.')
+setting('extruder_offset_x1', '-21.6', float, 'machine', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_y1', '0.0', float, 'machine', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_x2', '0.0', float, 'machine', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_y2', '0.0', float, 'machine', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_x3', '0.0', float, 'machine', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_y3', '0.0', float, 'machine', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
+setting('steps_per_e', '0', float, 'machine', 'hidden').setLabel('E-Steps per 1mm filament', 'Amount of steps per mm filament extrusion. If set to 0 then this value is ignored and the value in your firmware is used.')
+setting('serial_port', 'AUTO', str, 'machine', 'hidden').setLabel('Serial port', 'Serial port to use for communication with the printer')
+setting('serial_port_auto', '', str, 'machine', 'hidden')
+setting('serial_baud', 'AUTO', str, 'machine', '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, 'machine', 'hidden')
+
+setting('extruder_head_size_min_x', '0.0', float, 'machine', 'hidden').setLabel('Head size towards X min (mm)', 'The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head. 75mm for an Ultimaker if the fan is on the left side.')
+setting('extruder_head_size_min_y', '0.0', float, 'machine', 'hidden').setLabel('Head size towards Y min (mm)', 'The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head. 18mm for an Ultimaker if the fan is on the left side.')
+setting('extruder_head_size_max_x', '0.0', float, 'machine', 'hidden').setLabel('Head size towards X max (mm)', 'The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head. 18mm for an Ultimaker if the fan is on the left side.')
+setting('extruder_head_size_max_y', '0.0', float, 'machine', 'hidden').setLabel('Head size towards Y max (mm)', 'The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head. 35mm for an Ultimaker if the fan is on the left side.')
+setting('extruder_head_size_height', '0.0', float, 'machine', 'hidden').setLabel('Printer gantry height (mm)', 'The height of the gantry holding up the printer head. If an object is higher then this then you cannot print multiple objects one for one. 60mm for an Ultimaker.')
+
 validators.warningAbove(settingsDictionary['filament_flow'], 150, "More flow then 150% is rare and usually not recommended.")
 validators.warningBelow(settingsDictionary['filament_flow'], 50, "More flow then 50% is rare and usually not recommended.")
 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.")
@@ -362,31 +365,31 @@ validators.warningAbove(settingsDictionary['travel_speed'], 300.0, "It is highly
 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)
-settingsDictionary['retraction_dual_amount'].addCondition(lambda : int(getPreference('extruder_amount')) > 1)
+settingsDictionary['print_temperature2'].addCondition(lambda : int(getMachineSetting('extruder_amount')) > 1)
+settingsDictionary['print_temperature3'].addCondition(lambda : int(getMachineSetting('extruder_amount')) > 2)
+settingsDictionary['print_temperature4'].addCondition(lambda : int(getMachineSetting('extruder_amount')) > 3)
+settingsDictionary['filament_diameter2'].addCondition(lambda : int(getMachineSetting('extruder_amount')) > 1)
+settingsDictionary['filament_diameter3'].addCondition(lambda : int(getMachineSetting('extruder_amount')) > 2)
+settingsDictionary['filament_diameter4'].addCondition(lambda : int(getMachineSetting('extruder_amount')) > 3)
+settingsDictionary['support_dual_extrusion'].addCondition(lambda : int(getMachineSetting('extruder_amount')) > 1)
+settingsDictionary['retraction_dual_amount'].addCondition(lambda : int(getMachineSetting('extruder_amount')) > 1)
 #Heated bed
-settingsDictionary['print_bed_temperature'].addCondition(lambda : getPreference('has_heated_bed') == 'True')
-
-#UltiGCode uses less settings
-settingsDictionary['print_temperature'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['print_temperature2'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['print_temperature3'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['print_temperature4'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['filament_diameter'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['filament_diameter2'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['filament_diameter3'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['filament_diameter4'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['filament_flow'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['print_bed_temperature'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['retraction_speed'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['retraction_amount'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
-settingsDictionary['retraction_dual_amount'].addCondition(lambda : getPreference('gcode_flavor') != 'UltiGCode')
+settingsDictionary['print_bed_temperature'].addCondition(lambda : getMachineSetting('has_heated_bed') == 'True')
+
+#UltiGCode uses less settings, as these settings are located inside the machine instead of gcode.
+settingsDictionary['print_temperature'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['print_temperature2'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['print_temperature3'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['print_temperature4'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['filament_diameter'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['filament_diameter2'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['filament_diameter3'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['filament_diameter4'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['filament_flow'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['print_bed_temperature'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['retraction_speed'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['retraction_amount'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
+settingsDictionary['retraction_dual_amount'].addCondition(lambda : getMachineSetting('gcode_flavor') != 'UltiGCode')
 
 #########################################################
 ## Profile and preferences functions
@@ -460,7 +463,7 @@ def saveProfile(filename):
        profileParser.add_section('alterations')
        global settingsList
        for set in settingsList:
-               if set.isPreference():
+               if set.isPreference() or set.isMachineSetting():
                        continue
                if set.isAlteration():
                        profileParser.set('alterations', set.getName(), set.getValue().encode('utf-8'))
@@ -477,11 +480,11 @@ def resetProfile():
                        continue
                set.setValue(set.getDefault())
 
-       if getPreference('machine_type') == 'ultimaker':
+       if getMachineSetting('machine_type') == 'ultimaker':
                putProfileSetting('nozzle_size', '0.4')
-               if getPreference('ultimaker_extruder_upgrade') == 'True':
+               if getMachineSetting('ultimaker_extruder_upgrade') == 'True':
                        putProfileSetting('retraction_enable', 'True')
-       elif getPreference('machine_type') == 'ultimaker2':
+       elif getMachineSetting('machine_type') == 'ultimaker2':
                putProfileSetting('nozzle_size', '0.4')
                putProfileSetting('retraction_enable', 'True')
        else:
@@ -541,7 +544,8 @@ def getProfileSetting(name):
        global settingsDictionary
        if name in settingsDictionary and settingsDictionary[name].isProfile():
                return settingsDictionary[name].getValue()
-       print 'Error: "%s" not found in profile settings' % (name)
+       traceback.print_stack()
+       sys.stderr.write('Error: "%s" not found in profile settings\n' % (name))
        return ''
 
 def getProfileSettingFloat(name):
@@ -595,10 +599,13 @@ def savePreferences(filename):
        #Save the current profile to an ini file
        parser = ConfigParser.ConfigParser()
        parser.add_section('preference')
+       parser.add_section('machine')
        global settingsList
        for set in settingsList:
                if set.isPreference():
                        parser.set('preference', set.getName(), set.getValue().encode('utf-8'))
+               elif set.isMachineSetting():
+                       parser.set('machine', set.getName(), set.getValue().encode('utf-8'))
        parser.write(open(filename, 'w'))
 
 def getPreference(name):
@@ -607,7 +614,8 @@ def getPreference(name):
        global settingsDictionary
        if name in settingsDictionary and settingsDictionary[name].isPreference():
                return settingsDictionary[name].getValue()
-       print 'Error: "%s" not found in profile settings' % (name)
+       traceback.print_stack()
+       sys.stderr.write('Error: "%s" not found in preferences\n' % (name))
        return ''
 
 def putPreference(name, value):
@@ -615,7 +623,10 @@ def putPreference(name, value):
        global settingsDictionary
        if name in settingsDictionary and settingsDictionary[name].isPreference():
                settingsDictionary[name].setValue(value)
-       savePreferences(getPreferencePath())
+               savePreferences(getPreferencePath())
+               return
+       traceback.print_stack()
+       sys.stderr.write('Error: "%s" not found in preferences\n' % (name))
 
 def isPreference(name):
        global settingsDictionary
@@ -623,6 +634,36 @@ def isPreference(name):
                return True
        return False
 
+def getMachineSettingFloat(name):
+       try:
+               setting = getMachineSetting(name).replace(',', '.')
+               return float(eval(setting, {}, {}))
+       except:
+               return 0.0
+
+def getMachineSetting(name):
+       if name in tempOverride:
+               return tempOverride[name]
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isMachineSetting():
+               return settingsDictionary[name].getValue()
+       traceback.print_stack()
+       sys.stderr.write('Error: "%s" not found in machine settings\n' % (name))
+       return ''
+
+def putMachineSetting(name, value):
+       #Check if we have a configuration file loaded, else load the default.
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isMachineSetting():
+               settingsDictionary[name].setValue(value)
+       savePreferences(getPreferencePath())
+
+def isMachineSetting(name):
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isMachineSetting():
+               return True
+       return False
+
 ## Temp overrides for multi-extruder slicing and the project planner.
 tempOverride = {}
 def setTempOverride(name, value):
@@ -697,9 +738,9 @@ def calculateObjectSizeOffsets():
        return [size, size]
 
 def getMachineCenterCoords():
-       if getPreference('machine_center_is_zero') == 'True':
+       if getMachineSettingFloat('machine_center_is_zero') == 'True':
                return [0, 0]
-       return [getPreferenceFloat('machine_width') / 2, getPreferenceFloat('machine_depth') / 2]
+       return [getMachineSettingFloat('machine_width') / 2, getMachineSettingFloat('machine_depth') / 2]
 
 #########################################################
 ## Alteration file functions
@@ -754,7 +795,8 @@ def getAlterationFile(filename):
        global settingsDictionary
        if filename in settingsDictionary and settingsDictionary[filename].isAlteration():
                return settingsDictionary[filename].getValue()
-       print 'Error: "%s" not found in profile settings' % (filename)
+       traceback.print_stack()
+       sys.stderr.write('Error: "%s" not found in alteration settings\n' % (filename))
        return ''
 
 def setAlterationFile(name, value):
@@ -769,19 +811,19 @@ def getAlterationFileContents(filename, extruderCount = 1):
        prefix = ''
        postfix = ''
        alterationContents = getAlterationFile(filename)
-       if getPreference('gcode_flavor') == 'UltiGCode':
+       if getMachineSetting('gcode_flavor') == 'UltiGCode':
                return ''
        if filename == 'start.gcode':
                if extruderCount > 1:
                        alterationContents = getAlterationFile("start%d.gcode" % (extruderCount))
                #For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.
                #We also set our steps per E here, if configured.
-               eSteps = getPreferenceFloat('steps_per_e')
+               eSteps = getMachineSettingFloat('steps_per_e')
                if eSteps > 0:
                        prefix += 'M92 E%f\n' % (eSteps)
                temp = getProfileSettingFloat('print_temperature')
                bedTemp = 0
-               if getPreference('has_heated_bed') == 'True':
+               if getMachineSetting('has_heated_bed') == 'True':
                        bedTemp = getProfileSettingFloat('print_bed_temperature')
 
                if bedTemp > 0 and not '{print_bed_temperature}' in alterationContents:
index 67b1e1d2cdc0c90d9bb16951c00dde976625cd59..47bd5360c3279c351afa99588f9e655fb79fcf32 100644 (file)
@@ -209,7 +209,7 @@ class Slicer(object):
                                self._printTimeSeconds = int(line.split(':')[1].strip())
                        elif line.startswith('Filament:'):
                                self._filamentMM = int(line.split(':')[1].strip())
-                               if profile.getPreference('gcode_flavor') == 'UltiGCode':
+                               if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
                                        radius = profile.getProfileSettingFloat('filament_diameter') / 2.0
                                        self._filamentMM /= (math.pi * radius * radius)
                        else:
@@ -273,12 +273,12 @@ class Slicer(object):
                        'startCode': profile.getAlterationFileContents('start.gcode', extruderCount),
                        'endCode': profile.getAlterationFileContents('end.gcode', extruderCount),
 
-                       'extruderOffset[1].X': int(profile.getPreferenceFloat('extruder_offset_x1') * 1000),
-                       'extruderOffset[1].Y': int(profile.getPreferenceFloat('extruder_offset_y1') * 1000),
-                       'extruderOffset[2].X': int(profile.getPreferenceFloat('extruder_offset_x2') * 1000),
-                       'extruderOffset[2].Y': int(profile.getPreferenceFloat('extruder_offset_y2') * 1000),
-                       'extruderOffset[3].X': int(profile.getPreferenceFloat('extruder_offset_x3') * 1000),
-                       'extruderOffset[3].Y': int(profile.getPreferenceFloat('extruder_offset_y3') * 1000),
+                       'extruderOffset[1].X': int(profile.getMachineSettingFloat('extruder_offset_x1') * 1000),
+                       'extruderOffset[1].Y': int(profile.getMachineSettingFloat('extruder_offset_y1') * 1000),
+                       'extruderOffset[2].X': int(profile.getMachineSettingFloat('extruder_offset_x2') * 1000),
+                       'extruderOffset[2].Y': int(profile.getMachineSettingFloat('extruder_offset_y2') * 1000),
+                       'extruderOffset[3].X': int(profile.getMachineSettingFloat('extruder_offset_x3') * 1000),
+                       'extruderOffset[3].Y': int(profile.getMachineSettingFloat('extruder_offset_y3') * 1000),
                        'fixHorrible': 0,
                }
                if profile.getProfileSetting('platform_adhesion') == 'Brim':
@@ -309,7 +309,7 @@ class Slicer(object):
 
                if settings['layerThickness'] <= 0:
                        settings['layerThickness'] = 1000
-               if profile.getPreference('gcode_flavor') == 'UltiGCode':
+               if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
                        settings['gcodeFlavor'] = 1
                return settings
 
index 195db236ebedc9051e1d3d20b5bddc4133f05c3e..9c45fba79d707b6f03763c6b93eeed505d6742d7 100644 (file)
@@ -218,7 +218,7 @@ if __name__ == '__main__':
 
        f.write(';TYPE:CUSTOM\n')
        f.write(profile.getAlterationFileContents('start.gcode'))
-       svg.center(complex(profile.getPreferenceFloat('machine_width') / 2, profile.getPreferenceFloat('machine_depth') / 2))
+       svg.center(complex(profile.getMachineSettingFloat('machine_width') / 2, profile.getMachineSettingFloat('machine_depth') / 2))
 
        layerThickness = 0.4
        filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2