def __init__(self, port = None, baudrate = None): if port == None: port = profile.getPreference('serial_port') if baudrate == None: if profile.getPreference('serial_baud') == 'AUTO': baudrate = 0 else: baudrate = int(profile.getPreference('serial_baud')) self.serial = None if port == 'AUTO': programmer = stk500v2.Stk500v2() for port in serialList(): try: print "Connecting to: %s" % (port) programmer.connect(port) programmer.close() time.sleep(1) self.serial = self._openPortWithBaudrate(port, baudrate) break except ispBase.IspError as (e): print "Error while connecting to %s" % (port) print e pass except: print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0] programmer.close() elif port == 'VIRTUAL': self.serial = VirtualPrinter() else: try: self.serial = self._openPortWithBaudrate(port, baudrate) except: print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0] print self.serial
def main(splash): #app = wx.App(False) if profile.getPreference('machine_type') == 'unknown': if platform.system() == "Darwin": #Check if we need to copy our examples exampleFile = os.path.expanduser( '~/CuraExamples/UltimakerRobot_support.stl') if not os.path.isfile(exampleFile): try: os.makedirs(os.path.dirname(exampleFile)) except: pass for filename in glob.glob( os.path.normpath( os.path.join( os.path.dirname(os.path.abspath(__file__)), '..', 'example', '*.*'))): shutil.copy( filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename))) profile.putPreference('lastFile', exampleFile) splash.Show(False) configWizard.configWizard() if profile.getPreference('startMode') == 'Simple': simpleMode.simpleModeWindow() else: mainWindow()
def OnCopyToSD(self, e): for f in self.filenameList: exportFilename = sliceRun.getExportFilename(f) filename = os.path.basename(exportFilename) if profile.getPreference('sdshortnames') == 'True': filename = sliceRun.getShortFilename(filename) shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
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)") p = wx.Panel(self) p.SetSizer(wx.BoxSizer(wx.HORIZONTAL)) self.lengthInput = wx.TextCtrl(p, -1, '100') p.GetSizer().Add(self.lengthInput, 0, wx.RIGHT, 8) self.saveLengthButton = wx.Button(p, -1, 'Save') p.GetSizer().Add(self.saveLengthButton, 0) self.GetSizer().Add(p, 0, wx.LEFT, 5) self.AddText("This results in the following steps per E:") self.stepsPerEInput = wx.TextCtrl(self, -1, profile.getPreference('steps_per_e')) self.GetSizer().Add(self.stepsPerEInput, 0, wx.LEFT, 5) 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 __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 OnCopyToSD(self, e): if profile.getPreference('sdpath') == '': wx.MessageBox( "You need to configure your SD card drive first before you can copy files to it.\nOpening the preferences now.", 'No SD card drive.', wx.OK | wx.ICON_INFORMATION) prefDialog = preferencesDialog.preferencesDialog(self.GetParent()) prefDialog.Centre() prefDialog.Show(True) if profile.getPreference('sdpath') == '': print "No path set" return exportFilename = sliceRun.getExportFilename(self.filelist[0]) filename = os.path.basename(exportFilename) if profile.getPreference('sdshortnames') == 'True': filename = sliceRun.getShortFilename(filename) try: shutil.copy( exportFilename, os.path.join(profile.getPreference('sdpath'), filename)) except: self.GetParent().preview3d.ShowWarningPopup( "Failed to copy file to SD card.") return self.GetParent().preview3d.ShowWarningPopup( "Copy finished, safely remove SD card?", self.OnSafeRemove)
def __init__(self, port=None, baudrate=None, callbackObject=None): if port == None: port = profile.getPreference('serial_port') if baudrate == None: if profile.getPreference('serial_baud') == 'AUTO': baudrate = 0 else: baudrate = int(profile.getPreference('serial_baud')) if callbackObject == None: callbackObject = MachineComPrintCallback() self._port = port self._baudrate = baudrate self._callback = callbackObject self._state = self.STATE_NONE self._serial = None self._baudrateDetectList = baudrateList() self._baudrateDetectRetry = 0 self._temp = 0 self._bedTemp = 0 self._targetTemp = 0 self._bedTargetTemp = 0 self._gcodeList = None self._gcodePos = 0 self._commandQueue = queue.Queue() self._logQueue = queue.Queue(256) self._feedRateModifier = {} self._currentZ = -1 self._heatupWaitStartTime = 0 self._heatupWaitTimeLost = 0.0 self._printStartTime100 = None self.thread = threading.Thread(target=self._monitor) self.thread.daemon = True self.thread.start()
def OnCopyToSD(self, e): exportFilename = sliceRun.getExportFilename(self.filelist[0]) filename = os.path.basename(exportFilename) if profile.getPreference('sdshortnames') == 'True': filename = sliceRun.getShortFilename(filename) shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
def __init__(self, port=None, baudrate=None): if port == None: port = profile.getPreference("serial_port") if baudrate == None: baudrate = int(profile.getPreference("serial_baud")) self.serial = None if port == "AUTO": programmer = stk500v2.Stk500v2() for port in serialList(): try: print "Connecting to: %s %i" % (port, baudrate) programmer.connect(port) programmer.close() time.sleep(1) self.serial = Serial(port, baudrate, timeout=2) break except ispBase.IspError as (e): print "Error while connecting to %s %i" % (port, baudrate) print e pass except: print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0] programmer.close() elif port == "VIRTUAL": self.serial = VirtualPrinter() else: try: self.serial = Serial(port, baudrate, timeout=2) except: print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0] print self.serial
def __init__(self, port = None, baudrate = None, callbackObject = None): if port == None: port = profile.getPreference('serial_port') if baudrate == None: if profile.getPreference('serial_baud') == 'AUTO': baudrate = 0 else: baudrate = int(profile.getPreference('serial_baud')) if callbackObject == None: callbackObject = MachineComPrintCallback() self._port = port self._baudrate = baudrate self._callback = callbackObject self._state = self.STATE_NONE self._serial = None self._baudrateDetectList = baudrateList() self._baudrateDetectRetry = 0 self._temp = 0 self._bedTemp = 0 self._targetTemp = 0 self._bedTargetTemp = 0 self._gcodeList = None self._gcodePos = 0 self._commandQueue = queue.Queue() self._logQueue = queue.Queue(256) self._feedRateModifier = {} self._currentZ = -1 self._heatupWaitStartTime = 0 self._heatupWaitTimeLost = 0.0 self._printStartTime100 = None self.thread = threading.Thread(target=self._monitor) self.thread.daemon = True self.thread.start()
def __init__(self, port = None, baudrate = None): if port == None: port = profile.getPreference('serial_port') if baudrate == None: baudrate = int(profile.getPreference('serial_baud')) self.serial = None if port == 'AUTO': programmer = stk500v2.Stk500v2() for port in serialList(): try: print "Connecting to: %s %i" % (port, baudrate) programmer.connect(port) programmer.close() time.sleep(1) self.serial = Serial(port, baudrate, timeout=2) break except ispBase.IspError as (e): print "Error while connecting to %s %i" % (port, baudrate) print e pass except: print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0] programmer.close() elif port == 'VIRTUAL': self.serial = VirtualPrinter() else: try: self.serial = Serial(port, baudrate, timeout=2) except: print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0] print self.serial
def main(): #app = wx.App(False) if profile.getPreference('machine_type') == 'unknown': configWizard.configWizard() if profile.getPreference('startMode') == 'Simple': simpleMode.simpleModeWindow() else: mainWindow()
def main(): # app = wx.App(False) if profile.getPreference("machine_type") == "unknown": configWizard.configWizard() if profile.getPreference("startMode") == "Simple": simpleMode.simpleModeWindow() else: mainWindow()
def baudrateList(): ret = [250000, 230400, 115200, 57600, 38400, 19200, 9600] if profile.getPreference('serial_baud_auto') != '': prev = int(profile.getPreference('serial_baud_auto')) if prev in ret: ret.remove(prev) ret.insert(0, prev) return ret
def main(): #app = wx.App(False) if profile.getPreference('wizardDone') == 'False': configWizard.configWizard() profile.putPreference("wizardDone", "True") if profile.getPreference('startMode') == 'Simple': simpleMode.simpleModeWindow() else: mainWindow()
def main(): app = wx.App(False) if profile.getPreference("wizardDone") == "False": configWizard.configWizard() profile.putPreference("wizardDone", "True") if profile.getPreference("startMode") == "Simple": simpleMode.simpleModeWindow() else: mainWindow() app.MainLoop()
def OnSafeRemove(self): if platform.system() == "Windows": cmd = "%s %s>NUL" % (os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'EjectMedia.exe')), profile.getPreference('sdpath')) elif platform.system() == "Darwin": cmd = "diskutil eject '%s' > /dev/null 2>&1" % (profile.getPreference('sdpath')) else: cmd = "umount '%s' > /dev/null 2>&1" % (profile.getPreference('sdpath')) if os.system(cmd): self.GetParent().preview3d.ShowWarningPopup("Safe remove failed.") else: self.GetParent().preview3d.ShowWarningPopup("You can now eject the card.")
def OnCustomFirmware(self, e): if profile.getPreference('machine_type') == 'ultimaker': wx.MessageBox('Warning: Installing a custom firmware does not garantee that you machine will function correctly, and could damage your machine.', 'Firmware update', wx.OK | wx.ICON_EXCLAMATION) dlg=wx.FileDialog(self, "Open firmware to upload", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX") if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() if not(os.path.exists(filename)): return #For some reason my Ubuntu 10.10 crashes here. firmwareInstall.InstallFirmware(filename)
def getDefaultFirmware(): if profile.getPreference('machine_type') == 'ultimaker': if profile.getPreferenceFloat('extruder_amount') > 1: return None if profile.getPreference('has_heated_bed') == 'True': return None if sys.platform.startswith('linux'): return resources.getPathForFirmware("ultimaker_115200.hex") else: return resources.getPathForFirmware("ultimaker_250000.hex") return None
def __init__(self, parent): super(preferencesDialog, self).__init__(title="Project Planner Preferences") self.parent = parent wx.EVT_CLOSE(self, self.OnClose) extruderAmount = int(profile.getPreference('extruder_amount')) left, right, main = self.CreateConfigPanel(self) configBase.TitleRow(left, 'Machine head size') c = configBase.SettingRow(left, 'Head size - X towards home (mm)', 'extruder_head_size_min_x', '0', 'Size of your printer head in the X direction, on the Ultimaker your fan is in this direction.', type = 'preference') validators.validFloat(c, 0.1) c = configBase.SettingRow(left, 'Head size - X towards end (mm)', 'extruder_head_size_max_x', '0', 'Size of your printer head in the X direction.', type = 'preference') validators.validFloat(c, 0.1) c = configBase.SettingRow(left, 'Head size - Y towards home (mm)', 'extruder_head_size_min_y', '0', 'Size of your printer head in the Y direction.', type = 'preference') validators.validFloat(c, 0.1) c = configBase.SettingRow(left, 'Head size - Y towards end (mm)', 'extruder_head_size_max_y', '0', 'Size of your printer head in the Y direction.', type = 'preference') validators.validFloat(c, 0.1) c = configBase.SettingRow(left, 'Head gantry height (mm)', 'extruder_head_size_height', '0', 'The tallest object height that will always fit under your printers gantry system when the printer head is at the lowest Z position.', type = 'preference') validators.validFloat(c) self.okButton = wx.Button(left, -1, 'Ok') left.GetSizer().Add(self.okButton, (left.GetSizer().GetRows(), 1)) self.okButton.Bind(wx.EVT_BUTTON, self.OnClose) self.MakeModal(True) main.Fit() self.Fit()
def OnSaveProject(self, e): dlg=wx.FileDialog(self, "Save project file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE) dlg.SetWildcard("Project files (*.curaproject)|*.curaproject") if dlg.ShowModal() == wx.ID_OK: cp = ConfigParser.ConfigParser() i = 0 for item in self.list: section = 'model_%d' % (i) cp.add_section(section) cp.set(section, 'filename', item.filename.encode("utf-8")) cp.set(section, 'centerX', str(item.centerX)) cp.set(section, 'centerY', str(item.centerY)) cp.set(section, 'scale', str(item.scale)) cp.set(section, 'rotate', str(item.rotate)) cp.set(section, 'flipX', str(item.flipX)) cp.set(section, 'flipY', str(item.flipY)) cp.set(section, 'flipZ', str(item.flipZ)) cp.set(section, 'swapXZ', str(item.swapXZ)) cp.set(section, 'swapYZ', str(item.swapYZ)) cp.set(section, 'extruder', str(item.extruder+1)) if item.profile != None: cp.set(section, 'profile', item.profile) i += 1 cp.write(open(dlg.GetPath(), "w")) dlg.Destroy()
def OnSliceDone(self, result): self.progressGauge.Destroy() self.abortButton.Destroy() self.progressLog = result.progressLog self.logButton = wx.Button(self, -1, "Show Log") self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT) self.Bind(wx.EVT_BUTTON, self.OnShowLog, self.logButton) self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton) self.sizer.Add(self.logButton, 0) if result.returnCode == 0: status = "Ready: Filament: %.2fm %.2fg" % (result.gcode.extrusionAmount / 1000, result.gcode.calculateWeight() * 1000) status += " Print time: %02d:%02d" % (int(result.gcode.totalMoveTimeMinute / 60), int(result.gcode.totalMoveTimeMinute % 60)) cost = result.gcode.calculateCost() if cost != False: status += " Cost: %s" % (cost) self.statusText.SetLabel(status) if exporer.hasExporer(): self.openFileLocationButton = wx.Button(self, -1, "Open file location") self.Bind(wx.EVT_BUTTON, self.OnOpenFileLocation, self.openFileLocationButton) self.sizer.Add(self.openFileLocationButton, 0) if profile.getPreference('sdpath') != '': self.copyToSDButton = wx.Button(self, -1, "To SDCard") self.Bind(wx.EVT_BUTTON, self.OnCopyToSD, self.copyToSDButton) self.sizer.Add(self.copyToSDButton, 0) self.showButton = wx.Button(self, -1, "Show result") self.Bind(wx.EVT_BUTTON, self.OnShowGCode, self.showButton) self.sizer.Add(self.showButton, 0) else: self.statusText.SetLabel("Something went wrong during slicing!") self.sizer.Add(self.abortButton, 0) self.sizer.Layout() self.Layout() self.abort = True if self.mainWindow.preview3d.loadReModelFiles(self.filelist): self.mainWindow.preview3d.setViewMode("GCode")
def updateHeadSize(self, obj=None): xMin = profile.getMachineSettingFloat('extruder_head_size_min_x') xMax = profile.getMachineSettingFloat('extruder_head_size_max_x') yMin = profile.getMachineSettingFloat('extruder_head_size_min_y') yMax = profile.getMachineSettingFloat('extruder_head_size_max_y') gantryHeight = profile.getMachineSettingFloat( 'extruder_head_size_height') self._leftToRight = xMin < xMax self._frontToBack = yMin < yMax self._headSizeOffsets[0] = min(xMin, xMax) self._headSizeOffsets[1] = min(yMin, yMax) self._gantryHeight = gantryHeight self._oneAtATime = self._gantryHeight > 0 and profile.getPreference( 'oneAtATime') == 'True' for obj in self._objectList: if obj.getSize()[2] > self._gantryHeight: self._oneAtATime = False headArea = numpy.array( [[-xMin, -yMin], [xMax, -yMin], [xMax, yMax], [-xMin, yMax]], numpy.float32) if obj is None: for obj in self._objectList: obj.setHeadArea(headArea, self._headSizeOffsets) else: obj.setHeadArea(headArea, self._headSizeOffsets)
def __init__(self, filename, port = None): super(InstallFirmware, self).__init__(parent=None, title="Firmware install", size=(250, 100)) if port == None: port = profile.getPreference('serial_port') sizer = wx.BoxSizer(wx.VERTICAL) self.progressLabel = wx.StaticText(self, -1, 'Reading firmware...') sizer.Add(self.progressLabel, 0, flag=wx.ALIGN_CENTER) self.progressGauge = wx.Gauge(self, -1) sizer.Add(self.progressGauge, 0, flag=wx.EXPAND) self.okButton = wx.Button(self, -1, 'Ok') self.okButton.Disable() self.okButton.Bind(wx.EVT_BUTTON, self.OnOk) sizer.Add(self.okButton, 0, flag=wx.ALIGN_CENTER) self.SetSizer(sizer) self.filename = filename self.port = port threading.Thread(target=self.OnRun).start() self.ShowModal() self.Destroy() return
def OnSaveProfile(self, e): dlg=wx.FileDialog(self, "Select profile file to save", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE) dlg.SetWildcard("ini files (*.ini)|*.ini") if dlg.ShowModal() == wx.ID_OK: profileFile = dlg.GetPath() profile.saveGlobalProfile(profileFile) dlg.Destroy()
def updateProfileToControls(self): "Update the configuration wx controls to show the new configuration settings" for setting in self.settingControlList: if setting.type == 'profile': setting.SetValue(profile.getProfileSetting(setting.configName)) else: setting.SetValue(profile.getPreference(setting.configName))
def __init__(self, parent): wx.Panel.__init__(self, parent,-1) self.alterationFileList = ['start.gcode', 'end.gcode', 'support_start.gcode', 'support_end.gcode', 'nextobject.gcode', 'replace.csv'] if int(profile.getPreference('extruder_amount')) > 1: self.alterationFileList.append('switchExtruder.gcode') self.currentFile = None #self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB) #self.textArea.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) self.textArea = gcodeTextArea.GcodeTextArea(self) self.list = wx.ListBox(self, choices=self.alterationFileList, style=wx.LB_SINGLE) self.list.SetSelection(0) self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list) self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea) self.textArea.Bind(wx.stc.EVT_STC_CHANGE, self.OnFocusLost, self.textArea) sizer = wx.GridBagSizer() sizer.Add(self.list, (0,0), span=(1,1), flag=wx.EXPAND) sizer.Add(self.textArea, (0,1), span=(1,1), flag=wx.EXPAND) sizer.AddGrowableCol(1) sizer.AddGrowableRow(0) self.SetSizer(sizer) self.loadFile(self.alterationFileList[self.list.GetSelection()]) self.currentFile = self.list.GetSelection()
def takeNewImage(self): if self._cam == None: return if cv != None: frame = cv.QueryFrame(self._cam) cv.CvtColor(frame, frame, cv.CV_BGR2RGB) bitmap = wx.BitmapFromBuffer(frame.width, frame.height, frame.imageData) elif win32vidcap != None: buffer, width, height = self._cam.getbuffer() try: wxImage = wx.EmptyImage(width, height) wxImage.SetData(buffer[::-1]) if self._bitmap != None: del self._bitmap bitmap = wxImage.ConvertToBitmap() del wxImage del buffer except: pass dc = wx.MemoryDC() dc.SelectObject(bitmap) dc.DrawBitmap(self._overlayImage, bitmap.GetWidth() - self._overlayImage.GetWidth() - 5, 5, True) if profile.getPreference('machine_type') == 'ultimaker': dc.DrawBitmap(self._overlayUltimaker, (bitmap.GetWidth() - self._overlayUltimaker.GetWidth()) / 2, bitmap.GetHeight() - self._overlayUltimaker.GetHeight() - 5, True) dc.SelectObject(wx.NullBitmap) self._bitmap = bitmap if self._doTimelaps: filename = os.path.normpath(os.path.join(os.path.split(__file__)[0], "../__tmp_snap", "__tmp_snap_%04d.jpg" % (self._snapshotCount))) self._snapshotCount += 1 bitmap.SaveFile(filename, wx.BITMAP_TYPE_JPEG) return self._bitmap
def getDefaultFirmware(): if profile.getPreference('machine_type') == 'ultimaker': if sys.platform.startswith('linux'): return os.path.join(os.path.dirname(os.path.abspath(__file__)), "../firmware/ultimaker_115200.hex") else: return os.path.join(os.path.dirname(os.path.abspath(__file__)), "../firmware/ultimaker_250000.hex") return None
def updateProfileToControls(self): "Update the configuration wx controls to show the new configuration settings" for setting in self.settingControlList: if setting.type == "profile": setting.SetValue(profile.getProfileSetting(setting.configName)) else: setting.SetValue(profile.getPreference(setting.configName))
def __init__(self, filename=None, port=None): super(InstallFirmware, self).__init__(parent=None, title="Firmware install", size=(250, 100)) if port == None: port = profile.getPreference('serial_port') if filename == None: filename = getDefaultFirmware() if filename == None: wx.MessageBox( 'Cura does not ship with a default firmware for your machine.', 'Firmware update', wx.OK | wx.ICON_ERROR) self.Destroy() return sizer = wx.BoxSizer(wx.VERTICAL) self.progressLabel = wx.StaticText(self, -1, 'Reading firmware...') sizer.Add(self.progressLabel, 0, flag=wx.ALIGN_CENTER) self.progressGauge = wx.Gauge(self, -1) sizer.Add(self.progressGauge, 0, flag=wx.EXPAND) self.okButton = wx.Button(self, -1, 'Ok') self.okButton.Disable() self.okButton.Bind(wx.EVT_BUTTON, self.OnOk) sizer.Add(self.okButton, 0, flag=wx.ALIGN_CENTER) self.SetSizer(sizer) self.filename = filename self.port = port threading.Thread(target=self.OnRun).start() self.ShowModal() self.Destroy() return
def OnLoadProfileFromGcode(self, e): dlg = wx.FileDialog( self, "Select gcode file to load profile from", os.path.split(profile.getPreference("lastFile"))[0], style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST, ) dlg.SetWildcard("gcode files (*.gcode)|*.gcode") if dlg.ShowModal() == wx.ID_OK: gcodeFile = dlg.GetPath() f = open(gcodeFile, "r") hasProfile = False for line in f: if line.startswith(";CURA_PROFILE_STRING:"): profile.loadGlobalProfileFromString(line[line.find(":") + 1 :].strip()) hasProfile = True if hasProfile: self.updateProfileToControls() else: wx.MessageBox( "No profile found in GCode file.\nThis feature only works with GCode files made by Cura 12.07 or newer.", "Profile load error", wx.OK | wx.ICON_INFORMATION, ) dlg.Destroy()
def __init__(self, filename = None, port = None): super(InstallFirmware, self).__init__(parent=None, title="Firmware install", size=(250, 100)) if port == None: port = profile.getPreference('serial_port') if filename == None: filename = getDefaultFirmware() if filename == None: wx.MessageBox('Cura does not ship with a default firmware for your machine.', 'Firmware update', wx.OK | wx.ICON_ERROR) self.Destroy() return sizer = wx.BoxSizer(wx.VERTICAL) self.progressLabel = wx.StaticText(self, -1, 'Reading firmware...') sizer.Add(self.progressLabel, 0, flag=wx.ALIGN_CENTER) self.progressGauge = wx.Gauge(self, -1) sizer.Add(self.progressGauge, 0, flag=wx.EXPAND) self.okButton = wx.Button(self, -1, 'Ok') self.okButton.Disable() self.okButton.Bind(wx.EVT_BUTTON, self.OnOk) sizer.Add(self.okButton, 0, flag=wx.ALIGN_CENTER) self.SetSizer(sizer) self.filename = filename self.port = port threading.Thread(target=self.OnRun).start() self.ShowModal() self.Destroy() return
def OnSlice(self, e): put = profile.setTempOverride oldProfile = profile.getGlobalProfileString() put('model_multiply_x', '1') put('model_multiply_y', '1') put('enable_raft', 'False') put('add_start_end_gcode', 'False') put('gcode_extension', 'project_tmp') clearZ = 0 actionList = [] 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].x) put('machine_center_y', item.centerY - self.extruderOffset[item.extruder].y) put('model_scale', item.scale) put('flip_x', item.flipX) put('flip_y', item.flipY) put('flip_z', item.flipZ) put('model_rotate_base', item.rotate) put('swap_xz', item.swapXZ) put('swap_yz', item.swapYZ) action = Action() action.sliceCmd = sliceRun.getSliceCommand(item.filename) action.centerX = item.centerX action.centerY = item.centerY action.extruder = item.extruder action.filename = item.filename clearZ = max(clearZ, item.getMaximum().z * item.scale + 5.0) action.clearZ = clearZ action.leaveResultForNextSlice = False action.usePreviousSlice = False actionList.append(action) if self.list.index(item) > 0 and item.isSameExceptForPosition(self.list[self.list.index(item)-1]): actionList[-2].leaveResultForNextSlice = True actionList[-1].usePreviousSlice = True if item.profile != None: profile.loadGlobalProfileFromString(oldProfile) #Restore the old profile. profile.resetTempOverride() dlg=wx.FileDialog(self, "Save project gcode file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE) dlg.SetWildcard("GCode file (*.gcode)|*.gcode") if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return resultFilename = dlg.GetPath() dlg.Destroy() pspw = ProjectSliceProgressWindow(actionList, resultFilename) pspw.extruderOffset = self.extruderOffset pspw.Centre() pspw.Show(True)
def OnSafeRemove(self): if platform.system() == "Windows": cmd = "%s %s>NUL" % (os.path.abspath( os.path.join( os.path.dirname(__file__), '..', 'EjectMedia.exe')), profile.getPreference('sdpath')) elif platform.system() == "Darwin": cmd = "diskutil eject '%s' > /dev/null 2>&1" % ( profile.getPreference('sdpath')) else: cmd = "umount '%s' > /dev/null 2>&1" % ( profile.getPreference('sdpath')) if os.system(cmd): self.GetParent().preview3d.ShowWarningPopup("Safe remove failed.") else: self.GetParent().preview3d.ShowWarningPopup( "You can now eject the card.")
def OnCustomFirmware(self, e): if profile.getPreference('machine_type') == 'ultimaker': wx.MessageBox( 'Warning: Installing a custom firmware does not garantee that you machine will function correctly, and could damage your machine.', 'Firmware update', wx.OK | wx.ICON_EXCLAMATION) dlg = wx.FileDialog(self, "Open firmware to upload", os.path.split( profile.getPreference('lastFile'))[0], style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX") if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() if not (os.path.exists(filename)): return #For some reason my Ubuntu 10.10 crashes here. firmwareInstall.InstallFirmware(filename)
def OnLoadProfile(self, e): dlg=wx.FileDialog(self, "Select profile file to load", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("ini files (*.ini)|*.ini") if dlg.ShowModal() == wx.ID_OK: profileFile = dlg.GetPath() profile.loadGlobalProfile(profileFile) self.updateProfileToControls() dlg.Destroy()
def OnClose(self, e): if self.oldExtruderAmount != int( profile.getPreference('extruder_amount')): wx.MessageBox( 'After changing the amount of extruders you need to restart Cura for full effect.', 'Extruder amount warning.', wx.OK | wx.ICON_INFORMATION) self.MakeModal(False) self.parent.updateProfileToControls() self.Destroy()
def OnCustomFirmware(self, e): dlg=wx.FileDialog(self, "Open firmware to upload", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX") if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() if not(os.path.exists(filename)): return #For some reason my Ubuntu 10.10 crashes here. firmwareInstall.InstallFirmware(filename)
def OnLoadModel(self, e): dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL") if dlg.ShowModal() == wx.ID_OK: self.filelist = [dlg.GetPath()] profile.putPreference('lastFile', ';'.join(self.filelist)) self.preview3d.loadModelFiles(self.filelist) self.preview3d.setViewMode("Normal") dlg.Destroy()
def OnClose(self, e): if self.oldExtruderAmount != int(profile.getPreference("extruder_amount")): wx.MessageBox( "After changing the amount of extruders you need to restart Cura for full effect.", "Extruder amount warning.", wx.OK | wx.ICON_INFORMATION, ) self.MakeModal(False) self.Destroy()
def __init__(self, parent): super(preferencesDialog, self).__init__(title="Preferences") wx.EVT_CLOSE(self, self.OnClose) self.oldExtruderAmount = int(profile.getPreference('extruder_amount')) left, right, main = self.CreateConfigPanel(self) 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') validators.validFloat(c, 10.0) c = configBase.SettingRow(left, 'Machine 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') 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') for i in xrange(1, self.oldExtruderAmount): configBase.TitleRow(left, 'Extruder %d' % (i+1)) c = configBase.SettingRow(left, 'Offset X', 'extruder_offset_x%d' % (i), '0.0', 'The offset of your secondary extruder compared to the primary.', type = 'preference') validators.validFloat(c) c = configBase.SettingRow(left, 'Offset Y', 'extruder_offset_y%d' % (i), '0.0', 'The offset of your secondary extruder compared to the primary.', type = 'preference') validators.validFloat(c) 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') 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') 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') validators.validFloat(c, 0.0) configBase.TitleRow(right, 'Communication settings') c = configBase.SettingRow(right, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference') c = configBase.SettingRow(right, 'Baudrate', 'serial_baud', '250000', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference') configBase.TitleRow(right, 'Slicer settings') #c = configBase.SettingRow(right, 'Slicer selection', 'slicer', ['Cura (Skeinforge based)', 'Slic3r'], 'Which slicer to use to slice objects. Usually the Cura engine produces the best results. But Slic3r is developing fast and is faster with slicing.', type = 'preference') c = configBase.SettingRow(right, 'Save profile on slice', 'save_profile', False, 'When slicing save the profile as [stl_file]_profile.ini next to the model.', type = 'preference') configBase.TitleRow(right, 'SD Card settings') if len(getDrives()) > 1: c = configBase.SettingRow(right, 'SD card drive', 'sdpath', getDrives(), 'Location of your SD card, when using the copy to SD feature.', type = 'preference') else: c = configBase.SettingRow(right, 'SD card path', 'sdpath', '', 'Location of your SD card, when using the copy to SD feature.', type = 'preference') c = configBase.SettingRow(right, 'Copy to SD with 8.3 names', 'sdshortnames', False, 'Save the gcode files in short filenames, so they are properly shown on the UltiController', type = 'preference') self.okButton = wx.Button(left, -1, 'Ok') left.GetSizer().Add(self.okButton, (left.GetSizer().GetRows(), 1)) self.okButton.Bind(wx.EVT_BUTTON, self.OnClose) self.MakeModal(True) main.Fit() self.Fit()
def OnSaveProfile(self, e): dlg = wx.FileDialog(self, "Select profile file to save", os.path.split( profile.getPreference('lastFile'))[0], style=wx.FD_SAVE) dlg.SetWildcard("ini files (*.ini)|*.ini") if dlg.ShowModal() == wx.ID_OK: profileFile = dlg.GetPath() profile.saveGlobalProfile(profileFile) dlg.Destroy()
def OnLoadProfile(self, e): dlg = wx.FileDialog(self, "Select profile file to load", os.path.split( profile.getPreference('lastFile'))[0], style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("ini files (*.ini)|*.ini") if dlg.ShowModal() == wx.ID_OK: profileFile = dlg.GetPath() profile.loadGlobalProfile(profileFile) self.updateProfileToControls() dlg.Destroy()
def OnSetCustomProfile(self, e): if self.selection == None: return dlg=wx.FileDialog(self, "Select profile", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("Profile files (*.ini)|*.ini;*.INI") if dlg.ShowModal() == wx.ID_OK: self.selection.profile = dlg.GetPath() else: self.selection.profile = None self._updateListbox() dlg.Destroy()
def __init__(self, mainWindow, parent, filelist): wx.Panel.__init__(self, parent, -1) self.mainWindow = mainWindow self.filelist = filelist self.abort = False box = wx.StaticBox(self, -1, filelist[0]) self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(self.sizer, 0, flag=wx.EXPAND) self.statusText = wx.StaticText(self, -1, "Starting...") self.progressGauge = wx.Gauge(self, -1) self.progressGauge.SetRange(10000 * len(filelist)) self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT) self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER) self.sizer.Add(self.progressGauge, 2) self.sizer.Add(self.abortButton, 0) self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton) self.SetSizer(mainSizer) self.prevStep = 'start' self.totalDoneFactor = 0.0 self.startTime = time.time() if profile.getPreference('save_profile') == 'True': profile.saveGlobalProfile( self.filelist[0][:self.filelist[0].rfind('.')] + "_profile.ini") cmdList = [] for filename in self.filelist: idx = self.filelist.index(filename) #print filename, idx 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('alternative_center', self.filelist[0]) if len(self.filelist) > 1: profile.setTempOverride('add_start_end_gcode', 'False') profile.setTempOverride('gcode_extension', 'multi_extrude_tmp') cmdList.append(sliceRun.getSliceCommand(filename)) profile.resetTempOverride() self.thread = WorkerThread(self, filelist, cmdList)
def OnAddModel(self, e): dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE) dlg.SetWildcard(meshLoader.wildcardFilter()) if dlg.ShowModal() == wx.ID_OK: for filename in dlg.GetPaths(): item = ProjectObject(self, filename) profile.putPreference('lastFile', item.filename) self.list.append(item) self.selection = item self._updateListbox() self.OnListSelect(None) self.preview.Refresh() dlg.Destroy()
def OnSliceDone(self): self.abortButton.Destroy() self.closeButton = wx.Button(self, -1, "Close") self.sizer.Add(self.closeButton, (2 + self.threadCount * 2, 0), span=(1, 1)) if profile.getPreference('sdpath') != '': self.copyToSDButton = wx.Button(self, -1, "To SDCard") self.Bind(wx.EVT_BUTTON, self.OnCopyToSD, self.copyToSDButton) self.sizer.Add(self.copyToSDButton, (2 + self.threadCount * 2, 1), span=(1, 1)) self.Bind(wx.EVT_BUTTON, self.OnAbort, self.closeButton) self.Layout() self.Fit()
def OnLoadModel(self, e): dlg = wx.FileDialog(self, "Open file to print", os.path.split( profile.getPreference('lastFile'))[0], style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) dlg.SetWildcard(meshLoader.wildcardFilter()) if dlg.ShowModal() == wx.ID_OK: self.filelist = [dlg.GetPath()] profile.putPreference('lastFile', ';'.join(self.filelist)) self.preview3d.loadModelFiles(self.filelist, True) self.preview3d.setViewMode("Normal") dlg.Destroy()
def OnCustomFirmware(self, e): dlg = wx.FileDialog(self, "Open firmware to upload", os.path.split( profile.getPreference('lastFile'))[0], style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX") if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() if not (os.path.exists(filename)): return #For some reason my Ubuntu 10.10 crashes here. machineCom.InstallFirmware(filename)
def OnAddModel(self, e): dlg = wx.FileDialog( self, "Open file to batch slice", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE) dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL") if dlg.ShowModal() == wx.ID_OK: for filename in dlg.GetPaths(): profile.putPreference('lastFile', filename) self.list.append(filename) self.selection = filename self._updateListbox() dlg.Destroy()
def OnResetProfile(self, e): dlg = wx.MessageDialog( self, 'This will reset all profile settings to defaults.\nUnless you have saved your current profile, all settings will be lost!\nDo you really want to reset?', 'Profile reset', wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() == wx.ID_YES 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()