chiark / gitweb /
Cleanup the first run wizard a bit, and add configuration for reprap machines.
authordaid <daid303@gmail.com>
Fri, 3 Aug 2012 09:41:05 +0000 (11:41 +0200)
committerdaid <daid303@gmail.com>
Fri, 3 Aug 2012 09:41:05 +0000 (11:41 +0200)
Cura/gui/configWizard.py

index b0d42e80d018ab504ca6a4945ae71246cae48fc0..97311aed42d017f674761155825ef028b3a88a28 100644 (file)
@@ -12,46 +12,72 @@ class InfoPage(wx.wizard.WizardPageSimple):
        def __init__(self, parent, title):\r
                wx.wizard.WizardPageSimple.__init__(self, parent)\r
 \r
-               sizer = wx.BoxSizer(wx.VERTICAL)\r
+               sizer = wx.GridBagSizer(5, 5)\r
                self.sizer = sizer\r
                self.SetSizer(sizer)\r
+               sizer.AddGrowableCol(1)\r
 \r
                title = wx.StaticText(self, -1, title)\r
                title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))\r
-               sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5)\r
-               sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 5)\r
+               sizer.Add(title, pos=(0, 0), span=(1,2), flag=wx.ALIGN_CENTRE|wx.ALL)\r
+               sizer.Add(wx.StaticLine(self, -1), pos=(1,0), span=(1,2), flag=wx.EXPAND|wx.ALL)\r
+               \r
+               self.rowNr = 2\r
        \r
        def AddText(self,info):\r
                text = wx.StaticText(self, -1, info)\r
-               self.GetSizer().Add(text, 0, wx.LEFT|wx.RIGHT, 5)\r
+               self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1,2), flag=wx.LEFT|wx.RIGHT)\r
+               self.rowNr += 1\r
                return text\r
        \r
        def AddSeperator(self):\r
-               self.GetSizer().Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 5)\r
+               self.GetSizer().Add(wx.StaticLine(self, -1), pos=(self.rowNr, 0), span=(1,2), flag=wx.EXPAND|wx.ALL)\r
+               self.rowNr += 1\r
        \r
        def AddHiddenSeperator(self):\r
                self.AddText('')\r
        \r
        def AddRadioButton(self, label, style = 0):\r
                radio = wx.RadioButton(self, -1, label, style=style)\r
-               self.GetSizer().Add(radio, 0, wx.EXPAND|wx.ALL, 5)\r
+               self.GetSizer().Add(radio, pos=(self.rowNr, 0), span=(1,2), flag=wx.EXPAND|wx.ALL)\r
+               self.rowNr += 1\r
                return radio\r
        \r
        def AddButton(self, label):\r
                button = wx.Button(self, -1, label)\r
-               self.GetSizer().Add(button, 0, wx.LEFT, 5)\r
+               self.GetSizer().Add(button, pos=(self.rowNr, 0), span=(1,2), flag=wx.LEFT)\r
+               self.rowNr += 1\r
                return button\r
        \r
        def AddDualButton(self, label1, label2):\r
-               p = wx.Panel(self)\r
-               p.SetSizer(wx.BoxSizer(wx.HORIZONTAL))\r
-               button1 = wx.Button(p, -1, label1)\r
-               p.GetSizer().Add(button1, 0, wx.RIGHT, 8)\r
-               button2 = wx.Button(p, -1, label2)\r
-               p.GetSizer().Add(button2, 0)\r
-               self.GetSizer().Add(p, 0, wx.LEFT, 5)\r
+               button1 = wx.Button(self, -1, label1)\r
+               self.GetSizer().Add(button1, pos=(self.rowNr, 0), flag=wx.RIGHT)\r
+               button2 = wx.Button(self, -1, label2)\r
+               self.GetSizer().Add(button2, pos=(self.rowNr, 1))\r
+               self.rowNr += 1\r
                return button1, button2\r
        \r
