sizer.SetRows(x + 2)
class SettingRow(object):
- def __init__(self, panel, configName, valueOverride = None):
+ def __init__(self, panel, configName, valueOverride = None, index = None):
"Add a setting to the configuration panel"
sizer = panel.GetSizer()
x = sizer.GetRows()
flag = 0
self.setting = profile.settingsDictionary[configName]
+ self.settingIndex = index
self.validationMsg = ''
self.panel = panel
# flag = wx.EXPAND
if self.setting.getType() is types.BooleanType:
self.ctrl = wx.CheckBox(panel, -1, style=wx.ALIGN_RIGHT)
- self.SetValue(self.setting.getValue())
+ self.SetValue(self.setting.getValue(self.settingIndex))
self.ctrl.Bind(wx.EVT_CHECKBOX, self.OnSettingChange)
elif valueOverride is not None and valueOverride is wx.Colour:
self.ctrl = wx.ColourPickerCtrl(panel, -1)
- self.SetValue(self.setting.getValue())
+ self.SetValue(self.setting.getValue(self.settingIndex))
self.ctrl.Bind(wx.EVT_COLOURPICKER_CHANGED, self.OnSettingChange)
elif type(self.setting.getType()) is list or valueOverride is not None:
- value = self.setting.getValue()
+ value = self.setting.getValue(self.settingIndex)
choices = self.setting.getType()
if valueOverride is not None:
choices = valueOverride
self.ctrl.Bind(wx.EVT_LEFT_DOWN, self.OnMouseExit)
flag = wx.EXPAND
else:
- self.ctrl = wx.TextCtrl(panel, -1, self.setting.getValue())
+ self.ctrl = wx.TextCtrl(panel, -1, self.setting.getValue(self.settingIndex))
self.ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange)
flag = wx.EXPAND
e.Skip()
def OnSettingChange(self, e):
- self.setting.setValue(self.GetValue())
+ self.setting.setValue(self.GetValue(), self.settingIndex)
self.panel.main._validate()
def _validate(self):
self.fileMenu.AppendSeparator()
i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,"))
self.Bind(wx.EVT_MENU, self.OnPreferences, i)
+ i = self.fileMenu.Append(-1, _("Machine settings..."))
+ self.Bind(wx.EVT_MENU, self.OnMachineSettings, i)
self.fileMenu.AppendSeparator()
# Model MRU list
prefDialog.Centre()
prefDialog.Show()
+ def OnMachineSettings(self, e):
+ prefDialog = preferencesDialog.machineSettingsDialog(self)
+ prefDialog.Centre()
+ prefDialog.Show()
+
def OnDropFiles(self, files):
if len(files) > 0:
profile.setPluginConfig([])
def OnAddNewMachine(self, e):
self.Hide()
- n = 0
- while profile.getMachineSetting('machine_name', n) != '':
- n += 1
- profile.setActiveMachine(n)
+ profile.setActiveMachine(profile.getMachineCount())
configWizard.configWizard(True)
self.Show()
self.reloadSettingPanels()
#Plugin page
self.pluginPanel = pluginPanel.pluginPanel(self.nb, callback)
if len(self.pluginPanel.pluginList) > 0:
- self.nb.AddPage(self.pluginPanel, "Plugins")
+ self.nb.AddPage(self.pluginPanel, _("Plugins"))
else:
self.pluginPanel.Show(False)
wx.EVT_CLOSE(self, self.OnClose)
self.parent = parent
- self.oldExtruderAmount = int(profile.getMachineSetting('extruder_amount'))
+ extruderCount = int(profile.getMachineSetting('extruder_amount'))
self.panel = configBase.configPanelBase(self)
left, right, main = self.panel.CreateConfigPanel(self)
- configBase.TitleRow(left, _("Machine settings"))
- configBase.SettingRow(left, 'steps_per_e')
- configBase.SettingRow(left, 'machine_width')
- configBase.SettingRow(left, 'machine_depth')
- configBase.SettingRow(left, 'machine_height')
- configBase.SettingRow(left, 'extruder_amount')
- configBase.SettingRow(left, 'has_heated_bed')
- configBase.SettingRow(left, 'gcode_flavor')
-
- configBase.TitleRow(left, _("Printer head size"))
- configBase.SettingRow(left, 'extruder_head_size_min_x')
- configBase.SettingRow(left, 'extruder_head_size_min_y')
- configBase.SettingRow(left, 'extruder_head_size_max_x')
- configBase.SettingRow(left, 'extruder_head_size_max_y')
- configBase.SettingRow(left, 'extruder_head_size_height')
-
- for i in xrange(1, self.oldExtruderAmount):
- configBase.TitleRow(left, _("Extruder %d") % (i+1))
- configBase.SettingRow(left, 'extruder_offset_x%d' % (i))
- configBase.SettingRow(left, 'extruder_offset_y%d' % (i))
-
- configBase.TitleRow(right, _("Colours"))
- configBase.SettingRow(right, 'model_colour', wx.Colour)
- for i in xrange(1, self.oldExtruderAmount):
- configBase.SettingRow(right, 'model_colour%d' % (i+1), wx.Colour)
+
+ 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)
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, _("Communication settings"))
- configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList())
- configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()))
-
#configBase.TitleRow(right, 'Slicer settings')
#configBase.SettingRow(right, 'save_profile')
main.Fit()
self.Fit()
+ def OnClose(self, e):
+ #self.parent.reloadSettingPanels()
+ self.Destroy()
+
+class machineSettingsDialog(wx.Dialog):
+ def __init__(self, parent):
+ super(machineSettingsDialog, self).__init__(None, title="Machine settings")
+
+ wx.EVT_CLOSE(self, self.OnClose)
+
+ self.parent = parent
+ extruderCount = int(profile.getMachineSetting('extruder_amount'))
+
+ 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()):
+ 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)
+ configBase.SettingRow(left, 'extruder_amount', index=idx)
+ configBase.SettingRow(left, 'has_heated_bed', index=idx)
+ configBase.SettingRow(left, 'gcode_flavor', index=idx)
+
+ 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"))
+ configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList(), index=idx)
+ configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), index=idx)
+
+ self.nb.AddPage(main, profile.getMachineSetting('machine_name', idx))
+
+ 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())
+
+ main.Fit()
+ self.Fit()
+
def OnClose(self, e):
self.parent.reloadSettingPanels()
self.Destroy()
if forAutoDetect:
baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob("/dev/cu.usb*")
baselist = filter(lambda s: not 'Bluetooth' in s, baselist)
+ prev = profile.getMachineSetting('serial_port_auto')
+ if prev in baselist:
+ baselist.remove(prev)
+ baselist.insert(0, prev)
else:
baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob("/dev/cu.*") + glob.glob("/dev/tty.usb*") + glob.glob("/dev/rfcomm*")
- prev = profile.getMachineSetting('serial_port_auto')
- if prev in baselist:
- baselist.remove(prev)
- baselist.insert(0, prev)
if version.isDevVersion() and not forAutoDetect:
baselist.append('VIRTUAL')
return baselist
setting('machine_center_is_zero', 'False', bool, 'machine', 'hidden')
setting('ultimaker_extruder_upgrade', 'False', bool, 'machine', 'hidden')
setting('has_heated_bed', 'False', bool, 'machine', 'hidden').setLabel('Heated bed', 'If you have an heated bed, this enabled heated bed settings (requires restart)')
-setting('gcode_flavor', 'RepRap (Marlin/Sprinter)', ['RepRap (Marlin/Sprinter)', 'UltiGCode'], 'machine', 'hidden').setLabel('GCode Flavor', 'Flavor of generated GCode.\nRepRap...')
+setting('gcode_flavor', 'RepRap (Marlin/Sprinter)', ['RepRap (Marlin/Sprinter)', 'UltiGCode'], 'machine', 'hidden').setLabel('GCode Flavor', 'Flavor of generated GCode.\nRepRap is normal 5D GCode which works on Marlin/Sprinter based firmwares.\nUltiGCode is a variation of the RepRap GCode which puts more settings in the machine instead of the slicer.')
setting('extruder_amount', '1', ['1','2','3','4'], 'machine', 'hidden').setLabel('Extruder count', 'Amount of extruders in your machine.')
setting('extruder_offset_x1', '-21.6', float, 'machine', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
setting('extruder_offset_y1', '0.0', float, 'machine', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
-setting('extruder_offset_x2', '0.0', float, 'machine', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
-setting('extruder_offset_y2', '0.0', float, 'machine', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
-setting('extruder_offset_x3', '0.0', float, 'machine', 'hidden').setLabel('Offset X', 'The offset of your secondary extruder compared to the primary.')
-setting('extruder_offset_y3', '0.0', float, 'machine', 'hidden').setLabel('Offset Y', 'The offset of your secondary extruder compared to the primary.')
+setting('extruder_offset_x2', '0.0', float, 'machine', 'hidden').setLabel('Offset X', 'The offset of your tertiary extruder compared to the primary.')
+setting('extruder_offset_y2', '0.0', float, 'machine', 'hidden').setLabel('Offset Y', 'The offset of your tertiary extruder compared to the primary.')
+setting('extruder_offset_x3', '0.0', float, 'machine', 'hidden').setLabel('Offset X', 'The offset of your forth extruder compared to the primary.')
+setting('extruder_offset_y3', '0.0', float, 'machine', 'hidden').setLabel('Offset Y', 'The offset of your forth extruder compared to the primary.')
setting('steps_per_e', '0', float, 'machine', 'hidden').setLabel('E-Steps per 1mm filament', 'Amount of steps per mm filament extrusion. If set to 0 then this value is ignored and the value in your firmware is used.')
setting('serial_port', 'AUTO', str, 'machine', 'hidden').setLabel('Serial port', 'Serial port to use for communication with the printer')
setting('serial_port_auto', '', str, 'machine', 'hidden')
index = None
if name == '':
name = getMachineSetting('machine_type')
- n = 0
- while getMachineSetting('machine_name', n) != '':
+ for n in xrange(0, getMachineCount()):
if n == _selectedMachineIndex:
- n += 1
continue
print name, index, getMachineSetting('machine_name', n)
if index is None:
else:
if '%s (%d)' % (name, index) == getMachineSetting('machine_name', n):
index += 1
- n += 1
if index is not None:
name = '%s (%d)' % (name, index)
putMachineSetting('machine_name', name)
putPreference('active_machine', _selectedMachineIndex)
+def getMachineCount():
+ n = 0
+ while getMachineSetting('machine_name', n) != '':
+ n += 1
+ if n < 1:
+ return 1
+ return n
+
def setActiveMachine(index):
global _selectedMachineIndex
_selectedMachineIndex = index