chiark / gitweb /
Add machine switching menu items. Add tabs in machine settings window.
authordaid <daid303@gmail.com>
Wed, 25 Sep 2013 08:20:58 +0000 (10:20 +0200)
committerdaid <daid303@gmail.com>
Wed, 25 Sep 2013 08:20:58 +0000 (10:20 +0200)
Cura/gui/configWizard.py
Cura/gui/mainWindow.py
Cura/gui/preferencesDialog.py
Cura/util/profile.py

index 2c2f723b1773bee558f4879e5bbc7c99f82d4305..5a082355b9d7542ea17392bc1f66a26eb59797be 100644 (file)
@@ -241,6 +241,7 @@ class RepRapInfoPage(InfoPage):
                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")
@@ -249,19 +250,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):
index 4edb45dec192c0f376e44bd5110990b84ee980fe..88efb389253c71d1a1ccf4e90093a0c68b6ec886 100644 (file)
@@ -134,17 +134,17 @@ class mainWindow(wx.Frame):
                self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard,i)
                self.menubar.Append(toolsMenu, _("Tools"))
 
+               #Machine menu for machine configuration/tooling
+               self.machineMenu = wx.Menu()
+               self.updateMachineMenu()
+
+               self.menubar.Append(self.machineMenu, _("Machine"))
+
                expertMenu = wx.Menu()
                i = expertMenu.Append(-1, _("Open expert settings..."))
                self.normalModeOnlyItems.append(i)
                self.Bind(wx.EVT_MENU, self.OnExpertOpen, i)
                expertMenu.AppendSeparator()
-               if firmwareInstall.getDefaultFirmware() is not None:
-                       i = expertMenu.Append(-1, _("Install default Marlin firmware"))
-                       self.Bind(wx.EVT_MENU, self.OnDefaultMarlinFirmware, i)
-               i = expertMenu.Append(-1, _("Install custom firmware"))
-               self.Bind(wx.EVT_MENU, self.OnCustomFirmware, i)
-               expertMenu.AppendSeparator()
                i = expertMenu.Append(-1, _("Run first run wizard..."))
                self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i)
                i = expertMenu.Append(-1, _("Run bed leveling wizard..."))
@@ -153,9 +153,6 @@ class mainWindow(wx.Frame):
                        i = expertMenu.Append(-1, _("Run head offset wizard..."))
                        self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, i)
 
-               i = expertMenu.Append(-1, _("Add new machine..."))
-               self.Bind(wx.EVT_MENU, self.OnAddNewMachine, i)
-
                self.menubar.Append(expertMenu, _("Expert"))
 
                helpMenu = wx.Menu()
@@ -374,6 +371,30 @@ class mainWindow(wx.Frame):
                self.updateSliceMode()
                self.updateProfileToAllControls()
 
+       def updateMachineMenu(self):
+               #Remove all items so we can rebuild the menu. Inserting items seems to cause crashes, so this is the safest way.
+               for item in self.machineMenu.GetMenuItems():
+                       self.machineMenu.RemoveItem(item)
+
+               #Add a menu item for each machine configuration.
+               for n in xrange(0, profile.getMachineCount()):
+                       i = self.machineMenu.Append(n, profile.getMachineSetting('machine_name', n), 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()), i)
+
+               #Add tools for machines.
+               self.machineMenu.AppendSeparator()
+               i = self.machineMenu.Append(-1, _("Install custom firmware"))
+               self.Bind(wx.EVT_MENU, self.OnCustomFirmware, i)
+
+               i = self.machineMenu.Append(-1, _("Install default Marlin firmware"))
+               self.Bind(wx.EVT_MENU, self.OnDefaultMarlinFirmware, i)
+
+               self.machineMenu.AppendSeparator()
+               i = self.machineMenu.Append(-1, _("Add new machine..."))
+               self.Bind(wx.EVT_MENU, self.OnAddNewMachine, i)
+
        def OnLoadProfile(self, e):
                dlg=wx.FileDialog(self, _("Select profile file to load"), os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
                dlg.SetWildcard("ini files (*.ini)|*.ini")
@@ -454,6 +475,11 @@ class mainWindow(wx.Frame):
                configWizard.configWizard(True)
                self.Show()
                self.reloadSettingPanels()
+               self.updateMachineMenu()
+
+       def OnSelectMachine(self, index):
+               profile.setActiveMachine(index)
+               self.reloadSettingPanels()
 
        def OnBedLevelWizard(self, e):
                configWizard.bedLevelWizard()
index 17b30ec5a4accfe21fa54661684fe77ad0a20b54..8f28fe6610f30487479412fb58cc8c6a9f011dcb 100644 (file)
@@ -96,6 +96,8 @@ class machineSettingsDialog(wx.Dialog):
 
                        self.nb.AddPage(main, profile.getMachineSetting('machine_name', idx))
 
+               self.nb.SetSelection(int(profile.getPreferenceFloat('active_machine')))
+
                self.okButton = wx.Button(self.panel, -1, 'Ok')
                self.panel.GetSizer().Add(self.okButton, flag=wx.ALL, border=5)
                self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())
index bd360e1e9562952fe7fa15d61fe8dfdbae3973b4..3c890254d775fdda51262e4b7f302eb557c711cf 100644 (file)
@@ -643,7 +643,7 @@ def loadPreferences(filename):
                                        set.setValue(unicode(profileParser.get('machine_%d' % (n), set.getName()), 'utf-8', 'replace'), n)
                n += 1
 
-       setActiveMachine(int(getPreference('active_machine')))
+       setActiveMachine(int(getPreferenceFloat('active_machine')))
 
 def savePreferences(filename):
        global settingsList
@@ -729,7 +729,6 @@ def checkAndUpdateMachineName():
        for n in xrange(0, getMachineCount()):
                if n == _selectedMachineIndex:
                        continue
-               print name, index, getMachineSetting('machine_name', n)
                if index is None:
                        if name == getMachineSetting('machine_name', n):
                                index = 1