+       def AddTextCtrl(self, value):\r
+               ret = wx.TextCtrl(self, -1, value)\r
+               self.GetSizer().Add(ret, pos=(self.rowNr, 0), span=(1,2), flag=wx.LEFT)\r
+               self.rowNr += 1\r
+               return ret\r
+\r
+       def AddLabelTextCtrl(self, info, value):\r
+               text = wx.StaticText(self, -1, info)\r
+               ret = wx.TextCtrl(self, -1, value)\r
+               self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1,1), flag=wx.LEFT)\r
+               self.GetSizer().Add(ret, pos=(self.rowNr, 1), span=(1,1), flag=wx.LEFT)\r
+               self.rowNr += 1\r
+               return ret\r
+       \r
+       def AddTextCtrlButton(self, value, buttonText):\r
+               text = wx.TextCtrl(self, -1, value)\r
+               button = wx.Button(self, -1, buttonText)\r
+               self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1,1), flag=wx.LEFT)\r
+               self.GetSizer().Add(button, pos=(self.rowNr, 1), span=(1,1), flag=wx.LEFT)\r
+               return text, button\r
+               \r
        def AllowNext(self):\r
                return True\r
        \r
@@ -72,9 +98,24 @@ class FirstInfoPage(InfoPage):
 class RepRapInfoPage(InfoPage):\r
        def __init__(self, parent):\r
                super(RepRapInfoPage, self).__init__(parent, "RepRap information")\r
-               self.AddText('Sorry, but this wizard will not help you with\nconfiguring and calibrating your RepRap.')\r
+               self.AddText('RepRap machines are vastly different, and there is no\ndefault configuration in Cura for any of them.')\r
+               self.AddText('If you like a default profile for your machine added,\nthen make an issue on github.')\r
                self.AddSeperator()\r
-               self.AddText('You will have to manually install Marlin or Sprinter firmware\nand configure Cura.')\r
+               self.AddText('You will have to manually install Marlin or Sprinter firmware.')\r
+               self.AddSeperator()\r
+               self.machineWidth = self.AddLabelTextCtrl('Machine width (mm)', '80')\r
+               self.machineDepth = self.AddLabelTextCtrl('Machine depth (mm)', '80')\r
+               self.machineHeight = self.AddLabelTextCtrl('Machine height (mm)', '60')\r
+               self.nozzleSize = self.AddLabelTextCtrl('Nozzle size (mm)', '0.5')\r
+\r
+       def StoreData(self):\r
+               profile.putPreference('machine_width', self.machineWidth.GetValue())\r
+               profile.putPreference('machine_depth', self.machineDepth.GetValue())\r
+               profile.putPreference('machine_height', self.machineHeight.GetValue())\r
+               profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue())\r
+               profile.putProfileSetting('machine_center_x', profile.getPreferenceFloat('machine_width') / 2)\r
+               profile.putProfileSetting('machine_center_y', profile.getPreferenceFloat('machine_depth') / 2)\r
+               profile.putProfileSetting('wall_thickness', float(profile.getProfileSettingFloat('nozzle_size')) * 2)\r
 \r
 class MachineSelectPage(InfoPage):\r
        def __init__(self, parent):\r
@@ -150,7 +191,7 @@ class UltimakerCheckupPage(InfoPage):
                b1, b2 = self.AddDualButton('Run checks', 'Skip checks')\r
                b1.Bind(wx.EVT_BUTTON, self.OnCheckClick)\r
                b2.Bind(wx.EVT_BUTTON, self.OnSkipClick)\r
-               self.AddSeperator();\r
+               self.AddSeperator()\r
                self.checkPanel = None\r
        \r
        def AllowNext(self):\r
@@ -311,20 +352,19 @@ class UltimakerCalibrationPage(InfoPage):
        def __init__(self, parent):\r
                super(UltimakerCalibrationPage, self).__init__(parent, "Ultimaker Calibration")\r
                \r
