chiark / gitweb /
Add UI elements for V2 Toolheads and basic settings
authornickthetait <tait@alephobjects.com>
Mon, 20 Jul 2015 16:44:12 +0000 (10:44 -0600)
committernickthetait <tait@alephobjects.com>
Wed, 22 Jul 2015 19:38:54 +0000 (13:38 -0600)
Cura/gui/configBase.py
Cura/gui/configWizard.py
Cura/gui/preferencesDialog.py
Cura/util/profile.py

index f45fe157dcb52bd92d8c7bab7da23a42c3fe40a9..81c0aa51218e8ac25a0dbc1a80c6c5a702d8b22d 100644 (file)
@@ -1,4 +1,5 @@
 from __future__ import division
+from Cura.gui.configWizard import ConfigWizard
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
 import wx, wx.lib.stattext, types
@@ -247,3 +248,99 @@ class SettingRow(object):
                        self.ctrl.SetValue(_(value))
                else:
                        self.ctrl.SetValue(value)
+
+class ToolheadRow(object):
+       def __init__(self, panel, configName, valueOverride = None, index = None):
+               sizer = panel.GetSizer()
+               x = sizer.GetRows()
+               y = 0
+               flag = 0
+
+               self.setting = profile.settingsDictionary[configName]
+               self.settingIndex = index
+               self.validationMsg = ''
+               self.panel = panel
+
+               self.label = wx.lib.stattext.GenStaticText(panel, -1, self.setting.getLabel())
+               self.label.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
+
+               self.ctrl = wx.TextCtrl(panel, -1, self.setting.getValue(self.settingIndex))
+               self.ctrl.Enable(False)
+
+               self.changeToolheadButton = wx.Button(panel, -1, "Change Toolhead")
+               self.changeToolheadButton.Bind(wx.EVT_BUTTON, self.OnChangeToolheadButton)
+               self.flashButton = wx.Button(panel, -1, "Re-flash Firmware")
+               self.flashButton.Bind(wx.EVT_BUTTON, self.OnFlashButton)
+               
+               flag = wx.EXPAND
+               self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
+               sizer.Add(self.label, (x,y), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT,border=10)
+               sizer.Add(self.ctrl, (x,y+1), flag=wx.ALIGN_CENTER_VERTICAL|flag)
+               sizer.Add(self.changeToolheadButton, (x,y+2), flag=wx.ALIGN_CENTER_VERTICAL|flag)
+               sizer.Add(self.flashButton, (x,y+3), flag=wx.ALIGN_CENTER_VERTICAL|flag)
+               sizer.SetRows(x+1)
+
+               self.ctrl.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
+               if isinstance(self.ctrl, floatspin.FloatSpin):
+                       self.ctrl.GetTextCtrl().Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
+                       self.defaultBGColour = self.ctrl.GetTextCtrl().GetBackgroundColour()
+               else:
+                       self.defaultBGColour = self.ctrl.GetBackgroundColour()
+               
+               panel.main.settingControlList.append(self)
+
+       def OnFlashButton(self, e):
+               framey = PopUp(parent=None, id=-1, text="flash firmware")
+               framey.Show()
+       
+       def OnChangeToolheadButton(self, e):
+               import configWizard
+               import wx.wizard
+               self.ToolheadSelectPage = configWizard.ToolheadSelectPage(self)
+               wx.wizard.WizardPageSimple.Chain(self, self.GetParent().ToolheadSelectPage)
+               self.ToolheadSelectPage.test()
+               
+               #framey = PopUp(parent=None, id=-1, text="toolhead changer")
+               #framey.Show()
+       
+       def OnMouseEnter(self, e):
+               self.label.SetToolTipString(self.setting.getTooltip())
+               self.ctrl.SetToolTipString(self.setting.getTooltip())
+
+       def OnMouseExit(self, e):
+               self.label.SetToolTipString('')
+               self.ctrl.SetToolTipString('')
+               e.Skip()
+
+       def GetValue(self):
+               if isinstance(self.ctrl, wx.ColourPickerCtrl):
+                       return str(self.ctrl.GetColour().GetAsString(wx.C2S_HTML_SYNTAX))
+               elif isinstance(self.ctrl, wx.ComboBox):
+                       value = unicode(self.ctrl.GetValue())
+                       for ret in self._englishChoices:
+                               if _(ret) == value:
+                                       return ret
+                       return value
+               else:
+                       return str(self.ctrl.GetValue())
+
+       def SetValue(self, value):
+               if isinstance(self.ctrl, wx.CheckBox):
+                       self.ctrl.SetValue(str(value) == "True")
+               elif isinstance(self.ctrl, wx.ColourPickerCtrl):
+                       self.ctrl.SetColour(value)
+               elif isinstance(self.ctrl, floatspin.FloatSpin):
+                       try:
+                               self.ctrl.SetValue(float(value))
+                       except ValueError:
+                               pass
+               elif isinstance(self.ctrl, wx.ComboBox):
+                       self.ctrl.SetValue(_(value))
+               else:
+                       self.ctrl.SetValue(value)
+                       
+class PopUp(wx.Frame):
+       def __init__(self, parent, id, text):
+               wx.Frame.__init__(self, parent, id, 'Frame title', size=(400,300))
+               panely = wx.Panel(self)         
+               wx.StaticText(panely, -1, text, (10,10))
index 839322c8dc524367e6c082bf69ba27fdb032361a..182f2dba164a2296ab336a5674ed4ad691a1cc52 100644 (file)
@@ -1011,6 +1011,17 @@ class LulzbotReadyPage(InfoPage):
                self.AddText(_('For more information about using Cura with your LulzBot'))
                self.AddText(_('3D printer, please visit www.LulzBot.com/cura'))
                self.AddSeperator()
