Welcome to mirror list, hosted at ThFree Co, Russian Federation.

preferencesDialog.py « gui « Cura - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e9a2fe5efebdfef58a25f804844c32e3ca79539f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"

import wx
import os

from Cura.gui import configWizard
from Cura.gui import configBase
from Cura.util import machineCom
from Cura.util import profile
from Cura.util import pluginInfo
from Cura.util import resources

class preferencesDialog(wx.Dialog):
	def __init__(self, parent):
		super(preferencesDialog, self).__init__(parent, title=_("Preferences"))

		wx.EVT_CLOSE(self, self.OnClose)

		self.parent = parent
		extruderCount = int(profile.getMachineSetting('extruder_amount'))

		self.panel = configBase.configPanelBase(self)

		left, right, main = self.panel.CreateConfigPanel(self)

		configBase.TitleRow(left, _("Colours"))
		configBase.SettingRow(left, 'model_colour', wx.Colour)
		for i in xrange(1, extruderCount):
			configBase.SettingRow(left, 'model_colour%d' % (i+1), wx.Colour)

		if len(resources.getLanguageOptions()) > 1:
			configBase.TitleRow(left, _("Language"))
			configBase.SettingRow(left, 'language', map(lambda n: n[1], resources.getLanguageOptions()))

		configBase.TitleRow(right, _("Filament settings"))
		configBase.SettingRow(right, 'filament_physical_density')
		configBase.SettingRow(right, 'filament_cost_kg')
		configBase.SettingRow(right, 'filament_cost_meter')

		#configBase.TitleRow(right, 'Slicer settings')
		#configBase.SettingRow(right, 'save_profile')

		configBase.TitleRow(right, 'SD Card settings')
		configBase.SettingRow(right, 'auto_detect_sd')
		configBase.SettingRow(right, 'sdcard_rootfolder')
		#same as the expert settings button.
		self.browseButton = wx.Button(right, -1, '...', style=wx.BU_EXACTFIT)
		self.browseButton.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize() * 0.8, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_NORMAL))
		self.browseButton.Bind(wx.EVT_BUTTON, self.OnBrowseSDRootFolder)
		right.GetSizer().Add(self.browseButton, (right.GetSizer().GetRows()-1, 2), flag=wx.ALIGN_CENTER_VERTICAL)

		configBase.TitleRow(right, _("Cura settings"))
		configBase.SettingRow(right, 'check_for_updates')
		#configBase.SettingRow(right, 'submit_slice_information')

		self.okButton = wx.Button(right, -1, _('Ok'))
		right.GetSizer().Add(self.okButton, (right.GetSizer().GetRows(), 0), flag=wx.BOTTOM, border=5)
		self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())

		main.Fit()
		self.Fit()

	def OnClose(self, e):
		#self.parent.reloadSettingPanels()
		self.Destroy()

	def OnBrowseSDRootFolder(self, e):
		path = profile.getPreference('sdcard_rootfolder')
		if path == '':
			path = os.path.expanduser('~/Documents')
			if not os.path.exists(path):
				path = ''

		dlg=wx.DirDialog(self, _("Select replication root folder"), path)
		if dlg.ShowModal() != wx.ID_OK:
			dlg.Destroy()
			return

		profile.putPreference('sdcard_rootfolder', dlg.GetPath())
		dlg.Destroy()
		self.Close()
		self.parent.OnPreferences(None)