-               self.AddText("Your Ultimaker requires some calibration.");\r
-               self.AddText("This calibration is needed for a proper extrusion amount.");\r
+               self.AddText("Your Ultimaker requires some calibration.")\r
+               self.AddText("This calibration is needed for a proper extrusion amount.")\r
                self.AddSeperator()\r
-               self.AddText("The following values are needed:");\r
-               self.AddText("* Diameter of filament");\r
-               self.AddText("* Number of steps per mm of filament extrusion");\r
+               self.AddText("The following values are needed:")\r
+               self.AddText("* Diameter of filament")\r
+               self.AddText("* Number of steps per mm of filament extrusion")\r
                self.AddSeperator()\r
-               self.AddText("The better you have calibrated these values, the better your prints\nwill become.");\r
+               self.AddText("The better you have calibrated these values, the better your prints\nwill become.")\r
                self.AddSeperator()\r
-               self.AddText("First we need the diameter of your filament:");\r
-               self.filamentDiameter = wx.TextCtrl(self, -1, profile.getProfileSetting('filament_diameter'))\r
-               self.GetSizer().Add(self.filamentDiameter, 0, wx.LEFT, 5)\r
-               self.AddText("If you do not own digital Calipers that can measure\nat least 2 digits then use 2.89mm.\nWhich is the average diameter of most filament.");\r
-               self.AddText("Note: This value can be changed later at any time.");\r
+               self.AddText("First we need the diameter of your filament:")\r
+               self.filamentDiameter = self.AddTextCtrl(profile.getProfileSetting('filament_diameter'))\r
+               self.AddText("If you do not own digital Calipers that can measure\nat least 2 digits then use 2.89mm.\nWhich is the average diameter of most filament.")\r
+               self.AddText("Note: This value can be changed later at any time.")\r
 \r
        def StoreData(self):\r
                profile.putProfileSetting('filament_diameter', self.filamentDiameter.GetValue())\r
@@ -342,16 +382,9 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
                self.AddText("We'll push the filament 100mm")\r
                self.extrudeButton = self.AddButton("Extrude 100mm filament")\r
                self.AddText("Now measure the amount of extruded filament:\n(this can be more or less then 100mm)")\r
-               p = wx.Panel(self)\r
-               p.SetSizer(wx.BoxSizer(wx.HORIZONTAL))\r
-               self.lengthInput = wx.TextCtrl(p, -1, '100')\r
-               p.GetSizer().Add(self.lengthInput, 0, wx.RIGHT, 8)\r
-               self.saveLengthButton = wx.Button(p, -1, 'Save')\r
-               p.GetSizer().Add(self.saveLengthButton, 0)\r
-               self.GetSizer().Add(p, 0, wx.LEFT, 5)\r
+               self.lengthInput, self.saveLengthButton = self.AddTextCtrlButton('100', 'Save')\r
                self.AddText("This results in the following steps per E:")\r
-               self.stepsPerEInput = wx.TextCtrl(self, -1, profile.getPreference('steps_per_e'))\r
-               self.GetSizer().Add(self.stepsPerEInput, 0, wx.LEFT, 5)\r
+               self.stepsPerEInput = self.AddTextCtrl(profile.getPreference('steps_per_e'))\r
                self.AddText("You can repeat these steps to get better calibration.")\r
                self.AddSeperator()\r
                self.AddText("If you still have filament in your printer which needs\nheat to remove, press the heat up button below:")\r
@@ -391,9 +424,9 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
                time.sleep(3)\r
                \r
                self.sendGCommand('M302') #Disable cold extrusion protection\r
-               self.sendGCommand("M92 E%f" % (currentEValue));\r
-               self.sendGCommand("G92 E0");\r
-               self.sendGCommand("G1 E100 F600");\r
+               self.sendGCommand("M92 E%f" % (currentEValue))\r
+               self.sendGCommand("G92 E0")\r
+               self.sendGCommand("G1 E100 F600")\r
                time.sleep(15)\r
                self.comm.close()\r
                self.extrudeButton.Enable()\r