chiark / gitweb /
Add machine center is zero to machine settings. Properly handle depricated max_z_spee...
[cura.git] / Cura / gui / simpleMode.py
index acabd652cc96d36b1faef80d0f4f1a2d32194344..34aad5a85deeaa0139a3e03411ae192e64517f20 100644 (file)
 from __future__ import absolute_import
-import __init__
+__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
-import wx, os, platform, types, webbrowser
+import wx
 
-from gui import configBase
-from gui import preview3d
-from gui import sliceProgessPanel
-from gui import preferencesDialog
-from gui import configWizard
-from gui import firmwareInstall
-from gui import printWindow
-from gui import icon
-from util import validators
-from util import profile
-from util import version
-from util import sliceRun
+from Cura.util import profile
 
-class simpleModeWindow(configBase.configWindowBase):
+class simpleModePanel(wx.Panel):
        "Main user interface window for Quickprint mode"
-       def __init__(self):
-               super(simpleModeWindow, self).__init__(title='Cura - Quickprint - ' + version.getVersion())
+       def __init__(self, parent, callback):
+               super(simpleModePanel, self).__init__(parent)
+               self._callback = callback
+
+               #toolsMenu = wx.Menu()
+               #i = toolsMenu.Append(-1, 'Switch to Normal mode...')
+               #self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
+               #self.menubar.Insert(1, toolsMenu, 'Normal mode')
+
+               printTypePanel = wx.Panel(self)
+               self.printTypeHigh = wx.RadioButton(printTypePanel, -1, _("High quality print"), style=wx.RB_GROUP)
+               self.printTypeNormal = wx.RadioButton(printTypePanel, -1, _("Normal quality print"))
+               self.printTypeLow = wx.RadioButton(printTypePanel, -1, _("Fast low quality print"))
+               self.printTypeJoris = wx.RadioButton(printTypePanel, -1, _("Thin walled cup or vase"))
+               self.printTypeJoris.Hide()
+
+               printMaterialPanel = wx.Panel(self)
+               self.printMaterialPLA = wx.RadioButton(printMaterialPanel, -1, 'PLA', style=wx.RB_GROUP)
+               self.printMaterialABS = wx.RadioButton(printMaterialPanel, -1, 'ABS')
+               self.printMaterialDiameter = wx.TextCtrl(printMaterialPanel, -1, profile.getProfileSetting('filament_diameter'))
+               if profile.getMachineSetting('gcode_flavor') == 'UltiGCode':
+                       printMaterialPanel.Show(False)
                
-               wx.EVT_CLOSE(self, self.OnClose)
-               #self.SetIcon(icon.getMainIcon())
-               
-               menubar = wx.MenuBar()
-               fileMenu = wx.Menu()
-               i = fileMenu.Append(-1, 'Load model file...')
-               self.Bind(wx.EVT_MENU, self.OnLoadModel, i)
-               fileMenu.AppendSeparator()
-               i = fileMenu.Append(-1, 'Preferences...')
-               self.Bind(wx.EVT_MENU, self.OnPreferences, i)
-               fileMenu.AppendSeparator()
-               i = fileMenu.Append(wx.ID_EXIT, 'Quit')
-               self.Bind(wx.EVT_MENU, self.OnQuit, i)
-               menubar.Append(fileMenu, '&File')
-               
-               toolsMenu = wx.Menu()
-               i = toolsMenu.Append(-1, 'Switch to Normal mode...')
-               self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
-               menubar.Append(toolsMenu, 'Tools')
-               
-               helpMenu = wx.Menu()
-               i = helpMenu.Append(-1, 'Online documentation...')
-               self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://daid.github.com/Cura'), i)
-               i = helpMenu.Append(-1, 'Report a problem...')
-               self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i)
-               menubar.Append(helpMenu, 'Help')
-               self.SetMenuBar(menubar)
-               
-               if profile.getPreference('lastFile') != '':
-                       self.filelist = profile.getPreference('lastFile').split(';')
-                       self.SetTitle(self.filelist[-1] + ' - Cura - ' + version.getVersion())
-               else:
-                       self.filelist = []
-               self.progressPanelList = []
+               self.printSupport = wx.CheckBox(self, -1, _("Print support structure"))
 
