chiark / gitweb /
Enable retraction when selecting the UM2. Fix the reset-profile which clears out...
[cura.git] / Cura / gui / configWizard.py
index e6e4591a1617f0f524d7df12cee7c61e3abbd323..16452b4604abdfd625afdd2b98b248f50fd723b0 100644 (file)
@@ -1,6 +1,7 @@
 from __future__ import absolute_import
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
+import os
 import webbrowser
 import threading
 import time
@@ -14,7 +15,7 @@ from Cura.gui import printWindow
 from Cura.util import machineCom
 from Cura.util import profile
 from Cura.util import gcodeGenerator
-from Cura.util.resources import getPathForImage
+from Cura.util import resources
 
 
 class InfoBox(wx.Panel):
@@ -25,14 +26,14 @@ class InfoBox(wx.Panel):
                self.sizer = wx.GridBagSizer(5, 5)
                self.SetSizer(self.sizer)
 
-               self.attentionBitmap = wx.Bitmap(getPathForImage('attention.png'))
-               self.errorBitmap = wx.Bitmap(getPathForImage('error.png'))
-               self.readyBitmap = wx.Bitmap(getPathForImage('ready.png'))
+               self.attentionBitmap = wx.Bitmap(resources.getPathForImage('attention.png'))
+               self.errorBitmap = wx.Bitmap(resources.getPathForImage('error.png'))
+               self.readyBitmap = wx.Bitmap(resources.getPathForImage('ready.png'))
                self.busyBitmap = [
-                       wx.Bitmap(getPathForImage('busy-0.png')),
-                       wx.Bitmap(getPathForImage('busy-1.png')),
-                       wx.Bitmap(getPathForImage('busy-2.png')),
-                       wx.Bitmap(getPathForImage('busy-3.png'))
+                       wx.Bitmap(resources.getPathForImage('busy-0.png')),
+                       wx.Bitmap(resources.getPathForImage('busy-1.png')),
+                       wx.Bitmap(resources.getPathForImage('busy-2.png')),
+                       wx.Bitmap(resources.getPathForImage('busy-3.png'))
                ]
 
                self.bitmap = wx.StaticBitmap(self, -1, wx.EmptyBitmapRGBA(24, 24, red=255, green=255, blue=255, alpha=1))
@@ -215,29 +216,69 @@ class InfoPage(wx.wizard.WizardPageSimple):
 
 
 class FirstInfoPage(InfoPage):
-       def __init__(self, parent):
-               super(FirstInfoPage, self).__init__(parent, _("First time run wizard"))
-               self.AddText(_("Welcome, and thanks for trying Cura!"))
-               self.AddSeperator()
+       def __init__(self, parent, addNew):
+               if addNew:
+                       super(FirstInfoPage, self).__init__(parent, _("Add new machine wizard"))
+               else:
+                       super(FirstInfoPage, self).__init__(parent, _("First time run wizard"))
+                       self.AddText(_("Welcome, and thanks for trying Cura!"))
+                       self.AddSeperator()
                self.AddText(_("This wizard will help you with the following steps:"))
                self.AddText(_("* Configure Cura for your machine"))
-               self.AddText(_("* Upgrade your firmware"))
-               self.AddText(_("* Check if your machine is working safely"))
-               self.AddText(_("* Level your printer bed"))
+               self.AddText(_("* Optionally upgrade your firmware"))
+               self.AddText(_("* Optionally check if your machine is working safely"))
+               self.AddText(_("* Optionally level your printer bed"))
 
                #self.AddText('* Calibrate your machine')
                #self.AddText('* Do your first print')
 
 
-class RepRapInfoPage(InfoPage):
+class OtherMachineSelectPage(InfoPage):
        def __init__(self, parent):
