From 1030b06d6222ea6300ec3a32175fa007194b7cf5 Mon Sep 17 00:00:00 2001 From: Tyler Anderson Date: Mon, 27 Jun 2016 13:02:37 -0700 Subject: [PATCH] Added print cost estimate to Layer View --- PartPreviewWindow/ViewGcodeBasic.cs | 37 +++++++++++++++++------- StaticData/SliceSettings/Properties.json | 4 +-- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index 789693c5d..169b6ebfe 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -494,29 +494,46 @@ namespace MatterHackers.MatterControl.PartPreviewWindow modelInfoContainer.AddChild(estimatedPrintTime); } - string weightLabel = "Estimated Mass".Localize(); - string weightLabelFull = string.Format("{0}:", weightLabel); - modelInfoContainer.AddChild(new TextWidget(weightLabelFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor)); + string massLabel = "Estimated Mass".Localize(); + string massLabelFull = string.Format("{0}:", massLabel); + modelInfoContainer.AddChild(new TextWidget(massLabelFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor)); + double filamentDiameter = ActiveSliceSettings.Instance.GetValue("filament_diameter"); + double filamentDensity = ActiveSliceSettings.Instance.GetValue("filament_density"); + double filamentCost = ActiveSliceSettings.Instance.GetValue("filament_cost"); + + double totalMass = gcodeViewWidget.LoadedGCode.GetFilamentWeightGrams(filamentDiameter, filamentDensity); + double totalCost = totalMass / 1000 * filamentCost; { - double filamentDiameter = ActiveSliceSettings.Instance.GetValue("filament_diameter"); - double filamentDensity = ActiveSliceSettings.Instance.GetValue("filament_density"); - double filamentCost = ActiveSliceSettings.Instance.GetValue("filament_cost"); - - double totalMass = gcodeViewWidget.LoadedGCode.GetFilamentWeightGrams(filamentDiameter, filamentDensity); - double totalCost = totalMass / 1000 * totalMass; - string massText; if (totalMass != 0) { massText = string.Format("{0:0.00} g", totalMass); } else { massText = "Unknown"; } + GuiWidget estimatedPrintTime = new TextWidget(massText, pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor); //estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3); modelInfoContainer.AddChild(estimatedPrintTime); } + string costLabel = "Estimated Cost".Localize(); + string costLabelFull = string.Format("{0}:", costLabel); + modelInfoContainer.AddChild(new TextWidget(costLabelFull, pointSize: 9, textColor: ActiveTheme.Instance.PrimaryTextColor)); + { + string costText; + if (totalCost != 0) { + costText = string.Format("${0:0.00}", totalCost); + } else { + costText = "Unknown"; + } + + GuiWidget estimatedPrintTime = new TextWidget(costText, pointSize: 14, textColor: ActiveTheme.Instance.PrimaryTextColor); + //estimatedPrintTime.HAnchor = Agg.UI.HAnchor.ParentLeft; + estimatedPrintTime.Margin = new BorderDouble(0, 9, 0, 3); + modelInfoContainer.AddChild(estimatedPrintTime); + } + //modelInfoContainer.AddChild(new TextWidget("Layer Count:", textColor: ActiveTheme.Instance.PrimaryTextColor)); buttonPanel.AddChild(modelInfoContainer); diff --git a/StaticData/SliceSettings/Properties.json b/StaticData/SliceSettings/Properties.json index a2daa37a8..eb81bd567 100644 --- a/StaticData/SliceSettings/Properties.json +++ b/StaticData/SliceSettings/Properties.json @@ -546,7 +546,7 @@ "ShowAsOverride": true, "ShowIfSet": null, "ResetAtEndOfPrint": false, - "DefaultValue": "29" + "DefaultValue": "0.00" }, { "QuickMenuSettings": [], @@ -559,7 +559,7 @@ "ShowAsOverride": true, "ShowIfSet": null, "ResetAtEndOfPrint": false, - "DefaultValue": "1.24" + "DefaultValue": "0.00" }, { "QuickMenuSettings": [],