From b6e248590e81a8a4ce35bda63f33f3559e6caf4d Mon Sep 17 00:00:00 2001 From: daid Date: Thu, 30 Jan 2014 08:38:14 +0100 Subject: [PATCH] Fix doodle3D and Dummy printer connections for new in-memory engine interface. --- Cura/gui/mainWindow.py | 2 +- Cura/gui/sceneView.py | 3 +-- Cura/util/printerConnection/doodle3dConnect.py | 6 ++---- Cura/util/printerConnection/dummyConnection.py | 7 +++---- Cura/util/printerConnection/printerConnectionBase.py | 4 ++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index b78fe37d..8bc54b62 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -60,7 +60,7 @@ class mainWindow(wx.Frame): self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, _("Print...\tCTRL+P")) - self.Bind(wx.EVT_MENU, lambda e: self.scene.showPrintWindow(), i) + self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i) i = self.fileMenu.Append(-1, _("Save GCode...")) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, _("Show slice engine log...")) diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index 337a1883..d37a0c06 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -267,8 +267,7 @@ class SceneView(openglGui.glGuiPanel): connection.window = printWindow2.printWindow(connection) connection.window.Show() connection.window.Raise() - #TODO: Fix for _engine.getResult - if not connection.loadFile(self._gcodeFilename): + if not connection.loadGCodeData(StringIO.StringIO(self._engine.getResult().getGCode())): if connection.isPrinting(): self.notification.message("Cannot start print, because other print still running.") else: diff --git a/Cura/util/printerConnection/doodle3dConnect.py b/Cura/util/printerConnection/doodle3dConnect.py index 25b42851..918ee7a0 100644 --- a/Cura/util/printerConnection/doodle3dConnect.py +++ b/Cura/util/printerConnection/doodle3dConnect.py @@ -122,15 +122,14 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase): self.checkThread.start() #Load the file into memory for printing. - def loadFile(self, filename): + def loadGCodeData(self, dataStream): if self._printing: return False self._fileBlocks = [] self._lineCount = 0 block = [] blockSize = 0 - f = open(filename, "r") - for line in f: + for line in dataStream: #Strip out comments, we do not need to send comments if ';' in line: line = line[:line.index(';')] @@ -148,7 +147,6 @@ class doodle3dConnect(printerConnectionBase.printerConnectionBase): blockSize += len(line) + 1 block.append(line) self._fileBlocks.append('\n'.join(block) + '\n') - f.close() self._doCallback() return True diff --git a/Cura/util/printerConnection/dummyConnection.py b/Cura/util/printerConnection/dummyConnection.py index 4d8dee0f..98c7f94b 100644 --- a/Cura/util/printerConnection/dummyConnection.py +++ b/Cura/util/printerConnection/dummyConnection.py @@ -29,13 +29,12 @@ class dummyConnection(printerConnectionBase.printerConnectionBase): self.printThread.daemon = True self.printThread.start() - #Load the file into memory for printing. - def loadFile(self, filename): + #Load the data into memory for printing, returns True on success + def loadGCodeData(self, dataStream): if self._printing: return False self._lineCount = 0 - f = open(filename, "r") - for line in f: + for line in dataStream: #Strip out comments, we do not need to send comments if ';' in line: line = line[:line.index(';')] diff --git a/Cura/util/printerConnection/printerConnectionBase.py b/Cura/util/printerConnection/printerConnectionBase.py index 41594fef..ab556a5f 100644 --- a/Cura/util/printerConnection/printerConnectionBase.py +++ b/Cura/util/printerConnection/printerConnectionBase.py @@ -39,8 +39,8 @@ class printerConnectionBase(object): def getName(self): return self._name - #Load the file into memory for printing, returns True on success - def loadFile(self, filename): + #Load the data into memory for printing, returns True on success + def loadGCodeData(self, dataStream): return False #Start printing the previously loaded file -- 2.30.2