-               super(RepRapInfoPage, self).__init__(parent, "RepRap information")
-               self.AddText(
-                       _("RepRap machines are vastly different, and there is no\ndefault configuration in Cura for any of them."))
+               super(OtherMachineSelectPage, self).__init__(parent, "Other machine information")
+               self.AddText(_("The following pre-defined machine profiles are available"))
+               self.AddText(_("Note that these profiles are not guaranteed to give good results,\nor work at all. Extra tweaks might be required."))
+               self.options = []
+               machines = resources.getDefaultMachineProfiles()
+               machines.sort()
+               for filename in machines:
+                       name = os.path.splitext(os.path.basename(filename))[0]
+                       item = self.AddRadioButton(name)
+                       item.filename = filename
+                       item.Bind(wx.EVT_RADIOBUTTON, self.OnProfileSelect)
+                       self.options.append(item)
+               self.AddSeperator()
+               item = self.AddRadioButton('Custom...')
+               item.SetValue(True)
+               item.Bind(wx.EVT_RADIOBUTTON, self.OnOtherSelect)
+
+       def OnProfileSelect(self, e):
+               wx.wizard.WizardPageSimple.Chain(self, self.GetParent().otherMachineInfoPage)
+
+       def OnOtherSelect(self, e):
+               wx.wizard.WizardPageSimple.Chain(self, self.GetParent().customRepRapInfoPage)
+
+       def StoreData(self):
+               for option in self.options:
+                       if option.GetValue():
+                               profile.loadProfile(option.filename)
+                               profile.loadMachineSettings(option.filename)
+
+class OtherMachineInfoPage(InfoPage):
+       def __init__(self, parent):
+               super(OtherMachineInfoPage, self).__init__(parent, "Cura Ready!")
+               self.AddText(_("Cura is now ready to be used!"))
+
+class CustomRepRapInfoPage(InfoPage):
+       def __init__(self, parent):
+               super(CustomRepRapInfoPage, self).__init__(parent, "Custom RepRap information")
+               self.AddText(_("RepRap machines can be vastly different, so here you can set your own settings."))
+               self.AddText(_("Be sure to review the default profile before running it on your machine."))
                self.AddText(_("If you like a default profile for your machine added,\nthen make an issue on github."))
                self.AddSeperator()
                self.AddText(_("You will have to manually install Marlin or Sprinter firmware."))
                self.AddSeperator()
+               self.machineName = self.AddLabelTextCtrl(_("Machine name"), "RepRap")
                self.machineWidth = self.AddLabelTextCtrl(_("Machine width (mm)"), "80")
                self.machineDepth = self.AddLabelTextCtrl(_("Machine depth (mm)"), "80")
                self.machineHeight = self.AddLabelTextCtrl(_("Machine height (mm)"), "60")
@@ -246,19 +287,20 @@ class RepRapInfoPage(InfoPage):
                self.HomeAtCenter = self.AddCheckbox(_("Bed center is 0,0,0 (RoStock)"))
 
        def StoreData(self):
-               profile.putPreference('machine_width', self.machineWidth.GetValue())
-               profile.putPreference('machine_depth', self.machineDepth.GetValue())
-               profile.putPreference('machine_height', self.machineHeight.GetValue())
+               profile.putMachineSetting('machine_name', self.machineName.GetValue())
+               profile.putMachineSetting('machine_width', self.machineWidth.GetValue())
+               profile.putMachineSetting('machine_depth', self.machineDepth.GetValue())
+               profile.putMachineSetting('machine_height', self.machineHeight.GetValue())
                profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue())
                profile.putProfileSetting('wall_thickness', float(profile.getProfileSettingFloat('nozzle_size')) * 2)
-               profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue()))
-               profile.putPreference('machine_center_is_zero', str(self.HomeAtCenter.GetValue()))
-               profile.putPreference('extruder_head_size_min_x', '0')
-               profile.putPreference('extruder_head_size_min_y', '0')
-               profile.putPreference('extruder_head_size_max_x', '0')
-               profile.putPreference('extruder_head_size_max_y', '0')
-               profile.putPreference('extruder_head_size_height', '0')
-
+               profile.putMachineSetting('has_heated_bed', str(self.heatedBed.GetValue()))
+               profile.putMachineSetting('machine_center_is_zero', str(self.HomeAtCenter.GetValue()))
+               profile.putMachineSetting('extruder_head_size_min_x', '0')
+               profile.putMachineSetting('extruder_head_size_min_y', '0')
+               profile.putMachineSetting('extruder_head_size_max_x', '0')
+               profile.putMachineSetting('extruder_head_size_max_y', '0')
+               profile.putMachineSetting('extruder_head_size_height', '0')
+               profile.checkAndUpdateMachineName()
 
 class MachineSelectPage(InfoPage):
        def __init__(self, parent):