-               #Preview window
-               self.preview3d = preview3d.previewPanel(self)
-
-               configPanel = wx.Panel(self)
-               self.printTypeNormal = wx.RadioButton(configPanel, -1, 'Normal quality print', style=wx.RB_GROUP)
-               self.printTypeLow = wx.RadioButton(configPanel, -1, 'Fast low quality print')
-               self.printTypeHigh = wx.RadioButton(configPanel, -1, 'High quality print')
-               self.printTypeJoris = wx.RadioButton(configPanel, -1, 'Thin walled cup or vase')
-
-               self.printMaterialPLA = wx.RadioButton(configPanel, -1, 'PLA', style=wx.RB_GROUP)
-               self.printMaterialABS = wx.RadioButton(configPanel, -1, 'ABS')
-               self.printMaterialDiameter = wx.TextCtrl(configPanel, -1, profile.getProfileSetting('filament_diameter'))
-               
-               self.printSupport = wx.CheckBox(configPanel, -1, 'Print support structure')
-               
                sizer = wx.GridBagSizer()
-               configPanel.SetSizer(sizer)
+               self.SetSizer(sizer)
 
-               sb = wx.StaticBox(configPanel, label="Select a print type:")
+               sb = wx.StaticBox(printTypePanel, label=_("Select a print type:"))
                boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
+               boxsizer.Add(self.printTypeHigh)
                boxsizer.Add(self.printTypeNormal)
                boxsizer.Add(self.printTypeLow)
-               boxsizer.Add(self.printTypeHigh)
-               boxsizer.Add(self.printTypeJoris)
-               sizer.Add(boxsizer, (0,0), flag=wx.EXPAND)
+               boxsizer.Add(self.printTypeJoris, border=5, flag=wx.TOP)
+               printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
+               printTypePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
+               sizer.Add(printTypePanel, (0,0), flag=wx.EXPAND)
 
-               sb = wx.StaticBox(configPanel, label="Material:")
+               sb = wx.StaticBox(printMaterialPanel, label=_("Material:"))
                boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
                boxsizer.Add(self.printMaterialPLA)
                boxsizer.Add(self.printMaterialABS)
-               boxsizer.Add(wx.StaticText(configPanel, -1, 'Diameter:'))
+               boxsizer.Add(wx.StaticText(printMaterialPanel, -1, _("Diameter:")))
                boxsizer.Add(self.printMaterialDiameter)
-               sizer.Add(boxsizer, (1,0), flag=wx.EXPAND)
+               printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
+               printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
+               sizer.Add(printMaterialPanel, (1,0), flag=wx.EXPAND)
 
-               sb = wx.StaticBox(configPanel, label="Other:")
+               sb = wx.StaticBox(self, label=_("Other:"))
                boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
                boxsizer.Add(self.printSupport)
                sizer.Add(boxsizer, (2,0), flag=wx.EXPAND)
 
-               # load and slice buttons.
-               loadButton = wx.Button(self, -1, 'Load Model')
-               sliceButton = wx.Button(self, -1, 'Prepare print')
-               printButton = wx.Button(self, -1, 'Print')
-               self.Bind(wx.EVT_BUTTON, self.OnLoadModel, loadButton)
-               self.Bind(wx.EVT_BUTTON, self.OnSlice, sliceButton)
-               self.Bind(wx.EVT_BUTTON, self.OnPrint, printButton)
-               #Also bind double clicking the 3D preview to load an STL file.
-               self.preview3d.glCanvas.Bind(wx.EVT_LEFT_DCLICK, self.OnLoadModel, self.preview3d.glCanvas)
-
-               #Main sizer, to position the preview window, buttons and tab control
-               sizer = wx.GridBagSizer()
-               self.SetSizer(sizer)
-               sizer.Add(configPanel, (0,0), span=(1,1), flag=wx.EXPAND)
-               sizer.Add(self.preview3d, (0,1), span=(1,3), flag=wx.EXPAND)
-               sizer.AddGrowableCol(2)
-               sizer.AddGrowableRow(0)
-               sizer.Add(loadButton, (1,1), flag=wx.RIGHT, border=5)
-               sizer.Add(sliceButton, (1,2), flag=wx.RIGHT, border=5)
-               sizer.Add(printButton, (1,3), flag=wx.RIGHT, border=5)
-               self.sizer = sizer
-
-               if len(self.filelist) > 0:
-                       self.preview3d.loadModelFiles(self.filelist)
+               self.printTypeNormal.SetValue(True)
+               self.printMaterialPLA.SetValue(True)
 
