chiark / gitweb /
Show machine_name (toolhead_shortname) instead of adding the toolhead name as part...
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Thu, 30 Jul 2015 18:03:55 +0000 (14:03 -0400)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Thu, 30 Jul 2015 19:52:37 +0000 (15:52 -0400)
This allows users to configure the name of their printer without losing
that value when they change toolheads

Cura/gui/configWizard.py
Cura/gui/firmwareInstall.py
Cura/gui/mainWindow.py
Cura/gui/preferencesDialog.py
Cura/util/profile.py

index 2f56c90aaa7a58bee57465f02c3ca72405f4a918..17a7a472bfaa333537b69403efede4a740312eb8 100644 (file)
@@ -1139,17 +1139,20 @@ class LulzbotMachineSelectPage(InfoPage):
                                profile.putMachineSetting('machine_depth', '275')
                                profile.putMachineSetting('machine_height', '250')
                                profile.putMachineSetting('machine_type', 'lulzbot_TAZ_4')
+                               profile.putMachineSetting('machine_name', 'LulzBot TAZ 4')
                                profile.putMachineSetting('serial_baud', '115200')
                        elif self.LulzbotTaz5.GetValue():
                                # Nozzle size will be set in the toolhead selection page
                                # We set the machine_type here so later pages can differenciate between TAZ 4 and 5
                                profile.putMachineSetting('machine_type', 'lulzbot_TAZ_5')
+                               profile.putMachineSetting('machine_name', 'LulzBot TAZ 5')
                                profile.putMachineSetting('machine_width', '290')
                                profile.putMachineSetting('machine_depth', '275')
                                profile.putMachineSetting('machine_height', '250')
                                profile.putMachineSetting('serial_baud', '115200')
                        else:
-                               # Nozzle size and machine name/type will be set in the toolhead selection page
+                               # Nozzle size and machine type will be set in the toolhead selection page
+                               profile.putMachineSetting('machine_name', 'LulzBot Mini')
                                profile.putMachineSetting('machine_width', '155')
                                profile.putMachineSetting('machine_depth', '155')
                                profile.putMachineSetting('machine_height', '163')
@@ -1224,13 +1227,13 @@ class LulzbotMiniToolheadSelectPage(LulzbotToolheadSelectPage):
                        profile.putProfileSetting('nozzle_size', '0.5')
                        profile.putMachineSetting('extruder_amount', '1')
                        profile.putMachineSetting('toolhead', 'Single Extruder V2')
-                       profile.putMachineSetting('machine_name', 'LulzBot Mini')
+                       profile.putMachineSetting('toolhead_shortname', '')
                        profile.putMachineSetting('machine_type', 'lulzbot_mini')
                else:
                        profile.putProfileSetting('nozzle_size', '0.6')
                        profile.putMachineSetting('extruder_amount', '1')
                        profile.putMachineSetting('toolhead', 'Flexystruder V2')
-                       profile.putMachineSetting('machine_name', 'LulzBot Mini (Flexy)')
+                       profile.putMachineSetting('toolhead_shortname', 'Flexy')
                        profile.putMachineSetting('machine_type', 'lulzbot_mini_flexy')
 
 
@@ -1297,25 +1300,25 @@ class LulzbotTazToolheadSelectPage(LulzbotToolheadSelectPage):
                        profile.putProfileSetting('nozzle_size', '0.5' if self.version == 2 else '0.35')
                        profile.putMachineSetting('extruder_amount', '1')
                        profile.putMachineSetting('toolhead', 'Single Extruder V%d' % self.version)
-                       profile.putMachineSetting('machine_name', 'LulzBot TAZ %d' % taz_version)
+                       profile.putMachineSetting('toolhead_shortname', '')
                        profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_SingleV%d' % version)
                elif self.flexy.GetValue():
                        profile.putProfileSetting('nozzle_size', '0.6')
                        profile.putMachineSetting('extruder_amount', '1')
                        profile.putMachineSetting('toolhead', 'Flexystruder V%d' % self.version)
-                       profile.putMachineSetting('machine_name', 'LulzBot TAZ %d (Flexy v%d)' % version)
+                       profile.putMachineSetting('toolhead_shortname', 'Flexy v%d' % self.version)
                        profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_flexyV%d' % version)
                elif self.dually.GetValue():
-                       profile.putMachineSetting('extruder_amount', '2')
                        profile.putProfileSetting('nozzle_size', '0.5')
+                       profile.putMachineSetting('extruder_amount', '2')
                        profile.putMachineSetting('toolhead', 'Dual Extruder V%d' % self.version)
-                       profile.putMachineSetting('machine_name', 'LulzBot TAZ %d (Dually v%d)' % version)
+                       profile.putMachineSetting('toolhead_shortname', 'Dually v%d' % self.version)
                        profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_DuallyV%d' % version)
                elif self.flexydually.GetValue():
                        profile.putProfileSetting('nozzle_size', '0.6')
                        profile.putMachineSetting('extruder_amount', '2')
                        profile.putMachineSetting('toolhead', 'FlexyDually V%d' % self.version)
-                       profile.putMachineSetting('machine_name', 'LulzBot TAZ %d (FlexyDually v%d)' % version)
+                       profile.putMachineSetting('toolhead_shortname', 'FlexyDually v%d' % self.version)
                        profile.putMachineSetting('machine_type', 'lulzbot_TAZ_%d_FlexyDuallyV%d' % version)
 
 
@@ -1364,14 +1367,14 @@ class LulzbotTaz5NozzleSelectPage(LulzbotToolheadSelectPage):
        def StoreData(self):
                if self.Nozzle35Radio.GetValue():
                        profile.putProfileSetting('nozzle_size', '0.35')
