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
10 from Cura.util import resources
12 class preferencesDialog(wx.Dialog):
13 def __init__(self, parent):
14 super(preferencesDialog, self).__init__(None, title="Preferences")
16 wx.EVT_CLOSE(self, self.OnClose)
19 extruderCount = int(profile.getMachineSetting('extruder_amount'))
21 self.panel = configBase.configPanelBase(self)
23 left, right, main = self.panel.CreateConfigPanel(self)
25 configBase.TitleRow(left, _("Colours"))
26 configBase.SettingRow(left, 'model_colour', wx.Colour)
27 for i in xrange(1, extruderCount):
28 configBase.SettingRow(left, 'model_colour%d' % (i+1), wx.Colour)
30 if len(resources.getLanguageOptions()) > 1:
31 configBase.TitleRow(left, _("Language"))
32 configBase.SettingRow(left, 'language', map(lambda n: n[1], resources.getLanguageOptions()))
34 configBase.TitleRow(right, _("Filament settings"))
35 configBase.SettingRow(right, 'filament_physical_density')
36 configBase.SettingRow(right, 'filament_cost_kg')
37 configBase.SettingRow(right, 'filament_cost_meter')
39 #configBase.TitleRow(right, 'Slicer settings')
40 #configBase.SettingRow(right, 'save_profile')
42 #configBase.TitleRow(right, 'SD Card settings')
44 configBase.TitleRow(right, _("Cura settings"))
45 configBase.SettingRow(right, 'auto_detect_sd')
46 configBase.SettingRow(right, 'check_for_updates')
47 configBase.SettingRow(right, 'submit_slice_information')
49 self.okButton = wx.Button(right, -1, 'Ok')
50 right.GetSizer().Add(self.okButton, (right.GetSizer().GetRows(), 0), flag=wx.BOTTOM, border=5)
51 self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())
57 #self.parent.reloadSettingPanels()
60 class machineSettingsDialog(wx.Dialog):
61 def __init__(self, parent):
62 super(machineSettingsDialog, self).__init__(None, title="Machine settings")
64 wx.EVT_CLOSE(self, self.OnClose)
67 extruderCount = int(profile.getMachineSetting('extruder_amount'))
69 self.panel = configBase.configPanelBase(self)
70 self.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
71 self.GetSizer().Add(self.panel, 1, wx.EXPAND)
72 self.nb = wx.Notebook(self.panel)
73 self.panel.SetSizer(wx.BoxSizer(wx.VERTICAL))
74 self.panel.GetSizer().Add(self.nb, 1, wx.EXPAND)
76 for idx in xrange(0, profile.getMachineCount()):
77 left, right, main = self.panel.CreateConfigPanel(self.nb)
78 configBase.TitleRow(left, _("Machine settings"))
79 configBase.SettingRow(left, 'steps_per_e', index=idx)
80 configBase.SettingRow(left, 'machine_width', index=idx)
81 configBase.SettingRow(left, 'machine_depth', index=idx)
82 configBase.SettingRow(left, 'machine_height', index=idx)
83 configBase.SettingRow(left, 'extruder_amount', index=idx)
84 configBase.SettingRow(left, 'has_heated_bed', index=idx)
85 configBase.SettingRow(left, 'machine_center_is_zero', index=idx)
86 configBase.SettingRow(left, 'gcode_flavor', index=idx)
88 configBase.TitleRow(right, _("Printer head size"))
89 configBase.SettingRow(right, 'extruder_head_size_min_x', index=idx)
90 configBase.SettingRow(right, 'extruder_head_size_min_y', index=idx)
91 configBase.SettingRow(right, 'extruder_head_size_max_x', index=idx)
92 configBase.SettingRow(right, 'extruder_head_size_max_y', index=idx)
93 configBase.SettingRow(right, 'extruder_head_size_height', index=idx)
95 for i in xrange(1, extruderCount):
96 configBase.TitleRow(left, _("Extruder %d") % (i+1))
97 configBase.SettingRow(left, 'extruder_offset_x%d' % (i), index=idx)
98 configBase.SettingRow(left, 'extruder_offset_y%d' % (i), index=idx)
100 configBase.TitleRow(right, _("Communication settings"))
101 configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList(), index=idx)
102 configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), index=idx)
104 self.nb.AddPage(main, profile.getMachineSetting('machine_name', idx).title())
106 self.nb.SetSelection(int(profile.getPreferenceFloat('active_machine')))
108 self.buttonPanel = wx.Panel(self.panel)
109 self.panel.GetSizer().Add(self.buttonPanel)
111 self.buttonPanel.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
112 self.okButton = wx.Button(self.buttonPanel, -1, 'Ok')
113 self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())
114 self.buttonPanel.GetSizer().Add(self.okButton, flag=wx.ALL, border=5)
116 self.addButton = wx.Button(self.buttonPanel, -1, 'Add new machine')
117 self.addButton.Bind(wx.EVT_BUTTON, self.OnAddMachine)
118 self.buttonPanel.GetSizer().Add(self.addButton, flag=wx.ALL, border=5)
120 self.remButton = wx.Button(self.buttonPanel, -1, 'Remove machine')
121 self.remButton.Bind(wx.EVT_BUTTON, self.OnRemoveMachine)
122 self.buttonPanel.GetSizer().Add(self.remButton, flag=wx.ALL, border=5)
127 def OnAddMachine(self, e):
130 profile.setActiveMachine(profile.getMachineCount())
131 configWizard.configWizard(True)
133 self.parent.reloadSettingPanels()
134 self.parent.updateMachineMenu()
136 prefDialog = machineSettingsDialog(self.parent)
139 wx.CallAfter(self.Close)
141 def OnRemoveMachine(self, e):
142 if profile.getMachineCount() < 2:
143 wx.MessageBox(_("Cannot remove the last machine configuration in Cura"), _("Machine remove error"), wx.OK | wx.ICON_ERROR)
147 profile.removeMachine(self.nb.GetSelection())
148 self.parent.reloadSettingPanels()
149 self.parent.updateMachineMenu()
151 prefDialog = machineSettingsDialog(self.parent)
154 wx.CallAfter(self.Close)
156 def OnClose(self, e):
157 self.parent.reloadSettingPanels()