chiark / gitweb /
Add a print progress status text to the print window and show current Z
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Thu, 5 Nov 2015 20:34:14 +0000 (15:34 -0500)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Thu, 5 Nov 2015 20:35:37 +0000 (15:35 -0500)
This shows current percentage, currnet line and Z in the print window.

Cura/gui/printWindow.py
Cura/serialCommunication.py
Cura/util/printerConnection/dummyConnection.py
Cura/util/printerConnection/printerConnectionBase.py
Cura/util/printerConnection/serialConnection.py

index b21b79e149472f2e26bf114c32f29e23e178b85a..3fe5331c27ae6311e36791f8e65c4133e33e9953 100644 (file)
@@ -392,7 +392,11 @@ class printWindowPlugin(wx.Frame):
                isPrinting = connection.isPrinting() or connection.isPaused()
                if self._progressBar is not None:
                        if isPrinting:
-                               self._progressBar.SetValue(connection.getPrintProgress() * 1000)
+                               (current, total, z) = connection.getPrintProgress()
+                               progress = 0.0
+                               if total > 0:
+                                       progress = float(current) / float(total)
+                               self._progressBar.SetValue(progress * 1000)
                        else:
                                self._progressBar.SetValue(0)
                info = connection.getStatusString()
@@ -539,7 +543,11 @@ class printWindowBasic(wx.Frame):
                self._updateButtonStates()
                onGoingPrint = connection.isPrinting() or connection.isPaused()
                if onGoingPrint:
-                       self.progress.SetValue(connection.getPrintProgress() * 1000)
+                       (current, total, z) = connection.getPrintProgress()
+                       progress = 0.0
+                       if total > 0:
+                               progress = float(current) / float(total)
+                       self.progress.SetValue(progress * 1000)
                else:
                        self.progress.SetValue(0)
                info = connection.getStatusString()
@@ -665,6 +673,7 @@ class printWindowAdvanced(wx.Frame):
                self.temperatureBedField = TemperatureField(self.panel, self._setBedTemperature)
                self.temperatureGraph = TemperatureGraph(self.panel)
                self.temperatureGraph.SetMinSize((250, 100))
+               self.printStatus = wx.StaticText(parent=self.panel, id=-1, label="");
                self.progress = wx.Gauge(self.panel, -1, range=1000)
 
                f = wx.Font(8, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False)
@@ -692,7 +701,8 @@ class printWindowAdvanced(wx.Frame):
                self.sizer.Add(self.temperatureBedField, pos=(5, 2))
                self.sizer.Add(self._termLog, pos=(0, 3), span=(5, 3), flag=wx.EXPAND|wx.RIGHT, border=5)
                self.sizer.Add(self._termInput, pos=(5, 3), span=(1, 3), flag=wx.EXPAND|wx.RIGHT, border=5)
-               self.sizer.Add(self.progress, pos=(6, 0), span=(1, 6), flag=wx.EXPAND|wx.BOTTOM)
+               self.sizer.Add(self.printStatus, pos=(6, 0), span=(1, 6), flag=wx.EXPAND|wx.BOTTOM|wx.TOP, border=5)
+               self.sizer.Add(self.progress, pos=(7, 0), span=(1, 6), flag=wx.EXPAND|wx.BOTTOM)
 
                self.Bind(wx.EVT_SIZE, self.OnSize)
                self.Bind(wx.EVT_CLOSE, self.OnClose)
@@ -937,7 +947,12 @@ class printWindowAdvanced(wx.Frame):
                self._updateButtonStates()
                isPrinting = connection.isPrinting() or connection.isPaused()
                if isPrinting:
-                       self.progress.SetValue(connection.getPrintProgress() * 1000)
+                       (current, total, z) = connection.getPrintProgress()
+                       progress = 0.0
+                       if total > 0:
+                               progress = float(current) / float(total)
+                       self.progress.SetValue(progress * 1000)
+                       self.printStatus.SetLabel(_("Printing %.2f%% | Line %d of %d lines | Z: %.3f mm") % (progress * 100, current, total, z))
                else:
                        self.progress.SetValue(0)
                info = connection.getStatusString()