@@ -270,7 +312,7 @@ class MachineSelectPage(InfoPage):
                self.Ultimaker2Radio.Bind(wx.EVT_RADIOBUTTON, self.OnUltimaker2Select)
                self.UltimakerRadio = self.AddRadioButton("Ultimaker")
                self.UltimakerRadio.Bind(wx.EVT_RADIOBUTTON, self.OnUltimakerSelect)
-               self.OtherRadio = self.AddRadioButton(_("Other (Ex: RepRap)"))
+               self.OtherRadio = self.AddRadioButton(_("Other (Ex: RepRap, MakerBot)"))
                self.OtherRadio.Bind(wx.EVT_RADIOBUTTON, self.OnOtherSelect)
                self.AddSeperator()
                self.AddText(_("The collection of anonymous usage information helps with the continued improvement of Cura."))
@@ -286,7 +328,7 @@ class MachineSelectPage(InfoPage):
                wx.wizard.WizardPageSimple.Chain(self, self.GetParent().ultimakerSelectParts)
 
        def OnOtherSelect(self, e):
-               wx.wizard.WizardPageSimple.Chain(self, self.GetParent().repRapInfoPage)
+               wx.wizard.WizardPageSimple.Chain(self, self.GetParent().otherMachineSelectPage)
 
        def AllowNext(self):
                wx.wizard.WizardPageSimple.Chain(self, self.GetParent().ultimaker2ReadyPage)
@@ -297,19 +339,23 @@ class MachineSelectPage(InfoPage):
                        profile.putMachineSetting('machine_width', '230')
                        profile.putMachineSetting('machine_depth', '225')
                        profile.putMachineSetting('machine_height', '205')
+                       profile.putMachineSetting('machine_name', 'ultimaker2')
                        profile.putMachineSetting('machine_type', 'ultimaker2')
                        profile.putMachineSetting('machine_center_is_zero', 'False')
+                       profile.putMachineSetting('has_heated_bed', 'True')
                        profile.putMachineSetting('gcode_flavor', 'UltiGCode')
                        profile.putProfileSetting('nozzle_size', '0.4')
-                       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.putProfileSetting('retraction_enable', 'True')
+                       profile.putMachineSetting('extruder_head_size_min_x', '40.0')
+                       profile.putMachineSetting('extruder_head_size_min_y', '10.0')
+                       profile.putMachineSetting('extruder_head_size_max_x', '60.0')
+                       profile.putMachineSetting('extruder_head_size_max_y', '30.0')
                        profile.putMachineSetting('extruder_head_size_height', '60.0')
                elif self.UltimakerRadio.GetValue():
                        profile.putMachineSetting('machine_width', '205')
                        profile.putMachineSetting('machine_depth', '205')
                        profile.putMachineSetting('machine_height', '200')
+                       profile.putMachineSetting('machine_name', 'ultimaker')
                        profile.putMachineSetting('machine_type', 'ultimaker')
                        profile.putMachineSetting('machine_center_is_zero', 'False')
                        profile.putMachineSetting('gcode_flavor', 'RepRap (Marlin/Sprinter)')
@@ -323,10 +369,13 @@ class MachineSelectPage(InfoPage):
                        profile.putMachineSetting('machine_width', '80')
                        profile.putMachineSetting('machine_depth', '80')
                        profile.putMachineSetting('machine_height', '60')
+                       profile.putMachineSetting('machine_name', 'reprap')
                        profile.putMachineSetting('machine_type', 'reprap')
                        profile.putMachineSetting('gcode_flavor', 'RepRap (Marlin/Sprinter)')
                        profile.putPreference('startMode', 'Normal')
                        profile.putProfileSetting('nozzle_size', '0.5')
+                       profile.putProfileSetting('retraction_enable', 'True')
+               profile.checkAndUpdateMachineName()
                profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2)
                if self.SubmitUserStats.GetValue():
                        profile.putPreference('submit_slice_information', 'True')
@@ -397,16 +446,16 @@ class UltimakerCheckupPage(InfoPage):
        def __init__(self, parent):
                super(UltimakerCheckupPage, self).__init__(parent, "Ultimaker Checkup")
 
