1 from __future__ import absolute_import
2 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
6 from Cura.gui import configWizard
7 from Cura.gui import configBase
8 from Cura.util import machineCom
9 from Cura.util import profile
11 class preferencesDialog(wx.Dialog):
12 def __init__(self, parent):
13 super(preferencesDialog, self).__init__(None, title="Preferences")
15 wx.EVT_CLOSE(self, self.OnClose)
18 extruderCount = int(profile.getMachineSetting('extruder_amount'))
20 self.panel = configBase.configPanelBase(self)
22 left, right, main = self.panel.CreateConfigPanel(self)
24 configBase.TitleRow(left, _("Colours"))
25 configBase.SettingRow(left, 'model_colour', wx.Colour)
26 for i in xrange(1, extruderCount):
27 configBase.SettingRow(left, 'model_colour%d' % (i+1), wx.Colour)
29 configBase.TitleRow(right, _("Filament settings"))
30 configBase.SettingRow(right, 'filament_physical_density')
31 configBase.SettingRow(right, 'filament_cost_kg')
32 configBase.SettingRow(right, 'filament_cost_meter')
34 #configBase.TitleRow(right, 'Slicer settings')
35 #configBase.SettingRow(right, 'save_profile')
37 #configBase.TitleRow(right, 'SD Card settings')
39 configBase.TitleRow(right, _("Cura settings"))
40 configBase.SettingRow(right, 'auto_detect_sd')
41 configBase.SettingRow(right, 'check_for_updates')
42 configBase.SettingRow(right, 'submit_slice_information')
44 self.okButton = wx.Button(right, -1, 'Ok')
45 right.GetSizer().Add(self.okButton, (right.GetSizer().GetRows(), 0), flag=wx.BOTTOM, border=5)
46 self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())
52 #self.parent.reloadSettingPanels()
55 class machineSettingsDialog(wx.Dialog):
56 def __init__(self, parent):
57 super(machineSettingsDialog, self).__init__(None, title="Machine settings")
59 wx.EVT_CLOSE(self, self.OnClose)
62 extruderCount = int(profile.getMachineSetting('extruder_amount'))
64 self.panel = configBase.configPanelBase(self)
65 self.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
66 self.GetSizer().Add(self.panel, 1, wx.EXPAND)
67 self.nb = wx.Notebook(self.panel)
68 self.panel.SetSizer(wx.BoxSizer(wx.VERTICAL))
69 self.panel.GetSizer().Add(self.nb, 1, wx.EXPAND)
71 for idx in xrange(0, profile.getMachineCount()):
72 left, right, main = self.panel.CreateConfigPanel(self.nb)
73 configBase.TitleRow(left, _("Machine settings"))
74 configBase.SettingRow(left, 'steps_per_e', index=idx)
75 configBase.SettingRow(left, 'machine_width', index=idx)
76 configBase.SettingRow(left, 'machine_depth', index=idx)
77 configBase.SettingRow(left, 'machine_height', index=idx)
78 configBase.SettingRow(left, 'extruder_amount', index=idx)
79 configBase.SettingRow(left, 'has_heated_bed', index=idx)
80 configBase.SettingRow(left, 'gcode_flavor', index=idx)
82 configBase.TitleRow(right, _("Printer head size"))
83 configBase.SettingRow(right, 'extruder_head_size_min_x', index=idx)
84 configBase.SettingRow(right, 'extruder_head_size_min_y', index=idx)
85 configBase.SettingRow(right, 'extruder_head_size_max_x', index=idx)
86 configBase.SettingRow(right, 'extruder_head_size_max_y', index=idx)
87 configBase.SettingRow(right, 'extruder_head_size_height', index=idx)
89 for i in xrange(1, extruderCount):
90 configBase.TitleRow(left, _("Extruder %d") % (i+1))
91 configBase.SettingRow(left, 'extruder_offset_x%d' % (i), index=idx)
92 configBase.SettingRow(left, 'extruder_offset_y%d' % (i), index=idx)
94 configBase.TitleRow(right, _("Communication settings"))
95 configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList(), index=idx)
96 configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), index=idx)
98 self.nb.AddPage(main, profile.getMachineSetting('machine_name', idx).title())
100 self.nb.SetSelection(int(profile.getPreferenceFloat('active_machine')))
102 self.buttonPanel = wx.Panel(self.panel)
103 self.panel.GetSizer().Add(self.buttonPanel)
105 self.buttonPanel.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
106 self.okButton = wx.Button(self.buttonPanel, -1, 'Ok')
107 self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())
108 self.buttonPanel.GetSizer().Add(self.okButton, flag=wx.ALL, border=5)
110 self.addButton = wx.Button(self.buttonPanel, -1, 'Add new machine')
111 self.addButton.Bind(wx.EVT_BUTTON, self.OnAddMachine)
112 self.buttonPanel.GetSizer().Add(self.addButton, flag=wx.ALL, border=5)
114 self.remButton = wx.Button(self.buttonPanel, -1, 'Remove machine')
115 self.remButton.Bind(wx.EVT_BUTTON, self.OnRemoveMachine)
116 self.buttonPanel.GetSizer().Add(self.remButton, flag=wx.ALL, border=5)
121 def OnAddMachine(self, e):
124 profile.setActiveMachine(profile.getMachineCount())
125 configWizard.configWizard(True)
127 self.parent.reloadSettingPanels()
128 self.parent.updateMachineMenu()
130 prefDialog = machineSettingsDialog(self.parent)
133 wx.CallAfter(self.Close)
135 def OnRemoveMachine(self, e):
136 if profile.getMachineCount() < 2:
137 wx.MessageBox(_("Cannot remove the last machine configuration in Cura"), _("Machine remove error"), wx.OK | wx.ICON_ERROR)
141 profile.removeMachine(self.nb.GetSelection())
142 self.parent.reloadSettingPanels()
143 self.parent.updateMachineMenu()
145 prefDialog = machineSettingsDialog(self.parent)
148 wx.CallAfter(self.Close)
150 def OnClose(self, e):
151 self.parent.reloadSettingPanels()