class machineSettingsDialog(wx.Dialog):
	def __init__(self, parent):
		super(machineSettingsDialog, self).__init__(parent, title=_("Machine settings"))

		wx.EVT_CLOSE(self, self.OnClose)

		self.parent = parent

		self.panel = configBase.configPanelBase(self)
		self.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
		self.GetSizer().Add(self.panel, 1, wx.EXPAND)
		self.nb = wx.Notebook(self.panel)
		self.panel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		self.panel.GetSizer().Add(self.nb, 1, wx.EXPAND)

		for idx in xrange(0, profile.getMachineCount()):
			printer_type = profile.getMachineSetting('machine_type', idx)
			extruderCount = int(profile.getMachineSetting('extruder_amount', idx))
			left, right, main = self.panel.CreateConfigPanel(self.nb)
			configBase.TitleRow(left, _("Machine settings"))
			configBase.SettingRow(left, 'steps_per_e', index=idx)
			configBase.SettingRow(left, 'machine_width', index=idx)
			configBase.SettingRow(left, 'machine_depth', index=idx)
			configBase.SettingRow(left, 'machine_height', index=idx)
			if not printer_type.startswith('lulzbot_TAZ_6'): #Disabled for TAZ 6, use LCD controller instead
				configBase.SettingRow(left, 'extruder_z_offset', index=idx)
			configBase.SettingRow(left, 'extruder_amount', index=idx)
			configBase.SettingRow(left, 'has_heated_bed', index=idx)
			configBase.SettingRow(left, 'machine_center_is_zero', index=idx)
			configBase.SettingRow(left, 'machine_shape', index=idx)
			configBase.SettingRow(left, 'gcode_flavor', index=idx)

			if printer_type.startswith('lulzbot_'):
				configBase.TitleRow(right, _("Tool Head"))
				row = configBase.ToolHeadRow(right, 'toolhead', index=idx)
				row.button.Bind(wx.EVT_BUTTON, self.OnChangeToolheadButton)

			configBase.TitleRow(right, _("Printer head size"))
			configBase.SettingRow(right, 'extruder_head_size_min_x', index=idx)
			configBase.SettingRow(right, 'extruder_head_size_min_y', index=idx)
			configBase.SettingRow(right, 'extruder_head_size_max_x', index=idx)
			configBase.SettingRow(right, 'extruder_head_size_max_y', index=idx)
			configBase.SettingRow(right, 'extruder_head_size_height', index=idx)

			for i in xrange(1, extruderCount):
				configBase.TitleRow(left, _("Extruder %d") % (i+1))
				configBase.SettingRow(left, 'extruder_offset_x%d' % (i), index=idx)
				configBase.SettingRow(left, 'extruder_offset_y%d' % (i), index=idx)

			configBase.TitleRow(right, _("Communication settings"))
			serial_list = ['AUTO'] + machineCom.serialList()
			serial_list_labels = serial_list[:]
			if profile.getMachineSetting('serial_port') not in serial_list:
				serial_list.append(profile.getMachineSetting('serial_port'))
				serial_list_labels.append(profile.getMachineSetting('serial_port') + _(" (Currently unavailable)"))
			configBase.SettingRow(right, 'serial_port', serial_list, serial_list_labels, index=idx)
			configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), index=idx)

			machine_name = profile.getMachineName(idx)
			machine_title = machine_name.title()			
			machine_title = machine_title.replace('Taz', 'TAZ')
			machine_title = machine_title.replace('Lulzbot', 'LulzBot')
			self.nb.AddPage(main, machine_title)

		self.nb.SetSelection(int(profile.getPreferenceFloat('active_machine')))

		self.buttonPanel = wx.Panel(self.panel)
		self.panel.GetSizer().Add(self.buttonPanel)

		self.buttonPanel.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
		self.okButton = wx.Button(self.buttonPanel, -1, _('Ok'))
		self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())
		self.buttonPanel.GetSizer().Add(self.okButton, flag=wx.ALL, border=5)

		self.addButton = wx.Button(self.buttonPanel, -1, _('Add new machine'))
		self.addButton.Bind(wx.EVT_BUTTON, self.OnAddMachine)
		self.buttonPanel.GetSizer().Add(self.addButton, flag=wx.ALL, border=5)

		self.remButton = wx.Button(self.buttonPanel, -1, _('Remove machine'))
		self.remButton.Bind(wx.EVT_BUTTON, self.OnRemoveMachine)
		self.buttonPanel.GetSizer().Add(self.remButton, flag=wx.ALL, border=5)

		self.renButton = wx.Button(self.buttonPanel, -1, _('Change machine name'))
		self.renButton.Bind(wx.EVT_BUTTON, self.OnRenameMachine)
		self.buttonPanel.GetSizer().Add(self.renButton, flag=wx.ALL, border=5)

		main.Fit()
		self.Fit()

	def OnChangeToolheadButton(self, e):
		self.Hide()
		self.parent.Hide()
		old_active = int(profile.getPreferenceFloat('active_machine'))
		profile.setActiveMachine(self.nb.GetSelection())
		configWizard.LulzbotChangeToolheadWizard()
		profile.setActiveMachine(old_active)
		self.parent.Show()
		self.parent.reloadSettingPanels()
		self.parent.updateMachineMenu()

		prefDialog = machineSettingsDialog(self.parent)
		prefDialog.Centre()
		prefDialog.Show()
		wx.CallAfter(self.Close)

	def OnAddMachine(self, e):
		self.Hide()
		self.parent.Hide()
		configWizard.ConfigWizard(True)
		self.parent.Show()
		self.parent.reloadSettingPanels()
		self.parent.updateMachineMenu()

		prefDialog = machineSettingsDialog(self.parent)
		prefDialog.Centre()
		prefDialog.Show()
		wx.CallAfter(self.Close)

	def OnRemoveMachine(self, e):
		if profile.getMachineCount() < 2:
			wx.MessageBox(_("Cannot remove the last machine configuration in Cura"), _("Machine remove error"), wx.OK | wx.ICON_ERROR)
			return

		self.Hide()
		profile.removeMachine(self.nb.GetSelection())
		self.parent.reloadSettingPanels()
		self.parent.updateMachineMenu()

		prefDialog = machineSettingsDialog(self.parent)
		prefDialog.Centre()
		prefDialog.Show()
		wx.CallAfter(self.Close)

	def OnRenameMachine(self, e):
		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
		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):
		self.parent.reloadSettingPanels()
		self.Destroy()