chiark / gitweb /
Show print time, filemant used and cost estimate after slicing.
authorDaid <daid303@gmail.com>
Sun, 29 Apr 2012 10:00:13 +0000 (12:00 +0200)
committerDaid <daid303@gmail.com>
Sun, 29 Apr 2012 10:00:13 +0000 (12:00 +0200)
Cura/gui/printWindow.py
Cura/gui/sliceProgessPanel.py
Cura/util/gcodeInterpreter.py

index 195b5942575e56d999bcd3602fe0a4944974225a..5f68556d778726ebae66f77f57094ae12c7d7954 100644 (file)
@@ -176,14 +176,9 @@ class printWindow(wx.Frame):
                status = ""\r
                if self.gcode != None:\r
                        status += "Filament: %.2fm %.2fg\n" % (self.gcode.extrusionAmount / 1000, self.gcode.calculateWeight() * 1000)\r
-                       cost_kg = float(profile.getPreference('filament_cost_kg'))\r
-                       cost_meter = float(profile.getPreference('filament_cost_meter'))\r
-                       if cost_kg > 0.0 and cost_meter > 0.0:\r
-                               status += "Filament cost: %.2f / %.2f\n" % (self.gcode.calculateWeight() * cost_kg, self.gcode.extrusionAmount / 1000 * cost_meter)\r
-                       elif cost_kg > 0.0:\r
-                               status += "Filament cost: %.2f\n" % (self.gcode.calculateWeight() * cost_kg)\r
-                       elif cost_meter > 0.0:\r
-                               status += "Filament cost: %.2f\n" % (self.gcode.extrusionAmount / 1000 * cost_meter)\r
+                       cost = self.gcode.calculateCost()\r
+                       if cost != False:\r
+                               status += "Filament cost: %s\n" % (cost)\r
                        status += "Print time: %02d:%02d\n" % (int(self.gcode.totalMoveTimeMinute / 60), int(self.gcode.totalMoveTimeMinute % 60))\r
                if self.printIdx == None:\r
                        self.progress.SetValue(0)\r
index b56fc5edcc9a5b69db62612a4e1ad3e5359cc15e..c28e2cb88a92697137e9290fbec66551bcd3ceda 100644 (file)
@@ -6,6 +6,7 @@ import wx, sys, os, math, threading, subprocess, time
 from util import profile
 from util import sliceRun
 from util import exporer
+from util import gcodeInterpreter
 
 class sliceProgessPanel(wx.Panel):
        def __init__(self, mainWindow, parent, filelist):
@@ -100,7 +101,12 @@ class sliceProgessPanel(wx.Panel):
                self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)
                self.sizer.Add(self.logButton, 0)
                if result.returnCode == 0:
-                       self.statusText.SetLabel("Ready.")
+                       status = "Ready: Filament: %.2fm %.2fg" % (result.gcode.extrusionAmount / 1000, result.gcode.calculateWeight() * 1000)
+                       status += " Print time: %02d:%02d\n" % (int(result.gcode.totalMoveTimeMinute / 60), int(result.gcode.totalMoveTimeMinute % 60))
+                       cost = result.gcode.calculateCost()
+                       if cost != False:
+                               status += "Cost: %s\n" % (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)
@@ -169,6 +175,8 @@ class WorkerThread(threading.Thread):
                if self.fileIdx == len(self.cmdList):
                        if len(self.filelist) > 1:
                                self._stitchMultiExtruder()
+                       self.gcode = gcodeInterpreter.gcode()
+                       self.gcode.load(self.filelist[0][:self.filelist[0].rfind('.')]+'_export.gcode')
                        wx.CallAfter(self.notifyWindow.OnSliceDone, self)
                else:
                        self.run()
index 0518be27316f8bf0fefa97c3a49593877a173c10..7e83d3f47d24b21e0216c00cf3e0a9fd1818d6bb 100644 (file)
@@ -38,6 +38,17 @@ class gcode():
                volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000)
                return volumeM3 * float(profile.getPreference('filament_density'))
        
+       def calculateCost(self):
+               cost_kg = float(profile.getPreference('filament_cost_kg'))
+               cost_meter = float(profile.getPreference('filament_cost_meter'))
+               if cost_kg > 0.0 and cost_meter > 0.0:
+                       return "%.2f / %.2f" % (self.calculateWeight() * cost_kg, self.extrusionAmount / 1000 * cost_meter)
+               elif cost_kg > 0.0:
+                       return "%.2f" % (self.calculateWeight() * cost_kg)
+               elif cost_meter > 0.0:
+                       return "%.2f" % (self.extrusionAmount / 1000 * cost_meter)
+               return False
+       
        def _load(self, gcodeFile):
                filePos = 0
                pos = util3d.Vector3()
@@ -200,8 +211,8 @@ class gcode():
                self.layerList.append(currentLayer)
                self.extrusionAmount = maxExtrusion
                self.totalMoveTimeMinute = totalMoveTimeMinute
-               print "Extruded a total of: %d mm of filament" % (self.extrusionAmount)
-               print "Estimated print duration: %.2f minutes" % (self.totalMoveTimeMinute)
+               #print "Extruded a total of: %d mm of filament" % (self.extrusionAmount)
+               #print "Estimated print duration: %.2f minutes" % (self.totalMoveTimeMinute)
 
        def getCodeInt(self, line, code):
                if code not in self.regMatch: