From: daid Date: Wed, 25 Sep 2013 08:20:58 +0000 (+0200) Subject: Add machine switching menu items. Add tabs in machine settings window. X-Git-Tag: 13.10~51 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5ab0e95f56ae27c86374bfc964285bf211c57403;p=cura.git Add machine switching menu items. Add tabs in machine settings window. --- diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index 2c2f723b..5a082355 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -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): diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 4edb45de..88efb389 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -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() diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index 17b30ec5..8f28fe66 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -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()) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index bd360e1e..3c890254 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -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