diff options
Diffstat (limited to 'UVtools.Core/Layer/Layer.cs')
-rw-r--r-- | UVtools.Core/Layer/Layer.cs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/UVtools.Core/Layer/Layer.cs b/UVtools.Core/Layer/Layer.cs index 6da632c..4b65b64 100644 --- a/UVtools.Core/Layer/Layer.cs +++ b/UVtools.Core/Layer/Layer.cs @@ -57,7 +57,13 @@ namespace UVtools.Core public uint NonZeroPixelCount { get => _nonZeroPixelCount; - internal set => RaiseAndSetIfChanged(ref _nonZeroPixelCount, value); + internal set + { + if(!RaiseAndSetIfChanged(ref _nonZeroPixelCount, value)) return; + RaisePropertyChanged(nameof(MaterialMilliliters)); + if (SlicerFile is null) return; + SlicerFile.MaterialMilliliters = 0; + } } /// <summary> @@ -196,6 +202,18 @@ namespace UVtools.Core } /// <summary> + /// Gets the computed material milliliters spent on this layer + /// </summary> + public float MaterialMilliliters + { + get + { + if (ParentLayerManager?.SlicerFile is null) return 0; + return (float) Math.Round(ParentLayerManager.SlicerFile.PixelArea * LayerHeight * NonZeroPixelCount / 1000, 4); + } + } + + /// <summary> /// Gets or sets layer image compressed data /// </summary> public byte[] CompressedBytes @@ -393,7 +411,7 @@ namespace UVtools.Core public Rectangle GetBoundingRectangle(Mat mat = null, bool reCalculate = false) { - if (NonZeroPixelCount > 0 && !reCalculate) + if (_nonZeroPixelCount > 0 && !reCalculate) { return BoundingRectangle; } |