From 7f27198e7b7ee057d64c46dcd8cfde6be5466faf Mon Sep 17 00:00:00 2001 From: daid Date: Tue, 3 Apr 2012 10:44:53 +0200 Subject: [PATCH 1/7] Disable the window icon till we find out why the MacOS crashes, and the windows version does not work. --- Cura/gui/mainWindow.py | 2 +- Cura/gui/printWindow.py | 2 +- Cura/gui/simpleMode.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 20a00324ea..870e02df86 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -36,7 +36,7 @@ class mainWindow(configBase.configWindowBase): super(mainWindow, self).__init__(title='Cura') wx.EVT_CLOSE(self, self.OnClose) - self.SetIcon(icon.getMainIcon()) + #self.SetIcon(icon.getMainIcon()) menubar = wx.MenuBar() fileMenu = wx.Menu() diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index 7eae41fdb7..f4c22e0302 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -29,7 +29,7 @@ class printWindow(wx.Frame): self.bufferLineCount = 4 self.sendCnt = 0 - self.SetIcon(icon.getMainIcon()) + #self.SetIcon(icon.getMainIcon()) self.SetSizer(wx.BoxSizer()) self.panel = wx.Panel(self) diff --git a/Cura/gui/simpleMode.py b/Cura/gui/simpleMode.py index 13954fd10b..1b498be714 100644 --- a/Cura/gui/simpleMode.py +++ b/Cura/gui/simpleMode.py @@ -20,7 +20,7 @@ class simpleModeWindow(configBase.configWindowBase): super(simpleModeWindow, self).__init__(title='Cura - Simple mode') wx.EVT_CLOSE(self, self.OnClose) - self.SetIcon(icon.getMainIcon()) + #self.SetIcon(icon.getMainIcon()) menubar = wx.MenuBar() fileMenu = wx.Menu() From e999faf08ada85b32a9d665b13e77884cb3280be Mon Sep 17 00:00:00 2001 From: daid Date: Tue, 3 Apr 2012 11:59:38 +0200 Subject: [PATCH 2/7] Add hidden virtual printer, for testing --- Cura/gui/machineCom.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Cura/gui/machineCom.py b/Cura/gui/machineCom.py index ffd816535a..2ba186aeb6 100644 --- a/Cura/gui/machineCom.py +++ b/Cura/gui/machineCom.py @@ -103,6 +103,30 @@ class InstallFirmware(wx.Dialog): def OnClose(self, e): self.Destroy() +class VirtualPrinter(): + def __init__(self): + self.readList = ['start\n'] + + def write(self, data): + if self.readList == None: + return + time.sleep(0.001) + print "Send: %s" % (data.rstrip()) + self.readList.append("ok\n") + + def readline(self): + if self.readList == None: + return '' + while len(self.readList) < 1: + time.sleep(0.1) + if self.readList == None: + return '' + print "Recv: %s" % (self.readList[0].rstrip()) + return self.readList.pop(0) + + def close(self): + self.readList = None + class MachineCom(): def __init__(self, port = None, baudrate = None): if port == None: @@ -124,6 +148,8 @@ class MachineCom(): 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=5) @@ -134,8 +160,8 @@ class MachineCom(): if self.serial == None: return None ret = self.serial.readline() - if ret != '': - print "Recv: " + ret.rstrip() + #if ret != '': + # print "Recv: " + ret.rstrip() return ret def close(self): @@ -146,6 +172,6 @@ class MachineCom(): def sendCommand(self, cmd): if self.serial == None: return - print 'Send: ' + cmd + #print 'Send: ' + cmd self.serial.write(cmd + '\n') From c2ce7b9c243b25b46f4bdf66fe1fc5b894c69149 Mon Sep 17 00:00:00 2001 From: daid Date: Tue, 3 Apr 2012 12:06:02 +0200 Subject: [PATCH 3/7] Updated print window with statistics about the print. Filament used, and estimated print time. --- Cura/gui/preferencesDialog.py | 4 ++++ Cura/gui/printWindow.py | 21 ++++++++++++++------- Cura/util/gcodeInterpreter.py | 7 +++++++ Cura/util/profile.py | 1 + 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index 564a583c57..782ee33866 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -25,6 +25,10 @@ class preferencesDialog(configBase.configWindowBase): c = configBase.SettingRow(left, 'Machine height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference') validators.validFloat(c, 10.0) + configBase.TitleRow(left, 'Filament settings') + c = configBase.SettingRow(left, '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) + configBase.TitleRow(left, 'Communication settings') c = configBase.SettingRow(left, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference') c = configBase.SettingRow(left, 'Baudrate', 'serial_baud', '250000', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference') diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index f4c22e0302..ea86a6c9df 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -24,6 +24,7 @@ class printWindow(wx.Frame): self.machineCom = None self.machineConnected = False self.thread = None + self.gcode = None self.gcodeList = None self.printIdx = None self.bufferLineCount = 4 @@ -78,8 +79,13 @@ class printWindow(wx.Frame): def UpdateProgress(self): status = "" + if self.gcode != None: + status += "Filament: %.2fm %.2fg\n" % (self.gcode.extrusionAmount / 1000, self.gcode.calculateWeight() * 1000) + status += "Print time: %02d:%02d\n" % (int(self.gcode.totalMoveTimeMinute / 60), int(self.gcode.totalMoveTimeMinute % 60)) if self.printIdx == None: self.progress.SetValue(0) + if self.gcodeList != None: + status += 'Line: -/%d\n' % (len(self.gcodeList)) else: self.progress.SetValue(self.printIdx) status += 'Line: %d/%d\n' % (self.printIdx, len(self.gcodeList)) @@ -131,19 +137,19 @@ class printWindow(wx.Frame): gcodeList.append(line) gcode = gcodeInterpreter.gcode() gcode.loadList(gcodeList) - print gcode.extrusionAmount - print gcode.totalMoveTimeMinute print "Loaded: %s (%d)" % (filename, len(gcodeList)) self.progress.SetRange(len(gcodeList)) + self.gcode = gcode self.gcodeList = gcodeList self.UpdateButtonStates() self.UpdateProgress() def sendLine(self, lineNr): if lineNr >= len(self.gcodeList): - return + return False checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (lineNr, self.gcodeList[lineNr]))) self.machineCom.sendCommand("N%d%s*%d" % (lineNr, self.gcodeList[lineNr], checksum)) + return True def PrinterMonitor(self): skipCount = 0 @@ -151,7 +157,7 @@ class printWindow(wx.Frame): line = self.machineCom.readline() if line == None: self.machineConnected = False - wx.CallAfter(self.UpdateButtonState) + wx.CallAfter(self.UpdateButtonStates) return if self.machineConnected: while self.sendCnt > 0: @@ -160,14 +166,14 @@ class printWindow(wx.Frame): self.sendCnt -= 1 elif line.startswith("start"): self.machineConnected = True - wx.CallAfter(self.UpdateButtonState) + wx.CallAfter(self.UpdateButtonStates) if self.printIdx != None: if line.startswith("ok"): if skipCount > 0: skipCount -= 1 else: - self.sendLine(self.printIdx) - self.printIdx += 1 + if self.sendLine(self.printIdx): + self.printIdx += 1 wx.CallAfter(self.UpdateProgress) elif "resend" in line.lower() or "rs" in line: try: @@ -177,3 +183,4 @@ class printWindow(wx.Frame): lineNr=int(line.split()[1]) self.printIdx = lineNr #we should actually resend the line here, but we also get an "ok" for each error from Marlin. And thus we'll resend on the OK. + diff --git a/Cura/util/gcodeInterpreter.py b/Cura/util/gcodeInterpreter.py index 06ebd5ac6d..3570d49e99 100644 --- a/Cura/util/gcodeInterpreter.py +++ b/Cura/util/gcodeInterpreter.py @@ -7,6 +7,7 @@ import re import os from util import util3d +from util import profile class gcodePath(): def __init__(self, newType, pathType, startPoint): @@ -31,6 +32,12 @@ class gcode(): def loadList(self, l): self._load(l) + def calculateWeight(self): + #Calculates the weight of the filament in kg + radius = float(profile.getProfileSetting('filament_diameter')) / 2 + volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000) + return volumeM3 * float(profile.getPreference('filament_density')) + def _load(self, gcodeFile): filePos = 0 pos = util3d.Vector3() diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 2548ec8141..5845e14cc3 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -69,6 +69,7 @@ preferencesDefaultSettings = { 'machine_width': '205', 'machine_depth': '205', 'machine_height': '200', + 'filament_density': '1300', 'steps_per_e': '0', 'serial_port': 'AUTO', 'serial_baud': '250000', From 6cef0052a9aa6258efde823d7bd02c65c1ff5338 Mon Sep 17 00:00:00 2001 From: daid Date: Tue, 3 Apr 2012 12:27:36 +0200 Subject: [PATCH 4/7] Updated package script to run nsis if wine exists --- package.sh | 8 +++++++- scripts/win32/installer.nsi | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package.sh b/package.sh index 7eaed8040a..2a9038ae32 100755 --- a/package.sh +++ b/package.sh @@ -16,7 +16,7 @@ BUILD_TARGET=${1:-win32} ##Do we need to create the final archive ARCHIVE_FOR_DISTRIBUTION=1 ##Which version name are we appending to the final archive -BUILD_NAME=NewUI-Beta4 +BUILD_NAME=RC1 TARGET_DIR=${BUILD_TARGET}-Cura-${BUILD_NAME} ##Which versions of external programs to use @@ -159,6 +159,12 @@ if (( ${ARCHIVE_FOR_DISTRIBUTION} )); then cd ${TARGET_DIR} 7z a ../${TARGET_DIR}.zip * cd .. + + if [ ! -z `which wine` ]; then + #if we have wine, try to run our nsis script. + ln -sf `pwd`/${TARGET_DIR} scripts/win32/dist + wine ~/.wine/drive_c/Program\ Files/NSIS/makensis.exe /DVERSION=${BUILD_NAME} scripts/win32/installer.nsi + fi else echo "Archiving to ${TARGET_DIR}.tar.gz" $TAR cfp - ${TARGET_DIR} | gzip --best -c > ${TARGET_DIR}.tar.gz diff --git a/scripts/win32/installer.nsi b/scripts/win32/installer.nsi index 590deabb07..c5d36f5b15 100644 --- a/scripts/win32/installer.nsi +++ b/scripts/win32/installer.nsi @@ -1,4 +1,6 @@ -!define VERSION 'RC1' +!ifndef VERSION + !define VERSION 'DEV' +!endif ; The name of the installer Name "Cura ${VERSION}" From 7000945a072f385422d5ecff32764401b6cf0c5b Mon Sep 17 00:00:00 2001 From: daid Date: Tue, 3 Apr 2012 17:01:51 +0200 Subject: [PATCH 5/7] Simplify the printer interface. --- Cura/gui/machineCom.py | 2 +- Cura/gui/printWindow.py | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Cura/gui/machineCom.py b/Cura/gui/machineCom.py index 2ba186aeb6..7c1de22f02 100644 --- a/Cura/gui/machineCom.py +++ b/Cura/gui/machineCom.py @@ -110,7 +110,6 @@ class VirtualPrinter(): def write(self, data): if self.readList == None: return - time.sleep(0.001) print "Send: %s" % (data.rstrip()) self.readList.append("ok\n") @@ -121,6 +120,7 @@ class VirtualPrinter(): time.sleep(0.1) if self.readList == None: return '' + time.sleep(0.001) print "Recv: %s" % (self.readList[0].rstrip()) return self.readList.pop(0) diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index ea86a6c9df..8607f68ccb 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -13,6 +13,7 @@ def printFile(filename): global printWindowHandle if printWindowHandle == None: printWindowHandle = printWindow() + printWindowHandle.OnConnect(None) printWindowHandle.Show(True) printWindowHandle.Raise() printWindowHandle.LoadGCodeFile(filename) @@ -45,13 +46,13 @@ class printWindow(wx.Frame): self.sizer.Add(boxsizer, pos=(0,0), span=(4,1), flag=wx.EXPAND) - self.connectButton = wx.Button(self.panel, -1, 'Connect') - self.loadButton = wx.Button(self.panel, -1, 'Load GCode') + #self.connectButton = wx.Button(self.panel, -1, 'Connect') + #self.loadButton = wx.Button(self.panel, -1, 'Load GCode') self.printButton = wx.Button(self.panel, -1, 'Print GCode') self.cancelButton = wx.Button(self.panel, -1, 'Cancel print') self.progress = wx.Gauge(self.panel, -1) - self.sizer.Add(self.connectButton, pos=(0,1)) - self.sizer.Add(self.loadButton, pos=(1,1)) + #self.sizer.Add(self.connectButton, pos=(0,1)) + #self.sizer.Add(self.loadButton, pos=(1,1)) self.sizer.Add(self.printButton, pos=(2,1)) self.sizer.Add(self.cancelButton, pos=(3,1)) self.sizer.Add(self.progress, pos=(4,0), span=(1,2), flag=wx.EXPAND) @@ -59,8 +60,8 @@ class printWindow(wx.Frame): self.sizer.AddGrowableCol(0) self.Bind(wx.EVT_CLOSE, self.OnClose) - self.connectButton.Bind(wx.EVT_BUTTON, self.OnConnect) - self.loadButton.Bind(wx.EVT_BUTTON, self.OnLoad) + #self.connectButton.Bind(wx.EVT_BUTTON, self.OnConnect) + #self.loadButton.Bind(wx.EVT_BUTTON, self.OnLoad) self.printButton.Bind(wx.EVT_BUTTON, self.OnPrint) self.cancelButton.Bind(wx.EVT_BUTTON, self.OnCancel) @@ -72,8 +73,8 @@ class printWindow(wx.Frame): self.UpdateProgress() def UpdateButtonStates(self): - self.connectButton.Enable(not self.machineConnected) - self.loadButton.Enable(self.printIdx == None) + #self.connectButton.Enable(not self.machineConnected) + #self.loadButton.Enable(self.printIdx == None) self.printButton.Enable(self.machineConnected and self.gcodeList != None and self.printIdx == None) self.cancelButton.Enable(self.printIdx != None) @@ -128,6 +129,8 @@ class printWindow(wx.Frame): self.Destroy() def LoadGCodeFile(self, filename): + if self.printIdx != None: + return gcodeList = ["M110"] for line in open(filename, 'r'): if ';' in line: @@ -174,6 +177,9 @@ class printWindow(wx.Frame): else: if self.sendLine(self.printIdx): self.printIdx += 1 + else: + self.printIdx = None + wx.CallAfter(self.UpdateButtonStates) wx.CallAfter(self.UpdateProgress) elif "resend" in line.lower() or "rs" in line: try: From 0a5cc62205da0bb394bb858caaf462b4f49ade45 Mon Sep 17 00:00:00 2001 From: Daid Date: Tue, 3 Apr 2012 20:27:46 +0200 Subject: [PATCH 6/7] Add support to GCode comments. Show connect button in print dialog. --- .../export_plugins/static_plugins/gcode_small.py | 2 ++ Cura/gui/printWindow.py | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py index 8837e377bd..00e255405d 100644 --- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py +++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py @@ -126,6 +126,8 @@ class GcodeSmallSkein: self.output.write(';TYPE:FILL\n'); elif line.startswith('('): self.output.write(';TYPE:CUSTOM\n'); + elif line.startswith('('): + self.output.write(';TYPE:SUPPORT\n'); elif line.startswith('('): self.output.write(';LAYER:%d\n' % (self.layerNr)); self.layerNr += 1 diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index 8607f68ccb..ac42429015 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -41,17 +41,17 @@ class printWindow(wx.Frame): sb = wx.StaticBox(self.panel, label="Statistics") boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) - self.statsText = wx.StaticText(self.panel, -1, "Filament: #.##m #.##g\nPrint time: ##:##") + self.statsText = wx.StaticText(self.panel, -1, "Filament: ####.##m #.##g\nPrint time: #####:##") boxsizer.Add(self.statsText, flag=wx.LEFT, border=5) self.sizer.Add(boxsizer, pos=(0,0), span=(4,1), flag=wx.EXPAND) - #self.connectButton = wx.Button(self.panel, -1, 'Connect') + self.connectButton = wx.Button(self.panel, -1, 'Connect') #self.loadButton = wx.Button(self.panel, -1, 'Load GCode') self.printButton = wx.Button(self.panel, -1, 'Print GCode') self.cancelButton = wx.Button(self.panel, -1, 'Cancel print') self.progress = wx.Gauge(self.panel, -1) - #self.sizer.Add(self.connectButton, pos=(0,1)) + self.sizer.Add(self.connectButton, pos=(0,1)) #self.sizer.Add(self.loadButton, pos=(1,1)) self.sizer.Add(self.printButton, pos=(2,1)) self.sizer.Add(self.cancelButton, pos=(3,1)) @@ -60,7 +60,7 @@ class printWindow(wx.Frame): self.sizer.AddGrowableCol(0) self.Bind(wx.EVT_CLOSE, self.OnClose) - #self.connectButton.Bind(wx.EVT_BUTTON, self.OnConnect) + self.connectButton.Bind(wx.EVT_BUTTON, self.OnConnect) #self.loadButton.Bind(wx.EVT_BUTTON, self.OnLoad) self.printButton.Bind(wx.EVT_BUTTON, self.OnPrint) self.cancelButton.Bind(wx.EVT_BUTTON, self.OnCancel) @@ -73,7 +73,7 @@ class printWindow(wx.Frame): self.UpdateProgress() def UpdateButtonStates(self): - #self.connectButton.Enable(not self.machineConnected) + self.connectButton.Enable(not self.machineConnected) #self.loadButton.Enable(self.printIdx == None) self.printButton.Enable(self.machineConnected and self.gcodeList != None and self.printIdx == None) self.cancelButton.Enable(self.printIdx != None) From 96d014b2c4cef94dbbe4c3adc1c8d7a8ce929ad2 Mon Sep 17 00:00:00 2001 From: Daid Date: Tue, 3 Apr 2012 23:45:42 +0200 Subject: [PATCH 7/7] Add support and skirt/raft colors to GCode preview --- Cura/gui/preview3d.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py index c27558bd53..935cef7be5 100644 --- a/Cura/gui/preview3d.py +++ b/Cura/gui/preview3d.py @@ -459,6 +459,10 @@ class PreviewGLCanvas(glcanvas.GLCanvas): glColor3f(c/2,c/2,0) elif path.pathType == 'WALL-INNER': glColor3f(0,c,0) + elif path.pathType == 'SUPPORT': + glColor3f(0,c,c) + elif path.pathType == 'SKIRT': + glColor3f(0,c/2,c/2) else: glColor3f(c,0,0) if path.type == 'retract':