Files
UVtools/UVtools.Core/Objects/ExposureItem.cs
T
Tiago Conceição b5575b3ef1 v2.9.3
- (Upgrade) AvaloniaUI from 0.10.2 to 0.10.3
- (Change) PrusaSlicer printers: Set 'Light-Off Delay' and 'Bottom Light-Off Delay' to 0 as default to allow UVtools auto-compute the right value once open the file in
- **Exposure time finder:**
   - Optimize layers by merge same position/exposure layers
   - Add a fence option to the zebra bars
   - Add a option to pattern the loaded model and generate multiple exposures on that
   - Allow to generate tests without the holes feature
   - Prevent from using more chamfers than the base height
   - Removed two of the largest holes
   - Hide not so often used 'Multiple brightness' and 'Multiple layer height' by default
   - Disable Anti-Aliasing by default
   - Change 'Part margin' from 1.5mm to 2.0mm
   - Change 'Multiple exposures - Bottom exposure step' default to 0
   - Fix a error when generating tests with multiple exposures
   - Fix some typos
- **XYZ accuracy test:**
   - Change 'Wall thickess' default from 2.5mm to 3.0mm
- (Improvement) Allow compute print time without a lift sequence
2021-05-04 05:07:04 +01:00

107 lines
3.7 KiB
C#

using System;
namespace UVtools.Core.Objects
{
[Serializable]
public sealed class ExposureItem : BindableBase, IComparable<ExposureItem>
{
private decimal _layerHeight;
private decimal _bottomExposure;
private decimal _exposure;
private byte _brightness = byte.MaxValue;
/// <summary>
/// Gets or sets the layer height in millimeters
/// </summary>
public decimal LayerHeight
{
get => _layerHeight;
set => RaiseAndSetIfChanged(ref _layerHeight, Layer.RoundHeight(value));
}
/// <summary>
/// Gets or sets the bottom exposure in seconds
/// </summary>
public decimal BottomExposure
{
get => _bottomExposure;
set => RaiseAndSetIfChanged(ref _bottomExposure, Math.Round(value, 2));
}
/// <summary>
/// Gets or sets the bottom exposure in seconds
/// </summary>
public decimal Exposure
{
get => _exposure;
set => RaiseAndSetIfChanged(ref _exposure, Math.Round(value, 2));
}
/// <summary>
/// Gets or sets the brightness level
/// </summary>
public byte Brightness
{
get => _brightness;
set
{
if(!RaiseAndSetIfChanged(ref _brightness, value)) return;
RaisePropertyChanged(nameof(BrightnessPercent));
}
}
public decimal BrightnessPercent => Math.Round(_brightness * 100m / byte.MaxValue, 2);
public bool IsValid => _layerHeight > 0 && _bottomExposure > 0 && _exposure > 0 && _brightness > 0;
public ExposureItem() { }
public ExposureItem(decimal layerHeight, decimal bottomExposure = 0, decimal exposure = 0, byte brightness = 255)
{
_layerHeight = Layer.RoundHeight(layerHeight);
_bottomExposure = Math.Round(bottomExposure, 2);
_exposure = Math.Round(exposure, 2);
_brightness = brightness;
}
public override string ToString()
{
return $"{nameof(LayerHeight)}: {_layerHeight}mm, {nameof(BottomExposure)}: {_bottomExposure}s, {nameof(Exposure)}: {_exposure}s, {nameof(Brightness)}: {_brightness} ({BrightnessPercent} %)";
}
private bool Equals(ExposureItem other)
{
return _layerHeight == other._layerHeight && _bottomExposure == other._bottomExposure && _exposure == other._exposure && _brightness == other._brightness;
}
public override bool Equals(object obj)
{
return ReferenceEquals(this, obj) || obj is ExposureItem other && Equals(other);
}
public override int GetHashCode()
{
return HashCode.Combine(_layerHeight, _bottomExposure, _exposure, _brightness);
}
public int CompareTo(ExposureItem other)
{
if (ReferenceEquals(this, other)) return 0;
if (ReferenceEquals(null, other)) return 1;
var layerHeightComparison = _layerHeight.CompareTo(other._layerHeight);
if (layerHeightComparison != 0) return layerHeightComparison;
var bottomExposureComparison = _bottomExposure.CompareTo(other._bottomExposure);
if (bottomExposureComparison != 0) return bottomExposureComparison;
var exposureComparison = _exposure.CompareTo(other._exposure);
if (exposureComparison != 0) return exposureComparison;
return _brightness.CompareTo(other._brightness);
}
public ExposureItem Clone()
{
return MemberwiseClone() as ExposureItem;
}
}
}