+               
+class ToolheadSelectPage(InfoPage):
+       def __init__(self, parent):
+               super(ToolheadSelectPage, self).__init__(parent, _("LulzBot Toolhead Selection"))
+               printer_name = profile.getMachineSetting('machine_type')
+               
+               self.AddText(_('Selected printer is ({}).'.format(printer_name)))
+               self.Show()
+               
+       def test(self):
+               print("This is a test!")
 
 class Taz5NozzleSelectPage(InfoPage):
        url='http://lulzbot.com/printer-identification'
index bdeedf5bc8432bccacf15e4cb3dd694106acef64..eab853bc41828f0f3e7c4f1b3f6b479bd48d1221 100644 (file)
@@ -122,6 +122,12 @@ class machineSettingsDialog(wx.Dialog):
                        configBase.SettingRow(left, 'machine_shape', index=idx)
                        configBase.SettingRow(left, 'gcode_flavor', index=idx)
 
+                       printer_type = profile.getMachineSetting('machine_type', idx)
+                       isLulzBot = (printer_type.startswith('lulzbot_'))
+                       if(isLulzBot):
+                               configBase.TitleRow(right, _("Toolhead"))
+                               configBase.ToolheadRow(right, 'toolhead', 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)
index 693607068c41bf3f2c496a99ed31c26b4c771cf4..2ac0e18271c5f1049d7a4574166a6024abf61855 100644 (file)
@@ -552,6 +552,7 @@ setting('serial_port_auto', '', str, 'machine', 'hidden')
 setting('serial_baud', 'AUTO', str, 'machine', 'hidden').setLabel(_("Baudrate"), _("Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600"))
 setting('serial_baud_auto', '', int, 'machine', 'hidden')
 
+setting('toolhead', 'Default', str, 'machine', 'hidden').setLabel(_("Installed toolhead"), _("Which toolhead is currently installed. This setting is only used by LulzBot machines."))
 setting('extruder_head_size_min_x', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards X min (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head."))
 setting('extruder_head_size_min_y', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards Y min (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head."))
 setting('extruder_head_size_max_x', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards X max (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head."))