index 4add5f2314d8c1efd58ac48055ecc5fae0d08a05..1b095484a5477bcc5295aec0f1970fc2f871caeb 100644 (file)
@@ -48,7 +48,7 @@ class serialComm(object):
                sys.stdout.write('progress:%d\n' % (lineNr))
 
        def mcZChange(self, newZ):
-               pass
+               sys.stdout.write('changeZ:%f\n' % (newZ))
 
        def monitorStdin(self):
                while not (self._comm.isClosed() or sys.stdin.closed):
index cf148f69bfaa19bcb0df63a0228137b4ff1bf82a..37124bff0015df4f25bffa886b8ceb4b31629df6 100644 (file)
@@ -80,9 +80,7 @@ class dummyConnection(printerConnectionBase.printerConnectionBase):
 
        #Amount of progression of the current print file. 0.0 to 1.0
        def getPrintProgress(self):
-               if self._lineCount < 1:
-                       return 0.0
-               return float(self._progressLine) / float(self._lineCount)
+               return (self._progressLine, self._lineCount, 0.0)
 
        # Return if the printer with this connection type is available
        def isAvailable(self):
index 207131cea50c0926c6bedc636bbfd382c01dbfaf..15581ce6368513a2c17682bd7efd0f2d7713bf23 100644 (file)
@@ -65,9 +65,9 @@ class printerConnectionBase(object):
        def isPrinting(self):
                return False
 
-       #Amount of progression of the current print file. 0.0 to 1.0
+       #Amount of progression of the current print file. Returns (current line, total lines, current Z position)
        def getPrintProgress(self):
-               return 0.0
+               return (0, 0, 0.0)
 
        #Returns true if we need to establish an active connection.
        # Depending on the type of the connection some types do not need an active connection (Doodle3D WiFi Box for example)
index dccaaed873b89e78a86dcece8345560a0ff7c33a..a2ecf76f38a5eb7f828908fce8019bbc4aef2a87 100644 (file)
@@ -67,6 +67,8 @@ class serialConnection(printerConnectionBase.printerConnectionBase):
                self._commState = None
                self._commStateString = None
                self._gcodeData = []
+               self._printProgress = 0
+               self._ZPosition = 0
 
        #Load the data into memory for printing, returns True on success
        def loadGCodeData(self, dataStream):
@@ -94,6 +96,7 @@ class serialConnection(printerConnectionBase.printerConnectionBase):
                        self._process.stdin.write('G:%s\n' % (line))
                self._process.stdin.write('START\n')
                self._printProgress = 0
+               self._ZPosition = 0
 
        def coolDown(self):
                cooldown_toolhead = "M104 S0"
@@ -130,13 +133,14 @@ class serialConnection(printerConnectionBase.printerConnectionBase):
        def pause(self, value):
                if not (self.isPrinting() or self.isPaused()) or self._process is None:
                        return
-               self._process.stdin.write('PAUSE\n' if value else "RESUME\n")
+               if value:
+                       self._process.stdin.write("PAUSE\n")
+               else:
+                       self._process.stdin.write("RESUME\n")
 
        #Amount of progression of the current print file. 0.0 to 1.0
        def getPrintProgress(self):
-               if len(self._gcodeData) < 1:
-                       return 0.0
-               return float(self._printProgress) / float(len(self._gcodeData))
+               return (self._printProgress, len(self._gcodeData), self._ZPosition)
 
        # Return if the printer with this connection type is available
        def isAvailable(self):
@@ -240,6 +244,9 @@ class serialConnection(printerConnectionBase.printerConnectionBase):
                        elif line[0] == 'progress':
                                self._printProgress = int(line[1])
                                self._doCallback()
+                       elif line[0] == 'changeZ':
+                               self._ZPosition = float(line[1])
+                               self._doCallback()
                        else:
                                print line
                        line = self._process.stdout.readline()