From 3b2b76a8ac6168ccaae959711639e2a3ab91c757 Mon Sep 17 00:00:00 2001 From: daid Date: Thu, 12 Apr 2012 14:26:03 +0200 Subject: [PATCH] Fixed #46 - added support for calculating print costs. --- Cura/gui/preferencesDialog.py | 4 ++++ Cura/gui/printWindow.py | 9 +++++++++ Cura/util/profile.py | 2 ++ 3 files changed, 15 insertions(+) diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py index 9280505b..81734c28 100644 --- a/Cura/gui/preferencesDialog.py +++ b/Cura/gui/preferencesDialog.py @@ -28,6 +28,10 @@ class preferencesDialog(configBase.configWindowBase): 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) + 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') + validators.validFloat(c, 0.0) + 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') + validators.validFloat(c, 0.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') diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index fd9b0ef3..a7f2770a 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -5,6 +5,7 @@ import wx, threading, re from gui import machineCom from gui import icon +from util import profile from util import gcodeInterpreter printWindowHandle = None @@ -95,6 +96,14 @@ class printWindow(wx.Frame): status = "" if self.gcode != None: status += "Filament: %.2fm %.2fg\n" % (self.gcode.extrusionAmount / 1000, self.gcode.calculateWeight() * 1000) + 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: + status += "Filament cost: %.2f / %.2f\n" % (self.gcode.calculateWeight() * cost_kg, self.gcode.extrusionAmount / 1000 * cost_meter) + elif cost_kg > 0.0: + status += "Filament cost: %.2f\n" % (self.gcode.calculateWeight() * cost_kg) + elif cost_meter > 0.0: + status += "Filament cost: %.2f\n" % (self.gcode.extrusionAmount / 1000 * cost_meter) status += "Print time: %02d:%02d\n" % (int(self.gcode.totalMoveTimeMinute / 60), int(self.gcode.totalMoveTimeMinute % 60)) if self.printIdx == None: self.progress.SetValue(0) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index b1bbccf8..8735152d 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -80,6 +80,8 @@ preferencesDefaultSettings = { 'serial_baud': '250000', 'slicer': 'Cura (Skeinforge based)', 'save_profile': 'False', + 'filament_cost_kg': '0', + 'filament_cost_meter': '0', } def getDefaultProfilePath(): -- 2.30.2