-               self.checkBitmap = wx.Bitmap(getPathForImage('checkmark.png'))
-               self.crossBitmap = wx.Bitmap(getPathForImage('cross.png'))
-               self.unknownBitmap = wx.Bitmap(getPathForImage('question.png'))
-               self.endStopNoneBitmap = wx.Bitmap(getPathForImage('endstop_none.png'))
-               self.endStopXMinBitmap = wx.Bitmap(getPathForImage('endstop_xmin.png'))
-               self.endStopXMaxBitmap = wx.Bitmap(getPathForImage('endstop_xmax.png'))
-               self.endStopYMinBitmap = wx.Bitmap(getPathForImage('endstop_ymin.png'))
-               self.endStopYMaxBitmap = wx.Bitmap(getPathForImage('endstop_ymax.png'))
-               self.endStopZMinBitmap = wx.Bitmap(getPathForImage('endstop_zmin.png'))
-               self.endStopZMaxBitmap = wx.Bitmap(getPathForImage('endstop_zmax.png'))
+               self.checkBitmap = wx.Bitmap(resources.getPathForImage('checkmark.png'))
+               self.crossBitmap = wx.Bitmap(resources.getPathForImage('cross.png'))
+               self.unknownBitmap = wx.Bitmap(resources.getPathForImage('question.png'))
+               self.endStopNoneBitmap = wx.Bitmap(resources.getPathForImage('endstop_none.png'))
+               self.endStopXMinBitmap = wx.Bitmap(resources.getPathForImage('endstop_xmin.png'))
+               self.endStopXMaxBitmap = wx.Bitmap(resources.getPathForImage('endstop_xmax.png'))
+               self.endStopYMinBitmap = wx.Bitmap(resources.getPathForImage('endstop_ymin.png'))
+               self.endStopYMaxBitmap = wx.Bitmap(resources.getPathForImage('endstop_ymax.png'))
+               self.endStopZMinBitmap = wx.Bitmap(resources.getPathForImage('endstop_zmin.png'))
+               self.endStopZMaxBitmap = wx.Bitmap(resources.getPathForImage('endstop_zmax.png'))
 
                self.AddText(
                        _("It is a good idea to do a few sanity checks now on your Ultimaker.\nYou can skip these if you know your machine is functional."))
@@ -761,13 +810,13 @@ class Ultimaker2ReadyPage(InfoPage):
                self.AddSeperator()
 
 class configWizard(wx.wizard.Wizard):
-       def __init__(self):
+       def __init__(self, addNew = False):
                super(configWizard, self).__init__(None, -1, "Configuration Wizard")
 
                self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged)
                self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.OnPageChanging)
 
-               self.firstInfoPage = FirstInfoPage(self)
+               self.firstInfoPage = FirstInfoPage(self, addNew)
                self.machineSelectPage = MachineSelectPage(self)
                self.ultimakerSelectParts = SelectParts(self)
                self.ultimakerFirmwareUpgradePage = UltimakerFirmwareUpgradePage(self)
@@ -776,7 +825,9 @@ class configWizard(wx.wizard.Wizard):
                self.ultimakerCalibrateStepsPerEPage = UltimakerCalibrateStepsPerEPage(self)
                self.bedLevelPage = bedLevelWizardMain(self)
                self.headOffsetCalibration = headOffsetCalibrationPage(self)
-               self.repRapInfoPage = RepRapInfoPage(self)
+               self.otherMachineSelectPage = OtherMachineSelectPage(self)
+               self.customRepRapInfoPage = CustomRepRapInfoPage(self)
+               self.otherMachineInfoPage = OtherMachineInfoPage(self)
 
                self.ultimaker2ReadyPage = Ultimaker2ReadyPage(self)
 
@@ -787,6 +838,7 @@ class configWizard(wx.wizard.Wizard):
                wx.wizard.WizardPageSimple.Chain(self.ultimakerFirmwareUpgradePage, self.ultimakerCheckupPage)
                wx.wizard.WizardPageSimple.Chain(self.ultimakerCheckupPage, self.bedLevelPage)
                #wx.wizard.WizardPageSimple.Chain(self.ultimakerCalibrationPage, self.ultimakerCalibrateStepsPerEPage)
+               wx.wizard.WizardPageSimple.Chain(self.otherMachineSelectPage, self.customRepRapInfoPage)
 
                self.FitToPage(self.firstInfoPage)
                self.GetPageAreaSizer().Add(self.firstInfoPage)