-               self.updateProfileToControls()
+               self.printTypeHigh.Bind(wx.EVT_RADIOBUTTON, lambda e: self._callback())
+               self.printTypeNormal.Bind(wx.EVT_RADIOBUTTON, lambda e: self._callback())
+               self.printTypeLow.Bind(wx.EVT_RADIOBUTTON, lambda e: self._callback())
+               #self.printTypeJoris.Bind(wx.EVT_RADIOBUTTON, lambda e: self._callback())
 
-               self.Fit()
-               self.SetMinSize(self.GetSize())
-               self.Centre()
-               self.Show(True)
-       
-       def OnPreferences(self, e):
-               prefDialog = preferencesDialog.preferencesDialog(self)
-               prefDialog.Centre()
-               prefDialog.Show(True)
-       
-       def OnDefaultMarlinFirmware(self, e):
-               firmwareInstall.InstallFirmware()
+               self.printMaterialPLA.Bind(wx.EVT_RADIOBUTTON, lambda e: self._callback())
+               self.printMaterialABS.Bind(wx.EVT_RADIOBUTTON, lambda e: self._callback())
+               self.printMaterialDiameter.Bind(wx.EVT_TEXT, lambda e: self._callback())
 
-       def OnCustomFirmware(self, e):
-               dlg=wx.FileDialog(self, "Open firmware to upload", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
-               dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX")
-               if dlg.ShowModal() == wx.ID_OK:
-                       filename = dlg.GetPath()
-                       if not(os.path.exists(filename)):
-                               return
-                       #For some reason my Ubuntu 10.10 crashes here.
-                       firmwareInstall.InstallFirmware(filename)
+               self.printSupport.Bind(wx.EVT_CHECKBOX, lambda e: self._callback())
 
-       def OnFirstRunWizard(self, e):
-               configWizard.configWizard()
-               self.updateProfileToControls()
-
-       def OnLoadModel(self, e):
-               dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
-               dlg.SetWildcard(meshLoader.wildcardFilter())
-               if dlg.ShowModal() == wx.ID_OK:
-                       self.filelist = [dlg.GetPath()]
-                       profile.putPreference('lastFile', ';'.join(self.filelist))
-                       self.preview3d.loadModelFiles(self.filelist, True)
-                       self.preview3d.setViewMode("Normal")
-               dlg.Destroy()
-       
-       def OnSlice(self, e):
-               if len(self.filelist) < 1:
-                       wx.MessageBox('You need to load a file before you can slice it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
-                       return
-               #save the current profile so we can put it back latter
-               oldProfile = profile.getGlobalProfileString()
-               
-               put = profile.putProfileSetting
+       def setupSlice(self):
+               put = profile.setTempOverride
                get = profile.getProfileSetting
 
                put('layer_height', '0.2')
@@ -178,33 +87,24 @@ class simpleModeWindow(configBase.configWindowBase):
                put('print_speed', '50')
                put('print_temperature', '220')
                put('support', 'None')
-               #put('machine_center_x', '100')
-               #put('machine_center_y', '100')
-               #put('retraction_min_travel', '5.0')
-               #put('retraction_speed', '13.5')
-               #put('retraction_amount', '0.0')
-               #put('retraction_extra', '0.0')
+               put('retraction_enable', 'True')
+               put('retraction_min_travel', '5.0')
+               put('retraction_speed', '40.0')
+               put('retraction_amount', '4.5')
+               put('retraction_extra', '0.0')
                put('travel_speed', '150')
-               put('max_z_speed', '3.0')
                put('bottom_layer_speed', '25')
-               put('cool_min_layer_time', '10')
+               put('cool_min_layer_time', '5')
                put('fan_enabled', 'True')
                put('fan_layer', '1')
                put('fan_speed', '100')
-               #put('model_scale', '1.0')
-               #put('flip_x', 'False')
-               #put('flip_y', 'False')
-               #put('flip_z', 'False')
-               #put('model_rotate_base', '0')
-               #put('model_multiply_x', '1')
-               #put('model_multiply_y', '1')
                put('extra_base_wall_thickness', '0.0')
                put('sequence', 'Loops > Perimeter > Infill')
                put('force_first_layer_sequence', 'True')
                put('infill_type', 'Line')
                put('solid_top', 'True')
                put('fill_overlap', '15')
-               put('support_rate', '50')
+               put('support_rate', '80')
                put('support_distance', '0.5')
                put('joris', 'False')
                put('cool_min_feedrate', '5')
@@ -212,28 +112,28 @@ class simpleModeWindow(configBase.configWindowBase):
                put('raft_margin', '5')
                put('raft_base_material_amount', '100')
                put('raft_interface_material_amount', '100')
-               put('bottom_thickness', '0.0')
+               put('bottom_thickness', '0.3')
 
                if self.printSupport.GetValue():
-                       put('support', 'Exterior Only')
+                       put('support', _("Exterior Only"))
 
                nozzle_size = float(get('nozzle_size'))
                if self.printTypeNormal.GetValue():
                        put('wall_thickness', nozzle_size * 2.0)
-                       put('layer_height', '0.2')
+                       put('layer_height', '0.10')
                        put('fill_density', '20')
                elif self.printTypeLow.GetValue():
-                       put('wall_thickness', nozzle_size * 1.0)
-                       put('layer_height', '0.3')
+                       put('wall_thickness', nozzle_size * 2.5)
+                       put('layer_height', '0.20')
                        put('fill_density', '10')
-                       put('print_speed', '80')
-                       put('bottom_layer_speed', '40')
+                       put('print_speed', '50')
+                       put('cool_min_layer_time', '3')
+                       put('bottom_layer_speed', '30')
                elif self.printTypeHigh.GetValue():
                        put('wall_thickness', nozzle_size * 2.0)
-                       put('layer_height', '0.1')
-                       put('fill_density', '30')
+                       put('layer_height', '0.06')
+                       put('fill_density', '20')
                        put('bottom_layer_speed', '15')
-                       put('bottom_thickness', '0.2')
                elif self.printTypeJoris.GetValue():
                        put('wall_thickness', nozzle_size * 1.5)
                        put('layer_height', '0.3')
@@ -258,57 +158,8 @@ class simpleModeWindow(configBase.configWindowBase):
                        put('skirt_line_count', '0')
                        put('fan_layer', '1')
                        put('bottom_thickness', '0.0')
-                       put('print_temperature', '260')
-               
-               #Create a progress panel and add it to the window. The progress panel will start the Skein operation.
-               spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filelist)
-               self.sizer.Add(spp, (len(self.progressPanelList)+2,0), span=(1,4), flag=wx.EXPAND)
-               self.sizer.Layout()
-               newSize = self.GetSize();
-               newSize.IncBy(0, spp.GetSize().GetHeight())
-               self.SetSize(newSize)
-               self.progressPanelList.append(spp)
-               
-               #Restore the old profile.
-               profile.loadGlobalProfileFromString(oldProfile)
-       
-       def OnPrint(self, e):
-               if len(self.filelist) < 1:
-                       wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
-                       return
-               if not os.path.exists(sliceRun.getExportFilename(self.filelist[0])):
-                       wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
-                       return
-               printWindow.printFile(sliceRun.getExportFilename(self.filelist[0]))
-
-       def OnNormalSwitch(self, e):
-               from gui import mainWindow
-               profile.putPreference('startMode', 'Normal')
-               mainWindow.mainWindow()
-               self.Close()
-
-       def removeSliceProgress(self, spp):
-               self.progressPanelList.remove(spp)
-               newSize = self.GetSize();
-               newSize.IncBy(0, -spp.GetSize().GetHeight())
-               self.SetSize(newSize)
-               self.sizer.Remove(spp)
-               spp.Destroy()
-               for spp in self.progressPanelList:
-                       self.sizer.Remove(spp)
-               i = 2
-               for spp in self.progressPanelList:
-                       self.sizer.Add(spp, (i,0), span=(1,4), flag=wx.EXPAND)
-                       i += 1
-               self.sizer.Layout()
-
-       def OnQuit(self, e):
-               self.Close()
-       
-       def OnClose(self, e):
-               self.Destroy()
+                       put('print_temperature', '245')
+               put('plugin_config', '')
 
        def updateProfileToControls(self):
-               super(simpleModeWindow, self).updateProfileToControls()
-               self.preview3d.updateProfileToControls()
-
+               pass