diff --git a/Cura/avr_isp/stk500v2.py b/Cura/avr_isp/stk500v2.py index f22f50f..8577d86 100644 --- a/Cura/avr_isp/stk500v2.py +++ b/Cura/avr_isp/stk500v2.py @@ -10,8 +10,9 @@ class Stk500v2(ispBase.IspBase): self.serial = None self.seq = 1 self.lastAddr = -1 + self.progressCallback = None - def connect(self, port = 'COM31', speed = 115200): + def connect(self, port = 'COM22', speed = 115200): if self.serial != None: self.close() try: @@ -145,8 +146,8 @@ class Stk500v2(ispBase.IspBase): def main(): programmer = Stk500v2() - programmer.connect() - programmer.programChip(intelHex.readHex("cfg_4f55234def059.hex")) + programmer.connect(port = sys.argv[1]) + programmer.programChip(intelHex.readHex(sys.argv[2])) sys.exit(1) if __name__ == '__main__': diff --git a/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/interpret_plugins/dae.py b/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/interpret_plugins/dae.py index c51e026..c4a44ab 100644 --- a/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/interpret_plugins/dae.py +++ b/Cura/cura_sf/fabmetheus_utilities/fabmetheus_tools/interpret_plugins/dae.py @@ -27,6 +27,8 @@ class daeModel(triangle_mesh.TriangleMesh): self._idMap = {} self._geometryList = [] r.ParseFile(open(filename, "r")) + + self._scale = float(self._base['collada'][0]['asset'][0]['unit'][0]['_meter']) * 1000 for instance_visual_scene in self._base['collada'][0]['scene'][0]['instance_visual_scene']: for node in self._idMap[instance_visual_scene['_url']]['node']: @@ -81,9 +83,9 @@ class daeModel(triangle_mesh.TriangleMesh): startIndex = len(self.vertexes) for idx in xrange(0, len(positionList)/3): - x = positionList[idx*3] - y = positionList[idx*3+1] - z = positionList[idx*3+2] + x = positionList[idx*3] * self._scale + y = positionList[idx*3+1] * self._scale + z = positionList[idx*3+2] * self._scale if matrix != None: self.vertexes.append(Vector3(x * matrix[0] + y * matrix[1] + z * matrix[2] + matrix[3], x * matrix[4] + y * matrix[5] + z * matrix[6] + matrix[7], x * matrix[8] + y * matrix[9] + z * matrix[10] + matrix[11])) else: diff --git a/Cura/cura_sf/fabmetheus_utilities/settings.py b/Cura/cura_sf/fabmetheus_utilities/settings.py index 92aa109..cc9a7a2 100644 --- a/Cura/cura_sf/fabmetheus_utilities/settings.py +++ b/Cura/cura_sf/fabmetheus_utilities/settings.py @@ -114,8 +114,8 @@ def getProfileInformation(): 'SwapYZ': storedSetting("swap_yz"), 'Scale': storedSettingFloat("model_scale"), 'Rotate': storedSettingFloat("model_rotate_base"), - 'CenterX': storedSettingFloat("machine_center_x"), - 'CenterY': storedSettingFloat("machine_center_y"), + 'CenterX': lambda setting: profile.getProfileSettingFloat('object_center_x') if profile.getProfileSettingFloat('object_center_x') > 0 else profile.getPreferenceFloat("machine_width") / 2, + 'CenterY': lambda setting: profile.getProfileSettingFloat('object_center_y') if profile.getProfileSettingFloat('object_center_y') > 0 else profile.getPreferenceFloat("machine_depth") / 2, 'AlternativeCenterFile': storedSetting("alternative_center"), },'scale': { 'Activate_Scale': "False", @@ -176,8 +176,8 @@ def getProfileInformation(): 'Thread_Sequence_Choice': storedSetting('sequence'), },'multiply': { 'Activate_Multiply': "False", - 'Center_X_mm': storedSettingFloat("machine_center_x"), - 'Center_Y_mm': storedSettingFloat("machine_center_y"), + 'Center_X_mm': lambda setting: profile.getProfileSettingFloat('object_center_x') if profile.getProfileSettingFloat('object_center_x') > 0 else profile.getPreferenceFloat("machine_width") / 2, + 'Center_Y_mm': lambda setting: profile.getProfileSettingFloat('object_center_y') if profile.getProfileSettingFloat('object_center_y') > 0 else profile.getPreferenceFloat("machine_depth") / 2, 'Number_of_Columns_integer': storedSetting('model_multiply_x'), 'Number_of_Rows_integer': storedSetting('model_multiply_y'), 'Reverse_Sequence_every_Odd_Layer': DEFSET, @@ -311,8 +311,8 @@ def getProfileInformation(): 'Fan_speed_min_%': storedSettingInt('fan_speed'), 'Fan_speed_max_%': storedSettingInt('fan_speed_max'), },'hop': { - 'Activate_Hop': "False", - 'Hop_Over_Layer_Thickness_ratio': DEFSET, + 'Activate_Hop': storedSetting('hop_on_move'), + 'Hop_Over_Layer_Thickness_ratio': lambda setting: 0.2 / profile.getProfileSettingFloat('layer_height'), 'Minimum_Hop_Angle_degrees': DEFSET, },'wipe': { 'Activate_Wipe': "False", diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py index 72b0760..c76fbaa 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export.py @@ -266,7 +266,7 @@ def writeOutput(fileName, shouldAnalyze=True): repository = ExportRepository() settings.getReadRepository(repository) startTime = time.time() - print('File ' + archive.getSummarizedFileName(fileName) + ' is being chain exported.') + print('File ' + archive.getSummarizedFileName(fileName.encode('ascii', 'replace')) + ' is being chain exported.') fileNameSuffix = fileName[: fileName.rfind('.')] if repository.addExportSuffix.value: fileNameSuffix += '_export' diff --git a/Cura/example/UltimakerRobot_support.stl b/Cura/example/UltimakerRobot_support.stl index 7cf0d98..e75b137 100644 Binary files a/Cura/example/UltimakerRobot_support.stl and b/Cura/example/UltimakerRobot_support.stl differ diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py index daed5ad..54d734a 100644 --- a/Cura/gui/configWizard.py +++ b/Cura/gui/configWizard.py @@ -1,667 +1,714 @@ -# coding=utf-8 -from __future__ import absolute_import - -import webbrowser -import threading -import time - -import wx -import wx.wizard - -from gui import firmwareInstall -from gui import toolbarUtil -from util import machineCom -from util import profile -from util.resources import getPathForImage - -class InfoBox(wx.Panel): - def __init__(self, parent): - super(InfoBox, self).__init__(parent) - self.SetBackgroundColour('#FFFF80') - - self.sizer = wx.GridBagSizer(5, 5) - self.SetSizer(self.sizer) - - self.attentionBitmap = wx.Bitmap(getPathForImage('attention.png')) - self.errorBitmap = wx.Bitmap(getPathForImage('error.png')) - self.readyBitmap = wx.Bitmap(getPathForImage('ready.png')) - self.busyBitmap = [ - wx.Bitmap(getPathForImage('busy-0.png')), - wx.Bitmap(getPathForImage('busy-1.png')), - wx.Bitmap(getPathForImage('busy-2.png')), - wx.Bitmap(getPathForImage('busy-3.png')) - ] - - self.bitmap = wx.StaticBitmap(self, -1, wx.EmptyBitmapRGBA(24, 24, red=255, green=255, blue=255, alpha=1)) - self.text = wx.StaticText(self, -1, '') - self.sizer.Add(self.bitmap, pos=(0, 0), flag=wx.ALL, border=5) - self.sizer.Add(self.text, pos=(0, 1), flag=wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL, border=5) - - self.busyState = None - self.timer = wx.Timer(self) - self.Bind(wx.EVT_TIMER, self.doBusyUpdate, self.timer) - self.timer.Start(100) - - def SetInfo(self, info): - self.SetBackgroundColour('#FFFF80') - self.text.SetLabel(info) - self.Refresh() - - def SetError(self, info): - self.SetBackgroundColour('#FF8080') - self.text.SetLabel(info) - self.SetErrorIndicator() - self.Refresh() - - def SetAttention(self, info): - self.SetBackgroundColour('#FFFF80') - self.text.SetLabel(info) - self.SetAttentionIndicator() - self.Refresh() - - def SetBusyIndicator(self): - self.busyState = 0 - self.bitmap.SetBitmap(self.busyBitmap[self.busyState]) - - def doBusyUpdate(self, e): - if self.busyState == None: - return - self.busyState += 1 - if self.busyState >= len(self.busyBitmap): - self.busyState = 0 - self.bitmap.SetBitmap(self.busyBitmap[self.busyState]) - - def SetReadyIndicator(self): - self.busyState = None - self.bitmap.SetBitmap(self.readyBitmap) - - def SetErrorIndicator(self): - self.busyState = None - self.bitmap.SetBitmap(self.errorBitmap) - - def SetAttentionIndicator(self): - self.busyState = None - self.bitmap.SetBitmap(self.attentionBitmap) - - -class InfoPage(wx.wizard.WizardPageSimple): - def __init__(self, parent, title): - wx.wizard.WizardPageSimple.__init__(self, parent) - - sizer = wx.GridBagSizer(5, 5) - self.sizer = sizer - self.SetSizer(sizer) - - title = wx.StaticText(self, -1, title) - title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)) - sizer.Add(title, pos=(0, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL) - sizer.Add(wx.StaticLine(self, -1), pos=(1, 0), span=(1, 2), flag=wx.EXPAND | wx.ALL) - sizer.AddGrowableCol(1) - - self.rowNr = 2 - - def AddText(self, info): - text = wx.StaticText(self, -1, info) - self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT | wx.RIGHT) - self.rowNr += 1 - return text - - def AddSeperator(self): - self.GetSizer().Add(wx.StaticLine(self, -1), pos=(self.rowNr, 0), span=(1, 2), flag=wx.EXPAND | wx.ALL) - self.rowNr += 1 - - def AddHiddenSeperator(self): - self.AddText('') - - def AddInfoBox(self): - infoBox = InfoBox(self) - self.GetSizer().Add(infoBox, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT | wx.RIGHT | wx.EXPAND) - self.rowNr += 1 - return infoBox - - def AddRadioButton(self, label, style=0): - radio = wx.RadioButton(self, -1, label, style=style) - self.GetSizer().Add(radio, pos=(self.rowNr, 0), span=(1, 2), flag=wx.EXPAND | wx.ALL) - self.rowNr += 1 - return radio - - def AddCheckbox(self, label, checked=False): - check = wx.CheckBox(self, -1) - text = wx.StaticText(self, -1, label) - check.SetValue(checked) - self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 1), flag=wx.LEFT | wx.RIGHT) - self.GetSizer().Add(check, pos=(self.rowNr, 1), span=(1, 2), flag=wx.ALL) - self.rowNr += 1 - return check - - def AddButton(self, label): - button = wx.Button(self, -1, label) - self.GetSizer().Add(button, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT) - self.rowNr += 1 - return button - - def AddDualButton(self, label1, label2): - button1 = wx.Button(self, -1, label1) - self.GetSizer().Add(button1, pos=(self.rowNr, 0), flag=wx.RIGHT) - button2 = wx.Button(self, -1, label2) - self.GetSizer().Add(button2, pos=(self.rowNr, 1)) - self.rowNr += 1 - return button1, button2 - - def AddTextCtrl(self, value): - ret = wx.TextCtrl(self, -1, value) - self.GetSizer().Add(ret, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT) - self.rowNr += 1 - return ret - - def AddLabelTextCtrl(self, info, value): - text = wx.StaticText(self, -1, info) - ret = wx.TextCtrl(self, -1, value) - self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 1), flag=wx.LEFT) - self.GetSizer().Add(ret, pos=(self.rowNr, 1), span=(1, 1), flag=wx.LEFT) - self.rowNr += 1 - return ret - - def AddTextCtrlButton(self, value, buttonText): - text = wx.TextCtrl(self, -1, value) - button = wx.Button(self, -1, buttonText) - self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 1), flag=wx.LEFT) - self.GetSizer().Add(button, pos=(self.rowNr, 1), span=(1, 1), flag=wx.LEFT) - self.rowNr += 1 - return text, button - - def AddBitmap(self, bitmap): - bitmap = wx.StaticBitmap(self, -1, bitmap) - self.GetSizer().Add(bitmap, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT | wx.RIGHT) - self.rowNr += 1 - return bitmap - - def AddCheckmark(self, label, bitmap): - check = wx.StaticBitmap(self, -1, bitmap) - text = wx.StaticText(self, -1, label) - self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 1), flag=wx.LEFT | wx.RIGHT) - self.GetSizer().Add(check, pos=(self.rowNr, 1), span=(1, 1), flag=wx.ALL) - self.rowNr += 1 - return check - - def AllowNext(self): - return True - - def StoreData(self): - pass - - -class FirstInfoPage(InfoPage): - def __init__(self, parent): - super(FirstInfoPage, self).__init__(parent, "First time run wizard") - self.AddText('Welcome, and thanks for trying Cura!') - self.AddSeperator() - self.AddText('This wizard will help you with the following steps:') - self.AddText('* Configure Cura for your machine') - self.AddText('* Upgrade your firmware') - self.AddText('* Check if your machine is working safely') - - #self.AddText('* Calibrate your machine') - #self.AddText('* Do your first print') - - -class RepRapInfoPage(InfoPage): - def __init__(self, parent): - super(RepRapInfoPage, self).__init__(parent, "RepRap information") - self.AddText( - 'RepRap machines are vastly different, and there is no\ndefault configuration in Cura for any of them.') - self.AddText('If you like a default profile for your machine added,\nthen make an issue on github.') - self.AddSeperator() - self.AddText('You will have to manually install Marlin or Sprinter firmware.') - self.AddSeperator() - self.machineWidth = self.AddLabelTextCtrl('Machine width (mm)', '80') - self.machineDepth = self.AddLabelTextCtrl('Machine depth (mm)', '80') - self.machineHeight = self.AddLabelTextCtrl('Machine height (mm)', '60') - self.nozzleSize = self.AddLabelTextCtrl('Nozzle size (mm)', '0.5') - self.heatedBed = self.AddCheckbox('Heated bed') - - def StoreData(self): - profile.putPreference('machine_width', self.machineWidth.GetValue()) - profile.putPreference('machine_depth', self.machineDepth.GetValue()) - profile.putPreference('machine_height', self.machineHeight.GetValue()) - profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue()) - profile.putProfileSetting('machine_center_x', profile.getPreferenceFloat('machine_width') / 2) - profile.putProfileSetting('machine_center_y', profile.getPreferenceFloat('machine_depth') / 2) - profile.putProfileSetting('wall_thickness', float(profile.getProfileSettingFloat('nozzle_size')) * 2) - profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue())) - - -class MachineSelectPage(InfoPage): - def __init__(self, parent): - super(MachineSelectPage, self).__init__(parent, "Select your machine") - self.AddText('What kind of machine do you have:') - - self.UltimakerRadio = self.AddRadioButton("Ultimaker", style=wx.RB_GROUP) - self.UltimakerRadio.SetValue(True) - self.UltimakerRadio.Bind(wx.EVT_RADIOBUTTON, self.OnUltimakerSelect) - self.OtherRadio = self.AddRadioButton("Other (Ex: RepRap)") - self.OtherRadio.Bind(wx.EVT_RADIOBUTTON, self.OnOtherSelect) - - def OnUltimakerSelect(self, e): - wx.wizard.WizardPageSimple.Chain(self, self.GetParent().ultimakerFirmwareUpgradePage) - - def OnOtherSelect(self, e): - wx.wizard.WizardPageSimple.Chain(self, self.GetParent().repRapInfoPage) - - def StoreData(self): - if self.UltimakerRadio.GetValue(): - profile.putPreference('machine_width', '205') - profile.putPreference('machine_depth', '205') - profile.putPreference('machine_height', '200') - profile.putPreference('machine_type', 'ultimaker') - profile.putProfileSetting('nozzle_size', '0.4') - profile.putProfileSetting('machine_center_x', '100') - profile.putProfileSetting('machine_center_y', '100') - else: - profile.putPreference('machine_width', '80') - profile.putPreference('machine_depth', '80') - profile.putPreference('machine_height', '60') - profile.putPreference('machine_type', 'reprap') - profile.putPreference('startMode', 'Normal') - profile.putProfileSetting('nozzle_size', '0.5') - profile.putProfileSetting('machine_center_x', '40') - profile.putProfileSetting('machine_center_y', '40') - profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2) - - -class FirmwareUpgradePage(InfoPage): - def __init__(self, parent): - super(FirmwareUpgradePage, self).__init__(parent, "Upgrade Ultimaker Firmware") - self.AddText( - 'Firmware is the piece of software running directly on your 3D printer.\nThis firmware controls the step motors, regulates the temperature\nand ultimately makes your printer work.') - self.AddHiddenSeperator() - self.AddText( - 'The firmware shipping with new Ultimakers works, but upgrades\nhave been made to make better prints, and make calibration easier.') - self.AddHiddenSeperator() - self.AddText( - 'Cura requires these new features and thus\nyour firmware will most likely need to be upgraded.\nYou will get the chance to do so now.') - upgradeButton, skipUpgradeButton = self.AddDualButton('Upgrade to Marlin firmware', 'Skip upgrade') - upgradeButton.Bind(wx.EVT_BUTTON, self.OnUpgradeClick) - skipUpgradeButton.Bind(wx.EVT_BUTTON, self.OnSkipClick) - self.AddHiddenSeperator() - self.AddText('Do not upgrade to this firmware if:') - self.AddText('* You have an older machine based on ATMega1280') - self.AddText('* Have other changes in the firmware') - button = self.AddButton('Goto this page for a custom firmware') - button.Bind(wx.EVT_BUTTON, self.OnUrlClick) - - def AllowNext(self): - return False - - def OnUpgradeClick(self, e): - if firmwareInstall.InstallFirmware(): - self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() - - def OnSkipClick(self, e): - self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() - - def OnUrlClick(self, e): - webbrowser.open('http://daid.mine.nu/~daid/marlin_build/') - - -class UltimakerCheckupPage(InfoPage): - def __init__(self, parent): - super(UltimakerCheckupPage, self).__init__(parent, "Ultimaker Checkup") - - self.checkBitmap = wx.Bitmap(getPathForImage('checkmark.png')) - self.crossBitmap = wx.Bitmap(getPathForImage('cross.png')) - self.unknownBitmap = wx.Bitmap(getPathForImage('question.png')) - self.endStopNoneBitmap = wx.Bitmap(getPathForImage('endstop_none.png')) - self.endStopXMinBitmap = wx.Bitmap(getPathForImage('endstop_xmin.png')) - self.endStopXMaxBitmap = wx.Bitmap(getPathForImage('endstop_xmax.png')) - self.endStopYMinBitmap = wx.Bitmap(getPathForImage('endstop_ymin.png')) - self.endStopYMaxBitmap = wx.Bitmap(getPathForImage('endstop_ymax.png')) - self.endStopZMinBitmap = wx.Bitmap(getPathForImage('endstop_zmin.png')) - self.endStopZMaxBitmap = wx.Bitmap(getPathForImage('endstop_zmax.png')) - - self.AddText( - 'It is a good idea to do a few sanity checks now on your Ultimaker.\nYou can skip these if you know your machine is functional.') - b1, b2 = self.AddDualButton('Run checks', 'Skip checks') - b1.Bind(wx.EVT_BUTTON, self.OnCheckClick) - b2.Bind(wx.EVT_BUTTON, self.OnSkipClick) - self.AddSeperator() - self.commState = self.AddCheckmark('Communication:', self.unknownBitmap) - self.tempState = self.AddCheckmark('Temperature:', self.unknownBitmap) - self.stopState = self.AddCheckmark('Endstops:', self.unknownBitmap) - self.AddSeperator() - self.infoBox = self.AddInfoBox() - self.machineState = self.AddText('') - self.temperatureLabel = self.AddText('') - self.AddSeperator() - self.endstopBitmap = self.AddBitmap(self.endStopNoneBitmap) - self.comm = None - self.xMinStop = False - self.xMaxStop = False - self.yMinStop = False - self.yMaxStop = False - self.zMinStop = False - self.zMaxStop = False - - def __del__(self): - if self.comm != None: - self.comm.close() - - def AllowNext(self): - self.endstopBitmap.Show(False) - return False - - def OnSkipClick(self, e): - self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() - - def OnCheckClick(self, e=None): - if self.comm != None: - self.comm.close() - del self.comm - self.comm = None - wx.CallAfter(self.OnCheckClick) - return - self.infoBox.SetInfo('Connecting to machine.') - self.infoBox.SetBusyIndicator() - self.commState.SetBitmap(self.unknownBitmap) - self.tempState.SetBitmap(self.unknownBitmap) - self.stopState.SetBitmap(self.unknownBitmap) - self.checkupState = 0 - self.comm = machineCom.MachineCom(callbackObject=self) - - def mcLog(self, message): - pass - - def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp): - if not self.comm.isOperational(): - return - if self.checkupState == 0: - self.tempCheckTimeout = 20 - if temp > 70: - self.checkupState = 1 - wx.CallAfter(self.infoBox.SetInfo, 'Cooldown before temperature check.') - self.comm.sendCommand('M104 S0') - self.comm.sendCommand('M104 S0') - else: - self.startTemp = temp - self.checkupState = 2 - wx.CallAfter(self.infoBox.SetInfo, 'Checking the heater and temperature sensor.') - self.comm.sendCommand('M104 S200') - self.comm.sendCommand('M104 S200') - elif self.checkupState == 1: - if temp < 60: - self.startTemp = temp - self.checkupState = 2 - wx.CallAfter(self.infoBox.SetInfo, 'Checking the heater and temperature sensor.') - self.comm.sendCommand('M104 S200') - self.comm.sendCommand('M104 S200') - elif self.checkupState == 2: - #print "WARNING, TEMPERATURE TEST DISABLED FOR TESTING!" - if temp > self.startTemp + 40: - self.checkupState = 3 - wx.CallAfter(self.infoBox.SetAttention, 'Please make sure none of the endstops are pressed.') - wx.CallAfter(self.endstopBitmap.Show, True) - wx.CallAfter(self.Layout) - self.comm.sendCommand('M104 S0') - self.comm.sendCommand('M104 S0') - self.comm.sendCommand('M119') - wx.CallAfter(self.tempState.SetBitmap, self.checkBitmap) - else: - self.tempCheckTimeout -= 1 - if self.tempCheckTimeout < 1: - self.checkupState = -1 - wx.CallAfter(self.tempState.SetBitmap, self.crossBitmap) - wx.CallAfter(self.infoBox.SetError, 'Temperature measurement FAILED!') - self.comm.sendCommand('M104 S0') - self.comm.sendCommand('M104 S0') - wx.CallAfter(self.temperatureLabel.SetLabel, 'Head temperature: %d' % (temp)) - - def mcStateChange(self, state): - if self.comm == None: - return - if self.comm.isOperational(): - wx.CallAfter(self.commState.SetBitmap, self.checkBitmap) - elif self.comm.isError(): - wx.CallAfter(self.commState.SetBitmap, self.crossBitmap) - wx.CallAfter(self.infoBox.SetError, 'Failed to establish connection with the printer.') - wx.CallAfter(self.endstopBitmap.Show, False) - wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString())) - - def mcMessage(self, message): - if self.checkupState >= 3 and self.checkupState < 10 and 'x_min' in message: - for data in message.split(' '): - if ':' in data: - tag, value = data.split(':', 2) - if tag == 'x_min': - self.xMinStop = (value == 'H') - if tag == 'x_max': - self.xMaxStop = (value == 'H') - if tag == 'y_min': - self.yMinStop = (value == 'H') - if tag == 'y_max': - self.yMaxStop = (value == 'H') - if tag == 'z_min': - self.zMinStop = (value == 'H') - if tag == 'z_max': - self.zMaxStop = (value == 'H') - self.comm.sendCommand('M119') - - if self.checkupState == 3: - if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop: - self.checkupState = 4 - wx.CallAfter(self.infoBox.SetAttention, 'Please press the right X endstop.') - wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopXMaxBitmap) - elif self.checkupState == 4: - if not self.xMinStop and self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop: - self.checkupState = 5 - wx.CallAfter(self.infoBox.SetAttention, 'Please press the left X endstop.') - wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopXMinBitmap) - elif self.checkupState == 5: - if self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop: - self.checkupState = 6 - wx.CallAfter(self.infoBox.SetAttention, 'Please press the front Y endstop.') - wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopYMinBitmap) - elif self.checkupState == 6: - if not self.xMinStop and not self.xMaxStop and self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop: - self.checkupState = 7 - wx.CallAfter(self.infoBox.SetAttention, 'Please press the back Y endstop.') - wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopYMaxBitmap) - elif self.checkupState == 7: - if not self.xMinStop and not self.xMaxStop and not self.yMinStop and self.yMaxStop and not self.zMinStop and not self.zMaxStop: - self.checkupState = 8 - wx.CallAfter(self.infoBox.SetAttention, 'Please press the top Z endstop.') - wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopZMinBitmap) - elif self.checkupState == 8: - if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and self.zMinStop and not self.zMaxStop: - self.checkupState = 9 - wx.CallAfter(self.infoBox.SetAttention, 'Please press the bottom Z endstop.') - wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopZMaxBitmap) - elif self.checkupState == 9: - if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and self.zMaxStop: - self.checkupState = 10 - self.comm.close() - wx.CallAfter(self.infoBox.SetInfo, 'Checkup finished') - wx.CallAfter(self.infoBox.SetReadyIndicator) - wx.CallAfter(self.endstopBitmap.Show, False) - wx.CallAfter(self.stopState.SetBitmap, self.checkBitmap) - wx.CallAfter(self.OnSkipClick, None) - - def mcProgress(self, lineNr): - pass - - def mcZChange(self, newZ): - pass - - -class UltimakerCalibrationPage(InfoPage): - def __init__(self, parent): - super(UltimakerCalibrationPage, self).__init__(parent, "Ultimaker Calibration") - - self.AddText("Your Ultimaker requires some calibration.") - self.AddText("This calibration is needed for a proper extrusion amount.") - self.AddSeperator() - self.AddText("The following values are needed:") - self.AddText("* Diameter of filament") - self.AddText("* Number of steps per mm of filament extrusion") - self.AddSeperator() - self.AddText("The better you have calibrated these values, the better your prints\nwill become.") - self.AddSeperator() - self.AddText("First we need the diameter of your filament:") - self.filamentDiameter = self.AddTextCtrl(profile.getProfileSetting('filament_diameter')) - 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.") - self.AddText("Note: This value can be changed later at any time.") - - def StoreData(self): - profile.putProfileSetting('filament_diameter', self.filamentDiameter.GetValue()) - - -class UltimakerCalibrateStepsPerEPage(InfoPage): - def __init__(self, parent): - super(UltimakerCalibrateStepsPerEPage, self).__init__(parent, "Ultimaker Calibration") - - if profile.getPreference('steps_per_e') == '0': - profile.putPreference('steps_per_e', '865.888') - - self.AddText("Calibrating the Steps Per E requires some manual actions.") - self.AddText("First remove any filament from your machine.") - self.AddText("Next put in your filament so the tip is aligned with the\ntop of the extruder drive.") - self.AddText("We'll push the filament 100mm") - self.extrudeButton = self.AddButton("Extrude 100mm filament") - self.AddText("Now measure the amount of extruded filament:\n(this can be more or less then 100mm)") - self.lengthInput, self.saveLengthButton = self.AddTextCtrlButton('100', 'Save') - self.AddText("This results in the following steps per E:") - self.stepsPerEInput = self.AddTextCtrl(profile.getPreference('steps_per_e')) - self.AddText("You can repeat these steps to get better calibration.") - self.AddSeperator() - self.AddText( - "If you still have filament in your printer which needs\nheat to remove, press the heat up button below:") - self.heatButton = self.AddButton("Heatup for filament removal") - - self.saveLengthButton.Bind(wx.EVT_BUTTON, self.OnSaveLengthClick) - self.extrudeButton.Bind(wx.EVT_BUTTON, self.OnExtrudeClick) - self.heatButton.Bind(wx.EVT_BUTTON, self.OnHeatClick) - - def OnSaveLengthClick(self, e): - currentEValue = float(self.stepsPerEInput.GetValue()) - realExtrudeLength = float(self.lengthInput.GetValue()) - newEValue = currentEValue * 100 / realExtrudeLength - self.stepsPerEInput.SetValue(str(newEValue)) - self.lengthInput.SetValue("100") - - def OnExtrudeClick(self, e): - threading.Thread(target=self.OnExtrudeRun).start() - - def OnExtrudeRun(self): - self.heatButton.Enable(False) - self.extrudeButton.Enable(False) - currentEValue = float(self.stepsPerEInput.GetValue()) - self.comm = machineCom.MachineCom() - if not self.comm.isOpen(): - wx.MessageBox( - "Error: Failed to open serial port to machine\nIf this keeps happening, try disconnecting and reconnecting the USB cable", - 'Printer error', wx.OK | wx.ICON_INFORMATION) - self.heatButton.Enable(True) - self.extrudeButton.Enable(True) - return - while True: - line = self.comm.readline() - if line == '': - return - if 'start' in line: - break - #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found. - time.sleep(3) - - self.sendGCommand('M302') #Disable cold extrusion protection - self.sendGCommand("M92 E%f" % (currentEValue)) - self.sendGCommand("G92 E0") - self.sendGCommand("G1 E100 F600") - time.sleep(15) - self.comm.close() - self.extrudeButton.Enable() - self.heatButton.Enable() - - def OnHeatClick(self, e): - threading.Thread(target=self.OnHeatRun).start() - - def OnHeatRun(self): - self.heatButton.Enable(False) - self.extrudeButton.Enable(False) - self.comm = machineCom.MachineCom() - if not self.comm.isOpen(): - wx.MessageBox( - "Error: Failed to open serial port to machine\nIf this keeps happening, try disconnecting and reconnecting the USB cable", - 'Printer error', wx.OK | wx.ICON_INFORMATION) - self.heatButton.Enable(True) - self.extrudeButton.Enable(True) - return - while True: - line = self.comm.readline() - if line == '': - self.heatButton.Enable(True) - self.extrudeButton.Enable(True) - return - if 'start' in line: - break - #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found. - time.sleep(3) - - self.sendGCommand('M104 S200') #Set the temperature to 200C, should be enough to get PLA and ABS out. - wx.MessageBox( - 'Wait till you can remove the filament from the machine, and press OK.\n(Temperature is set to 200C)', - 'Machine heatup', wx.OK | wx.ICON_INFORMATION) - self.sendGCommand('M104 S0') - time.sleep(1) - self.comm.close() - self.heatButton.Enable(True) - self.extrudeButton.Enable(True) - - def sendGCommand(self, cmd): - self.comm.sendCommand(cmd) #Disable cold extrusion protection - while True: - line = self.comm.readline() - if line == '': - return - if line.startswith('ok'): - break - - def StoreData(self): - profile.putPreference('steps_per_e', self.stepsPerEInput.GetValue()) - - -class configWizard(wx.wizard.Wizard): - def __init__(self): - super(configWizard, self).__init__(None, -1, "Configuration Wizard") - - self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged) - self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.OnPageChanging) - - self.firstInfoPage = FirstInfoPage(self) - self.machineSelectPage = MachineSelectPage(self) - self.ultimakerFirmwareUpgradePage = FirmwareUpgradePage(self) - self.ultimakerCheckupPage = UltimakerCheckupPage(self) - self.ultimakerCalibrationPage = UltimakerCalibrationPage(self) - self.ultimakerCalibrateStepsPerEPage = UltimakerCalibrateStepsPerEPage(self) - self.repRapInfoPage = RepRapInfoPage(self) - - wx.wizard.WizardPageSimple.Chain(self.firstInfoPage, self.machineSelectPage) - wx.wizard.WizardPageSimple.Chain(self.machineSelectPage, self.ultimakerFirmwareUpgradePage) - wx.wizard.WizardPageSimple.Chain(self.ultimakerFirmwareUpgradePage, self.ultimakerCheckupPage) - #wx.wizard.WizardPageSimple.Chain(self.ultimakerCheckupPage, self.ultimakerCalibrationPage) - #wx.wizard.WizardPageSimple.Chain(self.ultimakerCalibrationPage, self.ultimakerCalibrateStepsPerEPage) - - self.FitToPage(self.firstInfoPage) - self.GetPageAreaSizer().Add(self.firstInfoPage) - - self.RunWizard(self.firstInfoPage) - self.Destroy() - - def OnPageChanging(self, e): - e.GetPage().StoreData() - - def OnPageChanged(self, e): - if e.GetPage().AllowNext(): - self.FindWindowById(wx.ID_FORWARD).Enable() - else: - self.FindWindowById(wx.ID_FORWARD).Disable() - self.FindWindowById(wx.ID_BACKWARD).Disable() +# coding=utf-8 +from __future__ import absolute_import + +import webbrowser +import threading +import time + +import wx +import wx.wizard + +from gui import firmwareInstall +from gui import toolbarUtil +from gui import printWindow +from util import machineCom +from util import profile +from util.resources import getPathForImage + +class InfoBox(wx.Panel): + def __init__(self, parent): + super(InfoBox, self).__init__(parent) + self.SetBackgroundColour('#FFFF80') + + self.sizer = wx.GridBagSizer(5, 5) + self.SetSizer(self.sizer) + + self.attentionBitmap = wx.Bitmap(getPathForImage('attention.png')) + self.errorBitmap = wx.Bitmap(getPathForImage('error.png')) + self.readyBitmap = wx.Bitmap(getPathForImage('ready.png')) + self.busyBitmap = [ + wx.Bitmap(getPathForImage('busy-0.png')), + wx.Bitmap(getPathForImage('busy-1.png')), + wx.Bitmap(getPathForImage('busy-2.png')), + wx.Bitmap(getPathForImage('busy-3.png')) + ] + + self.bitmap = wx.StaticBitmap(self, -1, wx.EmptyBitmapRGBA(24, 24, red=255, green=255, blue=255, alpha=1)) + self.text = wx.StaticText(self, -1, '') + self.extraInfoButton = wx.Button(self, -1, 'i', style=wx.BU_EXACTFIT) + self.sizer.Add(self.bitmap, pos=(0, 0), flag=wx.ALL, border=5) + self.sizer.Add(self.text, pos=(0, 1), flag=wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL, border=5) + self.sizer.Add(self.extraInfoButton, pos=(0,2), flag=wx.ALL|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5) + self.sizer.AddGrowableCol(1) + + self.extraInfoButton.Show(False) + + self.extraInfoUrl = '' + self.busyState = None + self.timer = wx.Timer(self) + self.Bind(wx.EVT_TIMER, self.doBusyUpdate, self.timer) + self.Bind(wx.EVT_BUTTON, self.doExtraInfo, self.extraInfoButton) + self.timer.Start(100) + + def SetInfo(self, info): + self.SetBackgroundColour('#FFFF80') + self.text.SetLabel(info) + self.extraInfoButton.Show(False) + self.Refresh() + + def SetError(self, info, extraInfoUrl): + self.extraInfoUrl = extraInfoUrl + self.SetBackgroundColour('#FF8080') + self.text.SetLabel(info) + self.extraInfoButton.Show(True) + self.Layout() + self.SetErrorIndicator() + self.Refresh() + + def SetAttention(self, info): + self.SetBackgroundColour('#FFFF80') + self.text.SetLabel(info) + self.extraInfoButton.Show(False) + self.SetAttentionIndicator() + self.Refresh() + + def SetBusyIndicator(self): + self.busyState = 0 + self.bitmap.SetBitmap(self.busyBitmap[self.busyState]) + + def doExtraInfo(self, e): + webbrowser.open(self.extraInfoUrl) + + def doBusyUpdate(self, e): + if self.busyState == None: + return + self.busyState += 1 + if self.busyState >= len(self.busyBitmap): + self.busyState = 0 + self.bitmap.SetBitmap(self.busyBitmap[self.busyState]) + + def SetReadyIndicator(self): + self.busyState = None + self.bitmap.SetBitmap(self.readyBitmap) + + def SetErrorIndicator(self): + self.busyState = None + self.bitmap.SetBitmap(self.errorBitmap) + + def SetAttentionIndicator(self): + self.busyState = None + self.bitmap.SetBitmap(self.attentionBitmap) + + +class InfoPage(wx.wizard.WizardPageSimple): + def __init__(self, parent, title): + wx.wizard.WizardPageSimple.__init__(self, parent) + + sizer = wx.GridBagSizer(5, 5) + self.sizer = sizer + self.SetSizer(sizer) + + title = wx.StaticText(self, -1, title) + title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD)) + sizer.Add(title, pos=(0, 0), span=(1, 2), flag=wx.ALIGN_CENTRE | wx.ALL) + sizer.Add(wx.StaticLine(self, -1), pos=(1, 0), span=(1, 2), flag=wx.EXPAND | wx.ALL) + sizer.AddGrowableCol(1) + + self.rowNr = 2 + + def AddText(self, info): + text = wx.StaticText(self, -1, info) + self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT | wx.RIGHT) + self.rowNr += 1 + return text + + def AddSeperator(self): + self.GetSizer().Add(wx.StaticLine(self, -1), pos=(self.rowNr, 0), span=(1, 2), flag=wx.EXPAND | wx.ALL) + self.rowNr += 1 + + def AddHiddenSeperator(self): + self.AddText('') + + def AddInfoBox(self): + infoBox = InfoBox(self) + self.GetSizer().Add(infoBox, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT | wx.RIGHT | wx.EXPAND) + self.rowNr += 1 + return infoBox + + def AddRadioButton(self, label, style=0): + radio = wx.RadioButton(self, -1, label, style=style) + self.GetSizer().Add(radio, pos=(self.rowNr, 0), span=(1, 2), flag=wx.EXPAND | wx.ALL) + self.rowNr += 1 + return radio + + def AddCheckbox(self, label, checked=False): + check = wx.CheckBox(self, -1) + text = wx.StaticText(self, -1, label) + check.SetValue(checked) + self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 1), flag=wx.LEFT | wx.RIGHT) + self.GetSizer().Add(check, pos=(self.rowNr, 1), span=(1, 2), flag=wx.ALL) + self.rowNr += 1 + return check + + def AddButton(self, label): + button = wx.Button(self, -1, label) + self.GetSizer().Add(button, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT) + self.rowNr += 1 + return button + + def AddDualButton(self, label1, label2): + button1 = wx.Button(self, -1, label1) + self.GetSizer().Add(button1, pos=(self.rowNr, 0), flag=wx.RIGHT) + button2 = wx.Button(self, -1, label2) + self.GetSizer().Add(button2, pos=(self.rowNr, 1)) + self.rowNr += 1 + return button1, button2 + + def AddTextCtrl(self, value): + ret = wx.TextCtrl(self, -1, value) + self.GetSizer().Add(ret, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT) + self.rowNr += 1 + return ret + + def AddLabelTextCtrl(self, info, value): + text = wx.StaticText(self, -1, info) + ret = wx.TextCtrl(self, -1, value) + self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 1), flag=wx.LEFT) + self.GetSizer().Add(ret, pos=(self.rowNr, 1), span=(1, 1), flag=wx.LEFT) + self.rowNr += 1 + return ret + + def AddTextCtrlButton(self, value, buttonText): + text = wx.TextCtrl(self, -1, value) + button = wx.Button(self, -1, buttonText) + self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 1), flag=wx.LEFT) + self.GetSizer().Add(button, pos=(self.rowNr, 1), span=(1, 1), flag=wx.LEFT) + self.rowNr += 1 + return text, button + + def AddBitmap(self, bitmap): + bitmap = wx.StaticBitmap(self, -1, bitmap) + self.GetSizer().Add(bitmap, pos=(self.rowNr, 0), span=(1, 2), flag=wx.LEFT | wx.RIGHT) + self.rowNr += 1 + return bitmap + + def AddCheckmark(self, label, bitmap): + check = wx.StaticBitmap(self, -1, bitmap) + text = wx.StaticText(self, -1, label) + self.GetSizer().Add(text, pos=(self.rowNr, 0), span=(1, 1), flag=wx.LEFT | wx.RIGHT) + self.GetSizer().Add(check, pos=(self.rowNr, 1), span=(1, 1), flag=wx.ALL) + self.rowNr += 1 + return check + + def AllowNext(self): + return True + + def StoreData(self): + pass + + +class FirstInfoPage(InfoPage): + def __init__(self, parent): + super(FirstInfoPage, self).__init__(parent, "First time run wizard") + self.AddText('Welcome, and thanks for trying Cura!') + self.AddSeperator() + self.AddText('This wizard will help you with the following steps:') + self.AddText('* Configure Cura for your machine') + self.AddText('* Upgrade your firmware') + self.AddText('* Check if your machine is working safely') + + #self.AddText('* Calibrate your machine') + #self.AddText('* Do your first print') + + +class RepRapInfoPage(InfoPage): + def __init__(self, parent): + super(RepRapInfoPage, self).__init__(parent, "RepRap information") + self.AddText( + 'RepRap machines are vastly different, and there is no\ndefault configuration in Cura for any of them.') + self.AddText('If you like a default profile for your machine added,\nthen make an issue on github.') + self.AddSeperator() + self.AddText('You will have to manually install Marlin or Sprinter firmware.') + self.AddSeperator() + self.machineWidth = self.AddLabelTextCtrl('Machine width (mm)', '80') + self.machineDepth = self.AddLabelTextCtrl('Machine depth (mm)', '80') + self.machineHeight = self.AddLabelTextCtrl('Machine height (mm)', '60') + self.nozzleSize = self.AddLabelTextCtrl('Nozzle size (mm)', '0.5') + self.heatedBed = self.AddCheckbox('Heated bed') + + def StoreData(self): + profile.putPreference('machine_width', self.machineWidth.GetValue()) + profile.putPreference('machine_depth', self.machineDepth.GetValue()) + profile.putPreference('machine_height', self.machineHeight.GetValue()) + profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue()) + profile.putProfileSetting('wall_thickness', float(profile.getProfileSettingFloat('nozzle_size')) * 2) + profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue())) + + +class MachineSelectPage(InfoPage): + def __init__(self, parent): + super(MachineSelectPage, self).__init__(parent, "Select your machine") + self.AddText('What kind of machine do you have:') + + self.UltimakerRadio = self.AddRadioButton("Ultimaker", style=wx.RB_GROUP) + self.UltimakerRadio.SetValue(True) + self.UltimakerRadio.Bind(wx.EVT_RADIOBUTTON, self.OnUltimakerSelect) + self.OtherRadio = self.AddRadioButton("Other (Ex: RepRap)") + self.OtherRadio.Bind(wx.EVT_RADIOBUTTON, self.OnOtherSelect) + + def OnUltimakerSelect(self, e): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().ultimakerFirmwareUpgradePage) + + def OnOtherSelect(self, e): + wx.wizard.WizardPageSimple.Chain(self, self.GetParent().repRapInfoPage) + + def StoreData(self): + if self.UltimakerRadio.GetValue(): + profile.putPreference('machine_width', '205') + profile.putPreference('machine_depth', '205') + profile.putPreference('machine_height', '200') + profile.putPreference('machine_type', 'ultimaker') + profile.putProfileSetting('nozzle_size', '0.4') + else: + profile.putPreference('machine_width', '80') + profile.putPreference('machine_depth', '80') + profile.putPreference('machine_height', '60') + profile.putPreference('machine_type', 'reprap') + profile.putPreference('startMode', 'Normal') + profile.putProfileSetting('nozzle_size', '0.5') + profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2) + + +class SelectParts(InfoPage): + def __init__(self, parent): + super(SelectParts, self).__init__(parent, "Select upgraded parts you have") + self.AddText('To assist you in having better default settings for your Ultimaker\nCura would like to know which upgrades you have in your machine.') + self.AddSeperator() + self.springExtruder = self.AddCheckbox('Extruder drive upgrade') + self.heatedBed = self.AddCheckbox('Heated printer bed (self build)') + self.dualExtrusion = self.AddCheckbox('Dual extrusion (experimental)') + self.AddSeperator() + self.AddText('If you have an Ultimaker bought after october 2012 you will have the\nExtruder drive upgrade. If you do not have this upgrade,\nit is highly recommended to improve reliablity.') + self.AddText('This upgrade can be bought from the Ultimaker webshop shop\nor found on thingiverse as thing:26094') + self.springExtruder.SetValue(True) + + def StoreData(self): + profile.putPreference('ultimaker_extruder_upgrade', str(self.springExtruder.GetValue())) + profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue())) + if self.dualExtrusion.GetValue(): + profile.putPreference('extruder_amount', '2') + if getPreference('ultimaker_extruder_upgrade') == 'True': + putProfileSetting('retraction_enable', 'True') + + +class FirmwareUpgradePage(InfoPage): + def __init__(self, parent): + super(FirmwareUpgradePage, self).__init__(parent, "Upgrade Ultimaker Firmware") + self.AddText( + 'Firmware is the piece of software running directly on your 3D printer.\nThis firmware controls the step motors, regulates the temperature\nand ultimately makes your printer work.') + self.AddHiddenSeperator() + self.AddText( + 'The firmware shipping with new Ultimakers works, but upgrades\nhave been made to make better prints, and make calibration easier.') + self.AddHiddenSeperator() + self.AddText( + 'Cura requires these new features and thus\nyour firmware will most likely need to be upgraded.\nYou will get the chance to do so now.') + upgradeButton, skipUpgradeButton = self.AddDualButton('Upgrade to Marlin firmware', 'Skip upgrade') + upgradeButton.Bind(wx.EVT_BUTTON, self.OnUpgradeClick) + skipUpgradeButton.Bind(wx.EVT_BUTTON, self.OnSkipClick) + self.AddHiddenSeperator() + self.AddText('Do not upgrade to this firmware if:') + self.AddText('* You have an older machine based on ATMega1280') + self.AddText('* Have other changes in the firmware') + button = self.AddButton('Goto this page for a custom firmware') + button.Bind(wx.EVT_BUTTON, self.OnUrlClick) + + def AllowNext(self): + return False + + def OnUpgradeClick(self, e): + if firmwareInstall.InstallFirmware(): + self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() + + def OnSkipClick(self, e): + self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() + + def OnUrlClick(self, e): + webbrowser.open('http://daid.mine.nu/~daid/marlin_build/') + + +class UltimakerCheckupPage(InfoPage): + def __init__(self, parent): + super(UltimakerCheckupPage, self).__init__(parent, "Ultimaker Checkup") + + self.checkBitmap = wx.Bitmap(getPathForImage('checkmark.png')) + self.crossBitmap = wx.Bitmap(getPathForImage('cross.png')) + self.unknownBitmap = wx.Bitmap(getPathForImage('question.png')) + self.endStopNoneBitmap = wx.Bitmap(getPathForImage('endstop_none.png')) + self.endStopXMinBitmap = wx.Bitmap(getPathForImage('endstop_xmin.png')) + self.endStopXMaxBitmap = wx.Bitmap(getPathForImage('endstop_xmax.png')) + self.endStopYMinBitmap = wx.Bitmap(getPathForImage('endstop_ymin.png')) + self.endStopYMaxBitmap = wx.Bitmap(getPathForImage('endstop_ymax.png')) + self.endStopZMinBitmap = wx.Bitmap(getPathForImage('endstop_zmin.png')) + self.endStopZMaxBitmap = wx.Bitmap(getPathForImage('endstop_zmax.png')) + + self.AddText( + 'It is a good idea to do a few sanity checks now on your Ultimaker.\nYou can skip these if you know your machine is functional.') + b1, b2 = self.AddDualButton('Run checks', 'Skip checks') + b1.Bind(wx.EVT_BUTTON, self.OnCheckClick) + b2.Bind(wx.EVT_BUTTON, self.OnSkipClick) + self.AddSeperator() + self.commState = self.AddCheckmark('Communication:', self.unknownBitmap) + self.tempState = self.AddCheckmark('Temperature:', self.unknownBitmap) + self.stopState = self.AddCheckmark('Endstops:', self.unknownBitmap) + self.AddSeperator() + self.infoBox = self.AddInfoBox() + self.machineState = self.AddText('') + self.temperatureLabel = self.AddText('') + self.errorLogButton = self.AddButton('Show error log') + self.errorLogButton.Show(False) + self.AddSeperator() + self.endstopBitmap = self.AddBitmap(self.endStopNoneBitmap) + self.comm = None + self.xMinStop = False + self.xMaxStop = False + self.yMinStop = False + self.yMaxStop = False + self.zMinStop = False + self.zMaxStop = False + + self.Bind(wx.EVT_BUTTON, self.OnErrorLog, self.errorLogButton) + + def __del__(self): + if self.comm != None: + self.comm.close() + + def AllowNext(self): + self.endstopBitmap.Show(False) + return False + + def OnSkipClick(self, e): + self.GetParent().FindWindowById(wx.ID_FORWARD).Enable() + + def OnCheckClick(self, e=None): + self.errorLogButton.Show(False) + if self.comm != None: + self.comm.close() + del self.comm + self.comm = None + wx.CallAfter(self.OnCheckClick) + return + self.infoBox.SetInfo('Connecting to machine.') + self.infoBox.SetBusyIndicator() + self.commState.SetBitmap(self.unknownBitmap) + self.tempState.SetBitmap(self.unknownBitmap) + self.stopState.SetBitmap(self.unknownBitmap) + self.checkupState = 0 + self.comm = machineCom.MachineCom(callbackObject=self) + + def OnErrorLog(self, e): + printWindow.LogWindow('\n'.join(self.comm.getLog())) + + def mcLog(self, message): + pass + + def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp): + if not self.comm.isOperational(): + return + if self.checkupState == 0: + self.tempCheckTimeout = 20 + if temp > 70: + self.checkupState = 1 + wx.CallAfter(self.infoBox.SetInfo, 'Cooldown before temperature check.') + self.comm.sendCommand('M104 S0') + self.comm.sendCommand('M104 S0') + else: + self.startTemp = temp + self.checkupState = 2 + wx.CallAfter(self.infoBox.SetInfo, 'Checking the heater and temperature sensor.') + self.comm.sendCommand('M104 S200') + self.comm.sendCommand('M104 S200') + elif self.checkupState == 1: + if temp < 60: + self.startTemp = temp + self.checkupState = 2 + wx.CallAfter(self.infoBox.SetInfo, 'Checking the heater and temperature sensor.') + self.comm.sendCommand('M104 S200') + self.comm.sendCommand('M104 S200') + elif self.checkupState == 2: + #print "WARNING, TEMPERATURE TEST DISABLED FOR TESTING!" + if temp > self.startTemp + 40: + self.checkupState = 3 + wx.CallAfter(self.infoBox.SetAttention, 'Please make sure none of the endstops are pressed.') + wx.CallAfter(self.endstopBitmap.Show, True) + wx.CallAfter(self.Layout) + self.comm.sendCommand('M104 S0') + self.comm.sendCommand('M104 S0') + self.comm.sendCommand('M119') + wx.CallAfter(self.tempState.SetBitmap, self.checkBitmap) + else: + self.tempCheckTimeout -= 1 + if self.tempCheckTimeout < 1: + self.checkupState = -1 + wx.CallAfter(self.tempState.SetBitmap, self.crossBitmap) + wx.CallAfter(self.infoBox.SetError, 'Temperature measurement FAILED!', 'http://wiki.ultimaker.com/Cura/Temperature_measurement_problems') + self.comm.sendCommand('M104 S0') + self.comm.sendCommand('M104 S0') + wx.CallAfter(self.temperatureLabel.SetLabel, 'Head temperature: %d' % (temp)) + + def mcStateChange(self, state): + if self.comm == None: + return + if self.comm.isOperational(): + wx.CallAfter(self.commState.SetBitmap, self.checkBitmap) + wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString())) + elif self.comm.isError(): + wx.CallAfter(self.commState.SetBitmap, self.crossBitmap) + wx.CallAfter(self.infoBox.SetError, 'Failed to establish connection with the printer.', 'http://wiki.ultimaker.com/Cura/Connection_problems') + wx.CallAfter(self.endstopBitmap.Show, False) + wx.CallAfter(self.machineState.SetLabel, '%s' % (self.comm.getErrorString())) + wx.CallAfter(self.errorLogButton.Show, True) + wx.CallAfter(self.Layout) + else: + wx.CallAfter(self.machineState.SetLabel, 'Communication State: %s' % (self.comm.getStateString())) + + def mcMessage(self, message): + if self.checkupState >= 3 and self.checkupState < 10 and 'x_min' in message: + for data in message.split(' '): + if ':' in data: + tag, value = data.split(':', 2) + if tag == 'x_min': + self.xMinStop = (value == 'H') + if tag == 'x_max': + self.xMaxStop = (value == 'H') + if tag == 'y_min': + self.yMinStop = (value == 'H') + if tag == 'y_max': + self.yMaxStop = (value == 'H') + if tag == 'z_min': + self.zMinStop = (value == 'H') + if tag == 'z_max': + self.zMaxStop = (value == 'H') + self.comm.sendCommand('M119') + + if self.checkupState == 3: + if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop: + self.checkupState = 4 + wx.CallAfter(self.infoBox.SetAttention, 'Please press the right X endstop.') + wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopXMaxBitmap) + elif self.checkupState == 4: + if not self.xMinStop and self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop: + self.checkupState = 5 + wx.CallAfter(self.infoBox.SetAttention, 'Please press the left X endstop.') + wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopXMinBitmap) + elif self.checkupState == 5: + if self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop: + self.checkupState = 6 + wx.CallAfter(self.infoBox.SetAttention, 'Please press the front Y endstop.') + wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopYMinBitmap) + elif self.checkupState == 6: + if not self.xMinStop and not self.xMaxStop and self.yMinStop and not self.yMaxStop and not self.zMinStop and not self.zMaxStop: + self.checkupState = 7 + wx.CallAfter(self.infoBox.SetAttention, 'Please press the back Y endstop.') + wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopYMaxBitmap) + elif self.checkupState == 7: + if not self.xMinStop and not self.xMaxStop and not self.yMinStop and self.yMaxStop and not self.zMinStop and not self.zMaxStop: + self.checkupState = 8 + wx.CallAfter(self.infoBox.SetAttention, 'Please press the top Z endstop.') + wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopZMinBitmap) + elif self.checkupState == 8: + if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and self.zMinStop and not self.zMaxStop: + self.checkupState = 9 + wx.CallAfter(self.infoBox.SetAttention, 'Please press the bottom Z endstop.') + wx.CallAfter(self.endstopBitmap.SetBitmap, self.endStopZMaxBitmap) + elif self.checkupState == 9: + if not self.xMinStop and not self.xMaxStop and not self.yMinStop and not self.yMaxStop and not self.zMinStop and self.zMaxStop: + self.checkupState = 10 + self.comm.close() + wx.CallAfter(self.infoBox.SetInfo, 'Checkup finished') + wx.CallAfter(self.infoBox.SetReadyIndicator) + wx.CallAfter(self.endstopBitmap.Show, False) + wx.CallAfter(self.stopState.SetBitmap, self.checkBitmap) + wx.CallAfter(self.OnSkipClick, None) + + def mcProgress(self, lineNr): + pass + + def mcZChange(self, newZ): + pass + + +class UltimakerCalibrationPage(InfoPage): + def __init__(self, parent): + super(UltimakerCalibrationPage, self).__init__(parent, "Ultimaker Calibration") + + self.AddText("Your Ultimaker requires some calibration.") + self.AddText("This calibration is needed for a proper extrusion amount.") + self.AddSeperator() + self.AddText("The following values are needed:") + self.AddText("* Diameter of filament") + self.AddText("* Number of steps per mm of filament extrusion") + self.AddSeperator() + self.AddText("The better you have calibrated these values, the better your prints\nwill become.") + self.AddSeperator() + self.AddText("First we need the diameter of your filament:") + self.filamentDiameter = self.AddTextCtrl(profile.getProfileSetting('filament_diameter')) + 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.") + self.AddText("Note: This value can be changed later at any time.") + + def StoreData(self): + profile.putProfileSetting('filament_diameter', self.filamentDiameter.GetValue()) + + +class UltimakerCalibrateStepsPerEPage(InfoPage): + def __init__(self, parent): + super(UltimakerCalibrateStepsPerEPage, self).__init__(parent, "Ultimaker Calibration") + + if profile.getPreference('steps_per_e') == '0': + profile.putPreference('steps_per_e', '865.888') + + self.AddText("Calibrating the Steps Per E requires some manual actions.") + self.AddText("First remove any filament from your machine.") + self.AddText("Next put in your filament so the tip is aligned with the\ntop of the extruder drive.") + self.AddText("We'll push the filament 100mm") + self.extrudeButton = self.AddButton("Extrude 100mm filament") + self.AddText("Now measure the amount of extruded filament:\n(this can be more or less then 100mm)") + self.lengthInput, self.saveLengthButton = self.AddTextCtrlButton('100', 'Save') + self.AddText("This results in the following steps per E:") + self.stepsPerEInput = self.AddTextCtrl(profile.getPreference('steps_per_e')) + self.AddText("You can repeat these steps to get better calibration.") + self.AddSeperator() + self.AddText( + "If you still have filament in your printer which needs\nheat to remove, press the heat up button below:") + self.heatButton = self.AddButton("Heatup for filament removal") + + self.saveLengthButton.Bind(wx.EVT_BUTTON, self.OnSaveLengthClick) + self.extrudeButton.Bind(wx.EVT_BUTTON, self.OnExtrudeClick) + self.heatButton.Bind(wx.EVT_BUTTON, self.OnHeatClick) + + def OnSaveLengthClick(self, e): + currentEValue = float(self.stepsPerEInput.GetValue()) + realExtrudeLength = float(self.lengthInput.GetValue()) + newEValue = currentEValue * 100 / realExtrudeLength + self.stepsPerEInput.SetValue(str(newEValue)) + self.lengthInput.SetValue("100") + + def OnExtrudeClick(self, e): + threading.Thread(target=self.OnExtrudeRun).start() + + def OnExtrudeRun(self): + self.heatButton.Enable(False) + self.extrudeButton.Enable(False) + currentEValue = float(self.stepsPerEInput.GetValue()) + self.comm = machineCom.MachineCom() + if not self.comm.isOpen(): + wx.MessageBox( + "Error: Failed to open serial port to machine\nIf this keeps happening, try disconnecting and reconnecting the USB cable", + 'Printer error', wx.OK | wx.ICON_INFORMATION) + self.heatButton.Enable(True) + self.extrudeButton.Enable(True) + return + while True: + line = self.comm.readline() + if line == '': + return + if 'start' in line: + break + #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found. + time.sleep(3) + + self.sendGCommand('M302') #Disable cold extrusion protection + self.sendGCommand("M92 E%f" % (currentEValue)) + self.sendGCommand("G92 E0") + self.sendGCommand("G1 E100 F600") + time.sleep(15) + self.comm.close() + self.extrudeButton.Enable() + self.heatButton.Enable() + + def OnHeatClick(self, e): + threading.Thread(target=self.OnHeatRun).start() + + def OnHeatRun(self): + self.heatButton.Enable(False) + self.extrudeButton.Enable(False) + self.comm = machineCom.MachineCom() + if not self.comm.isOpen(): + wx.MessageBox( + "Error: Failed to open serial port to machine\nIf this keeps happening, try disconnecting and reconnecting the USB cable", + 'Printer error', wx.OK | wx.ICON_INFORMATION) + self.heatButton.Enable(True) + self.extrudeButton.Enable(True) + return + while True: + line = self.comm.readline() + if line == '': + self.heatButton.Enable(True) + self.extrudeButton.Enable(True) + return + if 'start' in line: + break + #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found. + time.sleep(3) + + self.sendGCommand('M104 S200') #Set the temperature to 200C, should be enough to get PLA and ABS out. + wx.MessageBox( + 'Wait till you can remove the filament from the machine, and press OK.\n(Temperature is set to 200C)', + 'Machine heatup', wx.OK | wx.ICON_INFORMATION) + self.sendGCommand('M104 S0') + time.sleep(1) + self.comm.close() + self.heatButton.Enable(True) + self.extrudeButton.Enable(True) + + def sendGCommand(self, cmd): + self.comm.sendCommand(cmd) #Disable cold extrusion protection + while True: + line = self.comm.readline() + if line == '': + return + if line.startswith('ok'): + break + + def StoreData(self): + profile.putPreference('steps_per_e', self.stepsPerEInput.GetValue()) + + +class configWizard(wx.wizard.Wizard): + def __init__(self): + super(configWizard, self).__init__(None, -1, "Configuration Wizard") + + self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged) + self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.OnPageChanging) + + self.firstInfoPage = FirstInfoPage(self) + self.machineSelectPage = MachineSelectPage(self) + self.ultimakerSelectParts = SelectParts(self) + self.ultimakerFirmwareUpgradePage = FirmwareUpgradePage(self) + self.ultimakerCheckupPage = UltimakerCheckupPage(self) + self.ultimakerCalibrationPage = UltimakerCalibrationPage(self) + self.ultimakerCalibrateStepsPerEPage = UltimakerCalibrateStepsPerEPage(self) + self.repRapInfoPage = RepRapInfoPage(self) + + wx.wizard.WizardPageSimple.Chain(self.firstInfoPage, self.machineSelectPage) + wx.wizard.WizardPageSimple.Chain(self.machineSelectPage, self.ultimakerSelectParts) + wx.wizard.WizardPageSimple.Chain(self.ultimakerSelectParts, self.ultimakerFirmwareUpgradePage) + wx.wizard.WizardPageSimple.Chain(self.ultimakerFirmwareUpgradePage, self.ultimakerCheckupPage) + #wx.wizard.WizardPageSimple.Chain(self.ultimakerCheckupPage, self.ultimakerCalibrationPage) + #wx.wizard.WizardPageSimple.Chain(self.ultimakerCalibrationPage, self.ultimakerCalibrateStepsPerEPage) + + self.FitToPage(self.firstInfoPage) + self.GetPageAreaSizer().Add(self.firstInfoPage) + + self.RunWizard(self.firstInfoPage) + self.Destroy() + + def OnPageChanging(self, e): + e.GetPage().StoreData() + + def OnPageChanged(self, e): + if e.GetPage().AllowNext(): + self.FindWindowById(wx.ID_FORWARD).Enable() + else: + self.FindWindowById(wx.ID_FORWARD).Disable() + self.FindWindowById(wx.ID_BACKWARD).Disable() diff --git a/Cura/gui/expertConfig.py b/Cura/gui/expertConfig.py index 9233e33..c612ef9 100644 --- a/Cura/gui/expertConfig.py +++ b/Cura/gui/expertConfig.py @@ -67,6 +67,9 @@ class expertConfigWindow(configBase.configWindowBase): configBase.TitleRow(right, "Retraction") c = configBase.SettingRow(right, "Retract on jumps only", 'retract_on_jumps_only', True, 'Only retract when we are making a move that is over a hole in the model, else retract on every move. This effects print quality in different ways.') + configBase.TitleRow(right, "Hop") + c = configBase.SettingRow(right, "Enable hop on move", 'hop_on_move', False, 'When moving from print position to print position, raise the printer head 0.2mm so it does not knock off the print (experimental).') + main.Fit() self.Fit() diff --git a/Cura/gui/flatSlicerWindow.py b/Cura/gui/flatSlicerWindow.py index 5f28767..4c8f1d9 100644 --- a/Cura/gui/flatSlicerWindow.py +++ b/Cura/gui/flatSlicerWindow.py @@ -84,7 +84,7 @@ class flatSlicerWindow(wx.Frame): if dlg.ShowModal() == wx.ID_OK: self.filename = dlg.GetPath() self.svg = svg.SVG(self.filename) - self.svg.center(complex(profile.getProfileSettingFloat('machine_center_x'), profile.getProfileSettingFloat('machine_center_y'))) + self.svg.center(complex(profile.getPreferenceFloat('machine_width')/2, profile.getPreferenceFloat('machine_depth')/2)) self.preview.Refresh() dlg.Destroy() diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 48ee51d..d435194 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -113,7 +113,7 @@ class mainWindow(configBase.configWindowBase): helpMenu = wx.Menu() i = helpMenu.Append(-1, 'Online documentation...') - self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://daid.github.com/Cura'), i) + self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://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') @@ -134,7 +134,7 @@ class mainWindow(configBase.configWindowBase): (left, right) = self.CreateConfigTab(nb, 'Print config') - configBase.TitleRow(left, "Accuracy") + configBase.TitleRow(left, "Quality") c = configBase.SettingRow(left, "Layer height (mm)", 'layer_height', '0.2', 'Layer height in millimeters.\n0.2 is a good value for quick prints.\n0.1 gives high quality prints.') validators.validFloat(c, 0.0001) validators.warningAbove(c, lambda : (float(profile.getProfileSetting('nozzle_size')) * 80.0 / 100.0), "Thicker layers then %.2fmm (80%% nozzle size) usually give bad results and are not recommended.") @@ -149,12 +149,6 @@ class mainWindow(configBase.configWindowBase): c = configBase.SettingRow(left, "Fill Density (%)", 'fill_density', '20', 'This controls how densily filled the insides of your print will be. For a solid part use 100%, for an empty part use 0%. A value around 20% is usually enough') validators.validFloat(c, 0.0, 100.0) - configBase.TitleRow(left, "Skirt") - c = configBase.SettingRow(left, "Line count", 'skirt_line_count', '1', 'The skirt is a line drawn around the object at the first layer. This helps to prime your extruder, and to see if the object fits on your platform.\nSetting this to 0 will disable the skirt. Multiple skirt lines can help priming your extruder better for small objects.') - validators.validInt(c, 0, 10) - c = configBase.SettingRow(left, "Start distance (mm)", 'skirt_gap', '6.0', 'The distance between the skirt and the first layer.\nThis is the minimal distance, multiple skirt lines will be put outwards from this distance.') - validators.validFloat(c, 0.0) - configBase.TitleRow(right, "Speed && Temperature") c = configBase.SettingRow(right, "Print speed (mm/s)", 'print_speed', '50', 'Speed at which printing happens. A well adjusted Ultimaker can reach 150mm/s, but for good quality prints you want to print slower. Printing speed depends on a lot of factors. So you will be experimenting with optimal settings for this.') validators.validFloat(c, 1.0) @@ -187,15 +181,15 @@ class mainWindow(configBase.configWindowBase): configBase.TitleRow(left, "Machine size") c = configBase.SettingRow(left, "Nozzle size (mm)", 'nozzle_size', '0.4', 'The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings.') validators.validFloat(c, 0.1, 10.0) - c = configBase.SettingRow(left, "Machine center X (mm)", 'machine_center_x', '100', 'The center of your machine, your print will be placed at this location') - validators.validInt(c, 10) - configBase.settingNotify(c, self.preview3d.updateCenterX) - c = configBase.SettingRow(left, "Machine center Y (mm)", 'machine_center_y', '100', 'The center of your machine, your print will be placed at this location') - validators.validInt(c, 10) - configBase.settingNotify(c, self.preview3d.updateCenterY) + + configBase.TitleRow(left, "Skirt") + c = configBase.SettingRow(left, "Line count", 'skirt_line_count', '1', 'The skirt is a line drawn around the object at the first layer. This helps to prime your extruder, and to see if the object fits on your platform.\nSetting this to 0 will disable the skirt. Multiple skirt lines can help priming your extruder better for small objects.') + validators.validInt(c, 0, 10) + c = configBase.SettingRow(left, "Start distance (mm)", 'skirt_gap', '6.0', 'The distance between the skirt and the first layer.\nThis is the minimal distance, multiple skirt lines will be put outwards from this distance.') + validators.validFloat(c, 0.0) configBase.TitleRow(left, "Retraction") - c = configBase.SettingRow(left, "Minimal travel (mm)", 'retraction_min_travel', '5.0', 'Minimal amount of travel needed for a retraction to happen at all. To make sure you do not get a lot of retractions in a small area') + c = configBase.SettingRow(left, "Minimum travel (mm)", 'retraction_min_travel', '5.0', 'Minimum amount of travel needed for a retraction to happen at all. To make sure you do not get a lot of retractions in a small area') validators.validFloat(c, 0.0) c = configBase.SettingRow(left, "Speed (mm/s)", 'retraction_speed', '40.0', 'Speed at which the filament is retracted, a higher retraction speed works better. But a very high retraction speed can lead to filament grinding.') validators.validFloat(c, 0.1) @@ -218,11 +212,11 @@ class mainWindow(configBase.configWindowBase): validators.validFloat(c, 0.0) c = configBase.SettingRow(right, "Enable cooling fan", 'fan_enabled', True, 'Enable the cooling fan during the print. The extra cooling from the cooling fan is essensial during faster prints.') - configBase.TitleRow(right, "Accuracy") + configBase.TitleRow(right, "Quality") c = configBase.SettingRow(right, "Initial layer thickness (mm)", 'bottom_thickness', '0.0', 'Layer thickness of the bottom layer. A thicker bottom layer makes sticking to the bed easier. Set to 0.0 to have the bottom layer thickness the same as the other layers.') validators.validFloat(c, 0.0) validators.warningAbove(c, lambda : (float(profile.getProfileSetting('nozzle_size')) * 3.0 / 4.0), "A bottom layer of more then %.2fmm (3/4 nozzle size) usually give bad results and is not recommended.") - c = configBase.SettingRow(right, "Enable 'skin'", 'enable_skin', False, 'Skin prints the outer lines of the prints twice, each time with half the thickness. This gives the illusion of a higher print quality.') + c = configBase.SettingRow(right, "Duplicate outlines", 'enable_skin', False, 'Skin prints the outer lines of the prints twice, each time with half the thickness. This gives the illusion of a higher print quality.') #Plugin page self.pluginPanel = pluginPanel.pluginPanel(nb) @@ -236,7 +230,7 @@ class mainWindow(configBase.configWindowBase): nb.AddPage(self.alterationPanel, "Start/End-GCode") # load and slice buttons. - loadButton = wx.Button(self, -1, '&Load Model') + loadButton = wx.Button(self, -1, '&Load model') sliceButton = wx.Button(self, -1, 'P&repare print') printButton = wx.Button(self, -1, '&Print') self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(1), loadButton) @@ -331,10 +325,6 @@ class mainWindow(configBase.configWindowBase): dlg.Destroy() if result: profile.resetGlobalProfile() - if profile.getPreference('machine_type') == 'reprap': - profile.putProfileSetting('nozzle_size', '0.5') - profile.putProfileSetting('machine_center_x', '40') - profile.putProfileSetting('machine_center_y', '40') self.updateProfileToControls() def OnBatchRun(self, e): diff --git a/Cura/gui/opengl.py b/Cura/gui/opengl.py index 79f3328..8e327a7 100644 --- a/Cura/gui/opengl.py +++ b/Cura/gui/opengl.py @@ -1,458 +1,496 @@ -# coding=utf-8 -from __future__ import absolute_import - -import math - -from util import meshLoader -from util import util3d -from util import profile -from util.resources import getPathForMesh - -try: - import OpenGL - - OpenGL.ERROR_CHECKING = False - from OpenGL.GLU import * - from OpenGL.GL import * - - hasOpenGLlibs = True -except: - print "Failed to find PyOpenGL: http://pyopengl.sourceforge.net/" - hasOpenGLlibs = False - -def InitGL(window, view3D, zoom): - # set viewing projection - glMatrixMode(GL_MODELVIEW) - glLoadIdentity() - size = window.GetSize() - glViewport(0, 0, size.GetWidth(), size.GetHeight()) - - glLightfv(GL_LIGHT0, GL_POSITION, [0.2, 0.2, 1.0, 0.0]) - glLightfv(GL_LIGHT1, GL_POSITION, [1.0, 1.0, 1.0, 0.0]) - - glEnable(GL_RESCALE_NORMAL) - glEnable(GL_LIGHTING) - glEnable(GL_LIGHT0) - glEnable(GL_DEPTH_TEST) - glEnable(GL_CULL_FACE) - glDisable(GL_BLEND) - - glClearColor(1.0, 1.0, 1.0, 1.0) - glClearStencil(0) - glClearDepth(1.0) - - glMatrixMode(GL_PROJECTION) - glLoadIdentity() - aspect = float(size.GetWidth()) / float(size.GetHeight()) - if view3D: - gluPerspective(45.0, aspect, 1.0, 1000.0) - else: - glOrtho(-aspect * (zoom), aspect * (zoom), -1.0 * (zoom), 1.0 * (zoom), -1000.0, 1000.0) - - glMatrixMode(GL_MODELVIEW) - glLoadIdentity() - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) - -platformMesh = None - -def DrawMachine(machineSize): - if profile.getPreference('machine_type') == 'ultimaker': - glPushMatrix() - glEnable(GL_LIGHTING) - glTranslate(100, 200, -5) - glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.8, 0.8, 0.8]) - glLightfv(GL_LIGHT0, GL_AMBIENT, [0.5, 0.5, 0.5]) - glEnable(GL_BLEND) - glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) - - global platformMesh - if platformMesh == None: - platformMesh = meshLoader.loadMesh(getPathForMesh('ultimaker_platform.stl')) - platformMesh.setRotateMirror(0, False, False, False, False, False) - - DrawMesh(platformMesh) - glPopMatrix() - - glDisable(GL_LIGHTING) - if False: - glColor3f(0.7, 0.7, 0.7) - glLineWidth(2) - glBegin(GL_LINES) - for i in xrange(0, int(machineSize.x), 10): - glVertex3f(i, 0, 0) - glVertex3f(i, machineSize.y, 0) - for i in xrange(0, int(machineSize.y), 10): - glVertex3f(0, i, 0) - glVertex3f(machineSize.x, i, 0) - glEnd() - - glEnable(GL_LINE_SMOOTH) - glEnable(GL_BLEND) - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) - glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - - glColor3f(0.0, 0.0, 0.0) - glLineWidth(4) - glBegin(GL_LINE_LOOP) - glVertex3f(0, 0, 0) - glVertex3f(machineSize.x, 0, 0) - glVertex3f(machineSize.x, machineSize.y, 0) - glVertex3f(0, machineSize.y, 0) - glEnd() - - glLineWidth(2) - glBegin(GL_LINE_LOOP) - glVertex3f(0, 0, machineSize.z) - glVertex3f(machineSize.x, 0, machineSize.z) - glVertex3f(machineSize.x, machineSize.y, machineSize.z) - glVertex3f(0, machineSize.y, machineSize.z) - glEnd() - glBegin(GL_LINES) - glVertex3f(0, 0, 0) - glVertex3f(0, 0, machineSize.z) - glVertex3f(machineSize.x, 0, 0) - glVertex3f(machineSize.x, 0, machineSize.z) - glVertex3f(machineSize.x, machineSize.y, 0) - glVertex3f(machineSize.x, machineSize.y, machineSize.z) - glVertex3f(0, machineSize.y, 0) - glVertex3f(0, machineSize.y, machineSize.z) - glEnd() - else: - glDisable(GL_CULL_FACE) - glEnable(GL_BLEND) - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) - glColor4ub(5, 171, 231, 127) - glBegin(GL_QUADS) - for x in xrange(0, int(machineSize.x), 20): - for y in xrange(0, int(machineSize.y), 20): - glVertex3f(x, y, -0.01) - glVertex3f(min(x + 10, machineSize.x), y, -0.01) - glVertex3f(min(x + 10, machineSize.x), min(y + 10, machineSize.y), -0.01) - glVertex3f(x, min(y + 10, machineSize.y), -0.01) - for x in xrange(10, int(machineSize.x), 20): - for y in xrange(10, int(machineSize.y), 20): - glVertex3f(x, y, -0.01) - glVertex3f(min(x + 10, machineSize.x), y, -0.01) - glVertex3f(min(x + 10, machineSize.x), min(y + 10, machineSize.y), -0.01) - glVertex3f(x, min(y + 10, machineSize.y), -0.01) - glEnd() - glColor4ub(5 * 8 / 10, 171 * 8 / 10, 231 * 8 / 10, 128) - glBegin(GL_QUADS) - for x in xrange(10, int(machineSize.x), 20): - for y in xrange(0, int(machineSize.y), 20): - glVertex3f(x, y, -0.01) - glVertex3f(min(x + 10, machineSize.x), y, -0.01) - glVertex3f(min(x + 10, machineSize.x), min(y + 10, machineSize.y), -0.01) - glVertex3f(x, min(y + 10, machineSize.y), -0.01) - for x in xrange(0, int(machineSize.x), 20): - for y in xrange(10, int(machineSize.y), 20): - glVertex3f(x, y, -0.01) - glVertex3f(min(x + 10, machineSize.x), y, -0.01) - glVertex3f(min(x + 10, machineSize.x), min(y + 10, machineSize.y), -0.01) - glVertex3f(x, min(y + 10, machineSize.y), -0.01) - glEnd() - glEnable(GL_CULL_FACE) - - glColor4ub(5, 171, 231, 64) - glBegin(GL_QUADS) - glVertex3f(0, 0, machineSize.z) - glVertex3f(0, machineSize.y, machineSize.z) - glVertex3f(machineSize.x, machineSize.y, machineSize.z) - glVertex3f(machineSize.x, 0, machineSize.z) - glEnd() - - glColor4ub(5, 171, 231, 96) - glBegin(GL_QUADS) - glVertex3f(0, 0, 0) - glVertex3f(0, 0, machineSize.z) - glVertex3f(machineSize.x, 0, machineSize.z) - glVertex3f(machineSize.x, 0, 0) - - glVertex3f(0, machineSize.y, machineSize.z) - glVertex3f(0, machineSize.y, 0) - glVertex3f(machineSize.x, machineSize.y, 0) - glVertex3f(machineSize.x, machineSize.y, machineSize.z) - glEnd() - - glColor4ub(5, 171, 231, 128) - glBegin(GL_QUADS) - glVertex3f(0, 0, machineSize.z) - glVertex3f(0, 0, 0) - glVertex3f(0, machineSize.y, 0) - glVertex3f(0, machineSize.y, machineSize.z) - - glVertex3f(machineSize.x, 0, 0) - glVertex3f(machineSize.x, 0, machineSize.z) - glVertex3f(machineSize.x, machineSize.y, machineSize.z) - glVertex3f(machineSize.x, machineSize.y, 0) - glEnd() - - glDisable(GL_BLEND) - - glPushMatrix() - glTranslate(5, 5, 2) - glLineWidth(2) - glColor3f(0.5, 0, 0) - glBegin(GL_LINES) - glVertex3f(0, 0, 0) - glVertex3f(20, 0, 0) - glEnd() - glColor3f(0, 0.5, 0) - glBegin(GL_LINES) - glVertex3f(0, 0, 0) - glVertex3f(0, 20, 0) - glEnd() - glColor3f(0, 0, 0.5) - glBegin(GL_LINES) - glVertex3f(0, 0, 0) - glVertex3f(0, 0, 20) - glEnd() - - glDisable(GL_DEPTH_TEST) - #X - glColor3f(1, 0, 0) - glPushMatrix() - glTranslate(23, 0, 0) - noZ = ResetMatrixRotationAndScale() - glBegin(GL_LINES) - glVertex3f(-0.8, 1, 0) - glVertex3f(0.8, -1, 0) - glVertex3f(0.8, 1, 0) - glVertex3f(-0.8, -1, 0) - glEnd() - glPopMatrix() - - #Y - glColor3f(0, 1, 0) - glPushMatrix() - glTranslate(0, 23, 0) - ResetMatrixRotationAndScale() - glBegin(GL_LINES) - glVertex3f(-0.8, 1, 0) - glVertex3f(0.0, 0, 0) - glVertex3f(0.8, 1, 0) - glVertex3f(-0.8, -1, 0) - glEnd() - glPopMatrix() - - #Z - if not noZ: - glColor3f(0, 0, 1) - glPushMatrix() - glTranslate(0, 0, 23) - ResetMatrixRotationAndScale() - glBegin(GL_LINES) - glVertex3f(-0.8, 1, 0) - glVertex3f(0.8, 1, 0) - glVertex3f(0.8, 1, 0) - glVertex3f(-0.8, -1, 0) - glVertex3f(-0.8, -1, 0) - glVertex3f(0.8, -1, 0) - glEnd() - glPopMatrix() - - glPopMatrix() - glEnable(GL_DEPTH_TEST) - - -def ResetMatrixRotationAndScale(): - matrix = glGetFloatv(GL_MODELVIEW_MATRIX) - noZ = False - if matrix[3][2] > 0: - return False - scale2D = matrix[0][0] - matrix[0][0] = 1.0 - matrix[1][0] = 0.0 - matrix[2][0] = 0.0 - matrix[0][1] = 0.0 - matrix[1][1] = 1.0 - matrix[2][1] = 0.0 - matrix[0][2] = 0.0 - matrix[1][2] = 0.0 - matrix[2][2] = 1.0 - - if matrix[3][2] != 0.0: - matrix[3][0] = matrix[3][0] / (-matrix[3][2] / 100) - matrix[3][1] = matrix[3][1] / (-matrix[3][2] / 100) - matrix[3][2] = -100 - else: - matrix[0][0] = scale2D - matrix[1][1] = scale2D - matrix[2][2] = scale2D - matrix[3][2] = -100 - noZ = True - - glLoadMatrixf(matrix) - return noZ - - -def DrawBox(vMin, vMax): - glBegin(GL_LINE_LOOP) - glVertex3f(vMin[0], vMin[1], vMin[2]) - glVertex3f(vMax[0], vMin[1], vMin[2]) - glVertex3f(vMax[0], vMax[1], vMin[2]) - glVertex3f(vMin[0], vMax[1], vMin[2]) - glEnd() - - glBegin(GL_LINE_LOOP) - glVertex3f(vMin[0], vMin[1], vMax[2]) - glVertex3f(vMax[0], vMin[1], vMax[2]) - glVertex3f(vMax[0], vMax[1], vMax[2]) - glVertex3f(vMin[0], vMax[1], vMax[2]) - glEnd() - glBegin(GL_LINES) - glVertex3f(vMin[0], vMin[1], vMin[2]) - glVertex3f(vMin[0], vMin[1], vMax[2]) - glVertex3f(vMax[0], vMin[1], vMin[2]) - glVertex3f(vMax[0], vMin[1], vMax[2]) - glVertex3f(vMax[0], vMax[1], vMin[2]) - glVertex3f(vMax[0], vMax[1], vMax[2]) - glVertex3f(vMin[0], vMax[1], vMin[2]) - glVertex3f(vMin[0], vMax[1], vMax[2]) - glEnd() - - -def DrawMeshOutline(mesh): - glEnable(GL_CULL_FACE) - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, mesh.vertexes) - - glCullFace(GL_FRONT) - glLineWidth(3) - glPolygonMode(GL_BACK, GL_LINE) - glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount) - glPolygonMode(GL_BACK, GL_FILL) - glCullFace(GL_BACK) - - glDisableClientState(GL_VERTEX_ARRAY) - - -def DrawMesh(mesh): - glEnable(GL_CULL_FACE) - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, mesh.vertexes) - glNormalPointer(GL_FLOAT, 0, mesh.normal) - - #Odd, drawing in batchs is a LOT faster then drawing it all at once. - batchSize = 999 #Warning, batchSize needs to be dividable by 3 - extraStartPos = int(mesh.vertexCount / batchSize) * batchSize - extraCount = mesh.vertexCount - extraStartPos - - glCullFace(GL_BACK) - for i in xrange(0, int(mesh.vertexCount / batchSize)): - glDrawArrays(GL_TRIANGLES, i * batchSize, batchSize) - glDrawArrays(GL_TRIANGLES, extraStartPos, extraCount) - - glCullFace(GL_FRONT) - glNormalPointer(GL_FLOAT, 0, mesh.invNormal) - for i in xrange(0, int(mesh.vertexCount / batchSize)): - glDrawArrays(GL_TRIANGLES, i * batchSize, batchSize) - extraStartPos = int(mesh.vertexCount / batchSize) * batchSize - extraCount = mesh.vertexCount - extraStartPos - glDrawArrays(GL_TRIANGLES, extraStartPos, extraCount) - glCullFace(GL_BACK) - - glDisableClientState(GL_VERTEX_ARRAY) - glDisableClientState(GL_NORMAL_ARRAY); - - -def DrawGCodeLayer(layer): - filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2 - filamentArea = math.pi * filamentRadius * filamentRadius - lineWidth = profile.getProfileSettingFloat('nozzle_size') / 2 / 10 - - fillCycle = 0 - fillColorCycle = [[0.5, 0.5, 0.0], [0.0, 0.5, 0.5], [0.5, 0.0, 0.5]] - moveColor = [0, 0, 1] - retractColor = [1, 0, 0.5] - supportColor = [0, 1, 1] - extrudeColor = [1, 0, 0] - innerWallColor = [0, 1, 0] - skirtColor = [0, 0.5, 0.5] - prevPathWasRetract = False - - glDisable(GL_CULL_FACE) - for path in layer: - if path.type == 'move': - if prevPathWasRetract: - c = retractColor - else: - c = moveColor - zOffset = 0.01 - if path.type == 'extrude': - if path.pathType == 'FILL': - c = fillColorCycle[fillCycle] - fillCycle = (fillCycle + 1) % len(fillColorCycle) - elif path.pathType == 'WALL-INNER': - c = innerWallColor - zOffset = 0.02 - elif path.pathType == 'SUPPORT': - c = supportColor - elif path.pathType == 'SKIRT': - c = skirtColor - else: - c = extrudeColor - if path.type == 'retract': - c = [0, 1, 1] - if path.type == 'extrude': - drawLength = 0.0 - prevNormal = None - for i in xrange(0, len(path.list) - 1): - v0 = path.list[i] - v1 = path.list[i + 1] - - # Calculate line width from ePerDistance (needs layer thickness and filament diameter) - dist = (v0 - v1).vsize() - if dist > 0 and path.layerThickness > 0: - extrusionMMperDist = (v1.e - v0.e) / dist - lineWidth = extrusionMMperDist * filamentArea / path.layerThickness / 2 * v1.extrudeAmountMultiply - - drawLength += (v0 - v1).vsize() - normal = (v0 - v1).cross(util3d.Vector3(0, 0, 1)) - normal.normalize() - - vv2 = v0 + normal * lineWidth - vv3 = v1 + normal * lineWidth - vv0 = v0 - normal * lineWidth - vv1 = v1 - normal * lineWidth - - glBegin(GL_QUADS) - glColor3fv(c) - glVertex3f(vv0.x, vv0.y, vv0.z - zOffset) - glVertex3f(vv1.x, vv1.y, vv1.z - zOffset) - glVertex3f(vv3.x, vv3.y, vv3.z - zOffset) - glVertex3f(vv2.x, vv2.y, vv2.z - zOffset) - glEnd() - if prevNormal != None: - n = (normal + prevNormal) - n.normalize() - vv4 = v0 + n * lineWidth - vv5 = v0 - n * lineWidth - glBegin(GL_QUADS) - glColor3fv(c) - glVertex3f(vv2.x, vv2.y, vv2.z - zOffset) - glVertex3f(vv4.x, vv4.y, vv4.z - zOffset) - glVertex3f(prevVv3.x, prevVv3.y, prevVv3.z - zOffset) - glVertex3f(v0.x, v0.y, v0.z - zOffset) - - glVertex3f(vv0.x, vv0.y, vv0.z - zOffset) - glVertex3f(vv5.x, vv5.y, vv5.z - zOffset) - glVertex3f(prevVv1.x, prevVv1.y, prevVv1.z - zOffset) - glVertex3f(v0.x, v0.y, v0.z - zOffset) - glEnd() - - prevNormal = normal - prevVv1 = vv1 - prevVv3 = vv3 - else: - glBegin(GL_LINE_STRIP) - glColor3fv(c) - for v in path.list: - glVertex3f(v.x, v.y, v.z) - glEnd() - if not path.type == 'move': - prevPathWasRetract = False - if path.type == 'retract' and path.list[0].almostEqual(path.list[-1]): - prevPathWasRetract = True - glEnable(GL_CULL_FACE) +# coding=utf-8 +from __future__ import absolute_import + +import math + +from util import meshLoader +from util import util3d +from util import profile +from util.resources import getPathForMesh + +try: + import OpenGL + + OpenGL.ERROR_CHECKING = False + from OpenGL.GLU import * + from OpenGL.GL import * + + hasOpenGLlibs = True +except: + print "Failed to find PyOpenGL: http://pyopengl.sourceforge.net/" + hasOpenGLlibs = False + +def InitGL(window, view3D, zoom): + # set viewing projection + glMatrixMode(GL_MODELVIEW) + glLoadIdentity() + size = window.GetSize() + glViewport(0, 0, size.GetWidth(), size.GetHeight()) + + glLightfv(GL_LIGHT0, GL_POSITION, [0.2, 0.2, 1.0, 0.0]) + glLightfv(GL_LIGHT1, GL_POSITION, [1.0, 1.0, 1.0, 0.0]) + + glEnable(GL_RESCALE_NORMAL) + glEnable(GL_LIGHTING) + glEnable(GL_LIGHT0) + glEnable(GL_DEPTH_TEST) + glEnable(GL_CULL_FACE) + glDisable(GL_BLEND) + + glClearColor(1.0, 1.0, 1.0, 1.0) + glClearStencil(0) + glClearDepth(1.0) + + glMatrixMode(GL_PROJECTION) + glLoadIdentity() + aspect = float(size.GetWidth()) / float(size.GetHeight()) + if view3D: + gluPerspective(45.0, aspect, 1.0, 1000.0) + else: + glOrtho(-aspect * (zoom), aspect * (zoom), -1.0 * (zoom), 1.0 * (zoom), -1000.0, 1000.0) + + glMatrixMode(GL_MODELVIEW) + glLoadIdentity() + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) + +platformMesh = None + +def DrawMachine(machineSize): + if profile.getPreference('machine_type') == 'ultimaker': + glPushMatrix() + glEnable(GL_LIGHTING) + glTranslate(100, 200, -5) + glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.8, 0.8, 0.8]) + glLightfv(GL_LIGHT0, GL_AMBIENT, [0.5, 0.5, 0.5]) + glEnable(GL_BLEND) + glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) + + global platformMesh + if platformMesh == None: + platformMesh = meshLoader.loadMesh(getPathForMesh('ultimaker_platform.stl')) + platformMesh.setRotateMirror(0, False, False, False, False, False) + + DrawMesh(platformMesh) + glPopMatrix() + + glDisable(GL_LIGHTING) + if False: + glColor3f(0.7, 0.7, 0.7) + glLineWidth(2) + glBegin(GL_LINES) + for i in xrange(0, int(machineSize.x), 10): + glVertex3f(i, 0, 0) + glVertex3f(i, machineSize.y, 0) + for i in xrange(0, int(machineSize.y), 10): + glVertex3f(0, i, 0) + glVertex3f(machineSize.x, i, 0) + glEnd() + + glEnable(GL_LINE_SMOOTH) + glEnable(GL_BLEND) + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) + glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); + + glColor3f(0.0, 0.0, 0.0) + glLineWidth(4) + glBegin(GL_LINE_LOOP) + glVertex3f(0, 0, 0) + glVertex3f(machineSize.x, 0, 0) + glVertex3f(machineSize.x, machineSize.y, 0) + glVertex3f(0, machineSize.y, 0) + glEnd() + + glLineWidth(2) + glBegin(GL_LINE_LOOP) + glVertex3f(0, 0, machineSize.z) + glVertex3f(machineSize.x, 0, machineSize.z) + glVertex3f(machineSize.x, machineSize.y, machineSize.z) + glVertex3f(0, machineSize.y, machineSize.z) + glEnd() + glBegin(GL_LINES) + glVertex3f(0, 0, 0) + glVertex3f(0, 0, machineSize.z) + glVertex3f(machineSize.x, 0, 0) + glVertex3f(machineSize.x, 0, machineSize.z) + glVertex3f(machineSize.x, machineSize.y, 0) + glVertex3f(machineSize.x, machineSize.y, machineSize.z) + glVertex3f(0, machineSize.y, 0) + glVertex3f(0, machineSize.y, machineSize.z) + glEnd() + else: + glDisable(GL_CULL_FACE) + glEnable(GL_BLEND) + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) + glColor4ub(5, 171, 231, 127) + glBegin(GL_QUADS) + for x in xrange(0, int(machineSize.x), 20): + for y in xrange(0, int(machineSize.y), 20): + glVertex3f(x, y, -0.01) + glVertex3f(min(x + 10, machineSize.x), y, -0.01) + glVertex3f(min(x + 10, machineSize.x), min(y + 10, machineSize.y), -0.01) + glVertex3f(x, min(y + 10, machineSize.y), -0.01) + for x in xrange(10, int(machineSize.x), 20): + for y in xrange(10, int(machineSize.y), 20): + glVertex3f(x, y, -0.01) + glVertex3f(min(x + 10, machineSize.x), y, -0.01) + glVertex3f(min(x + 10, machineSize.x), min(y + 10, machineSize.y), -0.01) + glVertex3f(x, min(y + 10, machineSize.y), -0.01) + glEnd() + glColor4ub(5 * 8 / 10, 171 * 8 / 10, 231 * 8 / 10, 128) + glBegin(GL_QUADS) + for x in xrange(10, int(machineSize.x), 20): + for y in xrange(0, int(machineSize.y), 20): + glVertex3f(x, y, -0.01) + glVertex3f(min(x + 10, machineSize.x), y, -0.01) + glVertex3f(min(x + 10, machineSize.x), min(y + 10, machineSize.y), -0.01) + glVertex3f(x, min(y + 10, machineSize.y), -0.01) + for x in xrange(0, int(machineSize.x), 20): + for y in xrange(10, int(machineSize.y), 20): + glVertex3f(x, y, -0.01) + glVertex3f(min(x + 10, machineSize.x), y, -0.01) + glVertex3f(min(x + 10, machineSize.x), min(y + 10, machineSize.y), -0.01) + glVertex3f(x, min(y + 10, machineSize.y), -0.01) + glEnd() + glEnable(GL_CULL_FACE) + + glColor4ub(5, 171, 231, 64) + glBegin(GL_QUADS) + glVertex3f(0, 0, machineSize.z) + glVertex3f(0, machineSize.y, machineSize.z) + glVertex3f(machineSize.x, machineSize.y, machineSize.z) + glVertex3f(machineSize.x, 0, machineSize.z) + glEnd() + + glColor4ub(5, 171, 231, 96) + glBegin(GL_QUADS) + glVertex3f(0, 0, 0) + glVertex3f(0, 0, machineSize.z) + glVertex3f(machineSize.x, 0, machineSize.z) + glVertex3f(machineSize.x, 0, 0) + + glVertex3f(0, machineSize.y, machineSize.z) + glVertex3f(0, machineSize.y, 0) + glVertex3f(machineSize.x, machineSize.y, 0) + glVertex3f(machineSize.x, machineSize.y, machineSize.z) + glEnd() + + glColor4ub(5, 171, 231, 128) + glBegin(GL_QUADS) + glVertex3f(0, 0, machineSize.z) + glVertex3f(0, 0, 0) + glVertex3f(0, machineSize.y, 0) + glVertex3f(0, machineSize.y, machineSize.z) + + glVertex3f(machineSize.x, 0, 0) + glVertex3f(machineSize.x, 0, machineSize.z) + glVertex3f(machineSize.x, machineSize.y, machineSize.z) + glVertex3f(machineSize.x, machineSize.y, 0) + glEnd() + + glDisable(GL_BLEND) + + glPushMatrix() + glTranslate(5, 5, 2) + glLineWidth(2) + glColor3f(0.5, 0, 0) + glBegin(GL_LINES) + glVertex3f(0, 0, 0) + glVertex3f(20, 0, 0) + glEnd() + glColor3f(0, 0.5, 0) + glBegin(GL_LINES) + glVertex3f(0, 0, 0) + glVertex3f(0, 20, 0) + glEnd() + glColor3f(0, 0, 0.5) + glBegin(GL_LINES) + glVertex3f(0, 0, 0) + glVertex3f(0, 0, 20) + glEnd() + + glDisable(GL_DEPTH_TEST) + #X + glColor3f(1, 0, 0) + glPushMatrix() + glTranslate(23, 0, 0) + noZ = ResetMatrixRotationAndScale() + glBegin(GL_LINES) + glVertex3f(-0.8, 1, 0) + glVertex3f(0.8, -1, 0) + glVertex3f(0.8, 1, 0) + glVertex3f(-0.8, -1, 0) + glEnd() + glPopMatrix() + + #Y + glColor3f(0, 1, 0) + glPushMatrix() + glTranslate(0, 23, 0) + ResetMatrixRotationAndScale() + glBegin(GL_LINES) + glVertex3f(-0.8, 1, 0) + glVertex3f(0.0, 0, 0) + glVertex3f(0.8, 1, 0) + glVertex3f(-0.8, -1, 0) + glEnd() + glPopMatrix() + + #Z + if not noZ: + glColor3f(0, 0, 1) + glPushMatrix() + glTranslate(0, 0, 23) + ResetMatrixRotationAndScale() + glBegin(GL_LINES) + glVertex3f(-0.8, 1, 0) + glVertex3f(0.8, 1, 0) + glVertex3f(0.8, 1, 0) + glVertex3f(-0.8, -1, 0) + glVertex3f(-0.8, -1, 0) + glVertex3f(0.8, -1, 0) + glEnd() + glPopMatrix() + + glPopMatrix() + glEnable(GL_DEPTH_TEST) + + +def ResetMatrixRotationAndScale(): + matrix = glGetFloatv(GL_MODELVIEW_MATRIX) + noZ = False + if matrix[3][2] > 0: + return False + scale2D = matrix[0][0] + matrix[0][0] = 1.0 + matrix[1][0] = 0.0 + matrix[2][0] = 0.0 + matrix[0][1] = 0.0 + matrix[1][1] = 1.0 + matrix[2][1] = 0.0 + matrix[0][2] = 0.0 + matrix[1][2] = 0.0 + matrix[2][2] = 1.0 + + if matrix[3][2] != 0.0: + matrix[3][0] = matrix[3][0] / (-matrix[3][2] / 100) + matrix[3][1] = matrix[3][1] / (-matrix[3][2] / 100) + matrix[3][2] = -100 + else: + matrix[0][0] = scale2D + matrix[1][1] = scale2D + matrix[2][2] = scale2D + matrix[3][2] = -100 + noZ = True + + glLoadMatrixf(matrix) + return noZ + + +def DrawBox(vMin, vMax): + glBegin(GL_LINE_LOOP) + glVertex3f(vMin[0], vMin[1], vMin[2]) + glVertex3f(vMax[0], vMin[1], vMin[2]) + glVertex3f(vMax[0], vMax[1], vMin[2]) + glVertex3f(vMin[0], vMax[1], vMin[2]) + glEnd() + + glBegin(GL_LINE_LOOP) + glVertex3f(vMin[0], vMin[1], vMax[2]) + glVertex3f(vMax[0], vMin[1], vMax[2]) + glVertex3f(vMax[0], vMax[1], vMax[2]) + glVertex3f(vMin[0], vMax[1], vMax[2]) + glEnd() + glBegin(GL_LINES) + glVertex3f(vMin[0], vMin[1], vMin[2]) + glVertex3f(vMin[0], vMin[1], vMax[2]) + glVertex3f(vMax[0], vMin[1], vMin[2]) + glVertex3f(vMax[0], vMin[1], vMax[2]) + glVertex3f(vMax[0], vMax[1], vMin[2]) + glVertex3f(vMax[0], vMax[1], vMax[2]) + glVertex3f(vMin[0], vMax[1], vMin[2]) + glVertex3f(vMin[0], vMax[1], vMax[2]) + glEnd() + + +def DrawMeshOutline(mesh): + glEnable(GL_CULL_FACE) + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, mesh.vertexes) + + glCullFace(GL_FRONT) + glLineWidth(3) + glPolygonMode(GL_BACK, GL_LINE) + glDrawArrays(GL_TRIANGLES, 0, mesh.vertexCount) + glPolygonMode(GL_BACK, GL_FILL) + glCullFace(GL_BACK) + + glDisableClientState(GL_VERTEX_ARRAY) + + +def DrawMesh(mesh): + glEnable(GL_CULL_FACE) + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, mesh.vertexes) + glNormalPointer(GL_FLOAT, 0, mesh.normal) + + #Odd, drawing in batchs is a LOT faster then drawing it all at once. + batchSize = 999 #Warning, batchSize needs to be dividable by 3 + extraStartPos = int(mesh.vertexCount / batchSize) * batchSize + extraCount = mesh.vertexCount - extraStartPos + + glCullFace(GL_BACK) + for i in xrange(0, int(mesh.vertexCount / batchSize)): + glDrawArrays(GL_TRIANGLES, i * batchSize, batchSize) + glDrawArrays(GL_TRIANGLES, extraStartPos, extraCount) + + glCullFace(GL_FRONT) + glNormalPointer(GL_FLOAT, 0, mesh.invNormal) + for i in xrange(0, int(mesh.vertexCount / batchSize)): + glDrawArrays(GL_TRIANGLES, i * batchSize, batchSize) + extraStartPos = int(mesh.vertexCount / batchSize) * batchSize + extraCount = mesh.vertexCount - extraStartPos + glDrawArrays(GL_TRIANGLES, extraStartPos, extraCount) + glCullFace(GL_BACK) + + glDisableClientState(GL_VERTEX_ARRAY) + glDisableClientState(GL_NORMAL_ARRAY); + + +def DrawMeshSteep(mesh, angle): + cosAngle = math.sin(angle / 180.0 * math.pi) + glDisable(GL_LIGHTING) + glDepthFunc(GL_EQUAL) + for i in xrange(0, int(mesh.vertexCount), 3): + if mesh.normal[i][2] < -0.999999: + if mesh.vertexes[i + 0][2] > 0.01: + glColor3f(0.5, 0, 0) + glBegin(GL_TRIANGLES) + glVertex3f(mesh.vertexes[i + 0][0], mesh.vertexes[i + 0][1], mesh.vertexes[i + 0][2]) + glVertex3f(mesh.vertexes[i + 1][0], mesh.vertexes[i + 1][1], mesh.vertexes[i + 1][2]) + glVertex3f(mesh.vertexes[i + 2][0], mesh.vertexes[i + 2][1], mesh.vertexes[i + 2][2]) + glEnd() + elif mesh.normal[i][2] < -cosAngle: + glColor3f(-mesh.normal[i][2], 0, 0) + glBegin(GL_TRIANGLES) + glVertex3f(mesh.vertexes[i + 0][0], mesh.vertexes[i + 0][1], mesh.vertexes[i + 0][2]) + glVertex3f(mesh.vertexes[i + 1][0], mesh.vertexes[i + 1][1], mesh.vertexes[i + 1][2]) + glVertex3f(mesh.vertexes[i + 2][0], mesh.vertexes[i + 2][1], mesh.vertexes[i + 2][2]) + glEnd() + elif mesh.normal[i][2] > 0.999999: + if mesh.vertexes[i + 0][2] > 0.01: + glColor3f(0.5, 0, 0) + glBegin(GL_TRIANGLES) + glVertex3f(mesh.vertexes[i + 0][0], mesh.vertexes[i + 0][1], mesh.vertexes[i + 0][2]) + glVertex3f(mesh.vertexes[i + 2][0], mesh.vertexes[i + 2][1], mesh.vertexes[i + 2][2]) + glVertex3f(mesh.vertexes[i + 1][0], mesh.vertexes[i + 1][1], mesh.vertexes[i + 1][2]) + glEnd() + elif mesh.normal[i][2] > cosAngle: + glColor3f(mesh.normal[i][2], 0, 0) + glBegin(GL_TRIANGLES) + glVertex3f(mesh.vertexes[i + 0][0], mesh.vertexes[i + 0][1], mesh.vertexes[i + 0][2]) + glVertex3f(mesh.vertexes[i + 2][0], mesh.vertexes[i + 2][1], mesh.vertexes[i + 2][2]) + glVertex3f(mesh.vertexes[i + 1][0], mesh.vertexes[i + 1][1], mesh.vertexes[i + 1][2]) + glEnd() + glDepthFunc(GL_LESS) + + +def DrawGCodeLayer(layer): + filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2 + filamentArea = math.pi * filamentRadius * filamentRadius + lineWidth = profile.getProfileSettingFloat('nozzle_size') / 2 / 10 + + fillCycle = 0 + fillColorCycle = [[0.5, 0.5, 0.0], [0.0, 0.5, 0.5], [0.5, 0.0, 0.5]] + moveColor = [0, 0, 1] + retractColor = [1, 0, 0.5] + supportColor = [0, 1, 1] + extrudeColor = [1, 0, 0] + innerWallColor = [0, 1, 0] + skirtColor = [0, 0.5, 0.5] + prevPathWasRetract = False + + glDisable(GL_CULL_FACE) + for path in layer: + if path.type == 'move': + if prevPathWasRetract: + c = retractColor + else: + c = moveColor + zOffset = 0.01 + if path.type == 'extrude': + if path.pathType == 'FILL': + c = fillColorCycle[fillCycle] + fillCycle = (fillCycle + 1) % len(fillColorCycle) + elif path.pathType == 'WALL-INNER': + c = innerWallColor + zOffset = 0.02 + elif path.pathType == 'SUPPORT': + c = supportColor + elif path.pathType == 'SKIRT': + c = skirtColor + else: + c = extrudeColor + if path.type == 'retract': + c = [0, 1, 1] + if path.type == 'extrude': + drawLength = 0.0 + prevNormal = None + for i in xrange(0, len(path.list) - 1): + v0 = path.list[i] + v1 = path.list[i + 1] + + # Calculate line width from ePerDistance (needs layer thickness and filament diameter) + dist = (v0 - v1).vsize() + if dist > 0 and path.layerThickness > 0: + extrusionMMperDist = (v1.e - v0.e) / dist + lineWidth = extrusionMMperDist * filamentArea / path.layerThickness / 2 * v1.extrudeAmountMultiply + + drawLength += (v0 - v1).vsize() + normal = (v0 - v1).cross(util3d.Vector3(0, 0, 1)) + normal.normalize() + + vv2 = v0 + normal * lineWidth + vv3 = v1 + normal * lineWidth + vv0 = v0 - normal * lineWidth + vv1 = v1 - normal * lineWidth + + glBegin(GL_QUADS) + glColor3fv(c) + glVertex3f(vv0.x, vv0.y, vv0.z - zOffset) + glVertex3f(vv1.x, vv1.y, vv1.z - zOffset) + glVertex3f(vv3.x, vv3.y, vv3.z - zOffset) + glVertex3f(vv2.x, vv2.y, vv2.z - zOffset) + glEnd() + if prevNormal != None: + n = (normal + prevNormal) + n.normalize() + vv4 = v0 + n * lineWidth + vv5 = v0 - n * lineWidth + glBegin(GL_QUADS) + glColor3fv(c) + glVertex3f(vv2.x, vv2.y, vv2.z - zOffset) + glVertex3f(vv4.x, vv4.y, vv4.z - zOffset) + glVertex3f(prevVv3.x, prevVv3.y, prevVv3.z - zOffset) + glVertex3f(v0.x, v0.y, v0.z - zOffset) + + glVertex3f(vv0.x, vv0.y, vv0.z - zOffset) + glVertex3f(vv5.x, vv5.y, vv5.z - zOffset) + glVertex3f(prevVv1.x, prevVv1.y, prevVv1.z - zOffset) + glVertex3f(v0.x, v0.y, v0.z - zOffset) + glEnd() + + prevNormal = normal + prevVv1 = vv1 + prevVv3 = vv3 + else: + glBegin(GL_LINE_STRIP) + glColor3fv(c) + for v in path.list: + glVertex3f(v.x, v.y, v.z) + glEnd() + if not path.type == 'move': + prevPathWasRetract = False + if path.type == 'retract' and path.list[0].almostEqual(path.list[-1]): + prevPathWasRetract = True + glEnable(GL_CULL_FACE) diff --git a/Cura/gui/pluginPanel.py b/Cura/gui/pluginPanel.py index 5b9969d..204693a 100644 --- a/Cura/gui/pluginPanel.py +++ b/Cura/gui/pluginPanel.py @@ -3,6 +3,7 @@ import sys, math, threading, os, webbrowser from wx.lib import scrolledpanel from util import profile +from util import exporer class pluginPanel(wx.Panel): def __init__(self, parent): @@ -20,19 +21,23 @@ class pluginPanel(wx.Panel): self.listbox = wx.ListBox(self, -1, choices=effectStringList) title = wx.StaticText(self, -1, "Plugins:") title.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)) + helpButton = wx.Button(self, -1, '?', style=wx.BU_EXACTFIT) addButton = wx.Button(self, -1, '>', style=wx.BU_EXACTFIT) + openPluginLocationButton = wx.Button(self, -1, 'Open plugin location') sb = wx.StaticBox(self, label="Enabled plugins") boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) self.pluginEnabledPanel = scrolledpanel.ScrolledPanel(self) self.pluginEnabledPanel.SetupScrolling(False, True) sizer.Add(title, (0,0), border=10, flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.TOP) - sizer.Add(self.listbox, (1,0), span=(2,1), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM) - sizer.Add(addButton, (1,1), border=5, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_BOTTOM) - sizer.Add(boxsizer, (1,2), span=(2,1), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM) + sizer.Add(helpButton, (0,1), border=10, flag=wx.ALIGN_RIGHT|wx.RIGHT|wx.TOP) + sizer.Add(self.listbox, (1,0), span=(2,2), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT) + sizer.Add(addButton, (1,2), border=5, flag=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_BOTTOM) + sizer.Add(boxsizer, (1,3), span=(2,1), border=10, flag=wx.EXPAND|wx.LEFT|wx.RIGHT) + sizer.Add(openPluginLocationButton, (3, 0), span=(1,2), border=10, flag=wx.LEFT|wx.BOTTOM) boxsizer.Add(self.pluginEnabledPanel, 1, flag=wx.EXPAND) - sizer.AddGrowableCol(2) + sizer.AddGrowableCol(3) sizer.AddGrowableRow(1) sizer.AddGrowableRow(2) @@ -40,6 +45,9 @@ class pluginPanel(wx.Panel): self.pluginEnabledPanel.SetSizer(sizer) self.Bind(wx.EVT_BUTTON, self.OnAdd, addButton) + self.Bind(wx.EVT_BUTTON, self.OnGeneralHelp, helpButton) + self.Bind(wx.EVT_BUTTON, self.OnOpenPluginLocation, openPluginLocationButton) + self.listbox.Bind(wx.EVT_LEFT_DCLICK, self.OnAdd) self.panelList = [] self.updateProfileToControls() @@ -151,3 +159,9 @@ class pluginPanel(wx.Panel): fname = fname[0].upper() + fname[1:] fname = fname[:fname.rfind('.')] webbrowser.open('http://wiki.ultimaker.com/CuraPlugin:_' + fname) + + def OnGeneralHelp(self, e): + webbrowser.open('http://wiki.ultimaker.com/Category:CuraPlugin') + + def OnOpenPluginLocation(self, e): + exporer.openExporerPath(profile.getPluginBasePaths()[0]) diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index fcd1fbb..da41b3e 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -22,11 +22,11 @@ class preferencesDialog(configBase.configWindowBase): configBase.TitleRow(left, 'Machine settings') c = configBase.SettingRow(left, 'Steps per E', 'steps_per_e', '0', 'Amount of steps per mm filament extrusion', type = 'preference') validators.validFloat(c, 0.1) - c = configBase.SettingRow(left, 'Machine width (mm)', 'machine_width', '205', 'Size of the machine in mm', type = 'preference') + c = configBase.SettingRow(left, 'Maximum width (mm)', 'machine_width', '205', 'Size of the machine in mm', type = 'preference') validators.validFloat(c, 10.0) - c = configBase.SettingRow(left, 'Machine depth (mm)', 'machine_depth', '205', 'Size of the machine in mm', type = 'preference') + c = configBase.SettingRow(left, 'Maximum depth (mm)', 'machine_depth', '205', 'Size of the machine in mm', type = 'preference') validators.validFloat(c, 10.0) - c = configBase.SettingRow(left, 'Machine height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference') + c = configBase.SettingRow(left, 'Maximum height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference') validators.validFloat(c, 10.0) c = configBase.SettingRow(left, 'Extruder count', 'extruder_amount', ['1', '2', '3', '4'], 'Amount of extruders in your machine.', type = 'preference') c = configBase.SettingRow(left, 'Heated bed', 'has_heated_bed', False, 'If you have an heated bed, this enabled heated bed settings', type = 'preference') @@ -44,11 +44,11 @@ class preferencesDialog(configBase.configWindowBase): c = configBase.SettingRow(left, 'Model colour (%d)' % (i+1), 'model_colour%d' % (i+1), wx.Colour(0,0,0), '', type = 'preference') configBase.TitleRow(right, 'Filament settings') - c = configBase.SettingRow(right, 'Filament density (kg/m3)', 'filament_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference') + c = configBase.SettingRow(right, 'Density (kg/m3)', 'filament_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference') validators.validFloat(c, 500.0, 3000.0) - c = configBase.SettingRow(right, 'Filament cost (price/kg)', 'filament_cost_kg', '0', 'Cost of your filament per kg, to estimate the cost of the final print.', type = 'preference') + c = configBase.SettingRow(right, 'Cost (price/kg)', 'filament_cost_kg', '0', 'Cost of your filament per kg, to estimate the cost of the final print.', type = 'preference') validators.validFloat(c, 0.0) - c = configBase.SettingRow(right, 'Filament cost (price/m)', 'filament_cost_meter', '0', 'Cost of your filament per meter, to estimate the cost of the final print.', type = 'preference') + c = configBase.SettingRow(right, 'Cost (price/m)', 'filament_cost_meter', '0', 'Cost of your filament per meter, to estimate the cost of the final print.', type = 'preference') validators.validFloat(c, 0.0) configBase.TitleRow(right, 'Communication settings') diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index fb9df64..c830711 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -43,9 +43,10 @@ class previewPanel(wx.Panel): self.gcode = None self.objectsMinV = None self.objectsMaxV = None + self.objectsBounderyCircleSize = None self.loadThread = None self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')) - self.machineCenter = util3d.Vector3(float(profile.getProfileSetting('machine_center_x')), float(profile.getProfileSetting('machine_center_y')), 0) + self.machineCenter = util3d.Vector3(self.machineSize.x / 2, self.machineSize.y / 2, 0) self.glCanvas = PreviewGLCanvas(self) #Create the popup window @@ -77,6 +78,7 @@ class previewPanel(wx.Panel): self.toolbar.AddSeparator() self.showBorderButton = toolbarUtil.ToggleButton(self.toolbar, '', 'view-border-on.png', 'view-border-off.png', 'Show model borders', callback=self.OnViewChange) + self.showSteepOverhang = toolbarUtil.ToggleButton(self.toolbar, '', 'steepOverhang-on.png', 'steepOverhang-off.png', 'Show steep overhang', callback=self.OnViewChange) self.toolbar.AddSeparator() group = [] @@ -90,18 +92,21 @@ class previewPanel(wx.Panel): self.layerSpin = wx.SpinCtrl(self.toolbar, -1, '', size=(21*4,21), style=wx.SP_ARROW_KEYS) self.toolbar.AddControl(self.layerSpin) self.Bind(wx.EVT_SPINCTRL, self.OnLayerNrChange, self.layerSpin) + self.toolbar.AddSeparator() + self.toolbarInfo = wx.TextCtrl(self.toolbar, -1, '', style=wx.TE_READONLY) + self.toolbar.AddControl(self.toolbarInfo) self.toolbar2 = toolbarUtil.Toolbar(self) # Mirror - self.mirrorX = toolbarUtil.ToggleButton(self.toolbar2, 'flip_x', 'object-mirror-x-on.png', 'object-mirror-x-off.png', 'Mirror X', callback=self.updateModelTransform) - self.mirrorY = toolbarUtil.ToggleButton(self.toolbar2, 'flip_y', 'object-mirror-y-on.png', 'object-mirror-y-off.png', 'Mirror Y', callback=self.updateModelTransform) - self.mirrorZ = toolbarUtil.ToggleButton(self.toolbar2, 'flip_z', 'object-mirror-z-on.png', 'object-mirror-z-off.png', 'Mirror Z', callback=self.updateModelTransform) + self.mirrorX = toolbarUtil.ToggleButton(self.toolbar2, 'flip_x', 'object-mirror-x-on.png', 'object-mirror-x-off.png', 'Mirror X', callback=self.returnToModelViewAndUpdateModel) + self.mirrorY = toolbarUtil.ToggleButton(self.toolbar2, 'flip_y', 'object-mirror-y-on.png', 'object-mirror-y-off.png', 'Mirror Y', callback=self.returnToModelViewAndUpdateModel) + self.mirrorZ = toolbarUtil.ToggleButton(self.toolbar2, 'flip_z', 'object-mirror-z-on.png', 'object-mirror-z-off.png', 'Mirror Z', callback=self.returnToModelViewAndUpdateModel) self.toolbar2.AddSeparator() # Swap - self.swapXZ = toolbarUtil.ToggleButton(self.toolbar2, 'swap_xz', 'object-swap-xz-on.png', 'object-swap-xz-off.png', 'Swap XZ', callback=self.updateModelTransform) - self.swapYZ = toolbarUtil.ToggleButton(self.toolbar2, 'swap_yz', 'object-swap-yz-on.png', 'object-swap-yz-off.png', 'Swap YZ', callback=self.updateModelTransform) + self.swapXZ = toolbarUtil.ToggleButton(self.toolbar2, 'swap_xz', 'object-swap-xz-on.png', 'object-swap-xz-off.png', 'Swap XZ', callback=self.returnToModelViewAndUpdateModel) + self.swapYZ = toolbarUtil.ToggleButton(self.toolbar2, 'swap_yz', 'object-swap-yz-on.png', 'object-swap-yz-off.png', 'Swap YZ', callback=self.returnToModelViewAndUpdateModel) self.toolbar2.AddSeparator() # Scale @@ -136,6 +141,11 @@ class previewPanel(wx.Panel): sizer.Add(self.toolbar2, 0, flag=wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=1) self.SetSizer(sizer) + def returnToModelViewAndUpdateModel(self): + if self.glCanvas.viewMode == 'GCode' or self.glCanvas.viewMode == 'Mixed': + self.setViewMode('Normal') + self.updateModelTransform() + def OnMove(self, e = None): if e != None: e.Skip() @@ -168,21 +178,34 @@ class previewPanel(wx.Panel): if self.scale.GetValue() != '': scale = self.scale.GetValue() profile.putProfileSetting('model_scale', scale) + if self.glCanvas.viewMode == 'GCode' or self.glCanvas.viewMode == 'Mixed': + self.setViewMode('Normal') self.glCanvas.Refresh() - - def OnScaleMax(self, e): + + if self.objectsMaxV != None: + size = (self.objectsMaxV - self.objectsMinV) * float(scale) + self.toolbarInfo.SetValue('%0.1f %0.1f %0.1f' % (size[0], size[1], size[2])) + + def OnScaleMax(self, e = None, onlyScaleDown = False): if self.objectsMinV == None: return vMin = self.objectsMinV vMax = self.objectsMaxV - scaleX1 = (self.machineSize.x - self.machineCenter.x) / ((vMax[0] - vMin[0]) / 2) - scaleY1 = (self.machineSize.y - self.machineCenter.y) / ((vMax[1] - vMin[1]) / 2) - scaleX2 = (self.machineCenter.x) / ((vMax[0] - vMin[0]) / 2) - scaleY2 = (self.machineCenter.y) / ((vMax[1] - vMin[1]) / 2) + skirtSize = 3 + if profile.getProfileSettingFloat('skirt_line_count') > 0: + skirtSize = 3 + profile.getProfileSettingFloat('skirt_line_count') * profile.calculateEdgeWidth() + profile.getProfileSettingFloat('skirt_gap') + scaleX1 = (self.machineSize.x - self.machineCenter.x - skirtSize) / ((vMax[0] - vMin[0]) / 2) + scaleY1 = (self.machineSize.y - self.machineCenter.y - skirtSize) / ((vMax[1] - vMin[1]) / 2) + scaleX2 = (self.machineCenter.x - skirtSize) / ((vMax[0] - vMin[0]) / 2) + scaleY2 = (self.machineCenter.y - skirtSize) / ((vMax[1] - vMin[1]) / 2) scaleZ = self.machineSize.z / (vMax[2] - vMin[2]) scale = min(scaleX1, scaleY1, scaleX2, scaleY2, scaleZ) + if scale > 1.0 and onlyScaleDown: + return self.scale.SetValue(str(scale)) profile.putProfileSetting('model_scale', self.scale.GetValue()) + if self.glCanvas.viewMode == 'GCode' or self.glCanvas.viewMode == 'Mixed': + self.setViewMode('Normal') self.glCanvas.Refresh() def OnRotateReset(self, e): @@ -191,7 +214,7 @@ class previewPanel(wx.Panel): def OnRotate(self, e): profile.putProfileSetting('model_rotate_base', self.rotate.GetValue()) - self.updateModelTransform() + self.returnToModelViewAndUpdateModel() def On3DClick(self): self.glCanvas.yaw = 30 @@ -209,14 +232,6 @@ class previewPanel(wx.Panel): def OnLayerNrChange(self, e): self.glCanvas.Refresh() - - def updateCenterX(self): - self.machineCenter.x = profile.getProfileSettingFloat('machine_center_x') - self.glCanvas.Refresh() - - def updateCenterY(self): - self.machineCenter.y = profile.getProfileSettingFloat('machine_center_y') - self.glCanvas.Refresh() def setViewMode(self, mode): if mode == "Normal": @@ -249,8 +264,8 @@ class previewPanel(wx.Panel): self.loadThread.start() if showWarning: - if profile.getProfileSettingFloat('model_scale') != 1.0 or profile.getProfileSettingFloat('model_rotate_base') != 0 or profile.getProfileSetting('flip_x') != 'False' or profile.getProfileSetting('flip_y') != 'False' or profile.getProfileSetting('flip_z') != 'False' or profile.getProfileSetting('swap_xz') != 'False' or profile.getProfileSetting('swap_yz') != 'False': - self.ShowWarningPopup('Reset scale, rotation and mirror?', self.OnResetAll) + if profile.getProfileSettingFloat('model_scale') != 1.0 or profile.getProfileSettingFloat('model_rotate_base') != 0 or profile.getProfileSetting('flip_x') != 'False' or profile.getProfileSetting('flip_y') != 'False' or profile.getProfileSetting('flip_z') != 'False' or profile.getProfileSetting('swap_xz') != 'False' or profile.getProfileSetting('swap_yz') != 'False' or len(profile.getPluginConfig()) > 0: + self.ShowWarningPopup('Reset scale, rotation, mirror and plugins?', self.OnResetAll) def loadReModelFiles(self, filelist): #Only load this again if the filename matches the file we have already loaded (for auto loading GCode after slicing) @@ -268,10 +283,10 @@ class previewPanel(wx.Panel): obj.dirty = False obj.mesh = mesh self.updateModelTransform() + self.OnScaleMax(None, True) scale = profile.getProfileSettingFloat('model_scale') size = (self.objectsMaxV - self.objectsMinV) * scale - if size[0] > self.machineSize.x or size[1] > self.machineSize.y or size[2] > self.machineSize.z: - self.OnScaleMax(None) + self.toolbarInfo.SetValue('%0.1f %0.1f %0.1f' % (size[0], size[1], size[2])) self.glCanvas.zoom = numpy.max(size) * 2.5 self.errorList = [] wx.CallAfter(self.updateToolbar) @@ -311,7 +326,8 @@ class previewPanel(wx.Panel): profile.putProfileSetting('flip_z', 'False') profile.putProfileSetting('swap_xz', 'False') profile.putProfileSetting('swap_yz', 'False') - self.updateProfileToControls() + profile.setPluginConfig([]) + self.GetParent().updateProfileToControls() def ShowWarningPopup(self, text, callback = None): self.warningPopup.text.SetLabel(text) @@ -358,6 +374,7 @@ class previewPanel(wx.Panel): elif self.mixedViewButton.GetValue(): self.glCanvas.viewMode = "Mixed" self.glCanvas.drawBorders = self.showBorderButton.GetValue() + self.glCanvas.drawSteepOverhang = self.showSteepOverhang.GetValue() self.updateToolbar() self.glCanvas.Refresh() @@ -379,6 +396,7 @@ class previewPanel(wx.Panel): minV = self.objectList[0].mesh.getMinimum() maxV = self.objectList[0].mesh.getMaximum() + objectsBounderyCircleSize = self.objectList[0].mesh.bounderyCircleSize for obj in self.objectList: if obj.mesh == None: continue @@ -386,9 +404,11 @@ class previewPanel(wx.Panel): obj.mesh.getMinimumZ() minV = numpy.minimum(minV, obj.mesh.getMinimum()) maxV = numpy.maximum(maxV, obj.mesh.getMaximum()) + objectsBounderyCircleSize = max(objectsBounderyCircleSize, obj.mesh.bounderyCircleSize) self.objectsMaxV = maxV self.objectsMinV = minV + self.objectsBounderyCircleSize = objectsBounderyCircleSize for obj in self.objectList: if obj.mesh == None: continue @@ -400,6 +420,11 @@ class previewPanel(wx.Panel): # v[1] -= minV[1] + (maxV[1] - minV[1]) / 2 obj.mesh.getMinimumZ() obj.dirty = True + + scale = profile.getProfileSettingFloat('model_scale') + size = (self.objectsMaxV - self.objectsMinV) * scale + self.toolbarInfo.SetValue('%0.1f %0.1f %0.1f' % (size[0], size[1], size[2])) + self.glCanvas.Refresh() def updateProfileToControls(self): @@ -447,16 +472,15 @@ class PreviewGLCanvas(glcanvas.GLCanvas): def OnMouseMotion(self,e): cursorXY = 100000 - sizeXY = 0 + radius = 0 if self.parent.objectsMaxV != None: - size = (self.parent.objectsMaxV - self.parent.objectsMinV) - sizeXY = math.sqrt((size[0] * size[0]) + (size[1] * size[1])) + radius = self.parent.objectsBounderyCircleSize * profile.getProfileSettingFloat('model_scale') p0 = numpy.array(gluUnProject(e.GetX(), self.viewport[1] + self.viewport[3] - e.GetY(), 0, self.modelMatrix, self.projMatrix, self.viewport)) p1 = numpy.array(gluUnProject(e.GetX(), self.viewport[1] + self.viewport[3] - e.GetY(), 1, self.modelMatrix, self.projMatrix, self.viewport)) cursorZ0 = p0 - (p1 - p0) * (p0[2] / (p1[2] - p0[2])) cursorXY = math.sqrt((cursorZ0[0] * cursorZ0[0]) + (cursorZ0[1] * cursorZ0[1])) - if cursorXY >= sizeXY * 0.7 and cursorXY <= sizeXY * 0.7 + 3 and False: + if cursorXY >= radius * 1.1 and cursorXY <= radius * 1.3: self.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) else: self.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) @@ -464,7 +488,7 @@ class PreviewGLCanvas(glcanvas.GLCanvas): if e.Dragging() and e.LeftIsDown(): if self.dragType == '': #Define the drag type depending on the cursor position. - if cursorXY >= sizeXY * 0.7 and cursorXY <= sizeXY * 0.7 + 3 and False: + if cursorXY >= radius * 1.1 and cursorXY <= radius * 1.3: self.dragType = 'modelRotate' self.dragStart = math.atan2(cursorZ0[0], cursorZ0[1]) else: @@ -485,6 +509,8 @@ class PreviewGLCanvas(glcanvas.GLCanvas): angle = math.atan2(cursorZ0[0], cursorZ0[1]) diff = self.dragStart - angle self.tempRotate = diff * 180 / math.pi + rot = profile.getProfileSettingFloat('model_rotate_base') + self.tempRotate = round((self.tempRotate + rot) / 15) * 15 - rot #Workaround for buggy ATI cards. size = self.GetSizeTuple() self.SetSize((size[0]+1, size[1])) @@ -492,7 +518,13 @@ class PreviewGLCanvas(glcanvas.GLCanvas): self.Refresh() else: if self.tempRotate != 0: - profile.putProfileSetting('model_rotate_base', profile.getProfileSettingFloat('model_rotate_base') + self.tempRotate) + newRotation = profile.getProfileSettingFloat('model_rotate_base') + self.tempRotate + while newRotation >= 360: + newRotation -= 360 + while newRotation < 0: + newRotation += 360 + profile.putProfileSetting('model_rotate_base', newRotation) + self.parent.rotate.SetValue(newRotation) self.parent.updateModelTransform() self.tempRotate = 0 @@ -580,12 +612,16 @@ class PreviewGLCanvas(glcanvas.GLCanvas): if obj.mesh == None: continue if obj.displayList == None: - obj.displayList = glGenLists(1); + obj.displayList = glGenLists(1) + obj.steepDisplayList = glGenLists(1) if obj.dirty: obj.dirty = False glNewList(obj.displayList, GL_COMPILE) opengl.DrawMesh(obj.mesh) glEndList() + glNewList(obj.steepDisplayList, GL_COMPILE) + opengl.DrawMeshSteep(obj.mesh, 60) + glEndList() if self.viewMode == "Mixed": glDisable(GL_BLEND) @@ -706,6 +742,15 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glScalef(modelScale, modelScale, modelScale) opengl.DrawMeshOutline(obj.mesh) glPopMatrix() + + if self.drawSteepOverhang: + glDisable(GL_LIGHTING) + glColor3f(1,1,1) + glPushMatrix() + modelScale = profile.getProfileSettingFloat('model_scale') + glScalef(modelScale, modelScale, modelScale) + glCallList(obj.steepDisplayList) + glPopMatrix() glPopMatrix() if self.viewMode == "Normal" or self.viewMode == "Transparent" or self.viewMode == "X-Ray": @@ -720,29 +765,36 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glEnd() glEnable(GL_DEPTH_TEST) - opengl.DrawMachine(machineSize) - glPushMatrix() glTranslate(self.parent.machineCenter.x, self.parent.machineCenter.y, 0) #Draw the rotate circle - if self.parent.objectsMaxV != None and False: + if self.parent.objectsMaxV != None: glDisable(GL_LIGHTING) glDisable(GL_CULL_FACE) glEnable(GL_BLEND) + glRotate(self.tempRotate + profile.getProfileSettingFloat('model_rotate_base'), 0, 0, 1) + radius = self.parent.objectsBounderyCircleSize * profile.getProfileSettingFloat('model_scale') + glScalef(radius, radius, 1) glBegin(GL_TRIANGLE_STRIP) - size = (self.parent.objectsMaxV - self.parent.objectsMinV) - sizeXY = math.sqrt((size[0] * size[0]) + (size[1] * size[1])) for i in xrange(0, 64+1): f = i if i < 64/2 else 64 - i - glColor4ub(255,int(f*255/(64/2)),0,128) - glVertex3f(sizeXY * 0.7 * math.cos(i/32.0*math.pi), sizeXY * 0.7 * math.sin(i/32.0*math.pi),0.1) - glColor4ub( 0,128,0,128) - glVertex3f((sizeXY * 0.7 + 3) * math.cos(i/32.0*math.pi), (sizeXY * 0.7 + 3) * math.sin(i/32.0*math.pi),0.1) + glColor4ub(255,int(f*255/(64/2)),0,255) + glVertex3f(1.1 * math.cos(i/32.0*math.pi), 1.1 * math.sin(i/32.0*math.pi),0.1) + glColor4ub( 0,128,0,255) + glVertex3f(1.3 * math.cos(i/32.0*math.pi), 1.3 * math.sin(i/32.0*math.pi),0.1) + glEnd() + glBegin(GL_TRIANGLES) + glColor4ub(0,0,0,192) + glVertex3f(1, 0.1,0.15) + glVertex3f(1,-0.1,0.15) + glVertex3f(1.4,0,0.15) glEnd() glEnable(GL_CULL_FACE) glPopMatrix() + + opengl.DrawMachine(machineSize) glFlush() diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index 87d898b..145fd7c 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -134,7 +134,7 @@ class printWindow(wx.Frame): self.powerWarningText = wx.StaticText(parent=self.panel, id=-1, - label="Connect your computer to AC power\nIf it shuts down during printing, the product will be lost.", + label="Your computer is running on battery power.\nConnect your computer to AC power or your print might not finish.", style=wx.ALIGN_CENTER) self.powerWarningText.SetBackgroundColour('red') self.powerWarningText.SetForegroundColour('white') @@ -309,7 +309,7 @@ class printWindow(wx.Frame): self.camPreview.timer.Start(500) self.camPreview.Bind(wx.EVT_ERASE_BACKGROUND, self.OnCameraEraseBackground) - self.sizer.AddGrowableRow(5) + self.sizer.AddGrowableRow(6) self.sizer.AddGrowableCol(3) self.Bind(wx.EVT_CLOSE, self.OnClose) @@ -521,9 +521,11 @@ class printWindow(wx.Frame): type = self.powerManagement.get_providing_power_source_type() if type == power.POWER_TYPE_AC and self.powerWarningText.IsShown(): self.powerWarningText.Hide() + self.panel.Layout() self.Layout() elif type != power.POWER_TYPE_AC and not self.powerWarningText.IsShown(): self.powerWarningText.Show() + self.panel.Layout() self.Layout() def LoadGCodeFile(self, filename): @@ -579,10 +581,11 @@ class printWindow(wx.Frame): def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp): self.temperatureGraph.addPoint(temp, targetTemp, bedTemp, bedTargetTemp) - if self.temperatureSelect.GetValue() != targetTemp: - wx.CallAfter(self.temperatureSelect.SetValue, targetTemp) - if self.bedTemperatureSelect.GetValue() != bedTargetTemp: - wx.CallAfter(self.bedTemperatureSelect.SetValue, bedTargetTemp) +# ToFix, this causes problems with setting the temperature with the keyboard +# if self.temperatureSelect.GetValue() != targetTemp: +# wx.CallAfter(self.temperatureSelect.SetValue, targetTemp) +# if self.bedTemperatureSelect.GetValue() != bedTargetTemp: +# wx.CallAfter(self.bedTemperatureSelect.SetValue, bedTargetTemp) def mcStateChange(self, state): if self.machineCom != None: @@ -643,6 +646,7 @@ class temperatureGraph(wx.Panel): dc = wx.MemoryDC() dc.SelectObject(self.backBuffer) dc.Clear() + dc.SetFont(wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)) w, h = self.GetSizeTuple() bgLinePen = wx.Pen('#A0A0A0') tempPen = wx.Pen('#FF4040') @@ -677,9 +681,12 @@ class temperatureGraph(wx.Panel): for x in xrange(w, 0, -30): dc.SetPen(bgLinePen) dc.DrawLine(x, 0, x, h) + tmpNr = 0 for y in xrange(h - 1, 0, -h * 50 / 300): dc.SetPen(bgLinePen) dc.DrawLine(0, y, w, y) + dc.DrawText(str(tmpNr), 0, y - dc.GetFont().GetPixelSize().GetHeight()) + tmpNr += 50 dc.DrawLine(0, 0, w, 0) dc.DrawLine(0, 0, 0, h) diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index 767ca07..a6b4244 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -153,6 +153,7 @@ class projectPlanner(wx.Frame): self.list = [] self.selection = None self.printMode = 0 + self.alwaysAutoPlace = True self.machineSize = numpy.array([profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height')]) self.headSizeMin = numpy.array([profile.getPreferenceFloat('extruder_head_size_min_x'), profile.getPreferenceFloat('extruder_head_size_min_y'),0]) @@ -170,8 +171,8 @@ class projectPlanner(wx.Frame): toolbarUtil.NormalButton(self.toolbar, self.OnSaveProject, 'save.png', 'Save project') self.toolbar.AddSeparator() group = [] - toolbarUtil.RadioButton(self.toolbar, group, 'object-3d-on.png', 'object-3d-off.png', '3D view', callback=self.On3DClick) - toolbarUtil.RadioButton(self.toolbar, group, 'object-top-on.png', 'object-top-off.png', 'Topdown view', callback=self.OnTopClick).SetValue(True) + toolbarUtil.RadioButton(self.toolbar, group, 'object-3d-on.png', 'object-3d-off.png', '3D view', callback=self.On3DClick).SetValue(self.alwaysAutoPlace) + toolbarUtil.RadioButton(self.toolbar, group, 'object-top-on.png', 'object-top-off.png', 'Topdown view', callback=self.OnTopClick).SetValue(not self.alwaysAutoPlace) self.toolbar.AddSeparator() toolbarUtil.NormalButton(self.toolbar, self.OnPreferences, 'preferences.png', 'Project planner preferences') self.toolbar.AddSeparator() @@ -196,7 +197,8 @@ class projectPlanner(wx.Frame): toolbarUtil.NormalButton(self.toolbar2, self.OnCopy, 'copy.png', 'Make a copy of the current selected object') toolbarUtil.NormalButton(self.toolbar2, self.OnSetCustomProfile, 'set-profile.png', 'Set a custom profile to be used to prepare a specific object.') self.toolbar2.AddSeparator() - toolbarUtil.NormalButton(self.toolbar2, self.OnAutoPlace, 'autoplace.png', 'Automaticly organize the objects on the platform.') + if not self.alwaysAutoPlace: + toolbarUtil.NormalButton(self.toolbar2, self.OnAutoPlace, 'autoplace.png', 'Automaticly organize the objects on the platform.') toolbarUtil.NormalButton(self.toolbar2, self.OnSlice, 'slice.png', 'Prepare to project into a gcode file.') self.toolbar2.Realize() @@ -218,7 +220,8 @@ class projectPlanner(wx.Frame): self.addButton = wx.Button(self.panel, -1, "Add") self.remButton = wx.Button(self.panel, -1, "Remove") self.sliceButton = wx.Button(self.panel, -1, "Prepare") - self.autoPlaceButton = wx.Button(self.panel, -1, "Auto Place") + if not self.alwaysAutoPlace: + self.autoPlaceButton = wx.Button(self.panel, -1, "Auto Place") sizer.Add(self.toolbar, (0,0), span=(1,1), flag=wx.EXPAND|wx.LEFT|wx.RIGHT) sizer.Add(self.toolbar2, (0,1), span=(1,2), flag=wx.EXPAND|wx.LEFT|wx.RIGHT) @@ -228,14 +231,16 @@ class projectPlanner(wx.Frame): sizer.Add(self.addButton, (3,1), span=(1,1)) sizer.Add(self.remButton, (3,2), span=(1,1)) sizer.Add(self.sliceButton, (4,1), span=(1,1)) - sizer.Add(self.autoPlaceButton, (4,2), span=(1,1)) + if not self.alwaysAutoPlace: + sizer.Add(self.autoPlaceButton, (4,2), span=(1,1)) sizer.AddGrowableCol(0) sizer.AddGrowableRow(1) self.addButton.Bind(wx.EVT_BUTTON, self.OnAddModel) self.remButton.Bind(wx.EVT_BUTTON, self.OnRemModel) self.sliceButton.Bind(wx.EVT_BUTTON, self.OnSlice) - self.autoPlaceButton.Bind(wx.EVT_BUTTON, self.OnAutoPlace) + if not self.alwaysAutoPlace: + self.autoPlaceButton.Bind(wx.EVT_BUTTON, self.OnAutoPlace) self.listbox.Bind(wx.EVT_LISTBOX, self.OnListSelect) panel = wx.Panel(self.panel, -1) @@ -309,6 +314,8 @@ class projectPlanner(wx.Frame): self.printMode = 0 if self.printAllAtOnce.GetValue(): self.printMode = 1 + if self.alwaysAutoPlace: + self.OnAutoPlace(None) self.preview.Refresh() def OnSaveCombinedSTL(self, e): @@ -508,6 +515,8 @@ class projectPlanner(wx.Frame): else: self.selection = None self.listbox.SetSelection(-1) + if self.alwaysAutoPlace: + self.OnAutoPlace(None) def OnAutoPlace(self, e): bestAllowedSize = int(self.machineSize[1]) @@ -587,8 +596,8 @@ class projectPlanner(wx.Frame): for item in self.list: if item.profile != None and os.path.isfile(item.profile): profile.loadGlobalProfile(item.profile) - put('machine_center_x', item.centerX - self.extruderOffset[item.extruder][0]) - put('machine_center_y', item.centerY - self.extruderOffset[item.extruder][1]) + put('object_center_x', item.centerX - self.extruderOffset[item.extruder][0]) + put('object_center_y', item.centerY - self.extruderOffset[item.extruder][1]) put('model_scale', item.scale) put('flip_x', item.flipX) put('flip_y', item.flipY) @@ -630,8 +639,8 @@ class projectPlanner(wx.Frame): action = Action() action.sliceCmd = sliceRun.getSliceCommand(resultFilename + "_temp_.stl") - action.centerX = profile.getProfileSettingFloat('machine_center_x') - action.centerY = profile.getProfileSettingFloat('machine_center_y') + action.centerX = profile.getPreferenceFloat('machine_width') / 2 + action.centerY = profile.getPreferenceFloat('machine_depth') / 2 action.temperature = profile.getProfileSettingFloat('print_temperature') action.extruder = 0 action.filename = resultFilename + "_temp_.stl" @@ -663,6 +672,8 @@ class projectPlanner(wx.Frame): return self.selection.rotate = float(self.rotateCtrl.GetValue()) self.selection.updateModelTransform() + if self.alwaysAutoPlace: + self.OnAutoPlace(None) self.preview.Refresh() def OnExtruderChange(self, e): @@ -680,6 +691,8 @@ class projectPlanner(wx.Frame): self.selection.swapXZ = self.swapXZ.GetValue() self.selection.swapYZ = self.swapYZ.GetValue() self.selection.updateModelTransform() + if self.alwaysAutoPlace: + self.OnAutoPlace(None) self.preview.Refresh() def getExtraHeadSize(self): @@ -717,17 +730,25 @@ class PreviewGLCanvas(glcanvas.GLCanvas): wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel) self.yaw = 30 self.pitch = 60 - self.zoom = self.parent.machineSize[0] / 2 + 10 self.offsetX = 0 self.offsetY = 0 - self.view3D = False + self.view3D = self.parent.alwaysAutoPlace + if self.view3D: + self.zoom = 300 + else: + self.zoom = self.parent.machineSize[0] / 2 + 10 self.allowDrag = False self.objColor = profile.getPreferenceColour('model_colour') def OnMouseLeftDown(self,e): self.allowDrag = True - + if not self.parent.alwaysAutoPlace and not self.view3D: + #TODO: Translate mouse X/Y to 3D X/Y/Z + for item in self.parent.list: + iMin = (item.getMinimum() * item.scale) + numpy.array([item.centerX, item.centerY, 0]) - self.parent.extruderOffset[item.extruder] + iMax = (item.getMaximum() * item.scale) + numpy.array([item.centerX, item.centerY, 0]) - self.parent.extruderOffset[item.extruder] + def OnMouseMotion(self,e): if self.allowDrag and e.Dragging() and e.LeftIsDown(): if self.view3D: @@ -737,7 +758,7 @@ class PreviewGLCanvas(glcanvas.GLCanvas): self.pitch = 170 if self.pitch < 10: self.pitch = 10 - else: + elif not self.parent.alwaysAutoPlace: item = self.parent.selection if item != None: item.centerX += float(e.GetX() - self.oldX) * self.zoom / self.GetSize().GetHeight() * 2 @@ -851,29 +872,30 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glDisable(GL_LIGHTING) - if self.parent.selection == item: - if item.gotHit: - glColor3f(1.0,0.0,0.3) + if not self.parent.alwaysAutoPlace: + if self.parent.selection == item: + if item.gotHit: + glColor3f(1.0,0.0,0.3) + else: + glColor3f(1.0,0.0,1.0) + opengl.DrawBox(vMin, vMax) + if item.gotHit: + glColor3f(1.0,0.3,0.0) + else: + glColor3f(1.0,1.0,0.0) + opengl.DrawBox(vMinHead, vMaxHead) + elif seenSelected: + if item.gotHit: + glColor3f(0.5,0.0,0.1) + else: + glColor3f(0.5,0.0,0.5) + opengl.DrawBox(vMinHead, vMaxHead) else: - glColor3f(1.0,0.0,1.0) - opengl.DrawBox(vMin, vMax) - if item.gotHit: - glColor3f(1.0,0.3,0.0) - else: - glColor3f(1.0,1.0,0.0) - opengl.DrawBox(vMinHead, vMaxHead) - elif seenSelected: - if item.gotHit: - glColor3f(0.5,0.0,0.1) - else: - glColor3f(0.5,0.0,0.5) - opengl.DrawBox(vMinHead, vMaxHead) - else: - if item.gotHit: - glColor3f(0.7,0.1,0.0) - else: - glColor3f(0.7,0.7,0.0) - opengl.DrawBox(vMin, vMax) + if item.gotHit: + glColor3f(0.7,0.1,0.0) + else: + glColor3f(0.7,0.7,0.0) + opengl.DrawBox(vMin, vMax) glPopMatrix() @@ -964,8 +986,8 @@ class ProjectSliceProgressWindow(wx.Frame): line = p.stdout.readline() self.returnCode = p.wait() - put('machine_center_x', action.centerX - self.extruderOffset[action.extruder][0]) - put('machine_center_y', action.centerY - self.extruderOffset[action.extruder][1]) + put('object_center_x', action.centerX - self.extruderOffset[action.extruder][0]) + put('object_center_y', action.centerY - self.extruderOffset[action.extruder][1]) put('clear_z', action.clearZ) put('extruder', action.extruder) put('print_temperature', action.temperature) diff --git a/Cura/gui/simpleMode.py b/Cura/gui/simpleMode.py index 29dfa41..69eb7b4 100644 --- a/Cura/gui/simpleMode.py +++ b/Cura/gui/simpleMode.py @@ -110,7 +110,7 @@ class simpleModeWindow(configBase.configWindowBase): sizer.Add(boxsizer, (2,0), flag=wx.EXPAND) # load and slice buttons. - loadButton = wx.Button(self, -1, '&Load Model') + loadButton = wx.Button(self, -1, '&Load model') sliceButton = wx.Button(self, -1, 'P&repare print') printButton = wx.Button(self, -1, '&Print') self.Bind(wx.EVT_BUTTON, self.OnLoadModel, loadButton) @@ -187,8 +187,6 @@ 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_enable', 'False') put('retraction_min_travel', '5.0') put('retraction_speed', '40.0') diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py index 8801d17..52411cf 100644 --- a/Cura/gui/sliceProgessPanel.py +++ b/Cura/gui/sliceProgessPanel.py @@ -46,8 +46,8 @@ class sliceProgessPanel(wx.Panel): if idx > 0: profile.setTempOverride('fan_enabled', 'False') profile.setTempOverride('skirt_line_count', '0') - profile.setTempOverride('machine_center_x', profile.getProfileSettingFloat('machine_center_x') - profile.getPreferenceFloat('extruder_offset_x%d' % (idx))) - profile.setTempOverride('machine_center_y', profile.getProfileSettingFloat('machine_center_y') - profile.getPreferenceFloat('extruder_offset_y%d' % (idx))) + profile.setTempOverride('object_center_x', profile.getPreferenceFloat('machine_width') / 2 - profile.getPreferenceFloat('extruder_offset_x%d' % (idx))) + profile.setTempOverride('object_center_y', profile.getPreferenceFloat('machine_depth') / 2 - profile.getPreferenceFloat('extruder_offset_y%d' % (idx))) profile.setTempOverride('alternative_center', self.filelist[0]) if len(self.filelist) > 1: profile.setTempOverride('add_start_end_gcode', 'False') @@ -183,6 +183,11 @@ class WorkerThread(threading.Thread): wx.CallAfter(self.notifyWindow.statusText.SetLabel, "Aborted by user.") return line = p.stdout.readline() + line = p.stderr.readline() + while(len(line) > 0): + line = line.rstrip() + self.progressLog.append(line) + line = p.stderr.readline() self.returnCode = p.wait() self.fileIdx += 1 if self.fileIdx == len(self.cmdList): @@ -220,9 +225,11 @@ class WorkerThread(threading.Thread): resultFile.write('T%d\n' % (currentExtruder)) layerNr = -1 hasLine = True + filesOrder = files[:] while hasLine: hasLine = False - for f in files: + filesOrder.reverse() + for f in filesOrder: layerHasLine = False for line in f: hasLine = True @@ -237,7 +244,7 @@ class WorkerThread(threading.Thread): if nextExtruder != currentExtruder: resultFile.write(';TYPE:CUSTOM\n') profile.setTempOverride('extruder', nextExtruder) - resultFile.write(profile.getAlterationFileContents('switchExtruder.gcode')) + resultFile.write(profile.getAlterationFileContents('switchExtruder.gcode') + '\n') profile.resetTempOverride() currentExtruder = nextExtruder layerHasLine = True diff --git a/Cura/images/steepOverhang-off.png b/Cura/images/steepOverhang-off.png new file mode 100644 index 0000000..f1426aa Binary files /dev/null and b/Cura/images/steepOverhang-off.png differ diff --git a/Cura/images/steepOverhang-on.png b/Cura/images/steepOverhang-on.png new file mode 100644 index 0000000..73d474d Binary files /dev/null and b/Cura/images/steepOverhang-on.png differ diff --git a/Cura/util/dae.py b/Cura/util/dae.py index d694b46..deae1a8 100644 --- a/Cura/util/dae.py +++ b/Cura/util/dae.py @@ -27,6 +27,9 @@ class daeModel(mesh.mesh): for instance_visual_scene in self._base['collada'][0]['scene'][0]['instance_visual_scene']: for node in self._idMap[instance_visual_scene['_url']]['node']: self._ProcessNode2(node) + + scale = float(self._base['collada'][0]['asset'][0]['unit'][0]['_meter']) * 1000 + self.origonalVertexes *= scale self._base = None self._cur = None diff --git a/Cura/util/exporer.py b/Cura/util/exporer.py index 109711b..7ca6d3e 100644 --- a/Cura/util/exporer.py +++ b/Cura/util/exporer.py @@ -21,3 +21,14 @@ def openExporer(filename): elif os.path.isfile('/usr/bin/dolphin'): subprocess.Popen(['/usr/bin/dolphin', os.path.split(filename)[0]]) +def openExporerPath(filename): + if sys.platform == 'win32' or sys.platform == 'cygwin': + subprocess.Popen(r'explorer "%s"' % (filename)) + if sys.platform == 'darwin': + subprocess.Popen(['open', filename]) + if sys.platform.startswith('linux'): + if os.path.isfile('/usr/bin/nautilus'): + subprocess.Popen(['/usr/bin/nautilus', filename]) + elif os.path.isfile('/usr/bin/dolphin'): + subprocess.Popen(['/usr/bin/dolphin', filename]) + diff --git a/Cura/util/machineCom.py b/Cura/util/machineCom.py index 1dec1a1..5f1f301 100644 --- a/Cura/util/machineCom.py +++ b/Cura/util/machineCom.py @@ -207,6 +207,9 @@ class MachineCom(object): if len(self._errorValue) < 20: return self._errorValue return self._errorValue[:20] + "..." + + def getErrorString(self): + return self._errorValue def isClosedOrError(self): return self._state == self.STATE_ERROR or self._state == self.STATE_CLOSED_WITH_ERROR or self._state == self.STATE_CLOSED diff --git a/Cura/util/mesh.py b/Cura/util/mesh.py index 04ba9a2..89d96b7 100644 --- a/Cura/util/mesh.py +++ b/Cura/util/mesh.py @@ -41,6 +41,7 @@ class mesh(object): return self.size def setRotateMirror(self, rotate, mirrorX, mirrorY, mirrorZ, swapXZ, swapYZ): + #Modify the vertexes with the rotation/mirror rotate = rotate / 180.0 * math.pi scaleX = 1.0 scaleY = 1.0 @@ -62,7 +63,14 @@ class mesh(object): if swapYZ: mat = numpy.array([mat[0],mat[2],mat[1]], numpy.float32) self.vertexes = (numpy.matrix(self.origonalVertexes, copy = False) * numpy.matrix(mat)).getA() - + + #Calculate the boundery box of the object + self.getMinimumZ() + #Calculate the boundery circle + center = (self.max + self.min) / 2.0 + self.bounderyCircleSize = round(math.sqrt(numpy.max(((self.vertexes[::,0] - center[0]) * (self.vertexes[::,0] - center[0])) + ((self.vertexes[::,1] - center[1]) * (self.vertexes[::,1] - center[1])))), 3) + + #Calculate the normals tris = self.vertexes.reshape(self.vertexCount / 3, 3, 3) normals = numpy.cross( tris[::,1 ] - tris[::,0] , tris[::,2 ] - tris[::,0] ) lens = numpy.sqrt( normals[:,0]**2 + normals[:,1]**2 + normals[:,2]**2 ) @@ -76,8 +84,6 @@ class mesh(object): n[:,6:9] = normals self.normal = n.reshape(self.vertexCount, 3) self.invNormal = -self.normal - - self.getMinimumZ() def splitToParts(self, callback = None): t0 = time.time() diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 12469ba..a36ff20 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -31,8 +31,6 @@ profileDefaultSettings = { 'support': 'None', 'filament_diameter': '2.89', 'filament_density': '1.00', - 'machine_center_x': '100', - 'machine_center_y': '100', 'retraction_min_travel': '5.0', 'retraction_enable': 'False', 'retraction_speed': '40.0', @@ -42,7 +40,7 @@ profileDefaultSettings = { 'travel_speed': '150', 'max_z_speed': '3.0', 'bottom_layer_speed': '20', - 'cool_min_layer_time': '10', + 'cool_min_layer_time': '5', 'fan_enabled': 'True', 'fan_layer': '1', 'fan_speed': '100', @@ -74,6 +72,7 @@ profileDefaultSettings = { 'raft_base_material_amount': '100', 'raft_interface_material_amount': '100', 'bottom_thickness': '0.3', + 'hop_on_move': 'False', 'plugin_config': '', 'add_start_end_gcode': 'True', @@ -102,9 +101,6 @@ G1 Z15.0 F{max_z_speed} ;move the platform down 15mm G92 E0 ;zero the extruded length G1 F200 E3 ;extrude 3mm of feed stock G92 E0 ;zero the extruded length again - -;go to the middle of the platform (disabled, as there is no need to go to the center) -;G1 X{machine_center_x} Y{machine_center_y} F{travel_speed} G1 F{travel_speed} """, ####################################################################################### @@ -137,7 +133,7 @@ G90 ;absolute positioning G1 Z{clear_z} F{max_z_speed} G92 E0 -G1 X{machine_center_x} Y{machine_center_y} F{travel_speed} +G1 X{object_center_x} Y{object_center_x} F{travel_speed} G1 F200 E6 G92 E0 """, @@ -158,6 +154,7 @@ preferencesDefaultSettings = { 'machine_depth': '205', 'machine_height': '200', 'machine_type': 'unknown', + 'ultimaker_extruder_upgrade': 'False', 'has_heated_bed': 'False', 'extruder_amount': '1', 'extruder_offset_x1': '-22.0', @@ -219,6 +216,13 @@ def resetGlobalProfile(): global globalProfileParser globalProfileParser = ConfigParser.ConfigParser() + if getPreference('machine_type') == 'ultimaker': + putProfileSetting('nozzle_size', '0.4') + if getPreference('ultimaker_extruder_upgrade') == 'True': + putProfileSetting('retraction_enable', 'True') + else: + putProfileSetting('nozzle_size', '0.5') + def saveGlobalProfile(filename): #Save the current profile to an ini file globalProfileParser.write(open(filename, 'w')) @@ -545,9 +549,10 @@ def setPluginConfig(config): putProfileSetting('plugin_config', pickle.dumps(config)) def getPluginBasePaths(): - ret = [os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'plugins'))] + ret = [] if platform.system() != "Windows": ret.append(os.path.expanduser('~/.cura/plugins/')) + ret.append(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'plugins'))) return ret def getPluginList(): diff --git a/Cura/util/sliceRun.py b/Cura/util/sliceRun.py index d065abc..3bd6942 100644 --- a/Cura/util/sliceRun.py +++ b/Cura/util/sliceRun.py @@ -26,6 +26,7 @@ sliceStepTimeFactor = { 'dwindle': 1.0, 'comb': 23.7805759907, 'cool': 27.148763895, + 'hop': 1.0, 'dimension': 90.4914340973 } @@ -114,7 +115,7 @@ def getSliceCommand(filename): cmd = [slic3rExe, '--output-filename-format', '[input_filename_base].gcode', '--nozzle-diameter', str(profile.calculateEdgeWidth()), - '--print-center', '%s,%s' % (profile.getProfileSetting('machine_center_x'), profile.getProfileSetting('machine_center_y')), + '--print-center', '%s,%s' % (profile.getPreferenceFloat('machine_width') / 2, profile.getPreferenceFloat('machine_depth') / 2), '--z-offset', '0', '--gcode-flavor', 'reprap', '--gcode-comments', diff --git a/Cura/util/svg.py b/Cura/util/svg.py index c68206f..6485e93 100644 --- a/Cura/util/svg.py +++ b/Cura/util/svg.py @@ -215,7 +215,7 @@ if __name__ == '__main__': f.write(';TYPE:CUSTOM\n') f.write(profile.getAlterationFileContents('start.gcode')) - svg.center(complex(profile.getProfileSettingFloat('machine_center_x'), profile.getProfileSettingFloat('machine_center_y'))) + svg.center(complex(profile.getPreferenceFloat('machine_width') / 2, profile.getPreferenceFloat('machine_depth') / 2)) layerThickness = 0.4 filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2