chiark / gitweb /
Fixed #46 - added support for calculating print costs.
authordaid <daid303@gmail.com>
Thu, 12 Apr 2012 12:26:03 +0000 (14:26 +0200)
committerdaid <daid303@gmail.com>
Thu, 12 Apr 2012 12:26:03 +0000 (14:26 +0200)
Cura/gui/preferencesDialog.py
Cura/gui/printWindow.py
Cura/util/profile.py

index 9280505bb652ad0cb43600401586c62ecb8c80f1..81734c28cab551ada5694eb545decfc1568f2111 100644 (file)
@@ -28,6 +28,10 @@ class preferencesDialog(configBase.configWindowBase):
                configBase.TitleRow(left, 'Filament settings')\r
                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')\r
                validators.validFloat(c, 500.0, 3000.0)\r
+               c = configBase.SettingRow(left, 'Filament cost (price/kg)', 'filament_cost_kg', '0', 'Cost of your filament per kg, to estimate the cost of the final print.', type = 'preference')\r
+               validators.validFloat(c, 0.0)\r
+               c = configBase.SettingRow(left, 'Filament cost (price/m)', 'filament_cost_meter', '0', 'Cost of your filament per meter, to estimate the cost of the final print.', type = 'preference')\r
+               validators.validFloat(c, 0.0)\r
                \r
                configBase.TitleRow(left, 'Communication settings')\r
                c = configBase.SettingRow(left, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference')\r
index fd9b0ef3a838e758131b32b2b2e988bbe5930f17..a7f2770a91c880263bed0a5b3aeb827d83a3c678 100644 (file)
@@ -5,6 +5,7 @@ import wx, threading, re
 \r
 from gui import machineCom\r
 from gui import icon\r
+from util import profile\r
 from util import gcodeInterpreter\r
 \r
 printWindowHandle = None\r
@@ -95,6 +96,14 @@ 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
                        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 b1bbccf84131cbf1c828cf4e107ca32c623c2f01..8735152db0c237da613284daf75319f028b4aca9 100644 (file)
@@ -80,6 +80,8 @@ preferencesDefaultSettings = {
        'serial_baud': '250000',\r
        'slicer': 'Cura (Skeinforge based)',\r
        'save_profile': 'False',\r
+       'filament_cost_kg': '0',\r
+       'filament_cost_meter': '0',\r
 }\r
 \r
 def getDefaultProfilePath():\r