-                       profile.putMachineSetting('toolhead', 'Single Extruder V2 (0.35 nozzle)')
-                       profile.putMachineSetting('machine_name', 'LulzBot TAZ 5 (0.35 nozzle)')
+                       profile.putMachineSetting('toolhead', 'Single Extruder V2 (0.35mm nozzle)')
+                       profile.putMachineSetting('toolhead_shortname', '0.35 nozzle')
                        profile.putMachineSetting('machine_type', 'lulzbot_TAZ_5_035nozzle')
 
                else:
                        profile.putProfileSetting('nozzle_size', '0.5')
-                       profile.putMachineSetting('toolhead', 'Single Extruder V2 (0.5 nozzle)')
-                       profile.putMachineSetting('machine_name', 'LulzBot TAZ 5 (0.5 nozzle)')
+                       profile.putMachineSetting('toolhead', 'Single Extruder V2 (0.5mm nozzle)')
+                       profile.putMachineSetting('toolhead_shortname', '0.5 nozzle')
                        profile.putMachineSetting('machine_type', 'lulzbot_TAZ_5_05nozzle')
 
 class LulzbotChangeToolheadWizard(wx.wizard.Wizard):
index a06b02ae11c573bfa6b802f483b38249d4125617..90074c24b2e7520f91f82c988fc18765c428f13b 100644 (file)
@@ -64,7 +64,7 @@ def getDefaultFirmware(machineIndex = None):
 
 class InstallFirmware(wx.Dialog):
        def __init__(self, parent = None, filename = None, port = None, machineIndex = None):
-               super(InstallFirmware, self).__init__(parent=parent, title=_("Firmware install for %s") % (profile.getMachineSetting('machine_name', machineIndex).title()), size=(250, 100))
+               super(InstallFirmware, self).__init__(parent=parent, title=_("Firmware install for %s") % (profile.getMachineName(machineIndex).title()), size=(250, 100))
                if port is None:
                        port = profile.getMachineSetting('serial_port')
                if filename is None:
index 27223f21539b7615ac410a69c4594ff755a1a0d6..32476d36b91e3fcf7de90601317e7b9a9541bc72 100644 (file)
@@ -481,7 +481,7 @@ class mainWindow(wx.Frame):
 
                #Add a menu item for each machine configuration.
                for n in xrange(0, profile.getMachineCount()):
-                       i = self.machineMenu.Append(n + 0x1000, profile.getMachineSetting('machine_name', n).title(), kind=wx.ITEM_RADIO)
+                       i = self.machineMenu.Append(n + 0x1000, profile.getMachineName(n).title(), kind=wx.ITEM_RADIO)
                        if n == int(profile.getPreferenceFloat('active_machine')):
                                i.Check(True)
                        self.Bind(wx.EVT_MENU, lambda e: self.OnSelectMachine(e.GetId() - 0x1000), i)
index 883ce8eb4524b61a81670466ea44d5ecc08a2928..eee3c35c27e285e657ed701dc3af125064824677 100644 (file)
@@ -144,7 +144,7 @@ class machineSettingsDialog(wx.Dialog):
                        configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList(), index=idx)
                        configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), index=idx)
 
-                       self.nb.AddPage(main, profile.getMachineSetting('machine_name', idx).title())
+                       self.nb.AddPage(main, profile.getMachineName(idx).title())
 
                self.nb.SetSelection(int(profile.getPreferenceFloat('active_machine')))
 
@@ -216,11 +216,12 @@ class machineSettingsDialog(wx.Dialog):
                wx.CallAfter(self.Close)
 
        def OnRenameMachine(self, e):
-               dialog = wx.TextEntryDialog(self, _("Enter the new name:"), _("Change machine name"), self.nb.GetPageText(self.nb.GetSelection()))
+               dialog = wx.TextEntryDialog(self, _("Enter the new name:"), _("Change machine name"),
+                                                                       profile.getMachineSetting('machine_name', self.nb.GetSelection()))
                if dialog.ShowModal() != wx.ID_OK:
                        return
-               self.nb.SetPageText(self.nb.GetSelection(), dialog.GetValue())
                profile.putMachineSetting('machine_name', dialog.GetValue(), self.nb.GetSelection())
+               self.nb.SetPageText(self.nb.GetSelection(), profile.getMachineName(self.nb.GetSelection()))
                self.parent.updateMachineMenu()
 
        def OnClose(self, e):
index 2ac0e18271c5f1049d7a4574166a6024abf61855..45f052c71d898af1d24866bdb965974b5feb28ec 100644 (file)
@@ -553,6 +553,7 @@ setting('serial_baud', 'AUTO', str, 'machine', 'hidden').setLabel(_("Baudrate"),
 setting('serial_baud_auto', '', int, 'machine', 'hidden')
 
 setting('toolhead', 'Default', str, 'machine', 'hidden').setLabel(_("Installed toolhead"), _("Which toolhead is currently installed. This setting is only used by LulzBot machines."))
+setting('toolhead_shortname', '', str, '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."))
 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."))
 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."))
@@ -1104,6 +1105,15 @@ def getMachineCount():
                return 1
        return n
 
+def getMachineName(index = None):
+       name = getMachineSetting('machine_name', index)
+       type = getMachineSetting('machine_type', index)
+       if type.startswith('lulzbot_'):
+               toolhead = getMachineSetting('toolhead_shortname', index)
+               if toolhead != '':
+                       return "%s (%s)" % (name, toolhead)
+       return name
+
 def setActiveMachine(index):
        global _selectedMachineIndex
        _selectedMachineIndex = index