diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e641f0..1efd07a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 31/01/2025 - v5.0.6 + +- **PCB Exposure:** + - (Fix) When importing gerber files via drag and drop to the main window the file was created with 0mm layer height and no exposure set + - (Fix) Merging multiple gerber files with mirror active was mirroring the image in each draw causing the wrong output (#980) + - (Fix) Excellon drill format does not load tools when they have spindle parameters [F/C] (#980) + - (Fix) Excellon drill format to respect the integer and decimal digit count when specifying them (#980) +- **Stress Tower:** + - (Improvement) Allow to pause and cancel the operation + - (Improvement) Process layers in a more efficient way to reduce allocations and be able to produce the test without RAM hogging +- (Upgrade) .NET from 9.0.0 to 9.0.1 +- (Upgrade) OpenCV from 4.9.0 to 4.10.0 + ## 09/01/2025 - v5.0.5 - (Add) PrusaSlicer printer: Elegoo Saturn 4 Ultra 16K diff --git a/Directory.Build.props b/Directory.Build.props index 6143ee9b..44b1af57 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -37,7 +37,7 @@ true - 5.0.5 + 5.0.6 11.2.3 diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 787161e6..42fb6c0d 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,11 @@ -- (Add) PrusaSlicer printer: Elegoo Saturn 4 Ultra 16K -- (Improvement) Goo: Implement and support the tilting vat printers -- (Improvement) All shapes in pixel editor will now respect the non-equal pixel pitch and compensate the lower side to print a regular shape, this also affects the polygons on PCB exposure tool and other tools as well -- (Fix) PCB Exposure: Use raw polygons instead of angle aligned polygons to respect the gerber implementation (#976) +- **PCB Exposure:** + - (Fix) When importing gerber files via drag and drop to the main window the file was created with 0mm layer height and no exposure set + - (Fix) Merging multiple gerber files with mirror active was mirroring the image in each draw causing the wrong output (#980) + - (Fix) Excellon drill format does not load tools when they have spindle parameters [F/C] (#980) + - (Fix) Excellon drill format to respect the integer and decimal digit count when specifying them (#980) +- **Stress Tower:** + - (Improvement) Allow to pause and cancel the operation + - (Improvement) Process layers in a more efficient way to reduce allocations and be able to produce the test without RAM hogging +- (Upgrade) .NET from 9.0.0 to 9.0.1 +- (Upgrade) OpenCV from 4.9.0 to 4.10.0 diff --git a/Scripts/UVtools.ScriptSample/ScriptTimelapseSample.cs b/Scripts/UVtools.ScriptSample/ScriptTimelapseSample.cs index 4d7b77a8..36baf3fd 100644 --- a/Scripts/UVtools.ScriptSample/ScriptTimelapseSample.cs +++ b/Scripts/UVtools.ScriptSample/ScriptTimelapseSample.cs @@ -93,8 +93,8 @@ public void ScriptInit() Script.Version = new Version(0, 1); Script.MinimumVersionToRun = new Version(3, 0, 0); - InputPositionZ.Value = (float)Math.Round(SlicerFile.PrintHeight + 1, 2); - InputPositionZ.Minimum = (float) Math.Round(SlicerFile.PrintHeight + 0.1, 2); + InputPositionZ.Value = MathF.Round(SlicerFile.PrintHeight + 1, 2); + InputPositionZ.Minimum = MathF.Round(SlicerFile.PrintHeight + 0.1f, 2); Script.UserInputs.Add(InputPositionZ); Script.UserInputs.Add(InputRaiseEveryLayerN); Script.UserInputs.Add(InputWaitTime); diff --git a/UVtools.Core/Converters/SpeedConverter.cs b/UVtools.Core/Converters/SpeedConverter.cs index c7a34241..afe43209 100644 --- a/UVtools.Core/Converters/SpeedConverter.cs +++ b/UVtools.Core/Converters/SpeedConverter.cs @@ -31,21 +31,21 @@ public static float Convert(float value, SpeedUnit from, SpeedUnit to, byte roun SpeedUnit.MillimetersPerSecond => to switch { SpeedUnit.MillimetersPerSecond => value, - SpeedUnit.MillimetersPerMinute => (float) Math.Round(value * 60, rounding, MidpointRounding.AwayFromZero), - SpeedUnit.CentimetersPerMinute => (float) Math.Round(value * 6, rounding, MidpointRounding.AwayFromZero), + SpeedUnit.MillimetersPerMinute => MathF.Round(value * 60, rounding, MidpointRounding.AwayFromZero), + SpeedUnit.CentimetersPerMinute => MathF.Round(value * 6, rounding, MidpointRounding.AwayFromZero), _ => throw new ArgumentOutOfRangeException(nameof(to), to, null) }, SpeedUnit.MillimetersPerMinute => to switch { - SpeedUnit.MillimetersPerSecond => (float) Math.Round(value / 60, rounding, MidpointRounding.AwayFromZero), + SpeedUnit.MillimetersPerSecond => MathF.Round(value / 60, rounding, MidpointRounding.AwayFromZero), SpeedUnit.MillimetersPerMinute => value, - SpeedUnit.CentimetersPerMinute => (float) Math.Round(value / 10, rounding, MidpointRounding.AwayFromZero), + SpeedUnit.CentimetersPerMinute => MathF.Round(value / 10, rounding, MidpointRounding.AwayFromZero), _ => throw new ArgumentOutOfRangeException(nameof(to), to, null) }, SpeedUnit.CentimetersPerMinute => to switch { - SpeedUnit.MillimetersPerSecond => (float) Math.Round(value * (1.0/6.0), rounding, MidpointRounding.AwayFromZero), - SpeedUnit.MillimetersPerMinute => (float)Math.Round(value * 10, rounding, MidpointRounding.AwayFromZero), + SpeedUnit.MillimetersPerSecond => MathF.Round(value * (1.0f/6.0f), rounding, MidpointRounding.AwayFromZero), + SpeedUnit.MillimetersPerMinute => MathF.Round(value * 10, rounding, MidpointRounding.AwayFromZero), SpeedUnit.CentimetersPerMinute => value, _ => throw new ArgumentOutOfRangeException(nameof(to), to, null) }, diff --git a/UVtools.Core/Converters/TimeConverter.cs b/UVtools.Core/Converters/TimeConverter.cs index 06d47ab9..57f86f1f 100644 --- a/UVtools.Core/Converters/TimeConverter.cs +++ b/UVtools.Core/Converters/TimeConverter.cs @@ -19,7 +19,7 @@ public static class TimeConverter /// /// /// - public static float SecondsToMilliseconds(float value, byte rounding = 2) => (float)Math.Round(value * 1000f, rounding); + public static float SecondsToMilliseconds(float value, byte rounding = 2) => MathF.Round(value * 1000f, rounding); /// /// Converts seconds to milliseconds @@ -34,5 +34,5 @@ public static class TimeConverter /// /// /// - public static float MillisecondsToSeconds(float value, byte rounding = 2) => (float)Math.Round(value / 1000f, rounding); + public static float MillisecondsToSeconds(float value, byte rounding = 2) => MathF.Round(value / 1000f, rounding); } \ No newline at end of file diff --git a/UVtools.Core/EmguCV/CMat.cs b/UVtools.Core/EmguCV/CMat.cs index bb5c7ece..343f043e 100644 --- a/UVtools.Core/EmguCV/CMat.cs +++ b/UVtools.Core/EmguCV/CMat.cs @@ -142,7 +142,7 @@ public float CompressionRatio var uncompressedLength = UncompressedLength; if (uncompressedLength == 0 || Length == uncompressedLength) return 1; if (Length == 0) return uncompressedLength; - return (float)Math.Round((float)uncompressedLength / Length, 2, MidpointRounding.AwayFromZero); + return MathF.Round((float)uncompressedLength / Length, 2, MidpointRounding.AwayFromZero); } } @@ -156,7 +156,7 @@ public float CompressionPercentage var uncompressedLength = UncompressedLength; if (uncompressedLength == 0 || Length == uncompressedLength) return 0; if (Length == 0) return 100f; - return (float)Math.Round(100 - (Length * 100f / uncompressedLength), 2, MidpointRounding.AwayFromZero); + return MathF.Round(100 - (Length * 100f / uncompressedLength), 2, MidpointRounding.AwayFromZero); } } @@ -170,7 +170,7 @@ public float CompressionEfficiency var uncompressedLength = UncompressedLength; if (uncompressedLength == 0) return 0; if (Length == 0) return uncompressedLength; - return (float)Math.Round(uncompressedLength * 100f / Length, 2, MidpointRounding.AwayFromZero); + return MathF.Round(uncompressedLength * 100f / Length, 2, MidpointRounding.AwayFromZero); } } diff --git a/UVtools.Core/Excellon/ExcellonDrillFormat.cs b/UVtools.Core/Excellon/ExcellonDrillFormat.cs index efede372..6eb96574 100644 --- a/UVtools.Core/Excellon/ExcellonDrillFormat.cs +++ b/UVtools.Core/Excellon/ExcellonDrillFormat.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Globalization; using System.IO; using System.Text.RegularExpressions; using UVtools.Core.Extensions; @@ -21,7 +22,7 @@ namespace UVtools.Core.Excellon; /// /// The Excellon drill format is a subset of RS274D and is used by the drilling and routing machines made by the Excellon corporation. /// Because of Excellon's long history and dominance of the PCB drilling business for many years their format is a defacto industry standard. -/// Almost every PCB layout software can produce this format.However we have noticed that many PCB layout tools do not take +/// Almost every PCB layout software can produce this format. However we have noticed that many PCB layout tools do not take /// full advantage of the header information which makes reading the drill file more difficult than it should be. /// https://www.artwork.com/gerber/drl2laser/excellon/index.htm /// https://gist.github.com/katyo/5692b935abc085b1037e @@ -49,7 +50,7 @@ public Tool(uint index, float diameter) public override string ToString() { - return $"T{Index}C{nameof(Diameter)}"; + return $"T{Index}C{Diameter}"; } } @@ -188,6 +189,8 @@ private void Load(string filePath) uint selectedToolIndex = 0; float x = 0, y = 0; + int integerDigits = 0; + int fractionDigits = 0; while ((line = tr.ReadLine()?.Trim()) is not null) { @@ -224,6 +227,15 @@ private void Load(string filePath) continue; } + if (integerDigits == 0 && line.StartsWith(";FILE_FORMAT=")) + { + line = line.Remove(0, 13); + var split = line.Split(':', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); + if (split.Length < 2) continue; + int.TryParse(split[0], out integerDigits); + int.TryParse(split[0], out fractionDigits); + } + if (line is "ICI" or "ICI,ON") { throw new NotImplementedException("ICI (Incremental input of program coordinates) is not yet implemented, please use absolute coordinate system."); @@ -246,7 +258,7 @@ private void Load(string filePath) { if (!endOfHeader) { - var match = Regex.Match(line, @"^T([0-9]+)C(([0-9]*[.])?[0-9]+)"); + var match = Regex.Match(line, @"^T([0-9]+).*C(([0-9]*[.])?[0-9]+)"); if (match is { Success: true, @@ -254,7 +266,7 @@ private void Load(string filePath) }) { var index = uint.Parse(match.Groups[1].Value); - var diameter = float.Parse(match.Groups[2].Value); + var diameter = float.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture); var tool = new Tool(index, diameter); Tools.Add(index, tool); } @@ -280,22 +292,40 @@ private void Load(string filePath) Groups.Count: >= 2 }) { - if (match.Groups[1].Value.Contains('.') || ZerosIncludeType == ExcellonDrillZerosIncludeType.None) + if (match.Groups[1].Value.Contains('.')) { - x = float.Parse(match.Groups[1].Value); + x = float.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture); } else { switch (ZerosIncludeType) { + case ExcellonDrillZerosIncludeType.None: case ExcellonDrillZerosIncludeType.Leading: - x = ValueToCoordinate(float.Parse(match.Groups[1].Value.PadRight(PaddingZeros, '0'))); + if (integerDigits > 0) + { + var number = match.Groups[1].Value.Insert(integerDigits, "."); + x = float.Parse(number, CultureInfo.InvariantCulture); + } + else + { + x = ValueToCoordinate(float.Parse(match.Groups[1].Value.PadRight(PaddingZeros, '0'), CultureInfo.InvariantCulture)); + } break; case ExcellonDrillZerosIncludeType.Trail: - x = ValueToCoordinate(float.Parse(match.Groups[1].Value.PadLeft(PaddingZeros, '0'))); + if (fractionDigits > 0) + { + var number = match.Groups[1].Value.Insert(match.Groups[1].Value.Length - fractionDigits, "."); + x = float.Parse(number, CultureInfo.InvariantCulture); + } + else + { + x = ValueToCoordinate(float.Parse(match.Groups[1].Value.PadLeft(PaddingZeros, '0'), CultureInfo.InvariantCulture)); + } break; } } + } @@ -306,19 +336,36 @@ private void Load(string filePath) Groups.Count: >= 2 }) { - if (match.Groups[1].Value.Contains('.') || ZerosIncludeType == ExcellonDrillZerosIncludeType.None) + if (match.Groups[1].Value.Contains('.')) { - y = float.Parse(match.Groups[1].Value); + y = float.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture); } else { switch (ZerosIncludeType) { + case ExcellonDrillZerosIncludeType.None: case ExcellonDrillZerosIncludeType.Leading: - y = ValueToCoordinate(float.Parse(match.Groups[1].Value.PadRight(PaddingZeros, '0'))); + if (integerDigits > 0) + { + var number = match.Groups[1].Value.Insert(integerDigits, "."); + y = float.Parse(number, CultureInfo.InvariantCulture); + } + else + { + y = ValueToCoordinate(float.Parse(match.Groups[1].Value.PadRight(PaddingZeros, '0'), CultureInfo.InvariantCulture)); + } break; case ExcellonDrillZerosIncludeType.Trail: - y = ValueToCoordinate(float.Parse(match.Groups[1].Value.PadLeft(PaddingZeros, '0'))); + if (fractionDigits > 0) + { + var number = match.Groups[1].Value.Insert(match.Groups[1].Value.Length - fractionDigits, "."); + y = float.Parse(number, CultureInfo.InvariantCulture); + } + else + { + y = ValueToCoordinate(float.Parse(match.Groups[1].Value.PadLeft(PaddingZeros, '0'), CultureInfo.InvariantCulture)); + } break; } } @@ -336,8 +383,8 @@ private void Load(string filePath) public float ValueToCoordinate(float value) => UnitType switch { - ExcellonDrillUnitType.Millimeter => (float) Math.Round(value / MillimeterResolution, PaddingZeros), - ExcellonDrillUnitType.Inch => (float) Math.Round(value / InchResolution, PaddingZeros), + ExcellonDrillUnitType.Millimeter => MathF.Round(value / MillimeterResolution, PaddingZeros), + ExcellonDrillUnitType.Inch => MathF.Round(value / InchResolution, PaddingZeros), _ => throw new ArgumentOutOfRangeException() }; diff --git a/UVtools.Core/Extensions/EmguExtensions.cs b/UVtools.Core/Extensions/EmguExtensions.cs index ef61ef3e..47692711 100644 --- a/UVtools.Core/Extensions/EmguExtensions.cs +++ b/UVtools.Core/Extensions/EmguExtensions.cs @@ -22,9 +22,6 @@ using CommunityToolkit.Diagnostics; using UVtools.Core.EmguCV; using UVtools.Core.Objects; -using Emgu.CV.Reg; -using static UVtools.Core.FileFormats.UVJFile; -using System.Reflection.Metadata; using Size = System.Drawing.Size; namespace UVtools.Core.Extensions; @@ -1908,7 +1905,7 @@ public static void DrawPolygon(this Mat src, int sides, SizeF diameter, PointF c { if (sides == 1) { - var point1 = center with { X = (float)Math.Round(center.X - diameter.Width / 2, midpointRounding) }; + var point1 = center with { X = MathF.Round(center.X - diameter.Width / 2, midpointRounding) }; var point2 = point1 with { X = point1.X + diameter.Width - 1 }; point1 = point1.Rotate(startingAngle, center); point2 = point2.Rotate(startingAngle, center); diff --git a/UVtools.Core/Extensions/RectangleExtensions.cs b/UVtools.Core/Extensions/RectangleExtensions.cs index 513dc084..735a2a35 100644 --- a/UVtools.Core/Extensions/RectangleExtensions.cs +++ b/UVtools.Core/Extensions/RectangleExtensions.cs @@ -29,10 +29,10 @@ public static Rectangle OffsetBy(this Rectangle src, int x, int y) public static int Perimeter(this Rectangle src) => src.Width * 2 + src.Height * 2; public static float Perimeter(this RectangleF src) => src.Width * 2 + src.Height * 2; - public static float Perimeter(this RectangleF src, int round) => (float)Math.Round(src.Perimeter(), round); + public static float Perimeter(this RectangleF src, int round) => MathF.Round(src.Perimeter(), round); public static int Area(this Rectangle src) => src.Width * src.Height; public static float Area(this RectangleF src) => src.Width * src.Height; - public static float Area(this RectangleF src, int round) => (float)Math.Round(src.Area(), round); + public static float Area(this RectangleF src, int round) => MathF.Round(src.Area(), round); /// /// Gets the smallest rectangle among all rectangles diff --git a/UVtools.Core/Extensions/ReflectionExtensions.cs b/UVtools.Core/Extensions/ReflectionExtensions.cs index 5c649ad5..1a333de5 100644 --- a/UVtools.Core/Extensions/ReflectionExtensions.cs +++ b/UVtools.Core/Extensions/ReflectionExtensions.cs @@ -154,8 +154,8 @@ public static bool SetValueFromString(this PropertyInfo attribute, object obj, s var match = Regex.Match(value, string.Format("X={0},\\s?Y={0}", "([+-]?([0-9]*[.])?[0-9]+)")); if (match is { Success: true, Groups.Count: >= 3 }) { - if (float.TryParse(match.Groups[1].Value, out var x) - && float.TryParse(match.Groups[2].Value, out var y) + if (float.TryParse(match.Groups[1].Value, CultureInfo.InvariantCulture, out var x) + && float.TryParse(match.Groups[2].Value, CultureInfo.InvariantCulture, out var y) ) { attribute.SetValue(obj, new PointF(x, y)); @@ -171,8 +171,8 @@ public static bool SetValueFromString(this PropertyInfo attribute, object obj, s var match = Regex.Match(value, string.Format("Width={0},\\s?Height={0}", @"(\d+)")); if (match is { Success: true, Groups.Count: >= 3 }) { - if (int.TryParse(match.Groups[1].Value, out var width) - && int.TryParse(match.Groups[2].Value, out var height) + if (int.TryParse(match.Groups[1].Value, CultureInfo.InvariantCulture, out var width) + && int.TryParse(match.Groups[2].Value, CultureInfo.InvariantCulture, out var height) ) { attribute.SetValue(obj, new Size(width, height)); @@ -188,8 +188,8 @@ public static bool SetValueFromString(this PropertyInfo attribute, object obj, s var match = Regex.Match(value, string.Format("Width={0},\\s?Height={0}", "([+-]?([0-9]*[.])?[0-9]+)")); if (match is { Success: true, Groups.Count: >= 3 }) { - if (float.TryParse(match.Groups[1].Value, out var width) - && float.TryParse(match.Groups[2].Value, out var height) + if (float.TryParse(match.Groups[1].Value, CultureInfo.InvariantCulture, out var width) + && float.TryParse(match.Groups[2].Value, CultureInfo.InvariantCulture, out var height) ) { attribute.SetValue(obj, new SizeF(width, height)); @@ -224,10 +224,10 @@ public static bool SetValueFromString(this PropertyInfo attribute, object obj, s var match = Regex.Match(value, string.Format("X={0},\\s?Y={0},\\s?Width={0},\\s?Height={0}", "([+-]?([0-9]*[.])?[0-9]+)")); if (match is { Success: true, Groups.Count: >= 5 }) { - if (float.TryParse(match.Groups[1].Value, out var x) - && float.TryParse(match.Groups[2].Value, out var y) - && float.TryParse(match.Groups[3].Value, out var width) - && float.TryParse(match.Groups[4].Value, out var height) + if (float.TryParse(match.Groups[1].Value, CultureInfo.InvariantCulture, out var x) + && float.TryParse(match.Groups[2].Value, CultureInfo.InvariantCulture, out var y) + && float.TryParse(match.Groups[3].Value, CultureInfo.InvariantCulture, out var width) + && float.TryParse(match.Groups[4].Value, CultureInfo.InvariantCulture, out var height) ) { attribute.SetValue(obj, new RectangleF(x, y, width, height)); diff --git a/UVtools.Core/Extensions/SizeExtensions.cs b/UVtools.Core/Extensions/SizeExtensions.cs index e1fc946f..c5007d02 100644 --- a/UVtools.Core/Extensions/SizeExtensions.cs +++ b/UVtools.Core/Extensions/SizeExtensions.cs @@ -112,7 +112,7 @@ public static Size Max(params Size[] sizes) public static bool HaveZero(this SizeF size) => size.Width <= 0 || size.Height <= 0; public static float Area(this SizeF size) => size.Width * size.Height; - public static float Area(this SizeF size, int round) => (float)Math.Round(size.Area(), round) ; + public static float Area(this SizeF size, int round) => MathF.Round(size.Area(), round); public static float Max(this SizeF size) => Math.Max(size.Width, size.Height); diff --git a/UVtools.Core/FileFormats/AnycubicFile.cs b/UVtools.Core/FileFormats/AnycubicFile.cs index f1da8e6a..719d992b 100644 --- a/UVtools.Core/FileFormats/AnycubicFile.cs +++ b/UVtools.Core/FileFormats/AnycubicFile.cs @@ -645,10 +645,10 @@ public void Parse(FileFormat slicerFile) { var rect = slicerFile.BoundingRectangleMillimeters; rect.Offset(slicerFile.DisplayWidth / -2f, slicerFile.DisplayHeight / -2f); - MinX = (float)Math.Round(rect.X, 4); - MinY = (float)Math.Round(rect.Y, 4); - MaxX = (float)Math.Round(rect.Right, 4); - MaxY = (float)Math.Round(rect.Bottom, 4); + MinX = MathF.Round(rect.X, 4, MidpointRounding.AwayFromZero); + MinY = MathF.Round(rect.Y, 4, MidpointRounding.AwayFromZero); + MaxX = MathF.Round(rect.Right, 4, MidpointRounding.AwayFromZero); + MaxY = MathF.Round(rect.Bottom, 4, MidpointRounding.AwayFromZero); MinZ = 0; MaxZ = slicerFile.PrintHeight; @@ -1307,7 +1307,7 @@ public override float MachineZ _ => 0 }; } - set => base.MachineZ = MachineSettings.MachineZ = (float)Math.Round(value, 2); + set => base.MachineZ = MachineSettings.MachineZ = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } public override FlipDirection DisplayMirror @@ -1361,13 +1361,13 @@ public override ushort TransitionLayerCount public override float WaitTimeBeforeCure { get => HeaderSettings.WaitTimeBeforeCure; - set => base.WaitTimeBeforeCure = HeaderSettings.WaitTimeBeforeCure = (float)Math.Round(value, 2); + set => base.WaitTimeBeforeCure = HeaderSettings.WaitTimeBeforeCure = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } public override float BottomExposureTime { get => HeaderSettings.BottomExposureTime; - set => base.BottomExposureTime = HeaderSettings.BottomExposureTime = (float) Math.Round(value, 2); + set => base.BottomExposureTime = HeaderSettings.BottomExposureTime = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } public override float ExposureTime @@ -1376,7 +1376,7 @@ public override float ExposureTime set { HeaderSettings.IntelligentMode = false; - base.ExposureTime = HeaderSettings.ExposureTime = (float)Math.Round(value, 2); + base.ExposureTime = HeaderSettings.ExposureTime = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } } @@ -1387,11 +1387,11 @@ public override float BottomLiftHeight : base.BottomLiftHeight; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); ExtraSettings.BottomLiftHeight1 = value; if (FileMarkSettings.Version >= VERSION_516) { - base.BottomLiftHeight = (float)Math.Round(value + ExtraSettings.BottomLiftHeight2, 2); + base.BottomLiftHeight = MathF.Round(value + ExtraSettings.BottomLiftHeight2, 2, MidpointRounding.AwayFromZero); foreach (var layer in this) // Fix layer value { if (!layer.IsBottomLayer) continue; @@ -1409,7 +1409,7 @@ public override float BottomLiftSpeed : base.BottomLiftSpeed; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); ExtraSettings.BottomLiftSpeed1 = SpeedConverter.Convert(value, CoreSpeedUnit, FormatSpeedUnit); base.BottomLiftSpeed = value; } @@ -1422,11 +1422,11 @@ public override float LiftHeight : HeaderSettings.LiftHeight; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); ExtraSettings.LiftHeight1 = value; if (FileMarkSettings.Version >= VERSION_516) { - base.LiftHeight = HeaderSettings.LiftHeight = (float)Math.Round(value + ExtraSettings.LiftHeight2, 2); + base.LiftHeight = HeaderSettings.LiftHeight = MathF.Round(value + ExtraSettings.LiftHeight2, 2, MidpointRounding.AwayFromZero); foreach (var layer in this) // Fix layer value { if(!layer.IsNormalLayer) continue; @@ -1444,7 +1444,7 @@ public override float LiftSpeed : HeaderSettings.LiftSpeed, FormatSpeedUnit, CoreSpeedUnit); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); HeaderSettings.LiftSpeed = ExtraSettings.LiftSpeed1 = SpeedConverter.Convert(value, CoreSpeedUnit, FormatSpeedUnit); base.LiftSpeed = value; } @@ -1459,7 +1459,7 @@ public override float BottomLiftHeight2 { if (FileMarkSettings.Version < VERSION_516) return; var bottomLiftHeight = BottomLiftHeight; - ExtraSettings.BottomLiftHeight2 = (float)Math.Round(value, 2); + ExtraSettings.BottomLiftHeight2 = MathF.Round(value, 2, MidpointRounding.AwayFromZero); BottomLiftHeight = bottomLiftHeight; base.BottomLiftHeight2 = ExtraSettings.BottomLiftHeight2; HeaderSettings.AdvancedMode = System.Convert.ToUInt32(IsUsingTSMC); @@ -1475,7 +1475,7 @@ public override float BottomLiftSpeed2 set { if (FileMarkSettings.Version < VERSION_516) return; - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); ExtraSettings.BottomLiftSpeed2 = SpeedConverter.Convert(value, CoreSpeedUnit, FormatSpeedUnit); base.BottomLiftSpeed2 = value; } @@ -1490,7 +1490,7 @@ public override float LiftHeight2 { if (FileMarkSettings.Version < VERSION_516) return; var liftHeight = LiftHeight; - ExtraSettings.LiftHeight2 = (float)Math.Round(value, 2); + ExtraSettings.LiftHeight2 = MathF.Round(value, 2, MidpointRounding.AwayFromZero); LiftHeight = liftHeight; base.LiftHeight2 = ExtraSettings.LiftHeight2; HeaderSettings.AdvancedMode = System.Convert.ToUInt32(IsUsingTSMC); @@ -1506,7 +1506,7 @@ public override float LiftSpeed2 set { if (FileMarkSettings.Version < VERSION_516) return; - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); ExtraSettings.LiftSpeed2 = SpeedConverter.Convert(value, CoreSpeedUnit, FormatSpeedUnit); base.LiftSpeed2 = value; } @@ -1520,7 +1520,7 @@ public override float BottomRetractSpeed set { if (FileMarkSettings.Version < VERSION_516) return; - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); ExtraSettings.BottomRetractSpeed1 = SpeedConverter.Convert(value, CoreSpeedUnit, FormatSpeedUnit); base.BottomRetractSpeed = value; } @@ -1533,7 +1533,7 @@ public override float RetractSpeed : HeaderSettings.RetractSpeed, FormatSpeedUnit, CoreSpeedUnit); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); ExtraSettings.RetractSpeed1 = HeaderSettings.RetractSpeed = SpeedConverter.Convert(value, CoreSpeedUnit, FormatSpeedUnit); base.RetractSpeed = value; } @@ -1547,7 +1547,7 @@ public override float BottomRetractSpeed2 set { if (FileMarkSettings.Version < VERSION_516) return; - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2, MidpointRounding.AwayFromZero); ExtraSettings.BottomRetractSpeed2 = SpeedConverter.Convert(value, CoreSpeedUnit, FormatSpeedUnit); base.BottomRetractSpeed2 = value; } @@ -1561,7 +1561,7 @@ public override float RetractSpeed2 set { if (FileMarkSettings.Version < VERSION_516) return; - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); ExtraSettings.RetractSpeed2 = SpeedConverter.Convert(value, CoreSpeedUnit, FormatSpeedUnit); base.RetractSpeed2 = value; } @@ -1589,14 +1589,14 @@ public override float MaterialMilliliters public override float MaterialGrams { - get => (float) Math.Round(HeaderSettings.WeightG, 3); - set => base.MaterialGrams = HeaderSettings.WeightG = (float) Math.Round(value, 3); + get => MathF.Round(HeaderSettings.WeightG, 3, MidpointRounding.AwayFromZero); + set => base.MaterialGrams = HeaderSettings.WeightG = MathF.Round(value, 3, MidpointRounding.AwayFromZero); } public override float MaterialCost { - get => (float) Math.Round(HeaderSettings.Price, 3); - set => base.MaterialCost = HeaderSettings.Price = (float)Math.Round(value, 3); + get => MathF.Round(HeaderSettings.Price, 3, MidpointRounding.AwayFromZero); + set => base.MaterialCost = HeaderSettings.Price = MathF.Round(value, 3, MidpointRounding.AwayFromZero); } public override string MachineName diff --git a/UVtools.Core/FileFormats/AnycubicPhotonSFile.cs b/UVtools.Core/FileFormats/AnycubicPhotonSFile.cs index a6e32a3c..68472259 100644 --- a/UVtools.Core/FileFormats/AnycubicPhotonSFile.cs +++ b/UVtools.Core/FileFormats/AnycubicPhotonSFile.cs @@ -356,16 +356,16 @@ public override float LiftHeight public override float LiftSpeed { - get => (float) Math.Round(HeaderSettings.LiftSpeed * 60.0, 2); - set => base.LiftSpeed = (float) (HeaderSettings.LiftSpeed = Math.Round(value / 60.0, 2)); + get => MathF.Round((float)HeaderSettings.LiftSpeed * 60.0f, 2, MidpointRounding.AwayFromZero); + set => base.LiftSpeed = (float) (HeaderSettings.LiftSpeed = Math.Round(value / 60.0, 2, MidpointRounding.AwayFromZero)); } public override float BottomRetractSpeed => RetractSpeed; public override float RetractSpeed { - get => (float)Math.Round(HeaderSettings.RetractSpeed * 60.0, 2); - set => base.RetractSpeed = (float) (HeaderSettings.RetractSpeed = (float) Math.Round(value / 60.0, 2)); + get => MathF.Round((float)HeaderSettings.RetractSpeed * 60.0f, 2, MidpointRounding.AwayFromZero); + set => base.RetractSpeed = (float) (HeaderSettings.RetractSpeed = Math.Round(value / 60.0, 2, MidpointRounding.AwayFromZero)); } @@ -379,7 +379,7 @@ public override float MaterialMilliliters } } - public override object[] Configs => new object[] { HeaderSettings }; + public override object[] Configs => [HeaderSettings]; #endregion diff --git a/UVtools.Core/FileFormats/AnycubicZipFile.cs b/UVtools.Core/FileFormats/AnycubicZipFile.cs index 2d091a62..dd0e3180 100644 --- a/UVtools.Core/FileFormats/AnycubicZipFile.cs +++ b/UVtools.Core/FileFormats/AnycubicZipFile.cs @@ -853,13 +853,13 @@ protected override void EncodeInternally(OperationProgress progress) SceneSettings.LayersDef[layerIndex] = new SceneLayerDef { Height = this[layerIndex].PositionZ, - Area = (float)Math.Round(layer.Contours.TotalSolidArea * pixelArea, 4), - XStartBoundingRectangleOffsetFromCenter = (float)Math.Round(rect.X, 4), - YStartBoundingRectangleOffsetFromCenter = (float)Math.Round(rect.Y, 4), - XEndBoundingRectangleOffsetFromCenter = (float)Math.Round(rect.Right, 4), - YEndBoundingRectangleOffsetFromCenter = (float)Math.Round(rect.Bottom, 4), + Area = MathF.Round((float)layer.Contours.TotalSolidArea * pixelArea, 4, MidpointRounding.AwayFromZero), + XStartBoundingRectangleOffsetFromCenter = MathF.Round(rect.X, 4, MidpointRounding.AwayFromZero), + YStartBoundingRectangleOffsetFromCenter = MathF.Round(rect.Y, 4, MidpointRounding.AwayFromZero), + XEndBoundingRectangleOffsetFromCenter = MathF.Round(rect.Right, 4, MidpointRounding.AwayFromZero), + YEndBoundingRectangleOffsetFromCenter = MathF.Round(rect.Bottom, 4, MidpointRounding.AwayFromZero), ObjectCount = (uint)layer.Contours.ExternalContoursCount, - MaxContourArea = (float)Math.Round(layer.Contours.MaxSolidArea * pixelArea, 4) + MaxContourArea = MathF.Round((float)layer.Contours.MaxSolidArea * pixelArea, 4, MidpointRounding.AwayFromZero) }; encodedRle[layerIndex] = EncodeLayerRle(encodeWith, (uint)layerIndex); @@ -981,8 +981,8 @@ protected override void DecodeInternally(OperationProgress progress) { Index = layerIndex, PositionZ = Layer.RoundHeight(positionZ), - ExposureTime = (float)Math.Round(LayersSettings.Layers[layerIndex].ExposureTime, 2, MidpointRounding.AwayFromZero), - LiftHeight = (float)Math.Round(LayersSettings.Layers[layerIndex].LiftHeight, 2, MidpointRounding.AwayFromZero), + ExposureTime = MathF.Round(LayersSettings.Layers[layerIndex].ExposureTime, 2, MidpointRounding.AwayFromZero), + LiftHeight = MathF.Round(LayersSettings.Layers[layerIndex].LiftHeight, 2, MidpointRounding.AwayFromZero), LiftSpeed = SpeedConverter.Convert(LayersSettings.Layers[layerIndex].LiftSpeed, FormatSpeedUnit, CoreSpeedUnit) }; } diff --git a/UVtools.Core/FileFormats/CTBEncryptedFile.cs b/UVtools.Core/FileFormats/CTBEncryptedFile.cs index a8ca4b1b..9589964a 100644 --- a/UVtools.Core/FileFormats/CTBEncryptedFile.cs +++ b/UVtools.Core/FileFormats/CTBEncryptedFile.cs @@ -746,7 +746,7 @@ public override float DisplayHeight public override float MachineZ { get => Settings.MachineZ > 0 ? Settings.MachineZ : base.MachineZ; - set => base.MachineZ = Settings.MachineZ = (float)Math.Round(value, 2); + set => base.MachineZ = Settings.MachineZ = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -794,7 +794,7 @@ public override float BottomLightOffDelay get => Settings.BottomLightOffDelay; set { - base.BottomLightOffDelay = Settings.BottomLightOffDelay = (float)Math.Round(value, 2); + base.BottomLightOffDelay = Settings.BottomLightOffDelay = MathF.Round(value, 2); if (value > 0) { WaitTimeBeforeCure = 0; @@ -809,7 +809,7 @@ public override float LightOffDelay get => Settings.LightOffDelay; set { - base.LightOffDelay = Settings.LightOffDelay = (float)Math.Round(value, 2); + base.LightOffDelay = Settings.LightOffDelay = MathF.Round(value, 2); if (value > 0) { WaitTimeBeforeCure = 0; @@ -824,7 +824,7 @@ public override float WaitTimeBeforeCure get => Settings.RestTimeAfterRetract; set { - base.WaitTimeBeforeCure = Settings.RestTimeAfterRetract = Settings.RestTimeAfterRetract2 = (float)Math.Round(value, 2); + base.WaitTimeBeforeCure = Settings.RestTimeAfterRetract = Settings.RestTimeAfterRetract2 = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -836,7 +836,7 @@ public override float WaitTimeBeforeCure public override float BottomExposureTime { get => Settings.BottomExposureTime; - set => base.BottomExposureTime = Settings.BottomExposureTime = (float)Math.Round(value, 2); + set => base.BottomExposureTime = Settings.BottomExposureTime = MathF.Round(value, 2); } public override float WaitTimeAfterCure @@ -844,7 +844,7 @@ public override float WaitTimeAfterCure get => Settings.RestTimeBeforeLift; set { - base.WaitTimeAfterCure = Settings.RestTimeBeforeLift = (float)Math.Round(value, 2); + base.WaitTimeAfterCure = Settings.RestTimeBeforeLift = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -856,7 +856,7 @@ public override float WaitTimeAfterCure public override float ExposureTime { get => Settings.ExposureTime; - set => base.ExposureTime = Settings.ExposureTime = (float)Math.Round(value, 2); + set => base.ExposureTime = Settings.ExposureTime = MathF.Round(value, 2); } public override float BottomLiftHeight @@ -864,8 +864,8 @@ public override float BottomLiftHeight get => Math.Max(0,Settings.BottomLiftHeight - Settings.BottomLiftHeight2); set { - value = (float)Math.Round(value, 2); - Settings.BottomLiftHeight = (float)Math.Round(value + Settings.BottomLiftHeight2, 2); + value = MathF.Round(value, 2); + Settings.BottomLiftHeight = MathF.Round(value + Settings.BottomLiftHeight2, 2); base.BottomLiftHeight = value; } } @@ -873,7 +873,7 @@ public override float BottomLiftHeight public override float BottomLiftSpeed { get => Settings.BottomLiftSpeed; - set => base.BottomLiftSpeed = Settings.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = Settings.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftHeight @@ -881,8 +881,8 @@ public override float LiftHeight get => Math.Max(0,Settings.LiftHeight - Settings.LiftHeight2); set { - value = (float)Math.Round(value, 2); - Settings.LiftHeight = (float)Math.Round(value + Settings.LiftHeight2, 2); + value = MathF.Round(value, 2); + Settings.LiftHeight = MathF.Round(value + Settings.LiftHeight2, 2); base.LiftHeight = value; } } @@ -890,7 +890,7 @@ public override float LiftHeight public override float LiftSpeed { get => Settings.LiftSpeed; - set => base.LiftSpeed = Settings.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = Settings.LiftSpeed = MathF.Round(value, 2); } public override float BottomLiftHeight2 @@ -899,7 +899,7 @@ public override float BottomLiftHeight2 set { var bottomLiftHeight = BottomLiftHeight; - Settings.BottomLiftHeight2 = (float)Math.Round(value, 2); + Settings.BottomLiftHeight2 = MathF.Round(value, 2); BottomLiftHeight = bottomLiftHeight; base.BottomLiftHeight2 = Settings.BottomLiftHeight2; } @@ -908,7 +908,7 @@ public override float BottomLiftHeight2 public override float BottomLiftSpeed2 { get => Settings.BottomLiftSpeed2; - set => base.BottomLiftSpeed2 = Settings.BottomLiftSpeed2 = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed2 = Settings.BottomLiftSpeed2 = MathF.Round(value, 2); } public override float LiftHeight2 @@ -917,7 +917,7 @@ public override float LiftHeight2 set { var liftHeight = LiftHeight; - Settings.LiftHeight2 = (float)Math.Round(value, 2); + Settings.LiftHeight2 = MathF.Round(value, 2); LiftHeight = liftHeight; base.LiftHeight2 = Settings.LiftHeight2; } @@ -926,7 +926,7 @@ public override float LiftHeight2 public override float LiftSpeed2 { get => Settings.LiftSpeed2; - set => base.LiftSpeed2 = Settings.LiftSpeed2 = (float)Math.Round(value, 2); + set => base.LiftSpeed2 = Settings.LiftSpeed2 = MathF.Round(value, 2); } public override float WaitTimeAfterLift @@ -934,7 +934,7 @@ public override float WaitTimeAfterLift get => Settings.RestTimeAfterLift; set { - base.WaitTimeAfterLift = Settings.RestTimeAfterLift = Settings.RestTimeAfterLift2 = Settings.RestTimeAfterLift3 = (float)Math.Round(value, 2); + base.WaitTimeAfterLift = Settings.RestTimeAfterLift = Settings.RestTimeAfterLift2 = Settings.RestTimeAfterLift3 = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -946,13 +946,13 @@ public override float WaitTimeAfterLift public override float BottomRetractSpeed { get => Settings.BottomRetractSpeed; - set => base.BottomRetractSpeed = Settings.BottomRetractSpeed = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed = Settings.BottomRetractSpeed = MathF.Round(value, 2); } public override float RetractSpeed { get => Settings.RetractSpeed; - set => base.RetractSpeed = Settings.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = Settings.RetractSpeed = MathF.Round(value, 2); } public override float BottomRetractHeight2 @@ -960,7 +960,7 @@ public override float BottomRetractHeight2 get => Settings.BottomRetractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, BottomRetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, BottomRetractHeightTotal); base.BottomRetractHeight2 = Settings.BottomRetractHeight2 = value; } } @@ -968,7 +968,7 @@ public override float BottomRetractHeight2 public override float BottomRetractSpeed2 { get => Settings.BottomRetractSpeed2; - set => base.BottomRetractSpeed2 = Settings.BottomRetractSpeed2 = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed2 = Settings.BottomRetractSpeed2 = MathF.Round(value, 2); } public override float RetractHeight2 @@ -976,7 +976,7 @@ public override float RetractHeight2 get => Settings.RetractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, RetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, RetractHeightTotal); base.RetractHeight2 = Settings.RetractHeight2 = value; } } @@ -984,7 +984,7 @@ public override float RetractHeight2 public override float RetractSpeed2 { get => Settings.RetractSpeed2; - set => base.RetractSpeed2 = Settings.RetractSpeed2 = (float)Math.Round(value, 2); + set => base.RetractSpeed2 = Settings.RetractSpeed2 = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -1034,13 +1034,13 @@ public override string? MaterialName public override float MaterialGrams { get => Settings.MaterialGrams; - set => base.MaterialGrams = Settings.MaterialGrams = (float)Math.Round(value, 3); + set => base.MaterialGrams = Settings.MaterialGrams = MathF.Round(value, 3); } public override float MaterialCost { - get => (float)Math.Round(Settings.MaterialCost, 3); - set => base.MaterialCost = Settings.MaterialCost = (float)Math.Round(value, 3); + get => MathF.Round(Settings.MaterialCost, 3); + set => base.MaterialCost = Settings.MaterialCost = MathF.Round(value, 3); } public override object[] Configs diff --git a/UVtools.Core/FileFormats/CWSFile.cs b/UVtools.Core/FileFormats/CWSFile.cs index 2368a003..eb1a11ae 100644 --- a/UVtools.Core/FileFormats/CWSFile.cs +++ b/UVtools.Core/FileFormats/CWSFile.cs @@ -389,7 +389,7 @@ public override float DisplayHeight public override float MachineZ { get => OutputSettings.PlatformZSize > 0 ? OutputSettings.PlatformZSize : base.MachineZ; - set => base.MachineZ = OutputSettings.PlatformZSize = (float)Math.Round(value, 2); + set => base.MachineZ = OutputSettings.PlatformZSize = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -490,13 +490,13 @@ public override float ExposureTime public override float LiftHeight { get => OutputSettings.LiftDistance; - set => base.LiftHeight = OutputSettings.LiftDistance = SliceSettings.LiftDistance = (float)Math.Round(value, 2); + set => base.LiftHeight = OutputSettings.LiftDistance = SliceSettings.LiftDistance = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => OutputSettings.ZBottomLiftFeedRate; - set => base.BottomLiftSpeed = OutputSettings.ZBottomLiftFeedRate = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = OutputSettings.ZBottomLiftFeedRate = MathF.Round(value, 2); } @@ -506,13 +506,13 @@ public override float LiftSpeed set => base.LiftSpeed = OutputSettings.ZLiftFeedRate = - SliceSettings.LiftUpSpeed = (float)Math.Round(value, 2); + SliceSettings.LiftUpSpeed = MathF.Round(value, 2); } public override float RetractSpeed { get => OutputSettings.ZLiftRetractRate; - set => base.RetractSpeed = OutputSettings.ZLiftRetractRate = SliceSettings.LiftDownSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = OutputSettings.ZLiftRetractRate = SliceSettings.LiftDownSpeed = MathF.Round(value, 2); } public override byte BottomLightPWM diff --git a/UVtools.Core/FileFormats/ChituboxFile.cs b/UVtools.Core/FileFormats/ChituboxFile.cs index a757bdeb..4b17320d 100644 --- a/UVtools.Core/FileFormats/ChituboxFile.cs +++ b/UVtools.Core/FileFormats/ChituboxFile.cs @@ -1239,7 +1239,7 @@ public override float DisplayHeight public override float MachineZ { get => HeaderSettings.BedSizeZ > 0 ? HeaderSettings.BedSizeZ : base.MachineZ; - set => base.MachineZ = HeaderSettings.BedSizeZ = (float)Math.Round(value, 2); + set => base.MachineZ = HeaderSettings.BedSizeZ = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } public override FlipDirection DisplayMirror @@ -1312,7 +1312,7 @@ public override float BottomLightOffDelay get => PrintParametersSettings.BottomLightOffDelay; set { - base.BottomLightOffDelay = PrintParametersSettings.BottomLightOffDelay = (float) Math.Round(value, 2); + base.BottomLightOffDelay = PrintParametersSettings.BottomLightOffDelay = MathF.Round(value, 2); if (HeaderSettings.Version >= 4 && value > 0) { WaitTimeBeforeCure = 0; @@ -1327,7 +1327,7 @@ public override float LightOffDelay get => HeaderSettings.LightOffDelay; set { - base.LightOffDelay = HeaderSettings.LightOffDelay = PrintParametersSettings.LightOffDelay = (float) Math.Round(value, 2); + base.LightOffDelay = HeaderSettings.LightOffDelay = PrintParametersSettings.LightOffDelay = MathF.Round(value, 2, MidpointRounding.AwayFromZero); if (HeaderSettings.Version >= 4 && value > 0) { WaitTimeBeforeCure = 0; @@ -1370,7 +1370,7 @@ public override float WaitTimeBeforeCure return; } - base.WaitTimeBeforeCure = SlicerInfoSettings.RestTimeAfterRetract = PrintParametersV4Settings.RestTimeAfterRetract = (float)Math.Round(value, 2); + base.WaitTimeBeforeCure = SlicerInfoSettings.RestTimeAfterRetract = PrintParametersV4Settings.RestTimeAfterRetract = MathF.Round(value, 2, MidpointRounding.AwayFromZero); if (value > 0) { BottomLightOffDelay = 0; @@ -1382,7 +1382,7 @@ public override float WaitTimeBeforeCure public override float BottomExposureTime { get => HeaderSettings.BottomExposureSeconds; - set => base.BottomExposureTime = HeaderSettings.BottomExposureSeconds = (float) Math.Round(value, 2); + set => base.BottomExposureTime = HeaderSettings.BottomExposureSeconds = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } public override float BottomWaitTimeAfterCure @@ -1401,7 +1401,7 @@ public override float WaitTimeAfterCure set { if (HeaderSettings.Version < 4) return; - base.WaitTimeAfterCure = PrintParametersV4Settings.RestTimeBeforeLift = (float) Math.Round(value, 2); + base.WaitTimeAfterCure = PrintParametersV4Settings.RestTimeBeforeLift = MathF.Round(value, 2, MidpointRounding.AwayFromZero); if (value > 0) { BottomLightOffDelay = 0; @@ -1413,7 +1413,7 @@ public override float WaitTimeAfterCure public override float ExposureTime { get => HeaderSettings.LayerExposureSeconds; - set => base.ExposureTime = HeaderSettings.LayerExposureSeconds = (float)Math.Round(value, 2); + set => base.ExposureTime = HeaderSettings.LayerExposureSeconds = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } public override float BottomLiftHeight @@ -1421,13 +1421,13 @@ public override float BottomLiftHeight get { if (HeaderSettings.Version <= 3) return PrintParametersSettings.BottomLiftHeight; - return (float)Math.Round(Math.Max(0, PrintParametersSettings.BottomLiftHeight - SlicerInfoSettings.BottomLiftHeight2), 2); + return MathF.Round(Math.Max(0, PrintParametersSettings.BottomLiftHeight - SlicerInfoSettings.BottomLiftHeight2), 2); } set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (HeaderSettings.Version <= 3) PrintParametersSettings.BottomLiftHeight = value; - if (HeaderSettings.Version >= 4) PrintParametersSettings.BottomLiftHeight = (float)Math.Round(value + SlicerInfoSettings.BottomLiftHeight2, 2); + if (HeaderSettings.Version >= 4) PrintParametersSettings.BottomLiftHeight = MathF.Round(value + SlicerInfoSettings.BottomLiftHeight2, 2, MidpointRounding.AwayFromZero); base.BottomLiftHeight = value; } } @@ -1435,7 +1435,7 @@ public override float BottomLiftHeight public override float BottomLiftSpeed { get => PrintParametersSettings.BottomLiftSpeed; - set => base.BottomLiftSpeed = PrintParametersSettings.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = PrintParametersSettings.BottomLiftSpeed = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } public override float LiftHeight @@ -1447,9 +1447,9 @@ public override float LiftHeight } set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (HeaderSettings.Version <= 3) PrintParametersSettings.LiftHeight = value; - if (HeaderSettings.Version >= 4) PrintParametersSettings.LiftHeight = (float)Math.Round(value + SlicerInfoSettings.LiftHeight2, 2); + if (HeaderSettings.Version >= 4) PrintParametersSettings.LiftHeight = MathF.Round(value + SlicerInfoSettings.LiftHeight2, 2, MidpointRounding.AwayFromZero); base.LiftHeight = value; } } @@ -1457,7 +1457,7 @@ public override float LiftHeight public override float LiftSpeed { get => PrintParametersSettings.LiftSpeed; - set => base.LiftSpeed = PrintParametersSettings.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = PrintParametersSettings.LiftSpeed = MathF.Round(value, 2); } public override float BottomLiftHeight2 @@ -1467,7 +1467,7 @@ public override float BottomLiftHeight2 { if (HeaderSettings.Version < 4) return; var bottomLiftHeight = BottomLiftHeight; - SlicerInfoSettings.BottomLiftHeight2 = (float)Math.Round(value, 2); + SlicerInfoSettings.BottomLiftHeight2 = MathF.Round(value, 2); BottomLiftHeight = bottomLiftHeight; base.BottomLiftHeight2 = SlicerInfoSettings.BottomLiftHeight2; } @@ -1479,7 +1479,7 @@ public override float BottomLiftSpeed2 set { if (HeaderSettings.Version < 4) return; - base.BottomLiftSpeed2 = SlicerInfoSettings.BottomLiftSpeed2 = (float)Math.Round(value, 2); + base.BottomLiftSpeed2 = SlicerInfoSettings.BottomLiftSpeed2 = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } } @@ -1490,7 +1490,7 @@ public override float LiftHeight2 { if (HeaderSettings.Version < 4) return; var liftHeight = LiftHeight; - SlicerInfoSettings.LiftHeight2 = (float)Math.Round(value, 2); + SlicerInfoSettings.LiftHeight2 = MathF.Round(value, 2, MidpointRounding.AwayFromZero); LiftHeight = liftHeight; base.LiftHeight2 = SlicerInfoSettings.LiftHeight2; } @@ -1502,7 +1502,7 @@ public override float LiftSpeed2 set { if (HeaderSettings.Version < 4) return; - base.LiftSpeed2 = SlicerInfoSettings.LiftSpeed2 = (float)Math.Round(value, 2); + base.LiftSpeed2 = SlicerInfoSettings.LiftSpeed2 = MathF.Round(value, 2, MidpointRounding.AwayFromZero); } } @@ -1522,7 +1522,7 @@ public override float WaitTimeAfterLift set { if (HeaderSettings.Version < 4) return; - base.WaitTimeAfterLift = SlicerInfoSettings.RestTimeAfterLift = SlicerInfoSettings.RestTimeAfterLift2 = PrintParametersV4Settings.RestTimeAfterLift = (float)Math.Round(value, 2); + base.WaitTimeAfterLift = SlicerInfoSettings.RestTimeAfterLift = SlicerInfoSettings.RestTimeAfterLift2 = PrintParametersV4Settings.RestTimeAfterLift = MathF.Round(value, 2, MidpointRounding.AwayFromZero); if (value > 0) { BottomLightOffDelay = 0; @@ -1537,14 +1537,14 @@ public override float BottomRetractSpeed set { if (HeaderSettings.Version < 4) return; - base.BottomRetractSpeed = PrintParametersV4Settings.BottomRetractSpeed = (float)Math.Round(value, 2); + base.BottomRetractSpeed = PrintParametersV4Settings.BottomRetractSpeed = MathF.Round(value, 2); } } public override float RetractSpeed { get => PrintParametersSettings.RetractSpeed; - set => base.RetractSpeed = PrintParametersSettings.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = PrintParametersSettings.RetractSpeed = MathF.Round(value, 2); } public override float BottomRetractHeight2 @@ -1553,7 +1553,7 @@ public override float BottomRetractHeight2 set { if (HeaderSettings.Version < 4) return; - value = Math.Clamp((float)Math.Round(value, 2), 0, BottomRetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, BottomRetractHeightTotal); base.BottomRetractHeight2 = PrintParametersV4Settings.BottomRetractHeight2 = value; } } @@ -1564,7 +1564,7 @@ public override float BottomRetractSpeed2 set { if (HeaderSettings.Version < 4) return; - base.BottomRetractSpeed2 = PrintParametersV4Settings.BottomRetractSpeed2 = (float)Math.Round(value, 2); + base.BottomRetractSpeed2 = PrintParametersV4Settings.BottomRetractSpeed2 = MathF.Round(value, 2); } } @@ -1574,7 +1574,7 @@ public override float RetractHeight2 set { if (HeaderSettings.Version < 4) return; - value = Math.Clamp((float)Math.Round(value, 2), 0, RetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, RetractHeightTotal); base.RetractHeight2 = SlicerInfoSettings.RetractHeight2 = value; } } @@ -1582,7 +1582,7 @@ public override float RetractHeight2 public override float RetractSpeed2 { get => HeaderSettings.Version >= 4 ? SlicerInfoSettings.RetractSpeed2 : 0; - set => base.RetractSpeed2 = SlicerInfoSettings.RetractSpeed2 = (float)Math.Round(value, 2); + set => base.RetractSpeed2 = SlicerInfoSettings.RetractSpeed2 = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -1626,13 +1626,13 @@ public override string? MaterialName public override float MaterialGrams { get => PrintParametersSettings.WeightG; - set => base.MaterialGrams = PrintParametersSettings.WeightG = (float)Math.Round(value, 3); + set => base.MaterialGrams = PrintParametersSettings.WeightG = MathF.Round(value, 3); } public override float MaterialCost { - get => (float) Math.Round(PrintParametersSettings.CostDollars, 3); - set => base.MaterialCost = PrintParametersSettings.CostDollars = (float) Math.Round(value, 3); + get => MathF.Round(PrintParametersSettings.CostDollars, 3); + set => base.MaterialCost = PrintParametersSettings.CostDollars = MathF.Round(value, 3); } public override string MachineName diff --git a/UVtools.Core/FileFormats/ChituboxZipFile.cs b/UVtools.Core/FileFormats/ChituboxZipFile.cs index fb4f0151..8406fdad 100644 --- a/UVtools.Core/FileFormats/ChituboxZipFile.cs +++ b/UVtools.Core/FileFormats/ChituboxZipFile.cs @@ -169,7 +169,7 @@ public override float DisplayHeight public override float MachineZ { get => HeaderSettings.MachineZ > 0 ? HeaderSettings.MachineZ : base.MachineZ; - set => base.MachineZ = HeaderSettings.MachineZ = (float)Math.Round(value, 2); + set => base.MachineZ = HeaderSettings.MachineZ = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -222,55 +222,55 @@ public override float LightOffDelay public override float BottomWaitTimeBeforeCure { get => HeaderSettings.BottomLightOffDelay; - set => base.BottomWaitTimeBeforeCure = HeaderSettings.BottomLightOffDelay = (float)Math.Round(value, 2); + set => base.BottomWaitTimeBeforeCure = HeaderSettings.BottomLightOffDelay = MathF.Round(value, 2); } public override float WaitTimeBeforeCure { get => HeaderSettings.LightOffDelay; - set => base.WaitTimeBeforeCure = HeaderSettings.LightOffDelay = (float)Math.Round(value, 2); + set => base.WaitTimeBeforeCure = HeaderSettings.LightOffDelay = MathF.Round(value, 2); } public override float BottomExposureTime { get => HeaderSettings.BottomExposureTime; - set => base.BottomExposureTime = HeaderSettings.BottomExposureTime = HeaderSettings.BottomLayExposureTime = (float)Math.Round(value, 2); + set => base.BottomExposureTime = HeaderSettings.BottomExposureTime = HeaderSettings.BottomLayExposureTime = MathF.Round(value, 2); } public override float ExposureTime { get => HeaderSettings.ExposureTime; - set => base.ExposureTime = HeaderSettings.ExposureTime = (float)Math.Round(value, 2); + set => base.ExposureTime = HeaderSettings.ExposureTime = MathF.Round(value, 2); } public override float BottomLiftHeight { get => HeaderSettings.BottomLiftHeight; - set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = MathF.Round(value, 2); } public override float LiftHeight { get => HeaderSettings.LiftHeight; - set => base.LiftHeight = HeaderSettings.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = HeaderSettings.LiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => HeaderSettings.BottomLiftSpeed; - set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftSpeed { get => HeaderSettings.LiftSpeed; - set => base.LiftSpeed = HeaderSettings.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = HeaderSettings.LiftSpeed = MathF.Round(value, 2); } public override float RetractSpeed { get => HeaderSettings.RetractSpeed; - set => base.RetractSpeed = HeaderSettings.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = HeaderSettings.RetractSpeed = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -307,20 +307,20 @@ public override float MaterialMilliliters public override float MaterialGrams { - get => (float) Math.Round(HeaderSettings.WeightG, 3); + get => MathF.Round(HeaderSettings.WeightG, 3); set { - HeaderSettings.WeightG = (float)Math.Round(value, 3); + HeaderSettings.WeightG = MathF.Round(value, 3); RaisePropertyChanged(); } } public override float MaterialCost { - get => (float) Math.Round(HeaderSettings.Price, 3); + get => MathF.Round(HeaderSettings.Price, 3); set { - HeaderSettings.Price = (float)Math.Round(value, 3); + HeaderSettings.Price = MathF.Round(value, 3); RaisePropertyChanged(); } } diff --git a/UVtools.Core/FileFormats/CrealityCXDLPFile.cs b/UVtools.Core/FileFormats/CrealityCXDLPFile.cs index 7041bf28..25903498 100644 --- a/UVtools.Core/FileFormats/CrealityCXDLPFile.cs +++ b/UVtools.Core/FileFormats/CrealityCXDLPFile.cs @@ -453,10 +453,10 @@ public override uint ResolutionY public override float DisplayWidth { - get => (float)Math.Round(float.Parse(SlicerInfoSettings.DisplayWidth, CultureInfo.InvariantCulture), 2); + get => MathF.Round(float.Parse(SlicerInfoSettings.DisplayWidth, CultureInfo.InvariantCulture), 2); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); SlicerInfoSettings.DisplayWidth = value.ToString(CultureInfo.InvariantCulture); base.DisplayWidth = value; } @@ -464,10 +464,10 @@ public override float DisplayWidth public override float DisplayHeight { - get => (float)Math.Round(float.Parse(SlicerInfoSettings.DisplayHeight, CultureInfo.InvariantCulture), 3); + get => MathF.Round(float.Parse(SlicerInfoSettings.DisplayHeight, CultureInfo.InvariantCulture), 3); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); SlicerInfoSettings.DisplayHeight = value.ToString(CultureInfo.InvariantCulture); base.DisplayHeight = value; } @@ -519,10 +519,10 @@ public override float BottomExposureTime public override float ExposureTime { - get => (float)Math.Round(SlicerInfoSettings.ExposureTime / 10.0f, 1); + get => MathF.Round(SlicerInfoSettings.ExposureTime / 10.0f, 1); set { - value = (float)Math.Round(value, 1); + value = MathF.Round(value, 1); SlicerInfoSettings.ExposureTime = (ushort) (value * 10); base.ExposureTime = value; } diff --git a/UVtools.Core/FileFormats/CrealityCXDLPv1File.cs b/UVtools.Core/FileFormats/CrealityCXDLPv1File.cs index e7096178..98c06060 100644 --- a/UVtools.Core/FileFormats/CrealityCXDLPv1File.cs +++ b/UVtools.Core/FileFormats/CrealityCXDLPv1File.cs @@ -357,10 +357,10 @@ public override uint ResolutionY public override float DisplayWidth { - get => (float)Math.Round(float.Parse(SlicerInfoSettings.DisplayWidth, CultureInfo.InvariantCulture), 2); + get => MathF.Round(float.Parse(SlicerInfoSettings.DisplayWidth, CultureInfo.InvariantCulture), 2); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); SlicerInfoSettings.DisplayWidth = value.ToString(CultureInfo.InvariantCulture); base.DisplayWidth = value; } @@ -368,10 +368,10 @@ public override float DisplayWidth public override float DisplayHeight { - get => (float)Math.Round(float.Parse(SlicerInfoSettings.DisplayHeight, CultureInfo.InvariantCulture), 3); + get => MathF.Round(float.Parse(SlicerInfoSettings.DisplayHeight, CultureInfo.InvariantCulture), 3); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); SlicerInfoSettings.DisplayHeight = value.ToString(CultureInfo.InvariantCulture); base.DisplayHeight = value; } diff --git a/UVtools.Core/FileFormats/CrealityCXDLPv4File.cs b/UVtools.Core/FileFormats/CrealityCXDLPv4File.cs index 1b5319c9..d33265c8 100644 --- a/UVtools.Core/FileFormats/CrealityCXDLPv4File.cs +++ b/UVtools.Core/FileFormats/CrealityCXDLPv4File.cs @@ -776,7 +776,7 @@ public override float DisplayHeight public override float MachineZ { get => HeaderSettings.BedSizeZ > 0 ? HeaderSettings.BedSizeZ : base.MachineZ; - set => base.MachineZ = HeaderSettings.BedSizeZ = (float)Math.Round(value, 2); + set => base.MachineZ = HeaderSettings.BedSizeZ = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -830,7 +830,7 @@ public override float BottomLightOffDelay get => PrintParametersSettings.BottomLightOffDelay; set { - base.BottomLightOffDelay = PrintParametersSettings.BottomLightOffDelay = (float) Math.Round(value, 2); + base.BottomLightOffDelay = PrintParametersSettings.BottomLightOffDelay = MathF.Round(value, 2); if (value > 0) { WaitTimeBeforeCure = 0; @@ -845,7 +845,7 @@ public override float LightOffDelay get => PrintParametersSettings.LightOffDelay; set { - base.LightOffDelay = PrintParametersSettings.LightOffDelay = PrintParametersSettings.LightOffDelay = (float) Math.Round(value, 2); + base.LightOffDelay = PrintParametersSettings.LightOffDelay = PrintParametersSettings.LightOffDelay = MathF.Round(value, 2); if (value > 0) { WaitTimeBeforeCure = 0; @@ -860,7 +860,7 @@ public override float WaitTimeBeforeCure get => SlicerInfoSettings.RestTimeAfterRetract; set { - base.WaitTimeBeforeCure = SlicerInfoSettings.RestTimeAfterRetract = (float)Math.Round(value, 2); + base.WaitTimeBeforeCure = SlicerInfoSettings.RestTimeAfterRetract = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -872,7 +872,7 @@ public override float WaitTimeBeforeCure public override float BottomExposureTime { get => PrintParametersSettings.BottomExposureTime; - set => base.BottomExposureTime = PrintParametersSettings.BottomExposureTime = SlicerInfoSettings.BottomExposureTime = (float) Math.Round(value, 2); + set => base.BottomExposureTime = PrintParametersSettings.BottomExposureTime = SlicerInfoSettings.BottomExposureTime = MathF.Round(value, 2); } public override float WaitTimeAfterCure @@ -880,7 +880,7 @@ public override float WaitTimeAfterCure get => SlicerInfoSettings.RestTimeBeforeLift; set { - base.WaitTimeAfterCure = SlicerInfoSettings.RestTimeBeforeLift = (float) Math.Round(value, 2); + base.WaitTimeAfterCure = SlicerInfoSettings.RestTimeBeforeLift = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -892,16 +892,16 @@ public override float WaitTimeAfterCure public override float ExposureTime { get => PrintParametersSettings.ExposureTime; - set => base.ExposureTime = PrintParametersSettings.ExposureTime = SlicerInfoSettings.ExposureTime = (float)Math.Round(value, 2); + set => base.ExposureTime = PrintParametersSettings.ExposureTime = SlicerInfoSettings.ExposureTime = MathF.Round(value, 2); } public override float BottomLiftHeight { - get => (float)Math.Round(Math.Max(0, PrintParametersSettings.BottomLiftHeight - SlicerInfoSettings.BottomLiftHeight2), 2); + get => MathF.Round(Math.Max(0, PrintParametersSettings.BottomLiftHeight - SlicerInfoSettings.BottomLiftHeight2), 2); set { - value = (float)Math.Round(value, 2); - PrintParametersSettings.BottomLiftHeight = (float)Math.Round(value + SlicerInfoSettings.BottomLiftHeight2, 2); + value = MathF.Round(value, 2); + PrintParametersSettings.BottomLiftHeight = MathF.Round(value + SlicerInfoSettings.BottomLiftHeight2, 2); base.BottomLiftHeight = value; } } @@ -909,7 +909,7 @@ public override float BottomLiftHeight public override float BottomLiftSpeed { get => PrintParametersSettings.BottomLiftSpeed; - set => base.BottomLiftSpeed = PrintParametersSettings.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = PrintParametersSettings.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftHeight @@ -917,8 +917,8 @@ public override float LiftHeight get => Math.Max(0, PrintParametersSettings.LiftHeight - SlicerInfoSettings.LiftHeight2); set { - value = (float)Math.Round(value, 2); - PrintParametersSettings.LiftHeight = (float)Math.Round(value + SlicerInfoSettings.LiftHeight2, 2); + value = MathF.Round(value, 2); + PrintParametersSettings.LiftHeight = MathF.Round(value + SlicerInfoSettings.LiftHeight2, 2); base.LiftHeight = value; } } @@ -926,7 +926,7 @@ public override float LiftHeight public override float LiftSpeed { get => PrintParametersSettings.LiftSpeed; - set => base.LiftSpeed = PrintParametersSettings.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = PrintParametersSettings.LiftSpeed = MathF.Round(value, 2); } public override float BottomLiftHeight2 @@ -935,7 +935,7 @@ public override float BottomLiftHeight2 set { var bottomLiftHeight = BottomLiftHeight; - SlicerInfoSettings.BottomLiftHeight2 = (float)Math.Round(value, 2); + SlicerInfoSettings.BottomLiftHeight2 = MathF.Round(value, 2); BottomLiftHeight = bottomLiftHeight; base.BottomLiftHeight2 = SlicerInfoSettings.BottomLiftHeight2; } @@ -944,7 +944,7 @@ public override float BottomLiftHeight2 public override float BottomLiftSpeed2 { get => SlicerInfoSettings.BottomLiftSpeed2; - set => base.BottomLiftSpeed2 = SlicerInfoSettings.BottomLiftSpeed2 = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed2 = SlicerInfoSettings.BottomLiftSpeed2 = MathF.Round(value, 2); } public override float LiftHeight2 @@ -953,7 +953,7 @@ public override float LiftHeight2 set { var liftHeight = LiftHeight; - SlicerInfoSettings.LiftHeight2 = (float)Math.Round(value, 2); + SlicerInfoSettings.LiftHeight2 = MathF.Round(value, 2); LiftHeight = liftHeight; base.LiftHeight2 = SlicerInfoSettings.LiftHeight2; } @@ -962,7 +962,7 @@ public override float LiftHeight2 public override float LiftSpeed2 { get => SlicerInfoSettings.LiftSpeed2; - set => base.LiftSpeed2 = SlicerInfoSettings.LiftSpeed2 = (float)Math.Round(value, 2); + set => base.LiftSpeed2 = SlicerInfoSettings.LiftSpeed2 = MathF.Round(value, 2); } public override float WaitTimeAfterLift @@ -970,7 +970,7 @@ public override float WaitTimeAfterLift get => SlicerInfoSettings.RestTimeAfterLift; set { - base.WaitTimeAfterLift = SlicerInfoSettings.RestTimeAfterLift = SlicerInfoSettings.RestTimeAfterLift2 = (float)Math.Round(value, 2); + base.WaitTimeAfterLift = SlicerInfoSettings.RestTimeAfterLift = SlicerInfoSettings.RestTimeAfterLift2 = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -982,7 +982,7 @@ public override float WaitTimeAfterLift public override float RetractSpeed { get => PrintParametersSettings.RetractSpeed; - set => base.RetractSpeed = PrintParametersSettings.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = PrintParametersSettings.RetractSpeed = MathF.Round(value, 2); } public override float RetractHeight2 @@ -990,7 +990,7 @@ public override float RetractHeight2 get => SlicerInfoSettings.RetractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, RetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, RetractHeightTotal); base.RetractHeight2 = SlicerInfoSettings.RetractHeight2 = value; } } @@ -998,7 +998,7 @@ public override float RetractHeight2 public override float RetractSpeed2 { get => SlicerInfoSettings.RetractSpeed2; - set => base.RetractSpeed2 = SlicerInfoSettings.RetractSpeed2 = (float)Math.Round(value, 2); + set => base.RetractSpeed2 = SlicerInfoSettings.RetractSpeed2 = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -1036,13 +1036,13 @@ public override float MaterialMilliliters public override float MaterialGrams { get => PrintParametersSettings.WeightG; - set => base.MaterialGrams = PrintParametersSettings.WeightG = (float)Math.Round(value, 3); + set => base.MaterialGrams = PrintParametersSettings.WeightG = MathF.Round(value, 3); } public override float MaterialCost { - get => (float) Math.Round(PrintParametersSettings.CostDollars, 3); - set => base.MaterialCost = PrintParametersSettings.CostDollars = (float) Math.Round(value, 3); + get => MathF.Round(PrintParametersSettings.CostDollars, 3); + set => base.MaterialCost = PrintParametersSettings.CostDollars = MathF.Round(value, 3); } public override string MachineName diff --git a/UVtools.Core/FileFormats/FDGFile.cs b/UVtools.Core/FileFormats/FDGFile.cs index b2ca9c04..c322a8f3 100644 --- a/UVtools.Core/FileFormats/FDGFile.cs +++ b/UVtools.Core/FileFormats/FDGFile.cs @@ -600,7 +600,7 @@ public override float DisplayHeight public override float MachineZ { get => HeaderSettings.BedSizeZ > 0 ? HeaderSettings.BedSizeZ : base.MachineZ; - set => base.MachineZ = HeaderSettings.BedSizeZ = (float)Math.Round(value, 2); + set => base.MachineZ = HeaderSettings.BedSizeZ = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -646,13 +646,13 @@ public override ushort BottomLayerCount public override float BottomLightOffDelay { get => HeaderSettings.BottomLightOffDelay; - set => base.BottomLightOffDelay = HeaderSettings.BottomLightOffDelay = (float)Math.Round(value, 2); + set => base.BottomLightOffDelay = HeaderSettings.BottomLightOffDelay = MathF.Round(value, 2); } public override float LightOffDelay { get => HeaderSettings.LightOffDelay; - set => base.LightOffDelay = HeaderSettings.LightOffDelay = (float)Math.Round(value, 2); + set => base.LightOffDelay = HeaderSettings.LightOffDelay = MathF.Round(value, 2); } public override float BottomWaitTimeBeforeCure @@ -684,31 +684,31 @@ public override float BottomExposureTime public override float ExposureTime { get => HeaderSettings.LayerExposureSeconds; - set => base.ExposureTime = HeaderSettings.LayerExposureSeconds = (float)Math.Round(value, 2); + set => base.ExposureTime = HeaderSettings.LayerExposureSeconds = MathF.Round(value, 2); } public override float BottomLiftHeight { get => HeaderSettings.BottomLiftHeight; - set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = MathF.Round(value, 2); } public override float LiftHeight { get => HeaderSettings.LiftHeight; - set => base.LiftHeight = HeaderSettings.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = HeaderSettings.LiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => HeaderSettings.BottomLiftSpeed; - set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftSpeed { get => HeaderSettings.LiftSpeed; - set => base.LiftSpeed = HeaderSettings.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = HeaderSettings.LiftSpeed = MathF.Round(value, 2); } public override float BottomRetractSpeed => RetractSpeed; @@ -716,7 +716,7 @@ public override float LiftSpeed public override float RetractSpeed { get => HeaderSettings.RetractSpeed; - set => base.RetractSpeed = HeaderSettings.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = HeaderSettings.RetractSpeed = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -753,14 +753,14 @@ public override float MaterialMilliliters public override float MaterialGrams { - get => (float)Math.Round(HeaderSettings.WeightG, 3); - set => base.MaterialGrams = HeaderSettings.WeightG = (float)Math.Round(value, 3); + get => MathF.Round(HeaderSettings.WeightG, 3); + set => base.MaterialGrams = HeaderSettings.WeightG = MathF.Round(value, 3); } public override float MaterialCost { - get => (float) Math.Round(HeaderSettings.CostDollars, 3); - set => base.MaterialCost = HeaderSettings.CostDollars = (float)Math.Round(value, 3); + get => MathF.Round(HeaderSettings.CostDollars, 3); + set => base.MaterialCost = HeaderSettings.CostDollars = MathF.Round(value, 3); } public override string MachineName diff --git a/UVtools.Core/FileFormats/FileFormat.cs b/UVtools.Core/FileFormats/FileFormat.cs index ea953d48..3e3b97d3 100644 --- a/UVtools.Core/FileFormats/FileFormat.cs +++ b/UVtools.Core/FileFormats/FileFormat.cs @@ -25,7 +25,6 @@ using System.Threading.Tasks; using System.Timers; using CommunityToolkit.Diagnostics; -using UVtools.Core.EmguCV; using UVtools.Core.Extensions; using UVtools.Core.GCode; using UVtools.Core.Layers; @@ -34,7 +33,6 @@ using UVtools.Core.Operations; using UVtools.Core.PixelEditor; using UVtools.Core.Exceptions; -using UVtools.Core.Converters; namespace UVtools.Core.FileFormats; @@ -737,7 +735,7 @@ public static string GetFileNameStripExtensions(string filepath, out string stri public static Task OpenAsync(string fileFullPath, OperationProgress? progress = null) => OpenAsync(fileFullPath, FileDecodeType.Full, progress); - public static float RoundDisplaySize(float value) => (float)Math.Round(value, DisplayFloatPrecision); + public static float RoundDisplaySize(float value) => MathF.Round(value, DisplayFloatPrecision); public static double RoundDisplaySize(double value) => Math.Round(value, DisplayFloatPrecision); public static decimal RoundDisplaySize(decimal value) => Math.Round(value, DisplayFloatPrecision); @@ -1316,7 +1314,7 @@ public static bool IsFileNameValid(string filename, bool onlyAsciiCharacters = f protected ImageFormat _layerImageFormat = ImageFormat.Custom; - protected Layer[] _layers = Array.Empty(); + protected Layer[] _layers = []; private bool _haveModifiedLayers; private uint _version; @@ -1978,10 +1976,10 @@ public RectangleF BoundingRectangleMillimeters var pixelSize = PixelSize; var boundingRectangle = BoundingRectangle; return new RectangleF( - (float)Math.Round(boundingRectangle.X * pixelSize.Width, 2), - (float)Math.Round(boundingRectangle.Y * pixelSize.Height, 2), - (float)Math.Round(boundingRectangle.Width * pixelSize.Width, 2), - (float)Math.Round(boundingRectangle.Height * pixelSize.Height, 2)); + MathF.Round(boundingRectangle.X * pixelSize.Width, 2), + MathF.Round(boundingRectangle.Y * pixelSize.Height, 2), + MathF.Round(boundingRectangle.Width * pixelSize.Width, 2), + MathF.Round(boundingRectangle.Height * pixelSize.Height, 2)); } } @@ -2123,12 +2121,12 @@ public virtual float DisplayHeight /// /// Gets the display diagonal in millimeters /// - public float DisplayDiagonal => (float)Math.Round(Math.Sqrt(Math.Pow(DisplayWidth, 2) + Math.Pow(DisplayHeight, 2)), 2); + public float DisplayDiagonal => MathF.Round(MathF.Sqrt(MathF.Pow(DisplayWidth, 2) + MathF.Pow(DisplayHeight, 2)), 2, MidpointRounding.AwayFromZero); /// /// Gets the display diagonal in inch's /// - public float DisplayDiagonalInches => (float)Math.Round(Math.Sqrt(Math.Pow(DisplayWidth, 2) + Math.Pow(DisplayHeight, 2)) * UnitExtensions.MillimeterToInch, 2); + public float DisplayDiagonalInches => MathF.Round(MathF.Sqrt(MathF.Pow(DisplayWidth, 2) + MathF.Pow(DisplayHeight, 2)) * (float)UnitExtensions.MillimeterToInch, 2, MidpointRounding.AwayFromZero); /// /// Gets the display ratio @@ -2198,12 +2196,12 @@ public virtual float MachineZ /// /// Gets the pixel width in millimeters /// - public float PixelWidth => DisplayWidth > 0 && ResolutionX > 0 ? (float) Math.Round(DisplayWidth / ResolutionX, 4) : 0; + public float PixelWidth => DisplayWidth > 0 && ResolutionX > 0 ? MathF.Round(DisplayWidth / ResolutionX, 4) : 0; /// /// Gets the pixel height in millimeters /// - public float PixelHeight => DisplayHeight > 0 && ResolutionY > 0 ? (float) Math.Round(DisplayHeight / ResolutionY, 4) : 0; + public float PixelHeight => DisplayHeight > 0 && ResolutionY > 0 ? MathF.Round(DisplayHeight / ResolutionY, 4) : 0; /// /// Gets the pixel size in millimeters @@ -2223,12 +2221,12 @@ public virtual float MachineZ /// /// Gets the pixel width in microns /// - public float PixelWidthMicrons => DisplayWidth > 0 && ResolutionX > 0 ? (float)Math.Round(DisplayWidth / ResolutionX * 1000, 3) : 0; + public float PixelWidthMicrons => DisplayWidth > 0 && ResolutionX > 0 ? MathF.Round(DisplayWidth / ResolutionX * 1000, 3) : 0; /// /// Gets the pixel height in microns /// - public float PixelHeightMicrons => DisplayHeight > 0 && ResolutionY > 0 ? (float)Math.Round(DisplayHeight / ResolutionY * 1000, 3) : 0; + public float PixelHeightMicrons => DisplayHeight > 0 && ResolutionY > 0 ? MathF.Round(DisplayHeight / ResolutionY * 1000, 3) : 0; /// /// Gets the pixel size in microns @@ -2337,7 +2335,7 @@ public Size PixelsToNormalizedPitch(int size) /// /// Gets the file volume (XYZ) in mm^3 /// - public float Volume => (float)Math.Round(this.Sum(layer => layer.GetVolume()), 3); + public float Volume => MathF.Round(this.Sum(layer => layer.GetVolume()), 3); /// /// Gets if the printer have a tilting vat @@ -2520,7 +2518,7 @@ public virtual float BottomLightOffDelay get => _bottomLightOffDelay; set { - RaiseAndSet(ref _bottomLightOffDelay, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomLightOffDelay, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LightOffDelayRepresentation)); } } @@ -2533,7 +2531,7 @@ public virtual float LightOffDelay get => _lightOffDelay; set { - RaiseAndSet(ref _lightOffDelay, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _lightOffDelay, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LightOffDelayRepresentation)); } } @@ -2546,7 +2544,7 @@ public virtual float BottomWaitTimeBeforeCure get => _bottomWaitTimeBeforeCure; set { - RaiseAndSet(ref _bottomWaitTimeBeforeCure, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomWaitTimeBeforeCure, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(WaitTimeRepresentation)); } } @@ -2560,7 +2558,7 @@ public virtual float WaitTimeBeforeCure get => _waitTimeBeforeCure; set { - RaiseAndSet(ref _waitTimeBeforeCure, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _waitTimeBeforeCure, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(WaitTimeRepresentation)); } } @@ -2573,7 +2571,7 @@ public virtual float BottomExposureTime get => _bottomExposureTime; set { - RaiseAndSet(ref _bottomExposureTime, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomExposureTime, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(ExposureRepresentation)); RaisePropertyChanged(nameof(TransitionLayersRepresentation)); } @@ -2587,7 +2585,7 @@ public virtual float ExposureTime get => _exposureTime; set { - RaiseAndSet(ref _exposureTime, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _exposureTime, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(ExposureRepresentation)); RaisePropertyChanged(nameof(TransitionLayersRepresentation)); } @@ -2601,7 +2599,7 @@ public virtual float BottomWaitTimeAfterCure get => _bottomWaitTimeAfterCure; set { - RaiseAndSet(ref _bottomWaitTimeAfterCure, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomWaitTimeAfterCure, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(WaitTimeRepresentation)); } } @@ -2614,7 +2612,7 @@ public virtual float WaitTimeAfterCure get => _waitTimeAfterCure; set { - RaiseAndSet(ref _waitTimeAfterCure, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _waitTimeAfterCure, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(WaitTimeRepresentation)); } } @@ -2625,10 +2623,10 @@ public virtual float WaitTimeAfterCure /// public float BottomLiftHeightTotal { - get => (float)Math.Round(BottomLiftHeight + BottomLiftHeight2, 2); + get => MathF.Round(BottomLiftHeight + BottomLiftHeight2, 2); set { - BottomLiftHeight = (float)Math.Round(Math.Max(0, value), 2); + BottomLiftHeight = MathF.Round(Math.Max(0, value), 2); BottomLiftHeight2 = 0; } } @@ -2639,10 +2637,10 @@ public float BottomLiftHeightTotal /// public float LiftHeightTotal { - get => (float)Math.Round(LiftHeight + LiftHeight2, 2); + get => MathF.Round(LiftHeight + LiftHeight2, 2); set { - LiftHeight = (float)Math.Round(Math.Max(0, value), 2); + LiftHeight = MathF.Round(Math.Max(0, value), 2); LiftHeight2 = 0; } } @@ -2655,7 +2653,7 @@ public virtual float BottomLiftHeight get => _bottomLiftHeight; set { - RaiseAndSet(ref _bottomLiftHeight, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomLiftHeight, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(BottomLiftHeightTotal)); RaisePropertyChanged(nameof(LiftRepresentation)); BottomRetractHeight2 = BottomRetractHeight2; // Sanitize @@ -2670,7 +2668,7 @@ public virtual float BottomLiftSpeed get => _bottomLiftSpeed; set { - RaiseAndSet(ref _bottomLiftSpeed, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomLiftSpeed, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftRepresentation)); } } @@ -2683,7 +2681,7 @@ public virtual float BottomLiftAcceleration get => _bottomLiftAcceleration; set { - RaiseAndSet(ref _bottomLiftAcceleration, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomLiftAcceleration, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftRepresentation)); } } @@ -2696,7 +2694,7 @@ public virtual float LiftHeight get => _liftHeight; set { - RaiseAndSet(ref _liftHeight, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _liftHeight, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftHeightTotal)); RaisePropertyChanged(nameof(LiftRepresentation)); RetractHeight2 = RetractHeight2; // Sanitize @@ -2711,7 +2709,7 @@ public virtual float LiftSpeed get => _liftSpeed; set { - RaiseAndSet(ref _liftSpeed, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _liftSpeed, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftRepresentation)); } } @@ -2724,7 +2722,7 @@ public virtual float LiftAcceleration get => _liftAcceleration; set { - RaiseAndSet(ref _liftAcceleration, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _liftAcceleration, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftRepresentation)); } } @@ -2737,7 +2735,7 @@ public virtual float BottomLiftHeight2 get => _bottomLiftHeight2; set { - RaiseAndSet(ref _bottomLiftHeight2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomLiftHeight2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(BottomLiftHeightTotal)); RaisePropertyChanged(nameof(LiftRepresentation)); BottomRetractHeight2 = BottomRetractHeight2; // Sanitize @@ -2752,7 +2750,7 @@ public virtual float BottomLiftSpeed2 get => _bottomLiftSpeed2; set { - RaiseAndSet(ref _bottomLiftSpeed2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomLiftSpeed2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftRepresentation)); } } @@ -2765,7 +2763,7 @@ public virtual float BottomLiftAcceleration2 get => _bottomLiftAcceleration2; set { - RaiseAndSet(ref _bottomLiftAcceleration2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomLiftAcceleration2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftRepresentation)); } } @@ -2778,7 +2776,7 @@ public virtual float LiftHeight2 get => _liftHeight2; set { - RaiseAndSet(ref _liftHeight2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _liftHeight2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftHeightTotal)); RaisePropertyChanged(nameof(LiftRepresentation)); RetractHeight2 = RetractHeight2; // Sanitize @@ -2794,7 +2792,7 @@ public virtual float LiftSpeed2 get => _liftSpeed2; set { - RaiseAndSet(ref _liftSpeed2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _liftSpeed2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftRepresentation)); } } @@ -2807,7 +2805,7 @@ public virtual float LiftAcceleration2 get => _liftAcceleration2; set { - RaiseAndSet(ref _liftAcceleration2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _liftAcceleration2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(LiftRepresentation)); } } @@ -2820,7 +2818,7 @@ public virtual float BottomWaitTimeAfterLift get => _bottomWaitTimeAfterLift; set { - RaiseAndSet(ref _bottomWaitTimeAfterLift, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomWaitTimeAfterLift, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(WaitTimeRepresentation)); } } @@ -2833,7 +2831,7 @@ public virtual float WaitTimeAfterLift get => _waitTimeAfterLift; set { - RaiseAndSet(ref _waitTimeAfterLift, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _waitTimeAfterLift, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(WaitTimeRepresentation)); } } @@ -2851,7 +2849,7 @@ public virtual float WaitTimeAfterLift /// /// Gets the bottom retract height in mm /// - public float BottomRetractHeight => (float)Math.Round(BottomLiftHeightTotal - BottomRetractHeight2, 2); + public float BottomRetractHeight => MathF.Round(BottomLiftHeightTotal - BottomRetractHeight2, 2); /// /// Gets or sets the speed in mm/min for the bottom retracts @@ -2861,7 +2859,7 @@ public virtual float BottomRetractSpeed get => _bottomRetractSpeed; set { - RaiseAndSet(ref _bottomRetractSpeed, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomRetractSpeed, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(RetractRepresentation)); } } @@ -2874,7 +2872,7 @@ public virtual float BottomRetractAcceleration get => _bottomRetractAcceleration; set { - RaiseAndSet(ref _bottomRetractAcceleration, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomRetractAcceleration, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(RetractRepresentation)); } } @@ -2882,7 +2880,7 @@ public virtual float BottomRetractAcceleration /// /// Gets the retract height in mm /// - public float RetractHeight => (float)Math.Round(LiftHeightTotal - RetractHeight2, 2); + public float RetractHeight => MathF.Round(LiftHeightTotal - RetractHeight2, 2); /// /// Gets the speed in mm/min for the retracts @@ -2892,7 +2890,7 @@ public virtual float RetractSpeed get => _retractSpeed; set { - RaiseAndSet(ref _retractSpeed, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _retractSpeed, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(RetractRepresentation)); } } @@ -2905,7 +2903,7 @@ public virtual float RetractAcceleration get => _retractAcceleration; set { - RaiseAndSet(ref _retractAcceleration, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _retractAcceleration, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(RetractRepresentation)); } } @@ -2918,7 +2916,7 @@ public virtual float BottomRetractHeight2 get => _bottomRetractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, BottomRetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, BottomRetractHeightTotal); RaiseAndSet(ref _bottomRetractHeight2, value); RaisePropertyChanged(nameof(BottomRetractHeight)); RaisePropertyChanged(nameof(BottomRetractHeightTotal)); @@ -2934,7 +2932,7 @@ public virtual float BottomRetractSpeed2 get => _bottomRetractSpeed2; set { - RaiseAndSet(ref _bottomRetractSpeed2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomRetractSpeed2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(RetractRepresentation)); } } @@ -2947,7 +2945,7 @@ public virtual float BottomRetractAcceleration2 get => _bottomRetractAcceleration2; set { - RaiseAndSet(ref _bottomRetractAcceleration2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _bottomRetractAcceleration2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(RetractRepresentation)); } } @@ -2960,7 +2958,7 @@ public virtual float RetractHeight2 get => _retractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, RetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, RetractHeightTotal); RaiseAndSet(ref _retractHeight2, value); RaisePropertyChanged(nameof(RetractHeight)); RaisePropertyChanged(nameof(RetractHeightTotal)); @@ -2976,7 +2974,7 @@ public virtual float RetractSpeed2 get => _retractSpeed2; set { - RaiseAndSet(ref _retractSpeed2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _retractSpeed2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(RetractRepresentation)); } } @@ -2989,7 +2987,7 @@ public virtual float RetractAcceleration2 get => _retractAcceleration2; set { - RaiseAndSet(ref _retractAcceleration2, (float)Math.Round(Math.Max(0, value), 2)); + RaiseAndSet(ref _retractAcceleration2, MathF.Round(Math.Max(0, value), 2)); RaisePropertyChanged(nameof(RetractRepresentation)); } } @@ -3561,14 +3559,14 @@ public float PrintTimeComputed } } - return (float) Math.Round(time, 2); + return MathF.Round(time, 2); } } /// /// Gets the estimate print time in hours /// - public float PrintTimeHours => (float) Math.Round(PrintTime / 3600, 2); + public float PrintTimeHours => MathF.Round(PrintTime / 3600, 2); /// /// Gets the estimate print time in hours and minutes formatted @@ -3585,7 +3583,7 @@ public string PrintTimeString /// /// Gets the total time in seconds the display will remain on exposing the layers during the print /// - public float DisplayTotalOnTime => (float)Math.Round(this.Where(layer => layer is not null).Sum(layer => layer.ExposureTime), 2); + public float DisplayTotalOnTime => MathF.Round(this.Where(layer => layer is not null).Sum(layer => layer.ExposureTime), 2); /// /// Gets the total time formatted in hours, minutes and seconds the display will remain on exposing the layers during the print @@ -3602,7 +3600,7 @@ public float DisplayTotalOffTime { var printTime = PrintTime; if (float.IsPositiveInfinity(printTime) || float.IsNaN(printTime)) return float.NaN; - var value = (float) Math.Round(PrintTime - DisplayTotalOnTime, 2); + var value = MathF.Round(PrintTime - DisplayTotalOnTime, 2); return value <= 0 ? float.NaN : value; } } @@ -3634,11 +3632,11 @@ public virtual float MaterialMilliliters { { if (value <= 0) // Recalculate { - value = (float)Math.Round(this.Where(layer => layer is not null).Sum(layer => layer.MaterialMilliliters), 3); + value = MathF.Round(this.Where(layer => layer is not null).Sum(layer => layer.MaterialMilliliters), 3); } else // Set from value { - value = (float)Math.Round(value, 3); + value = MathF.Round(value, 3); } if(!RaiseAndSetIfChanged(ref _materialMilliliters, value)) return; @@ -3666,7 +3664,7 @@ public virtual float MaterialMilliliters { public virtual float MaterialGrams { get => _materialGrams; - set => RaiseAndSetIfChanged(ref _materialGrams, (float)Math.Round(value, 3)); + set => RaiseAndSetIfChanged(ref _materialGrams, MathF.Round(value, 3)); } /// @@ -3680,7 +3678,7 @@ public virtual float MaterialGrams public virtual float MaterialCost { get => _materialCost; - set => RaiseAndSetIfChanged(ref _materialCost, (float)Math.Round(value, 3)); + set => RaiseAndSetIfChanged(ref _materialCost, MathF.Round(value, 3)); } /// @@ -3688,7 +3686,7 @@ public virtual float MaterialCost /// public float MaterialMilliliterCost => StartingMaterialMilliliters > 0 ? StartingMaterialCost / StartingMaterialMilliliters : 0; - public float GetMaterialCostPer(float milliliters, byte roundDigits = 3) => (float)Math.Round(MaterialMilliliterCost * milliliters, roundDigits); + public float GetMaterialCostPer(float milliliters, byte roundDigits = 3) => MathF.Round(MaterialMilliliterCost * milliliters, roundDigits); /// /// Gets the material name @@ -5241,7 +5239,7 @@ public float ParseTransitionStepTimeFromLayers() var transitionLayerCount = ParseTransitionLayerCountFromLayers(); return transitionLayerCount == 0 ? 0 - : (float)Math.Round(this[BottomLayerCount].ExposureTime - this[BottomLayerCount + 1].ExposureTime, 2, MidpointRounding.AwayFromZero); + : MathF.Round(this[BottomLayerCount].ExposureTime - this[BottomLayerCount + 1].ExposureTime, 2, MidpointRounding.AwayFromZero); } /// @@ -5255,7 +5253,7 @@ public static float GetTransitionStepTime(float longExposureTime, float shortExp { return transitionLayerCount == 0 || longExposureTime == shortExposureTime ? 0 - : (float)Math.Round((longExposureTime - shortExposureTime) / (transitionLayerCount + 1), 2, MidpointRounding.AwayFromZero); + : MathF.Round((longExposureTime - shortExposureTime) / (transitionLayerCount + 1), 2, MidpointRounding.AwayFromZero); } /// @@ -6090,7 +6088,7 @@ public float CalculateMotorMovementTime(LayerGroup layerGroup, float extraTime = public float CalculateLightOffDelay(LayerGroup layerGroup, float extraTime = 0) { - extraTime = (float)Math.Round(extraTime, 2); + extraTime = MathF.Round(extraTime, 2); if (SupportGCode) return extraTime; return CalculateMotorMovementTime(layerGroup, extraTime); } @@ -6809,7 +6807,7 @@ public float MillimetersToPixelsF(float millimeters, uint fallbackToPixels = 0) /// X position in pixels /// Decimal precision /// Display position in millimeters - public float PixelToDisplayPositionX(int x, byte precision = DisplayFloatPrecision) => (float)Math.Round(PixelWidth * x, precision); + public float PixelToDisplayPositionX(int x, byte precision = DisplayFloatPrecision) => MathF.Round(PixelWidth * x, precision); /// /// From a pixel position get the equivalent position on the display @@ -6817,7 +6815,7 @@ public float MillimetersToPixelsF(float millimeters, uint fallbackToPixels = 0) /// Y position in pixels /// Decimal precision /// Display position in millimeters - public float PixelToDisplayPositionY(int y, byte precision = DisplayFloatPrecision) => (float)Math.Round(PixelHeight * y, precision); + public float PixelToDisplayPositionY(int y, byte precision = DisplayFloatPrecision) => MathF.Round(PixelHeight * y, precision); /// /// From a pixel position get the equivalent position on the display @@ -7798,13 +7796,13 @@ is PixelOperation.PixelOperationType.Supports var drawnDrainHoleLayers = 0; for (int operationLayer = (int)layerOperationGroup.Key - 1; operationLayer >= 0 && toProcess.Count > 0; operationLayer--) { - progress.PauseOrCancelIfRequested(); var layer = this[operationLayer]; var mat = matCache.Get1((uint) operationLayer); var isMatModified = false; for (var i = toProcess.Count-1; i >= 0; i--) { + progress.PauseOrCancelIfRequested(); var operation = toProcess[i]; if (operation.OperationType == PixelOperation.PixelOperationType.Supports) { diff --git a/UVtools.Core/FileFormats/FlashForgeSVGXFile.cs b/UVtools.Core/FileFormats/FlashForgeSVGXFile.cs index 47e8cff4..2868ae76 100644 --- a/UVtools.Core/FileFormats/FlashForgeSVGXFile.cs +++ b/UVtools.Core/FileFormats/FlashForgeSVGXFile.cs @@ -311,7 +311,7 @@ public override FlipDirection DisplayMirror public override float MachineZ { get => SVGDocument.PrintParameters.MachineZ > 0 ? SVGDocument.PrintParameters.MachineZ : base.MachineZ; - set => base.MachineZ = SVGDocument.PrintParameters.MachineZ = (float)Math.Round(value, 2); + set => base.MachineZ = SVGDocument.PrintParameters.MachineZ = MathF.Round(value, 2); } public override float LayerHeight @@ -341,38 +341,38 @@ public override ushort BottomLayerCount public override float BottomExposureTime { get => SVGDocument.PrintParameters.ProjectionTime.BottomExposureTime; - set => base.BottomExposureTime = SVGDocument.PrintParameters.ProjectionTime.BottomExposureTime = (float)Math.Round(value, 2); + set => base.BottomExposureTime = SVGDocument.PrintParameters.ProjectionTime.BottomExposureTime = MathF.Round(value, 2); } public override float ExposureTime { get => SVGDocument.PrintParameters.ProjectionTime.ExposureTime; - set => base.ExposureTime = SVGDocument.PrintParameters.ProjectionTime.ExposureTime = (float)Math.Round(value, 2); + set => base.ExposureTime = SVGDocument.PrintParameters.ProjectionTime.ExposureTime = MathF.Round(value, 2); } /*public override float BottomLiftHeight { get => HeaderSettings.BottomLiftHeight; - set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = MathF.Round(value, 2); } public override float LiftHeight { get => HeaderSettings.LiftHeight; - set => base.LiftHeight = HeaderSettings.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = HeaderSettings.LiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => HeaderSettings.BottomLiftSpeed; - set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftSpeed { get => HeaderSettings.LiftSpeed; - set => base.LiftSpeed = HeaderSettings.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = HeaderSettings.LiftSpeed = MathF.Round(value, 2); } public override float BottomRetractSpeed => RetractSpeed; @@ -380,7 +380,7 @@ public override float LiftSpeed public override float RetractSpeed { get => HeaderSettings.RetractSpeed; - set => base.RetractSpeed = HeaderSettings.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = HeaderSettings.RetractSpeed = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -519,8 +519,8 @@ protected override void EncodeInternally(OperationProgress progress) path.Append(' '); } - var mmX = (float)Math.Round(contours[i][0].X / ppmm.Width - halfDisplay.Width, 3); - var mmY = (float)Math.Round(contours[i][0].Y / ppmm.Height - halfDisplay.Height, 3); + var mmX = MathF.Round(contours[i][0].X / ppmm.Width - halfDisplay.Width, 3); + var mmY = MathF.Round(contours[i][0].Y / ppmm.Height - halfDisplay.Height, 3); minx = Math.Min(minx, mmX); miny = Math.Min(miny, mmY); @@ -530,8 +530,8 @@ protected override void EncodeInternally(OperationProgress progress) path.Append($"M {mmX} {mmY} L"); for (int x = 1; x < contours[i].Size; x++) { - mmX = (float)Math.Round(contours[i][x].X / ppmm.Width - halfDisplay.Width, 3); - mmY = (float)Math.Round(contours[i][x].Y / ppmm.Height - halfDisplay.Height, 3); + mmX = MathF.Round(contours[i][x].X / ppmm.Width - halfDisplay.Width, 3); + mmY = MathF.Round(contours[i][x].Y / ppmm.Height - halfDisplay.Height, 3); path.Append($" {mmX} {mmY}"); minx = Math.Min(minx, mmX); diff --git a/UVtools.Core/FileFormats/GR1File.cs b/UVtools.Core/FileFormats/GR1File.cs index 108b26d1..2a0cd1e6 100644 --- a/UVtools.Core/FileFormats/GR1File.cs +++ b/UVtools.Core/FileFormats/GR1File.cs @@ -191,10 +191,10 @@ public override uint ResolutionY public override float DisplayWidth { - get => (float)Math.Round(float.Parse(SlicerInfoSettings.DisplayWidth, CultureInfo.InvariantCulture), 2); + get => MathF.Round(float.Parse(SlicerInfoSettings.DisplayWidth, CultureInfo.InvariantCulture), 2); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); SlicerInfoSettings.DisplayWidth = value.ToString(CultureInfo.InvariantCulture); base.DisplayWidth = value; } @@ -202,10 +202,10 @@ public override float DisplayWidth public override float DisplayHeight { - get => (float)Math.Round(float.Parse(SlicerInfoSettings.DisplayHeight, CultureInfo.InvariantCulture), 3); + get => MathF.Round(float.Parse(SlicerInfoSettings.DisplayHeight, CultureInfo.InvariantCulture), 3); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); SlicerInfoSettings.DisplayHeight = value.ToString(CultureInfo.InvariantCulture); base.DisplayHeight = value; } diff --git a/UVtools.Core/FileFormats/GooFile.cs b/UVtools.Core/FileFormats/GooFile.cs index 7a67909c..e341b100 100644 --- a/UVtools.Core/FileFormats/GooFile.cs +++ b/UVtools.Core/FileFormats/GooFile.cs @@ -674,7 +674,7 @@ public override float DisplayHeight public override float MachineZ { get => Header.MachineZ > 0 ? Header.MachineZ : base.MachineZ; - set => base.MachineZ = Header.MachineZ = (float)Math.Round(value, 2); + set => base.MachineZ = Header.MachineZ = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -746,7 +746,7 @@ public override float LightOffDelay get => Header.LightOffDelay; set { - base.LightOffDelay = Header.LightOffDelay = (float)Math.Round(value, 2); + base.LightOffDelay = Header.LightOffDelay = MathF.Round(value, 2); if (value > 0) { Header.DelayMode = DelayModes.LightOff; @@ -770,7 +770,7 @@ public override float WaitTimeBeforeCure get => Header.WaitTimeBeforeCure; set { - base.WaitTimeBeforeCure = Header.WaitTimeBeforeCure = Header.WaitTimeBeforeCure = (float)Math.Round(value, 2); + base.WaitTimeBeforeCure = Header.WaitTimeBeforeCure = Header.WaitTimeBeforeCure = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -783,7 +783,7 @@ public override float WaitTimeBeforeCure public override float BottomExposureTime { get => Header.BottomExposureTime; - set => base.BottomExposureTime = Header.BottomExposureTime = (float)Math.Round(value, 2); + set => base.BottomExposureTime = Header.BottomExposureTime = MathF.Round(value, 2); } public override float BottomWaitTimeAfterCure @@ -801,7 +801,7 @@ public override float WaitTimeAfterCure get => Header.WaitTimeAfterCure; set { - base.WaitTimeAfterCure = Header.WaitTimeAfterCure = (float)Math.Round(value, 2); + base.WaitTimeAfterCure = Header.WaitTimeAfterCure = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -814,55 +814,55 @@ public override float WaitTimeAfterCure public override float ExposureTime { get => Header.ExposureTime; - set => base.ExposureTime = Header.ExposureTime = (float)Math.Round(value, 2); + set => base.ExposureTime = Header.ExposureTime = MathF.Round(value, 2); } public override float BottomLiftHeight { get => Header.BottomLiftHeight; - set => base.BottomLiftHeight = Header.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = Header.BottomLiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => Header.BottomLiftSpeed; - set => base.BottomLiftSpeed = Header.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = Header.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftHeight { get => Header.LiftHeight; - set => base.LiftHeight = Header.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = Header.LiftHeight = MathF.Round(value, 2); } public override float LiftSpeed { get => Header.LiftSpeed; - set => base.LiftSpeed = Header.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = Header.LiftSpeed = MathF.Round(value, 2); } public override float BottomLiftHeight2 { get => Header.BottomLiftHeight2; - set => base.BottomLiftHeight2 = Header.BottomLiftHeight2 = (float)Math.Round(value, 2); + set => base.BottomLiftHeight2 = Header.BottomLiftHeight2 = MathF.Round(value, 2); } public override float BottomLiftSpeed2 { get => Header.BottomLiftSpeed2; - set => base.BottomLiftSpeed2 = Header.BottomLiftSpeed2 = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed2 = Header.BottomLiftSpeed2 = MathF.Round(value, 2); } public override float LiftHeight2 { get => Header.LiftHeight2; - set => base.LiftHeight2 = Header.LiftHeight2 = (float)Math.Round(value, 2); + set => base.LiftHeight2 = Header.LiftHeight2 = MathF.Round(value, 2); } public override float LiftSpeed2 { get => Header.LiftSpeed2; - set => base.LiftSpeed2 = Header.LiftSpeed2 = (float)Math.Round(value, 2); + set => base.LiftSpeed2 = Header.LiftSpeed2 = MathF.Round(value, 2); } public override float BottomWaitTimeAfterLift @@ -880,7 +880,7 @@ public override float WaitTimeAfterLift get => Header.WaitTimeAfterLift; set { - base.WaitTimeAfterLift = Header.WaitTimeAfterLift = Header.WaitTimeAfterLift = (float)Math.Round(value, 2); + base.WaitTimeAfterLift = Header.WaitTimeAfterLift = Header.WaitTimeAfterLift = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -893,13 +893,13 @@ public override float WaitTimeAfterLift public override float BottomRetractSpeed { get => Header.BottomRetractSpeed; - set => base.BottomRetractSpeed = Header.BottomRetractSpeed = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed = Header.BottomRetractSpeed = MathF.Round(value, 2); } public override float RetractSpeed { get => Header.RetractSpeed; - set => base.RetractSpeed = Header.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = Header.RetractSpeed = MathF.Round(value, 2); } public override float BottomRetractHeight2 @@ -907,7 +907,7 @@ public override float BottomRetractHeight2 get => Header.BottomRetractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, BottomRetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, BottomRetractHeightTotal); base.BottomRetractHeight2 = Header.BottomRetractHeight2 = value; Header.BottomRetractHeight = BottomRetractHeight; } @@ -916,7 +916,7 @@ public override float BottomRetractHeight2 public override float BottomRetractSpeed2 { get => Header.BottomRetractSpeed2; - set => base.BottomRetractSpeed2 = Header.BottomRetractSpeed2 = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed2 = Header.BottomRetractSpeed2 = MathF.Round(value, 2); } public override float RetractHeight2 @@ -924,7 +924,7 @@ public override float RetractHeight2 get => Header.RetractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, RetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, RetractHeightTotal); base.RetractHeight2 = Header.RetractHeight2 = value; Header.RetractHeight = RetractHeight; } @@ -933,7 +933,7 @@ public override float RetractHeight2 public override float RetractSpeed2 { get => Header.RetractSpeed2; - set => base.RetractSpeed2 = Header.RetractSpeed2 = (float)Math.Round(value, 2); + set => base.RetractSpeed2 = Header.RetractSpeed2 = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -967,13 +967,13 @@ public override string MachineName public override float MaterialGrams { get => Header.MaterialGrams; - set => base.MaterialGrams = Header.MaterialGrams = (float)Math.Round(value, 3); + set => base.MaterialGrams = Header.MaterialGrams = MathF.Round(value, 3); } public override float MaterialCost { - get => (float)Math.Round(Header.MaterialCost, 3); - set => base.MaterialCost = Header.MaterialCost = (float)Math.Round(value, 3); + get => MathF.Round(Header.MaterialCost, 3); + set => base.MaterialCost = Header.MaterialCost = MathF.Round(value, 3); } public override object[] Configs => new object[] { Header, Footer }; diff --git a/UVtools.Core/FileFormats/JXSFile.cs b/UVtools.Core/FileFormats/JXSFile.cs index fa0c7abc..7911024a 100644 --- a/UVtools.Core/FileFormats/JXSFile.cs +++ b/UVtools.Core/FileFormats/JXSFile.cs @@ -241,25 +241,25 @@ public override float ExposureTime public override float BottomLiftHeight { get => ConfigFile.LiftHeight1; - set => base.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = MathF.Round(value, 2); } public override float LiftHeight { get => ConfigFile.LiftHeight1; - set => base.LiftHeight = ConfigFile.LiftHeight1 = (float)Math.Round(value, 2); + set => base.LiftHeight = ConfigFile.LiftHeight1 = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => ConfigFile.BottomLiftSpeed; - set => base.BottomLiftSpeed = ConfigFile.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = ConfigFile.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftSpeed { get => ConfigFile.LiftSpeed1; - set => base.LiftSpeed = ConfigFile.LiftSpeed1 = (float)Math.Round(value, 2); + set => base.LiftSpeed = ConfigFile.LiftSpeed1 = MathF.Round(value, 2); } public override float PrintTime diff --git a/UVtools.Core/FileFormats/KlipperFile.cs b/UVtools.Core/FileFormats/KlipperFile.cs index 55945daf..84f1ef77 100644 --- a/UVtools.Core/FileFormats/KlipperFile.cs +++ b/UVtools.Core/FileFormats/KlipperFile.cs @@ -208,7 +208,7 @@ public override float DisplayHeight public override float MachineZ { get => HeaderSettings.MachineZ > 0 ? HeaderSettings.MachineZ : base.MachineZ; - set => base.MachineZ = HeaderSettings.MachineZ = (float)Math.Round(value, 2); + set => base.MachineZ = HeaderSettings.MachineZ = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -275,181 +275,181 @@ public override float LightOffDelay public override float BottomWaitTimeBeforeCure { get => HeaderSettings.BottomWaitTimeBeforeCure; - set => base.BottomWaitTimeBeforeCure = HeaderSettings.BottomWaitTimeBeforeCure = (float)Math.Round(value, 2); + set => base.BottomWaitTimeBeforeCure = HeaderSettings.BottomWaitTimeBeforeCure = MathF.Round(value, 2); } public override float WaitTimeBeforeCure { get => HeaderSettings.WaitTimeBeforeCure; - set => base.WaitTimeBeforeCure = HeaderSettings.WaitTimeBeforeCure = (float)Math.Round(value, 2); + set => base.WaitTimeBeforeCure = HeaderSettings.WaitTimeBeforeCure = MathF.Round(value, 2); } public override float BottomExposureTime { get => HeaderSettings.BottomExposureTime; - set => base.BottomExposureTime = HeaderSettings.BottomExposureTime = (float)Math.Round(value, 2); + set => base.BottomExposureTime = HeaderSettings.BottomExposureTime = MathF.Round(value, 2); } public override float ExposureTime { get => HeaderSettings.ExposureTime; - set => base.ExposureTime = HeaderSettings.ExposureTime = (float)Math.Round(value, 2); + set => base.ExposureTime = HeaderSettings.ExposureTime = MathF.Round(value, 2); } public override float BottomWaitTimeAfterCure { get => HeaderSettings.BottomWaitTimeAfterCure; - set => base.BottomWaitTimeAfterCure = HeaderSettings.BottomWaitTimeAfterCure = (float)Math.Round(value, 2); + set => base.BottomWaitTimeAfterCure = HeaderSettings.BottomWaitTimeAfterCure = MathF.Round(value, 2); } public override float WaitTimeAfterCure { get => HeaderSettings.WaitTimeAfterCure; - set => base.WaitTimeAfterCure = HeaderSettings.WaitTimeAfterCure = (float)Math.Round(value, 2); + set => base.WaitTimeAfterCure = HeaderSettings.WaitTimeAfterCure = MathF.Round(value, 2); } public override float BottomLiftHeight { get => HeaderSettings.BottomLiftHeight; - set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => HeaderSettings.BottomLiftSpeed; - set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = MathF.Round(value, 2); } public override float BottomLiftAcceleration { get => HeaderSettings.BottomLiftAcceleration; - set => base.BottomLiftAcceleration = HeaderSettings.BottomLiftAcceleration = (float)Math.Round(Math.Max(0, value), 2); + set => base.BottomLiftAcceleration = HeaderSettings.BottomLiftAcceleration = MathF.Round(Math.Max(0, value), 2); } public override float BottomLiftHeight2 { get => HeaderSettings.BottomLiftHeight2; - set => base.BottomLiftHeight2 = HeaderSettings.BottomLiftHeight2 = (float)Math.Round(value, 2); + set => base.BottomLiftHeight2 = HeaderSettings.BottomLiftHeight2 = MathF.Round(value, 2); } public override float BottomLiftSpeed2 { get => HeaderSettings.BottomLiftSpeed2; - set => base.BottomLiftSpeed2 = HeaderSettings.BottomLiftSpeed2 = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed2 = HeaderSettings.BottomLiftSpeed2 = MathF.Round(value, 2); } public override float BottomLiftAcceleration2 { get => HeaderSettings.BottomLiftAcceleration2; - set => base.BottomLiftAcceleration2 = HeaderSettings.BottomLiftAcceleration2 = (float)Math.Round(Math.Max(0, value), 2); + set => base.BottomLiftAcceleration2 = HeaderSettings.BottomLiftAcceleration2 = MathF.Round(Math.Max(0, value), 2); } public override float LiftHeight { get => HeaderSettings.LiftHeight; - set => base.LiftHeight = HeaderSettings.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = HeaderSettings.LiftHeight = MathF.Round(value, 2); } public override float LiftSpeed { get => HeaderSettings.LiftSpeed; - set => base.LiftSpeed = HeaderSettings.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = HeaderSettings.LiftSpeed = MathF.Round(value, 2); } public override float LiftAcceleration { get => HeaderSettings.LiftAcceleration; - set => base.LiftAcceleration = HeaderSettings.LiftAcceleration = (float)Math.Round(Math.Max(0, value), 2); + set => base.LiftAcceleration = HeaderSettings.LiftAcceleration = MathF.Round(Math.Max(0, value), 2); } public override float LiftHeight2 { get => HeaderSettings.LiftHeight2; - set => base.LiftHeight2 = HeaderSettings.LiftHeight2 = (float)Math.Round(value, 2); + set => base.LiftHeight2 = HeaderSettings.LiftHeight2 = MathF.Round(value, 2); } public override float LiftSpeed2 { get => HeaderSettings.LiftSpeed2; - set => base.LiftSpeed2 = HeaderSettings.LiftSpeed2 = (float)Math.Round(value, 2); + set => base.LiftSpeed2 = HeaderSettings.LiftSpeed2 = MathF.Round(value, 2); } public override float LiftAcceleration2 { get => HeaderSettings.LiftAcceleration2; - set => base.LiftAcceleration2 = HeaderSettings.LiftAcceleration2 = (float)Math.Round(Math.Max(0, value), 2); + set => base.LiftAcceleration2 = HeaderSettings.LiftAcceleration2 = MathF.Round(Math.Max(0, value), 2); } public override float BottomWaitTimeAfterLift { get => HeaderSettings.BottomWaitTimeAfterLift; - set => base.BottomWaitTimeAfterLift = HeaderSettings.BottomWaitTimeAfterLift = (float)Math.Round(value, 2); + set => base.BottomWaitTimeAfterLift = HeaderSettings.BottomWaitTimeAfterLift = MathF.Round(value, 2); } public override float WaitTimeAfterLift { get => HeaderSettings.WaitTimeAfterLift; - set => base.WaitTimeAfterLift = HeaderSettings.WaitTimeAfterLift = (float)Math.Round(value, 2); + set => base.WaitTimeAfterLift = HeaderSettings.WaitTimeAfterLift = MathF.Round(value, 2); } public override float BottomRetractSpeed { get => HeaderSettings.BottomRetractSpeed; - set => base.BottomRetractSpeed = HeaderSettings.BottomRetractSpeed = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed = HeaderSettings.BottomRetractSpeed = MathF.Round(value, 2); } public override float BottomRetractAcceleration { get => HeaderSettings.BottomRetractAcceleration; - set => base.BottomRetractAcceleration = HeaderSettings.BottomRetractAcceleration = (float)Math.Round(Math.Max(0, value), 2); + set => base.BottomRetractAcceleration = HeaderSettings.BottomRetractAcceleration = MathF.Round(Math.Max(0, value), 2); } public override float BottomRetractHeight2 { get => HeaderSettings.BottomRetractHeight2; - set => base.BottomRetractHeight2 = HeaderSettings.BottomRetractHeight2 = (float)Math.Round(value, 2); + set => base.BottomRetractHeight2 = HeaderSettings.BottomRetractHeight2 = MathF.Round(value, 2); } public override float BottomRetractSpeed2 { get => HeaderSettings.BottomRetractSpeed2; - set => base.BottomRetractSpeed2 = HeaderSettings.BottomRetractSpeed2 = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed2 = HeaderSettings.BottomRetractSpeed2 = MathF.Round(value, 2); } public override float BottomRetractAcceleration2 { get => HeaderSettings.BottomRetractAcceleration2; - set => base.BottomRetractAcceleration2 = HeaderSettings.BottomRetractAcceleration2 = (float)Math.Round(Math.Max(0, value), 2); + set => base.BottomRetractAcceleration2 = HeaderSettings.BottomRetractAcceleration2 = MathF.Round(Math.Max(0, value), 2); } public override float RetractSpeed { get => HeaderSettings.RetractSpeed; - set => base.RetractSpeed = HeaderSettings.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = HeaderSettings.RetractSpeed = MathF.Round(value, 2); } public override float RetractAcceleration { get => HeaderSettings.RetractAcceleration; - set => base.RetractAcceleration = HeaderSettings.RetractAcceleration = (float)Math.Round(Math.Max(0, value), 2); + set => base.RetractAcceleration = HeaderSettings.RetractAcceleration = MathF.Round(Math.Max(0, value), 2); } public override float RetractHeight2 { get => HeaderSettings.RetractHeight2; - set => base.RetractHeight2 = HeaderSettings.RetractHeight2 = (float)Math.Round(value, 2); + set => base.RetractHeight2 = HeaderSettings.RetractHeight2 = MathF.Round(value, 2); } public override float RetractSpeed2 { get => HeaderSettings.RetractSpeed2; - set => base.RetractSpeed2 = HeaderSettings.RetractSpeed2 = (float)Math.Round(value, 2); + set => base.RetractSpeed2 = HeaderSettings.RetractSpeed2 = MathF.Round(value, 2); } public override float RetractAcceleration2 { get => HeaderSettings.RetractAcceleration2; - set => base.RetractAcceleration2 = HeaderSettings.RetractAcceleration2 = (float)Math.Round(Math.Max(0, value), 2); + set => base.RetractAcceleration2 = HeaderSettings.RetractAcceleration2 = MathF.Round(Math.Max(0, value), 2); } public override byte BottomLightPWM @@ -476,14 +476,14 @@ public override float PrintTime public override float MaterialGrams { - get => (float) Math.Round(HeaderSettings.MaterialGrams, 3); - set => base.MaterialGrams = HeaderSettings.MaterialGrams = (float)Math.Round(value, 3); + get => MathF.Round(HeaderSettings.MaterialGrams, 3); + set => base.MaterialGrams = HeaderSettings.MaterialGrams = MathF.Round(value, 3); } public override float MaterialCost { - get => (float) Math.Round(HeaderSettings.Price, 3); - set => base.MaterialCost = HeaderSettings.Price = (float)Math.Round(value, 3); + get => MathF.Round(HeaderSettings.Price, 3); + set => base.MaterialCost = HeaderSettings.Price = MathF.Round(value, 3); } public override string? MaterialName diff --git a/UVtools.Core/FileFormats/LGSFile.cs b/UVtools.Core/FileFormats/LGSFile.cs index 9c36d598..806f75ce 100644 --- a/UVtools.Core/FileFormats/LGSFile.cs +++ b/UVtools.Core/FileFormats/LGSFile.cs @@ -314,7 +314,7 @@ public override uint ResolutionY public override float DisplayWidth { - get => (float) Math.Round(ResolutionX / HeaderSettings.PixelPerMmX, 3); + get => MathF.Round(ResolutionX / HeaderSettings.PixelPerMmX, 3); set { base.DisplayWidth = value; @@ -324,7 +324,7 @@ public override float DisplayWidth public override float DisplayHeight { - get => (float)Math.Round(ResolutionY / HeaderSettings.PixelPerMmY, 3); + get => MathF.Round(ResolutionY / HeaderSettings.PixelPerMmY, 3); set { base.DisplayHeight = value; @@ -335,7 +335,7 @@ public override float DisplayHeight public override float MachineZ { get => HeaderSettings.MachineZ > 0 ? HeaderSettings.MachineZ : base.MachineZ; - set => base.MachineZ = HeaderSettings.MachineZ = (float)Math.Round(value, 2); + set => base.MachineZ = HeaderSettings.MachineZ = MathF.Round(value, 2); } public override FlipDirection DisplayMirror diff --git a/UVtools.Core/FileFormats/MDLPFile.cs b/UVtools.Core/FileFormats/MDLPFile.cs index fe961060..ea70a33a 100644 --- a/UVtools.Core/FileFormats/MDLPFile.cs +++ b/UVtools.Core/FileFormats/MDLPFile.cs @@ -196,10 +196,10 @@ public override uint ResolutionY public override float DisplayWidth { - get => (float)Math.Round(float.Parse(SlicerInfoSettings.DisplayWidth, CultureInfo.InvariantCulture), 2); + get => MathF.Round(float.Parse(SlicerInfoSettings.DisplayWidth, CultureInfo.InvariantCulture), 2); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); SlicerInfoSettings.DisplayWidth = value.ToString(CultureInfo.InvariantCulture); base.DisplayWidth = value; } @@ -207,10 +207,10 @@ public override float DisplayWidth public override float DisplayHeight { - get => (float)Math.Round(float.Parse(SlicerInfoSettings.DisplayHeight, CultureInfo.InvariantCulture), 3); + get => MathF.Round(float.Parse(SlicerInfoSettings.DisplayHeight, CultureInfo.InvariantCulture), 3); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); SlicerInfoSettings.DisplayHeight = value.ToString(CultureInfo.InvariantCulture); base.DisplayHeight = value; } diff --git a/UVtools.Core/FileFormats/NanoDLPFile.cs b/UVtools.Core/FileFormats/NanoDLPFile.cs index 0aa2ff12..eaad4c63 100644 --- a/UVtools.Core/FileFormats/NanoDLPFile.cs +++ b/UVtools.Core/FileFormats/NanoDLPFile.cs @@ -535,7 +535,7 @@ public override float DisplayWidth set { base.DisplayWidth = RoundDisplaySize(value); - SlicerManifest.XPixelSize = value > 0 && ResolutionX > 0 ? (float)Math.Round(value / ResolutionX, 4) : 0; + SlicerManifest.XPixelSize = value > 0 && ResolutionX > 0 ? MathF.Round(value / ResolutionX, 4) : 0; } } @@ -545,7 +545,7 @@ public override float DisplayHeight set { base.DisplayHeight = RoundDisplaySize(value); - SlicerManifest.YPixelSize = value > 0 && ResolutionY > 0 ? (float)Math.Round(value / ResolutionY, 4) : 0; + SlicerManifest.YPixelSize = value > 0 && ResolutionY > 0 ? MathF.Round(value / ResolutionY, 4) : 0; } } @@ -640,11 +640,11 @@ public override float BottomWaitTimeBeforeCure { if (OverrideManifest is not null) { - base.BottomWaitTimeBeforeCure = OverrideManifest.SupportWaitBeforePrint = (float)Math.Round(value, 2); + base.BottomWaitTimeBeforeCure = OverrideManifest.SupportWaitBeforePrint = MathF.Round(value, 2); } else { - base.BottomWaitTimeBeforeCure = ProfileManifest.SupportWaitBeforePrint = (float)Math.Round(value, 2); + base.BottomWaitTimeBeforeCure = ProfileManifest.SupportWaitBeforePrint = MathF.Round(value, 2); } } } @@ -656,11 +656,11 @@ public override float WaitTimeBeforeCure { if (OverrideManifest is not null) { - base.WaitTimeBeforeCure = OverrideManifest.WaitBeforePrint = (float)Math.Round(value, 2); + base.WaitTimeBeforeCure = OverrideManifest.WaitBeforePrint = MathF.Round(value, 2); } else { - base.WaitTimeBeforeCure = ProfileManifest.WaitBeforePrint = (float)Math.Round(value, 2); + base.WaitTimeBeforeCure = ProfileManifest.WaitBeforePrint = MathF.Round(value, 2); } } } @@ -672,11 +672,11 @@ public override float BottomExposureTime { if (OverrideManifest is not null) { - base.BottomExposureTime = OverrideManifest.SupportCureTime = (float)Math.Round(value, 2); + base.BottomExposureTime = OverrideManifest.SupportCureTime = MathF.Round(value, 2); } else { - base.BottomExposureTime = ProfileManifest.SupportCureTime = (float)Math.Round(value, 2); + base.BottomExposureTime = ProfileManifest.SupportCureTime = MathF.Round(value, 2); } } } @@ -688,11 +688,11 @@ public override float BottomWaitTimeAfterCure { if (OverrideManifest is not null) { - base.BottomWaitTimeAfterCure = OverrideManifest.SupportWaitAfterPrint = (float)Math.Round(value, 2); + base.BottomWaitTimeAfterCure = OverrideManifest.SupportWaitAfterPrint = MathF.Round(value, 2); } else { - base.BottomWaitTimeAfterCure = ProfileManifest.SupportWaitAfterPrint = (float)Math.Round(value, 2); + base.BottomWaitTimeAfterCure = ProfileManifest.SupportWaitAfterPrint = MathF.Round(value, 2); } } } @@ -704,11 +704,11 @@ public override float WaitTimeAfterCure { if (OverrideManifest is not null) { - base.WaitTimeAfterCure = OverrideManifest.WaitAfterPrint = (float)Math.Round(value, 2); + base.WaitTimeAfterCure = OverrideManifest.WaitAfterPrint = MathF.Round(value, 2); } else { - base.WaitTimeAfterCure = ProfileManifest.WaitAfterPrint = (float)Math.Round(value, 2); + base.WaitTimeAfterCure = ProfileManifest.WaitAfterPrint = MathF.Round(value, 2); } } } @@ -720,11 +720,11 @@ public override float ExposureTime { if (OverrideManifest is not null) { - base.ExposureTime = OverrideManifest.CureTime = (float)Math.Round(value, 2); + base.ExposureTime = OverrideManifest.CureTime = MathF.Round(value, 2); } else { - base.ExposureTime = ProfileManifest.CureTime = (float)Math.Round(value, 2); + base.ExposureTime = ProfileManifest.CureTime = MathF.Round(value, 2); } } } @@ -736,11 +736,11 @@ public override float BottomLiftHeight { if (OverrideManifest is not null) { - base.BottomLiftHeight = OverrideManifest.SupportWaitHeight = (float)Math.Round(value, 2); + base.BottomLiftHeight = OverrideManifest.SupportWaitHeight = MathF.Round(value, 2); } else { - base.BottomLiftHeight = ProfileManifest.SupportWaitHeight = (float)Math.Round(value, 2); + base.BottomLiftHeight = ProfileManifest.SupportWaitHeight = MathF.Round(value, 2); } } } @@ -752,11 +752,11 @@ public override float LiftHeight { if (OverrideManifest is not null) { - base.LiftHeight = OverrideManifest.WaitHeight = (float)Math.Round(value, 2); + base.LiftHeight = OverrideManifest.WaitHeight = MathF.Round(value, 2); } else { - base.LiftHeight = ProfileManifest.WaitHeight = (float)Math.Round(value, 2); + base.LiftHeight = ProfileManifest.WaitHeight = MathF.Round(value, 2); } } } @@ -768,11 +768,11 @@ public override float BottomWaitTimeAfterLift { if (OverrideManifest is not null) { - base.BottomWaitTimeAfterLift = OverrideManifest.SupportTopWait = (float)Math.Round(value, 2); + base.BottomWaitTimeAfterLift = OverrideManifest.SupportTopWait = MathF.Round(value, 2); } else { - base.BottomWaitTimeAfterLift = ProfileManifest.SupportTopWait = (float)Math.Round(value, 2); + base.BottomWaitTimeAfterLift = ProfileManifest.SupportTopWait = MathF.Round(value, 2); } } } @@ -784,11 +784,11 @@ public override float WaitTimeAfterLift { if (OverrideManifest is not null) { - base.WaitTimeAfterLift = OverrideManifest.TopWait = (float)Math.Round(value, 2); + base.WaitTimeAfterLift = OverrideManifest.TopWait = MathF.Round(value, 2); } else { - base.WaitTimeAfterLift = ProfileManifest.TopWait = (float)Math.Round(value, 2); + base.WaitTimeAfterLift = ProfileManifest.TopWait = MathF.Round(value, 2); } } } @@ -807,8 +807,8 @@ public override byte LightPWM { get { - if (OverrideManifest is not null && ProfileManifest.CustomValues.TryGetValue("UvPwmValue", out var pwmValueStr) && float.TryParse(pwmValueStr, out var pwmValue)) return (byte)Math.Round(pwmValue * byte.MaxValue, MidpointRounding.AwayFromZero); - if (ProfileManifest.CustomValues.TryGetValue("UvPwmValue", out var pwmValueStr2) && float.TryParse(pwmValueStr2, out var pwmValue2)) return (byte)Math.Round(pwmValue2 * byte.MaxValue, MidpointRounding.AwayFromZero); + if (OverrideManifest is not null && ProfileManifest.CustomValues.TryGetValue("UvPwmValue", out var pwmValueStr) && float.TryParse(pwmValueStr, CultureInfo.InvariantCulture, out var pwmValue)) return (byte)Math.Round(pwmValue * byte.MaxValue, MidpointRounding.AwayFromZero); + if (ProfileManifest.CustomValues.TryGetValue("UvPwmValue", out var pwmValueStr2) && float.TryParse(pwmValueStr2, CultureInfo.InvariantCulture, out var pwmValue2)) return (byte)Math.Round(pwmValue2 * byte.MaxValue, MidpointRounding.AwayFromZero); return base.LightPWM; } set @@ -898,10 +898,10 @@ protected override void OnBeforeEncode(bool isPartialEncode) var rect = BoundingRectangleMillimeters; rect.Offset(DisplayWidth / -2f, DisplayHeight / -2f); - SlicerManifest.Boundary.XMin = PlateManifest.XMin = (float)Math.Round(rect.X, 4); - SlicerManifest.Boundary.XMax = PlateManifest.XMax = (float)Math.Round(rect.Right, 4); - SlicerManifest.Boundary.YMin = PlateManifest.YMin = (float)Math.Round(rect.Y, 4); - SlicerManifest.Boundary.YMax = PlateManifest.YMax = (float)Math.Round(rect.Bottom, 4); + SlicerManifest.Boundary.XMin = PlateManifest.XMin = MathF.Round(rect.X, 4); + SlicerManifest.Boundary.XMax = PlateManifest.XMax = MathF.Round(rect.Right, 4); + SlicerManifest.Boundary.YMin = PlateManifest.YMin = MathF.Round(rect.Y, 4); + SlicerManifest.Boundary.YMax = PlateManifest.YMax = MathF.Round(rect.Bottom, 4); } var thumbnail = GetLargestThumbnail(); @@ -952,9 +952,9 @@ protected override void EncodeInternally(OperationProgress progress) if (pixelArea > 0) { var contours = layer.Contours; - item.TotalSolidArea = (float)Math.Round(contours.TotalSolidArea * pixelArea, 4); - item.SmallestArea = (float)Math.Round(contours.MinSolidArea * pixelArea, 4); - item.LargestArea = (float)Math.Round(contours.MaxSolidArea * pixelArea, 4); + item.TotalSolidArea = MathF.Round((float)contours.TotalSolidArea * pixelArea, 4, MidpointRounding.AwayFromZero); + item.SmallestArea = MathF.Round((float)contours.MinSolidArea * pixelArea, 4, MidpointRounding.AwayFromZero); + item.LargestArea = MathF.Round((float)contours.MaxSolidArea * pixelArea, 4, MidpointRounding.AwayFromZero); item.AreaCount = (uint)contours.ExternalContoursCount; } diff --git a/UVtools.Core/FileFormats/OSFFile.cs b/UVtools.Core/FileFormats/OSFFile.cs index 40b6acb1..bc30ada0 100644 --- a/UVtools.Core/FileFormats/OSFFile.cs +++ b/UVtools.Core/FileFormats/OSFFile.cs @@ -463,70 +463,70 @@ public override ushort TransitionLayerCount public override float BottomWaitTimeBeforeCure { - get => (float)Math.Round(Settings.BottomWaitTimeBeforeCureMagnified100Times / 100f, 2); + get => MathF.Round(Settings.BottomWaitTimeBeforeCureMagnified100Times / 100f, 2); set { Settings.BottomWaitTimeBeforeCureMagnified100Times = (ushort) (value * 100); - base.BottomWaitTimeBeforeCure = (float)Math.Round(value, 2); + base.BottomWaitTimeBeforeCure = MathF.Round(value, 2); } } public override float WaitTimeBeforeCure { - get => (float)Math.Round(Settings.WaitTimeBeforeCureMagnified100Times.Value / 100f, 2); + get => MathF.Round(Settings.WaitTimeBeforeCureMagnified100Times.Value / 100f, 2); set { Settings.WaitTimeBeforeCureMagnified100Times.Value = (uint)(value * 100); - base.WaitTimeBeforeCure = (float)Math.Round(value, 2); + base.WaitTimeBeforeCure = MathF.Round(value, 2); } } public override float BottomExposureTime { - get => (float)Math.Round(Settings.BottomExposureTimeMagnified100Times.Value / 100f, 2); + get => MathF.Round(Settings.BottomExposureTimeMagnified100Times.Value / 100f, 2); set { Settings.BottomExposureTimeMagnified100Times.Value = (uint)(value * 100); - base.BottomExposureTime = (float)Math.Round(value, 2); + base.BottomExposureTime = MathF.Round(value, 2); } } public override float ExposureTime { - get => (float)Math.Round(Settings.ExposureTimeMagnified100Times.Value / 100f, 2); + get => MathF.Round(Settings.ExposureTimeMagnified100Times.Value / 100f, 2); set { Settings.ExposureTimeMagnified100Times.Value = (uint)(value * 100); - base.ExposureTime = (float)Math.Round(value, 2); + base.ExposureTime = MathF.Round(value, 2); } } public override float BottomWaitTimeAfterCure { - get => (float)Math.Round(Settings.BottomWaitTimeAfterCureMagnified100Times / 100f, 2); + get => MathF.Round(Settings.BottomWaitTimeAfterCureMagnified100Times / 100f, 2); set { Settings.BottomWaitTimeAfterCureMagnified100Times = (ushort)(value * 100); - base.BottomWaitTimeAfterCure = (float)Math.Round(value, 2); + base.BottomWaitTimeAfterCure = MathF.Round(value, 2); } } public override float WaitTimeAfterCure { - get => (float)Math.Round(Settings.WaitTimeAfterCureMagnified100Times.Value / 100f, 2); + get => MathF.Round(Settings.WaitTimeAfterCureMagnified100Times.Value / 100f, 2); set { Settings.WaitTimeAfterCureMagnified100Times.Value = (uint)(value * 100); - base.WaitTimeAfterCure = (float)Math.Round(value, 2); + base.WaitTimeAfterCure = MathF.Round(value, 2); } } public override float BottomLiftHeight { - get => (float)Math.Round(Settings.BottomLiftHeightSlowMagnified1000Times.Value / 1000f, 2); + get => MathF.Round(Settings.BottomLiftHeightSlowMagnified1000Times.Value / 1000f, 2); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); Settings.BottomLiftHeightTotalMagnified1000Times.Value -= Settings.BottomLiftHeightSlowMagnified1000Times.Value; Settings.BottomLiftHeightSlowMagnified1000Times.Value = (uint)(value * 1000); Settings.BottomLiftHeightTotalMagnified1000Times.Value += Settings.BottomLiftHeightSlowMagnified1000Times.Value; @@ -536,10 +536,10 @@ public override float BottomLiftHeight public override float LiftHeight { - get => (float)Math.Round(Settings.LiftHeightSlowMagnified1000Times.Value / 1000f, 2); + get => MathF.Round(Settings.LiftHeightSlowMagnified1000Times.Value / 1000f, 2); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); Settings.LiftHeightTotalMagnified1000Times.Value -= Settings.LiftHeightSlowMagnified1000Times.Value; Settings.LiftHeightSlowMagnified1000Times.Value = (uint)(value * 1000); Settings.LiftHeightTotalMagnified1000Times.Value += Settings.LiftHeightSlowMagnified1000Times.Value; @@ -564,7 +564,7 @@ public override float BottomLiftHeight2 get => (float)Math.Max(0, Math.Round((Settings.BottomLiftHeightTotalMagnified1000Times - Settings.BottomLiftHeightSlowMagnified1000Times) / 1000f, 2)); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); Settings.BottomLiftHeightTotalMagnified1000Times.Value = Settings.BottomLiftHeightSlowMagnified1000Times.Value + (uint)(value * 1000); base.BottomLiftHeight2 = value; } @@ -581,7 +581,7 @@ public override float LiftHeight2 get => (float)Math.Max(0, Math.Round((Settings.LiftHeightTotalMagnified1000Times - Settings.LiftHeightSlowMagnified1000Times) / 1000f, 2)); set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); Settings.LiftHeightTotalMagnified1000Times.Value = Settings.LiftHeightSlowMagnified1000Times.Value + (uint)(value * 1000); base.LiftHeight2 = value; } @@ -594,21 +594,21 @@ public override float LiftSpeed2 } public override float BottomWaitTimeAfterLift { - get => (float)Math.Round(Settings.BottomWaitTimeAfterLiftMagnified100Times / 100f, 2); + get => MathF.Round(Settings.BottomWaitTimeAfterLiftMagnified100Times / 100f, 2); set { Settings.BottomWaitTimeAfterLiftMagnified100Times = (ushort)(value * 100); - base.BottomWaitTimeAfterLift = (float)Math.Round(value, 2); + base.BottomWaitTimeAfterLift = MathF.Round(value, 2); } } public override float WaitTimeAfterLift { - get => (float)Math.Round(Settings.WaitTimeAfterLiftMagnified100Times.Value / 100f, 2); + get => MathF.Round(Settings.WaitTimeAfterLiftMagnified100Times.Value / 100f, 2); set { Settings.WaitTimeAfterLiftMagnified100Times.Value = (uint)(value * 100); - base.WaitTimeAfterLift = (float)Math.Round(value, 2); + base.WaitTimeAfterLift = MathF.Round(value, 2); } } @@ -626,10 +626,10 @@ public override float RetractSpeed public override float BottomRetractHeight2 { - get => (float)Math.Round(Settings.BottomRetractHeightSlowMagnified1000Times.Value / 1000f, 2); + get => MathF.Round(Settings.BottomRetractHeightSlowMagnified1000Times.Value / 1000f, 2); set { - value = Math.Clamp((float)Math.Round(value, 2), 0, BottomRetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, BottomRetractHeightTotal); Settings.BottomRetractHeightSlowMagnified1000Times.Value = (uint)(value * 1000); Settings.BottomRetractHeightTotalMagnified1000Times.Value = (uint)(BottomRetractHeightTotal * 1000); base.BottomRetractHeight2 = value; @@ -644,10 +644,10 @@ public override float BottomRetractSpeed2 public override float RetractHeight2 { - get => (float)Math.Round(Settings.RetractHeightSlowMagnified1000Times.Value / 1000f, 2); + get => MathF.Round(Settings.RetractHeightSlowMagnified1000Times.Value / 1000f, 2); set { - value = Math.Clamp((float)Math.Round(value, 2), 0, RetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, RetractHeightTotal); Settings.RetractHeightSlowMagnified1000Times.Value = (uint)(value * 1000); Settings.RetractHeightTotalMagnified1000Times.Value = (uint)(RetractHeightTotal * 1000); base.RetractHeight2 = value; diff --git a/UVtools.Core/FileFormats/OSLAFile.cs b/UVtools.Core/FileFormats/OSLAFile.cs index 6e81b01b..c458cc3c 100644 --- a/UVtools.Core/FileFormats/OSLAFile.cs +++ b/UVtools.Core/FileFormats/OSLAFile.cs @@ -345,7 +345,7 @@ public override float MachineZ get => HeaderSettings.MachineZ > 0 ? HeaderSettings.MachineZ : base.MachineZ; set { - HeaderSettings.MachineZ = (float)Math.Round(value, 2); + HeaderSettings.MachineZ = MathF.Round(value, 2); RaisePropertyChanged(); } } @@ -400,8 +400,8 @@ public override float MaterialMilliliters public override float MaterialCost { - get => (float) Math.Round(HeaderSettings.MaterialCost, 3); - set => base.MaterialCost = HeaderSettings.MaterialCost = (float)Math.Round(value, 3); + get => MathF.Round(HeaderSettings.MaterialCost, 3); + set => base.MaterialCost = HeaderSettings.MaterialCost = MathF.Round(value, 3); } public override string? MaterialName diff --git a/UVtools.Core/FileFormats/PHZFile.cs b/UVtools.Core/FileFormats/PHZFile.cs index 86ad67e2..e40ed107 100644 --- a/UVtools.Core/FileFormats/PHZFile.cs +++ b/UVtools.Core/FileFormats/PHZFile.cs @@ -617,7 +617,7 @@ public override float DisplayHeight public override float MachineZ { get => HeaderSettings.BedSizeZ > 0 ? HeaderSettings.BedSizeZ : base.MachineZ; - set => base.MachineZ = HeaderSettings.BedSizeZ = (float)Math.Round(value, 2); + set => base.MachineZ = HeaderSettings.BedSizeZ = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -663,19 +663,19 @@ public override ushort BottomLayerCount public override float BottomLightOffDelay { get => HeaderSettings.BottomLightOffDelay; - set => base.BottomLightOffDelay = HeaderSettings.BottomLightOffDelay = (float)Math.Round(value, 2); + set => base.BottomLightOffDelay = HeaderSettings.BottomLightOffDelay = MathF.Round(value, 2); } public override float LightOffDelay { get => HeaderSettings.LightOffDelay; - set => base.LightOffDelay = HeaderSettings.LightOffDelay = (float)Math.Round(value, 2); + set => base.LightOffDelay = HeaderSettings.LightOffDelay = MathF.Round(value, 2); } public override float BottomExposureTime { get => HeaderSettings.BottomExposureSeconds; - set => base.BottomExposureTime = HeaderSettings.BottomExposureSeconds = (float)Math.Round(value, 2); + set => base.BottomExposureTime = HeaderSettings.BottomExposureSeconds = MathF.Round(value, 2); } public override float BottomWaitTimeBeforeCure @@ -701,31 +701,31 @@ public override float WaitTimeBeforeCure public override float ExposureTime { get => HeaderSettings.LayerExposureSeconds; - set => base.ExposureTime = HeaderSettings.LayerExposureSeconds = (float)Math.Round(value, 2); + set => base.ExposureTime = HeaderSettings.LayerExposureSeconds = MathF.Round(value, 2); } public override float BottomLiftHeight { get => HeaderSettings.BottomLiftHeight; - set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = HeaderSettings.BottomLiftHeight = MathF.Round(value, 2); } public override float LiftHeight { get => HeaderSettings.LiftHeight; - set => base.LiftHeight = HeaderSettings.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = HeaderSettings.LiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => HeaderSettings.BottomLiftSpeed; - set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = HeaderSettings.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftSpeed { get => HeaderSettings.LiftSpeed; - set => base.LiftSpeed = HeaderSettings.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = HeaderSettings.LiftSpeed = MathF.Round(value, 2); } public override float BottomRetractSpeed => RetractSpeed; @@ -733,7 +733,7 @@ public override float LiftSpeed public override float RetractSpeed { get => HeaderSettings.RetractSpeed; - set => base.RetractSpeed = HeaderSettings.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = HeaderSettings.RetractSpeed = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -770,14 +770,14 @@ public override float MaterialMilliliters public override float MaterialGrams { - get => (float) Math.Round(HeaderSettings.WeightG, 3); - set => base.MaterialGrams = HeaderSettings.WeightG = (float) Math.Round(value, 3); + get => MathF.Round(HeaderSettings.WeightG, 3); + set => base.MaterialGrams = HeaderSettings.WeightG = MathF.Round(value, 3); } public override float MaterialCost { - get => (float) Math.Round(HeaderSettings.CostDollars, 3); - set => base.MaterialCost = HeaderSettings.CostDollars = (float)Math.Round(value, 3); + get => MathF.Round(HeaderSettings.CostDollars, 3); + set => base.MaterialCost = HeaderSettings.CostDollars = MathF.Round(value, 3); } public override string MachineName diff --git a/UVtools.Core/FileFormats/SL1File.cs b/UVtools.Core/FileFormats/SL1File.cs index 8c9065c9..e9a9d6f4 100644 --- a/UVtools.Core/FileFormats/SL1File.cs +++ b/UVtools.Core/FileFormats/SL1File.cs @@ -437,7 +437,7 @@ public override float DisplayHeight public override float MachineZ { get => PrinterSettings.MaxPrintHeight; - set => base.MachineZ = PrinterSettings.MaxPrintHeight = (float)Math.Round(value, 2); + set => base.MachineZ = PrinterSettings.MaxPrintHeight = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -488,13 +488,13 @@ public override ushort BottomLayerCount public override float BottomExposureTime { get => OutputConfigSettings.ExpTimeFirst; - set => base.BottomExposureTime = OutputConfigSettings.ExpTimeFirst = (float)Math.Round(value, 2); + set => base.BottomExposureTime = OutputConfigSettings.ExpTimeFirst = MathF.Round(value, 2); } public override float ExposureTime { get => OutputConfigSettings.ExpTime; - set => base.ExposureTime = OutputConfigSettings.ExpTime = (float)Math.Round(value, 2); + set => base.ExposureTime = OutputConfigSettings.ExpTime = MathF.Round(value, 2); } public override float PrintTime @@ -517,11 +517,11 @@ public override float MaterialMilliliters } } - public override float MaterialGrams => (float) Math.Round(OutputConfigSettings.UsedMaterial * MaterialSettings.MaterialDensity, 3); + public override float MaterialGrams => MathF.Round(OutputConfigSettings.UsedMaterial * MaterialSettings.MaterialDensity, 3); public override float MaterialCost => MaterialSettings.BottleVolume > 0 - ? (float) Math.Round(OutputConfigSettings.UsedMaterial * MaterialSettings.BottleCost / MaterialSettings.BottleVolume, 3) + ? MathF.Round(OutputConfigSettings.UsedMaterial * MaterialSettings.BottleCost / MaterialSettings.BottleVolume, 3) : base.MaterialCost; public override string? MaterialName diff --git a/UVtools.Core/FileFormats/UVJFile.cs b/UVtools.Core/FileFormats/UVJFile.cs index a21a9d7c..654c2f06 100644 --- a/UVtools.Core/FileFormats/UVJFile.cs +++ b/UVtools.Core/FileFormats/UVJFile.cs @@ -311,7 +311,7 @@ public override float BottomLightOffDelay get => JsonSettings.Properties.Bottom.LightOffTime; set { - base.BottomLightOffDelay = JsonSettings.Properties.Bottom.LightOffTime = (float)Math.Round(value, 2); + base.BottomLightOffDelay = JsonSettings.Properties.Bottom.LightOffTime = MathF.Round(value, 2); if (value > 0) { BottomWaitTimeBeforeCure = 0; @@ -326,7 +326,7 @@ public override float LightOffDelay get => JsonSettings.Properties.Exposure.LightOffTime; set { - base.LightOffDelay = JsonSettings.Properties.Exposure.LightOffTime = (float)Math.Round(value, 2); + base.LightOffDelay = JsonSettings.Properties.Exposure.LightOffTime = MathF.Round(value, 2); if (value > 0) { WaitTimeBeforeCure = 0; @@ -341,7 +341,7 @@ public override float BottomWaitTimeBeforeCure get => base.BottomWaitTimeBeforeCure; set { - base.BottomWaitTimeBeforeCure = JsonSettings.Properties.Bottom.WaitTimeBeforeCure = (float)Math.Round(value, 2); + base.BottomWaitTimeBeforeCure = JsonSettings.Properties.Bottom.WaitTimeBeforeCure = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -355,7 +355,7 @@ public override float WaitTimeBeforeCure get => base.WaitTimeBeforeCure; set { - base.WaitTimeBeforeCure = JsonSettings.Properties.Exposure.WaitTimeBeforeCure = (float)Math.Round(value, 2); + base.WaitTimeBeforeCure = JsonSettings.Properties.Exposure.WaitTimeBeforeCure = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -367,13 +367,13 @@ public override float WaitTimeBeforeCure public override float BottomExposureTime { get => JsonSettings.Properties.Bottom.LightOnTime; - set => base.BottomExposureTime = JsonSettings.Properties.Bottom.LightOnTime = (float)Math.Round(value, 2); + set => base.BottomExposureTime = JsonSettings.Properties.Bottom.LightOnTime = MathF.Round(value, 2); } public override float ExposureTime { get => JsonSettings.Properties.Exposure.LightOnTime; - set => base.ExposureTime = JsonSettings.Properties.Exposure.LightOnTime = (float)Math.Round(value, 2); + set => base.ExposureTime = JsonSettings.Properties.Exposure.LightOnTime = MathF.Round(value, 2); } public override float BottomWaitTimeAfterCure @@ -381,7 +381,7 @@ public override float BottomWaitTimeAfterCure get => base.BottomWaitTimeAfterCure; set { - base.BottomWaitTimeAfterCure = JsonSettings.Properties.Bottom.WaitTimeAfterCure = (float)Math.Round(value, 2); + base.BottomWaitTimeAfterCure = JsonSettings.Properties.Bottom.WaitTimeAfterCure = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -395,7 +395,7 @@ public override float WaitTimeAfterCure get => base.WaitTimeAfterCure; set { - base.WaitTimeAfterCure = JsonSettings.Properties.Exposure.WaitTimeAfterCure = (float)Math.Round(value, 2); + base.WaitTimeAfterCure = JsonSettings.Properties.Exposure.WaitTimeAfterCure = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -407,37 +407,37 @@ public override float WaitTimeAfterCure public override float BottomLiftHeight { get => JsonSettings.Properties.Bottom.LiftHeight; - set => base.BottomLiftHeight = JsonSettings.Properties.Bottom.LiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = JsonSettings.Properties.Bottom.LiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => JsonSettings.Properties.Bottom.LiftSpeed; - set => base.BottomLiftSpeed = JsonSettings.Properties.Bottom.LiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = JsonSettings.Properties.Bottom.LiftSpeed = MathF.Round(value, 2); } public override float LiftHeight { get => JsonSettings.Properties.Exposure.LiftHeight; - set => base.LiftHeight = JsonSettings.Properties.Exposure.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = JsonSettings.Properties.Exposure.LiftHeight = MathF.Round(value, 2); } public override float LiftSpeed { get => JsonSettings.Properties.Exposure.LiftSpeed; - set => base.LiftSpeed = JsonSettings.Properties.Exposure.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = JsonSettings.Properties.Exposure.LiftSpeed = MathF.Round(value, 2); } public override float BottomLiftHeight2 { get => JsonSettings.Properties.Bottom.LiftHeight2; - set => base.BottomLiftHeight2 = JsonSettings.Properties.Bottom.LiftHeight2 = (float)Math.Round(value, 2); + set => base.BottomLiftHeight2 = JsonSettings.Properties.Bottom.LiftHeight2 = MathF.Round(value, 2); } public override float BottomLiftSpeed2 { get => JsonSettings.Properties.Bottom.LiftSpeed2; - set => base.BottomLiftSpeed2 = JsonSettings.Properties.Bottom.LiftSpeed2 = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed2 = JsonSettings.Properties.Bottom.LiftSpeed2 = MathF.Round(value, 2); } public override float BottomWaitTimeAfterLift @@ -445,7 +445,7 @@ public override float BottomWaitTimeAfterLift get => base.BottomWaitTimeAfterLift; set { - base.BottomWaitTimeAfterLift = JsonSettings.Properties.Bottom.WaitTimeAfterLift = (float)Math.Round(value, 2); + base.BottomWaitTimeAfterLift = JsonSettings.Properties.Bottom.WaitTimeAfterLift = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -459,7 +459,7 @@ public override float WaitTimeAfterLift get => base.WaitTimeAfterLift; set { - base.WaitTimeAfterLift = JsonSettings.Properties.Exposure.WaitTimeAfterLift = (float)Math.Round(value, 2); + base.WaitTimeAfterLift = JsonSettings.Properties.Exposure.WaitTimeAfterLift = MathF.Round(value, 2); if (value > 0) { BottomLightOffDelay = 0; @@ -471,49 +471,49 @@ public override float WaitTimeAfterLift public override float LiftHeight2 { get => JsonSettings.Properties.Exposure.LiftHeight2; - set => base.LiftHeight2 = JsonSettings.Properties.Exposure.LiftHeight2 = (float)Math.Round(value, 2); + set => base.LiftHeight2 = JsonSettings.Properties.Exposure.LiftHeight2 = MathF.Round(value, 2); } public override float LiftSpeed2 { get => JsonSettings.Properties.Exposure.LiftSpeed2; - set => base.LiftSpeed2 = JsonSettings.Properties.Exposure.LiftSpeed2 = (float)Math.Round(value, 2); + set => base.LiftSpeed2 = JsonSettings.Properties.Exposure.LiftSpeed2 = MathF.Round(value, 2); } public override float BottomRetractSpeed { get => JsonSettings.Properties.Bottom.RetractSpeed; - set => base.BottomRetractSpeed = JsonSettings.Properties.Bottom.RetractSpeed = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed = JsonSettings.Properties.Bottom.RetractSpeed = MathF.Round(value, 2); } public override float RetractSpeed { get => JsonSettings.Properties.Exposure.RetractSpeed; - set => base.RetractSpeed = JsonSettings.Properties.Exposure.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = JsonSettings.Properties.Exposure.RetractSpeed = MathF.Round(value, 2); } public override float BottomRetractHeight2 { get => JsonSettings.Properties.Bottom.RetractHeight2; - set => base.BottomRetractHeight2 = JsonSettings.Properties.Bottom.RetractHeight2 = (float)Math.Round(value, 2); + set => base.BottomRetractHeight2 = JsonSettings.Properties.Bottom.RetractHeight2 = MathF.Round(value, 2); } public override float BottomRetractSpeed2 { get => JsonSettings.Properties.Bottom.RetractSpeed2; - set => base.BottomRetractSpeed2 = JsonSettings.Properties.Bottom.RetractSpeed2 = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed2 = JsonSettings.Properties.Bottom.RetractSpeed2 = MathF.Round(value, 2); } public override float RetractHeight2 { get => JsonSettings.Properties.Exposure.RetractHeight2; - set => base.RetractHeight2 = JsonSettings.Properties.Exposure.RetractHeight2 = (float)Math.Round(value, 2); + set => base.RetractHeight2 = JsonSettings.Properties.Exposure.RetractHeight2 = MathF.Round(value, 2); } public override float RetractSpeed2 { get => JsonSettings.Properties.Exposure.RetractSpeed2; - set => base.RetractSpeed2 = JsonSettings.Properties.Exposure.RetractSpeed2 = (float)Math.Round(value, 2); + set => base.RetractSpeed2 = JsonSettings.Properties.Exposure.RetractSpeed2 = MathF.Round(value, 2); } diff --git a/UVtools.Core/FileFormats/VDAFile.cs b/UVtools.Core/FileFormats/VDAFile.cs index bd0dc2e6..f644281c 100644 --- a/UVtools.Core/FileFormats/VDAFile.cs +++ b/UVtools.Core/FileFormats/VDAFile.cs @@ -202,7 +202,7 @@ public override float DisplayWidth if (ushort.TryParse(umStr, out var um) && um > 0) { - ManifestFile.Machines.XLength = (float) Math.Round(ResolutionX * um / 1000f, 2); + ManifestFile.Machines.XLength = MathF.Round(ResolutionX * um / 1000f, 2); } return ManifestFile.Machines.XLength; @@ -224,7 +224,7 @@ public override float DisplayHeight if (ushort.TryParse(umStr, out var um) && um > 0) { - ManifestFile.Machines.YWidth = (float)Math.Round(ResolutionY * um / 1000f, 2); + ManifestFile.Machines.YWidth = MathF.Round(ResolutionY * um / 1000f, 2); } return ManifestFile.Machines.YWidth; diff --git a/UVtools.Core/FileFormats/VDTFile.cs b/UVtools.Core/FileFormats/VDTFile.cs index 38da7266..af3a2648 100644 --- a/UVtools.Core/FileFormats/VDTFile.cs +++ b/UVtools.Core/FileFormats/VDTFile.cs @@ -315,7 +315,7 @@ public override float DisplayHeight public override float MachineZ { get => ManifestFile.Machine.ZHeight > 0 ? ManifestFile.Machine.ZHeight : base.MachineZ; - set => base.MachineZ = ManifestFile.Machine.ZHeight = (float)Math.Round(value, 2); + set => base.MachineZ = ManifestFile.Machine.ZHeight = MathF.Round(value, 2); } public override FlipDirection DisplayMirror @@ -370,118 +370,118 @@ public override ushort TransitionLayerCount public override float BottomLightOffDelay { get => ManifestFile.Print.BottomLightOffDelay; - set => base.BottomLightOffDelay = ManifestFile.Print.BottomLightOffDelay = (float)Math.Round(value, 2); + set => base.BottomLightOffDelay = ManifestFile.Print.BottomLightOffDelay = MathF.Round(value, 2); } public override float LightOffDelay { get => ManifestFile.Print.LightOffDelay; - set => base.LightOffDelay = ManifestFile.Print.LightOffDelay = (float)Math.Round(value, 2); + set => base.LightOffDelay = ManifestFile.Print.LightOffDelay = MathF.Round(value, 2); } public override float BottomWaitTimeBeforeCure { get => ManifestFile.Print.BottomWaitTimeBeforeCure; - set => base.BottomWaitTimeBeforeCure = ManifestFile.Print.BottomWaitTimeBeforeCure = (float)Math.Round(value, 2); + set => base.BottomWaitTimeBeforeCure = ManifestFile.Print.BottomWaitTimeBeforeCure = MathF.Round(value, 2); } public override float WaitTimeBeforeCure { get => ManifestFile.Print.WaitTimeBeforeCure; - set => base.WaitTimeBeforeCure = ManifestFile.Print.WaitTimeBeforeCure = (float)Math.Round(value, 2); + set => base.WaitTimeBeforeCure = ManifestFile.Print.WaitTimeBeforeCure = MathF.Round(value, 2); } public override float BottomExposureTime { get => ManifestFile.Print.BottomExposureTime; - set => base.BottomExposureTime = ManifestFile.Print.BottomExposureTime = (float)Math.Round(value, 2); + set => base.BottomExposureTime = ManifestFile.Print.BottomExposureTime = MathF.Round(value, 2); } public override float ExposureTime { get => ManifestFile.Print.ExposureTime; - set => base.ExposureTime = ManifestFile.Print.ExposureTime = (float)Math.Round(value, 2); + set => base.ExposureTime = ManifestFile.Print.ExposureTime = MathF.Round(value, 2); } public override float BottomWaitTimeAfterCure { get => ManifestFile.Print.BottomWaitTimeAfterCure; - set => base.BottomWaitTimeAfterCure = ManifestFile.Print.BottomWaitTimeAfterCure = (float)Math.Round(value, 2); + set => base.BottomWaitTimeAfterCure = ManifestFile.Print.BottomWaitTimeAfterCure = MathF.Round(value, 2); } public override float WaitTimeAfterCure { get => ManifestFile.Print.WaitTimeAfterCure; - set => base.WaitTimeAfterCure = ManifestFile.Print.WaitTimeAfterCure = (float)Math.Round(value, 2); + set => base.WaitTimeAfterCure = ManifestFile.Print.WaitTimeAfterCure = MathF.Round(value, 2); } public override float BottomLiftHeight { get => ManifestFile.Print.BottomLiftHeight; - set => base.BottomLiftHeight = ManifestFile.Print.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = ManifestFile.Print.BottomLiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => ManifestFile.Print.BottomLiftSpeed; - set => base.BottomLiftSpeed = ManifestFile.Print.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = ManifestFile.Print.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftHeight { get => ManifestFile.Print.LiftHeight; - set => base.LiftHeight = ManifestFile.Print.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = ManifestFile.Print.LiftHeight = MathF.Round(value, 2); } public override float LiftSpeed { get => ManifestFile.Print.LiftSpeed; - set => base.LiftSpeed = ManifestFile.Print.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = ManifestFile.Print.LiftSpeed = MathF.Round(value, 2); } public override float BottomLiftHeight2 { get => ManifestFile.Print.BottomLiftHeight2; - set => base.BottomLiftHeight2 = ManifestFile.Print.BottomLiftHeight2 = (float)Math.Round(value, 2); + set => base.BottomLiftHeight2 = ManifestFile.Print.BottomLiftHeight2 = MathF.Round(value, 2); } public override float BottomLiftSpeed2 { get => ManifestFile.Print.BottomLiftSpeed2; - set => base.BottomLiftSpeed2 = ManifestFile.Print.BottomLiftSpeed2 = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed2 = ManifestFile.Print.BottomLiftSpeed2 = MathF.Round(value, 2); } public override float LiftHeight2 { get => ManifestFile.Print.LiftHeight2; - set => base.LiftHeight2 = ManifestFile.Print.LiftHeight2 = (float)Math.Round(value, 2); + set => base.LiftHeight2 = ManifestFile.Print.LiftHeight2 = MathF.Round(value, 2); } public override float LiftSpeed2 { get => ManifestFile.Print.LiftSpeed2; - set => base.LiftSpeed2 = ManifestFile.Print.LiftSpeed2 = (float)Math.Round(value, 2); + set => base.LiftSpeed2 = ManifestFile.Print.LiftSpeed2 = MathF.Round(value, 2); } public override float BottomWaitTimeAfterLift { get => ManifestFile.Print.BottomWaitTimeAfterLift; - set => base.BottomWaitTimeAfterLift = ManifestFile.Print.BottomWaitTimeAfterLift = (float)Math.Round(value, 2); + set => base.BottomWaitTimeAfterLift = ManifestFile.Print.BottomWaitTimeAfterLift = MathF.Round(value, 2); } public override float WaitTimeAfterLift { get => ManifestFile.Print.WaitTimeAfterLift; - set => base.WaitTimeAfterLift = ManifestFile.Print.WaitTimeAfterLift = (float)Math.Round(value, 2); + set => base.WaitTimeAfterLift = ManifestFile.Print.WaitTimeAfterLift = MathF.Round(value, 2); } public override float BottomRetractSpeed { get => ManifestFile.Print.BottomRetractSpeed; - set => base.BottomRetractSpeed = ManifestFile.Print.BottomRetractSpeed = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed = ManifestFile.Print.BottomRetractSpeed = MathF.Round(value, 2); } public override float RetractSpeed { get => ManifestFile.Print.RetractSpeed; - set => base.RetractSpeed = ManifestFile.Print.RetractSpeed = (float)Math.Round(value, 2); + set => base.RetractSpeed = ManifestFile.Print.RetractSpeed = MathF.Round(value, 2); } public override float BottomRetractHeight2 @@ -489,7 +489,7 @@ public override float BottomRetractHeight2 get => ManifestFile.Print.BottomRetractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, BottomRetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, BottomRetractHeightTotal); base.BottomRetractHeight2 = ManifestFile.Print.BottomRetractHeight2 = value; } } @@ -497,7 +497,7 @@ public override float BottomRetractHeight2 public override float BottomRetractSpeed2 { get => ManifestFile.Print.BottomRetractSpeed2; - set => base.BottomRetractSpeed2 = ManifestFile.Print.BottomRetractSpeed2 = (float)Math.Round(value, 2); + set => base.BottomRetractSpeed2 = ManifestFile.Print.BottomRetractSpeed2 = MathF.Round(value, 2); } public override float RetractHeight2 @@ -505,7 +505,7 @@ public override float RetractHeight2 get => ManifestFile.Print.RetractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, RetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, RetractHeightTotal); base.RetractHeight2 = ManifestFile.Print.RetractHeight2 = value; } } @@ -513,7 +513,7 @@ public override float RetractHeight2 public override float RetractSpeed2 { get => ManifestFile.Print.RetractSpeed2; - set => base.RetractSpeed2 = ManifestFile.Print.RetractSpeed2 = (float)Math.Round(value, 2); + set => base.RetractSpeed2 = ManifestFile.Print.RetractSpeed2 = MathF.Round(value, 2); } public override byte BottomLightPWM @@ -550,8 +550,8 @@ public override float MaterialMilliliters public override float MaterialGrams { - get => (float)Math.Round(ManifestFile.PrintStatistics.Weight, 3); - set => base.MaterialGrams = ManifestFile.PrintStatistics.Weight = (float)Math.Round(value, 3); + get => MathF.Round(ManifestFile.PrintStatistics.Weight, 3); + set => base.MaterialGrams = ManifestFile.PrintStatistics.Weight = MathF.Round(value, 3); } public override string? MaterialName @@ -562,8 +562,8 @@ public override string? MaterialName public override float MaterialCost { - get => (float)Math.Round(ManifestFile.Resin.Cost, 3); - set => base.MaterialCost = ManifestFile.Resin.Cost = (float)Math.Round(value, 3); + get => MathF.Round(ManifestFile.Resin.Cost, 3); + set => base.MaterialCost = ManifestFile.Resin.Cost = MathF.Round(value, 3); } public override string MachineName diff --git a/UVtools.Core/FileFormats/ZCodeFile.cs b/UVtools.Core/FileFormats/ZCodeFile.cs index c12850af..0f02b75b 100644 --- a/UVtools.Core/FileFormats/ZCodeFile.cs +++ b/UVtools.Core/FileFormats/ZCodeFile.cs @@ -249,13 +249,13 @@ public override uint ResolutionY public override float DisplayWidth { - get => (float) Math.Round(ManifestFile.Device.ResolutionX * ManifestFile.Device.PixelSize / 1000, 2); + get => MathF.Round(ManifestFile.Device.ResolutionX * ManifestFile.Device.PixelSize / 1000, 2); set => RaisePropertyChanged(); } public override float DisplayHeight { - get => (float)Math.Round(ManifestFile.Device.ResolutionY * ManifestFile.Device.PixelSize / 1000, 2); + get => MathF.Round(ManifestFile.Device.ResolutionY * ManifestFile.Device.PixelSize / 1000, 2); set => RaisePropertyChanged(); } @@ -350,25 +350,25 @@ public override float ExposureTime public override float BottomLiftHeight { get => ManifestFile.Profile.Slice.BottomLiftHeight; - set => base.BottomLiftHeight = ManifestFile.Profile.Slice.BottomLiftHeight = (float)Math.Round(value, 2); + set => base.BottomLiftHeight = ManifestFile.Profile.Slice.BottomLiftHeight = MathF.Round(value, 2); } public override float LiftHeight { get => ManifestFile.Profile.Slice.LiftHeight; - set => base.LiftHeight = ManifestFile.Profile.Slice.LiftHeight = (float)Math.Round(value, 2); + set => base.LiftHeight = ManifestFile.Profile.Slice.LiftHeight = MathF.Round(value, 2); } public override float BottomLiftSpeed { get => ManifestFile.Profile.Slice.BottomLiftSpeed; - set => base.BottomLiftSpeed = ManifestFile.Profile.Slice.BottomLiftSpeed = (float)Math.Round(value, 2); + set => base.BottomLiftSpeed = ManifestFile.Profile.Slice.BottomLiftSpeed = MathF.Round(value, 2); } public override float LiftSpeed { get => ManifestFile.Profile.Slice.LiftSpeed; - set => base.LiftSpeed = ManifestFile.Profile.Slice.LiftSpeed = (float)Math.Round(value, 2); + set => base.LiftSpeed = ManifestFile.Profile.Slice.LiftSpeed = MathF.Round(value, 2); } public override byte LightPWM @@ -405,13 +405,13 @@ public override float MaterialMilliliters public override float MaterialGrams { get => ManifestFile.Job.WeightG; - set => base.MaterialGrams = ManifestFile.Job.WeightG = (float)Math.Round(value, 3); + set => base.MaterialGrams = ManifestFile.Job.WeightG = MathF.Round(value, 3); } public override float MaterialCost { get => ManifestFile.Job.Price; - set => base.MaterialCost = ManifestFile.Job.Price = (float)Math.Round(value, 3); + set => base.MaterialCost = ManifestFile.Job.Price = MathF.Round(value, 3); } /*public override string MaterialName diff --git a/UVtools.Core/FileFormats/ZCodexFile.cs b/UVtools.Core/FileFormats/ZCodexFile.cs index 82bf2411..de91cebd 100644 --- a/UVtools.Core/FileFormats/ZCodexFile.cs +++ b/UVtools.Core/FileFormats/ZCodexFile.cs @@ -265,7 +265,7 @@ public override float ExposureTime public override float LiftHeight { get => UserSettings.ZLiftDistance; - set => base.LiftHeight = UserSettings.ZLiftDistance = (float)Math.Round(value, 2); + set => base.LiftHeight = UserSettings.ZLiftDistance = MathF.Round(value, 2); } public override float BottomLiftSpeed => LiftSpeed; @@ -273,13 +273,13 @@ public override float LiftHeight public override float LiftSpeed { get => UserSettings.ZLiftFeedRate; - set => base.LiftSpeed = UserSettings.ZLiftFeedRate = (float)Math.Round(value, 2); + set => base.LiftSpeed = UserSettings.ZLiftFeedRate = MathF.Round(value, 2); } public override float RetractSpeed { get => UserSettings.ZLiftRetractRate; - set => base.RetractSpeed = UserSettings.ZLiftRetractRate = (float)Math.Round(value, 2); + set => base.RetractSpeed = UserSettings.ZLiftRetractRate = MathF.Round(value, 2); } @@ -307,8 +307,8 @@ public override float MaterialMilliliters public override float MaterialGrams { - get => (float) Math.Round(ResinMetadataSettings.TotalMaterialWeightUsed, 3); - set => base.MaterialGrams = ResinMetadataSettings.TotalMaterialWeightUsed = (float) Math.Round(value, 3); + get => MathF.Round(ResinMetadataSettings.TotalMaterialWeightUsed, 3); + set => base.MaterialGrams = ResinMetadataSettings.TotalMaterialWeightUsed = MathF.Round(value, 3); } public override string? MaterialName diff --git a/UVtools.Core/GCode/GCodeBuilder.cs b/UVtools.Core/GCode/GCodeBuilder.cs index e3ffc974..b0698b13 100644 --- a/UVtools.Core/GCode/GCodeBuilder.cs +++ b/UVtools.Core/GCode/GCodeBuilder.cs @@ -1031,8 +1031,8 @@ public void RebuildGCode(FileFormat slicerFile, string? header = null) AppendLineIfCanComment(BeginLayerComments, layerIndex, layer.PositionZ); if (!OnBeforeWriteLayerGCode(layerIndex)) { - AppendPrintProgressM73((float)Math.Round(layerIndex * 100.0 / slicerFile.LayerCount, 2, MidpointRounding.AwayFromZero), - (float)Math.Round(slicerFile.Skip((int)layerIndex).Sum(l => l.PrintTime) / 60, 2, MidpointRounding.AwayFromZero)); + AppendPrintProgressM73(MathF.Round(layerIndex * 100.0f / slicerFile.LayerCount, 2, MidpointRounding.AwayFromZero), + MathF.Round(slicerFile.Skip((int)layerIndex).Sum(l => l.PrintTime) / 60, 2, MidpointRounding.AwayFromZero)); AppendLayerPause(layer); AppendLayerChangeResinM600(layer); @@ -1432,7 +1432,7 @@ public void ParseLayersFromGCode(FileFormat slicerFile, string? gcode, bool rebu { if (lineSplit[i].StartsWith("S")) { - if(!float.TryParse(lineSplit[i][1..], out var pwmValue)) continue; + if(!float.TryParse(lineSplit[i][1..], CultureInfo.InvariantCulture, out var pwmValue)) continue; pwm = _maxLedPower == byte.MaxValue ? (byte)pwmValue : (byte)(pwmValue * byte.MaxValue / _maxLedPower); @@ -1531,8 +1531,8 @@ public float ConvertFromMillimetersPerMinute(float mmMin) return _gCodeSpeedUnit switch { GCodeSpeedUnits.MillimetersPerMinute => mmMin, - GCodeSpeedUnits.MillimetersPerSecond => (float) Math.Round(mmMin / 60, 2), - GCodeSpeedUnits.CentimetersPerMinute => (float) Math.Round(mmMin / 10, 2), + GCodeSpeedUnits.MillimetersPerSecond => MathF.Round(mmMin / 60, 2), + GCodeSpeedUnits.CentimetersPerMinute => MathF.Round(mmMin / 10, 2), _ => throw new InvalidExpressionException($"Unhandled speed unit for {_gCodeSpeedUnit}") }; } @@ -1562,8 +1562,8 @@ public float ConvertToMillimetersPerMinute(float speed) return _gCodeSpeedUnit switch { GCodeSpeedUnits.MillimetersPerMinute => speed, - GCodeSpeedUnits.MillimetersPerSecond => (float)Math.Round(speed * 60, 2), - GCodeSpeedUnits.CentimetersPerMinute => (float)Math.Round(speed * 10, 2), + GCodeSpeedUnits.MillimetersPerSecond => MathF.Round(speed * 60, 2), + GCodeSpeedUnits.CentimetersPerMinute => MathF.Round(speed * 10, 2), _ => throw new InvalidExpressionException($"Unhandled speed unit for {_gCodeSpeedUnit}") }; } diff --git a/UVtools.Core/GCode/GCodeLayer.cs b/UVtools.Core/GCode/GCodeLayer.cs index 67efbea3..86dad5d4 100644 --- a/UVtools.Core/GCode/GCodeLayer.cs +++ b/UVtools.Core/GCode/GCodeLayer.cs @@ -52,19 +52,19 @@ public float? PositionZ public float? WaitTimeBeforeCure { get => _waitTimeBeforeCure; - set => _waitTimeBeforeCure = value is null ? null : (float)Math.Round(value.Value, 2); + set => _waitTimeBeforeCure = value is null ? null : MathF.Round(value.Value, 2); } public float? ExposureTime { get => _exposureTime; - set => _exposureTime = value is null ? null : (float)Math.Round(value.Value, 2); + set => _exposureTime = value is null ? null : MathF.Round(value.Value, 2); } public float? WaitTimeAfterCure { get => _waitTimeAfterCure; - set => _waitTimeAfterCure = value is null ? null : (float)Math.Round(value.Value, 2); + set => _waitTimeAfterCure = value is null ? null : MathF.Round(value.Value, 2); } public float? LiftHeight @@ -76,13 +76,13 @@ public float? LiftHeight public float? LiftSpeed { get => _liftSpeed; - set => _liftSpeed = value is null ? null : (float)Math.Round(value.Value, 2); + set => _liftSpeed = value is null ? null : MathF.Round(value.Value, 2); } public float LiftAcceleration { get => _liftAcceleration; - set => _liftAcceleration = (float)Math.Round(Math.Max(value, 0), 2); + set => _liftAcceleration = MathF.Round(Math.Max(value, 0), 2); } public float LiftHeightTotal => Layer.RoundHeight((LiftHeight ?? 0) + (LiftHeight2 ?? 0)); @@ -96,30 +96,30 @@ public float? LiftHeight2 public float? LiftSpeed2 { get => _liftSpeed2; - set => _liftSpeed2 = value is null ? null : (float)Math.Round(value.Value, 2); + set => _liftSpeed2 = value is null ? null : MathF.Round(value.Value, 2); } public float LiftAcceleration2 { get => _liftAcceleration2; - set => _liftAcceleration2 = (float)Math.Round(Math.Max(value, 0), 2); + set => _liftAcceleration2 = MathF.Round(Math.Max(value, 0), 2); } public float? WaitTimeAfterLift { get => _waitTimeAfterLift; - set => _waitTimeAfterLift = value is null ? null : (float)Math.Round(value.Value, 2); + set => _waitTimeAfterLift = value is null ? null : MathF.Round(value.Value, 2); } public float? RetractSpeed { get => _retractSpeed; - set => _retractSpeed = value is null ? null : (float)Math.Round(value.Value, 2); + set => _retractSpeed = value is null ? null : MathF.Round(value.Value, 2); } public float RetractAcceleration { get => _retractAcceleration; - set => _retractAcceleration = (float)Math.Round(Math.Max(value, 0), 2); + set => _retractAcceleration = MathF.Round(Math.Max(value, 0), 2); } public float? RetractHeight2 @@ -131,13 +131,13 @@ public float? RetractHeight2 public float? RetractSpeed2 { get => _retractSpeed2; - set => _retractSpeed2 = value is null ? null : (float)Math.Round(value.Value, 2); + set => _retractSpeed2 = value is null ? null : MathF.Round(value.Value, 2); } public float RetractAcceleration2 { get => _retractAcceleration2; - set => _retractAcceleration2 = (float)Math.Round(Math.Max(value, 0), 2); + set => _retractAcceleration2 = MathF.Round(Math.Max(value, 0), 2); } public byte? LightPWM { get; set; } @@ -351,7 +351,7 @@ public void SetLayer(bool reinit = false) var syncTime = OperationCalculator.LightOffDelayC.CalculateSeconds(layer, 1.5f); if (syncTime < layer.WaitTimeBeforeCure) { - layer.WaitTimeBeforeCure = (float) Math.Round(layer.WaitTimeBeforeCure - syncTime, 2); + layer.WaitTimeBeforeCure = MathF.Round(layer.WaitTimeBeforeCure - syncTime, 2); } } diff --git a/UVtools.Core/Helpers.cs b/UVtools.Core/Helpers.cs index 5cc47cef..3001a074 100644 --- a/UVtools.Core/Helpers.cs +++ b/UVtools.Core/Helpers.cs @@ -46,5 +46,5 @@ public static void SwapVariables(ref T var1, ref T var2) (var1, var2) = (var2, var1); } - public static float BrightnessToPercent(byte brightness, byte roundPlates = 2) => (float)Math.Round(brightness * 100 / 255.0, roundPlates); + public static float BrightnessToPercent(byte brightness, byte roundPlates = 2) => MathF.Round(brightness * 100 / 255.0f, roundPlates); } \ No newline at end of file diff --git a/UVtools.Core/Layers/Layer.cs b/UVtools.Core/Layers/Layer.cs index 87abdade..59ab2b10 100644 --- a/UVtools.Core/Layers/Layer.cs +++ b/UVtools.Core/Layers/Layer.cs @@ -208,10 +208,10 @@ public RectangleF BoundingRectangleMillimeters { var pixelSize = SlicerFile.PixelSize; return new RectangleF( - (float) Math.Round(_boundingRectangle.X * pixelSize.Width, 2), - (float)Math.Round(_boundingRectangle.Y * pixelSize.Height, 2), - (float)Math.Round(_boundingRectangle.Width * pixelSize.Width, 2), - (float)Math.Round(_boundingRectangle.Height * pixelSize.Height, 2)); + MathF.Round(_boundingRectangle.X * pixelSize.Width, 2), + MathF.Round(_boundingRectangle.Y * pixelSize.Height, 2), + MathF.Round(_boundingRectangle.Width * pixelSize.Width, 2), + MathF.Round(_boundingRectangle.Height * pixelSize.Height, 2)); } } @@ -494,7 +494,7 @@ public float WaitTimeBeforeCure get => _waitTimeBeforeCure; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value < 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomWaitTimeBeforeCure, SlicerFile.WaitTimeBeforeCure); if (!RaiseAndSetIfChanged(ref _waitTimeBeforeCure, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -509,7 +509,7 @@ public float ExposureTime get => _exposureTime; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value < 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomExposureTime, SlicerFile.ExposureTime); if(!RaiseAndSetIfChanged(ref _exposureTime, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -526,7 +526,7 @@ public float WaitTimeAfterCure get => _waitTimeAfterCure; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value < 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomWaitTimeAfterCure, SlicerFile.WaitTimeAfterCure); if (!RaiseAndSetIfChanged(ref _waitTimeAfterCure, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -541,7 +541,7 @@ public float LightOffDelay get => _lightOffDelay; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value < 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomLightOffDelay, SlicerFile.LightOffDelay); if(!RaiseAndSetIfChanged(ref _lightOffDelay, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -554,10 +554,10 @@ public float LightOffDelay /// public float LiftHeightTotal { - get => (float)Math.Round(_liftHeight + _liftHeight2, 2); + get => MathF.Round(_liftHeight + _liftHeight2, 2); set { - LiftHeight = (float)Math.Round(value, 2); + LiftHeight = MathF.Round(value, 2); LiftHeight2 = 0; } } @@ -570,7 +570,7 @@ public float LiftHeight get => _liftHeight; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value < 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomLiftHeight, SlicerFile.LiftHeight); if(!RaiseAndSetIfChanged(ref _liftHeight, value)) return; RaisePropertyChanged(nameof(LiftHeightTotal)); @@ -587,7 +587,7 @@ public float LiftSpeed get => _liftSpeed; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value <= 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomLiftSpeed, SlicerFile.LiftSpeed); if(!RaiseAndSetIfChanged(ref _liftSpeed, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -600,7 +600,7 @@ public float LiftSpeed public float LiftAcceleration { get => _liftAcceleration; - set => RaiseAndSetIfChanged(ref _liftAcceleration, (float)Math.Round(Math.Max(value, 0), 2)); + set => RaiseAndSetIfChanged(ref _liftAcceleration, MathF.Round(Math.Max(value, 0), 2)); } /// @@ -611,7 +611,7 @@ public float LiftHeight2 get => _liftHeight2; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value < 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomLiftHeight2, SlicerFile.LiftHeight2); if (!RaiseAndSetIfChanged(ref _liftHeight2, value)) return; RaisePropertyChanged(nameof(LiftHeightTotal)); @@ -628,7 +628,7 @@ public float LiftSpeed2 get => _liftSpeed2; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value <= 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomLiftSpeed2, SlicerFile.LiftSpeed2); if (!RaiseAndSetIfChanged(ref _liftSpeed2, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -641,7 +641,7 @@ public float LiftSpeed2 public float LiftAcceleration2 { get => _liftAcceleration2; - set => RaiseAndSetIfChanged(ref _liftAcceleration2, (float)Math.Round(Math.Max(value, 0), 2)); + set => RaiseAndSetIfChanged(ref _liftAcceleration2, MathF.Round(Math.Max(value, 0), 2)); } public float WaitTimeAfterLift @@ -649,7 +649,7 @@ public float WaitTimeAfterLift get => _waitTimeAfterLift; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value < 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomWaitTimeAfterLift, SlicerFile.WaitTimeAfterLift); if (!RaiseAndSetIfChanged(ref _waitTimeAfterLift, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -664,7 +664,7 @@ public float WaitTimeAfterLift /// /// Gets the retract height in mm /// - public float RetractHeight => (float)Math.Round(LiftHeightTotal - _retractHeight2, 2); + public float RetractHeight => MathF.Round(LiftHeightTotal - _retractHeight2, 2); /// /// Gets the speed in mm/min for the retracts @@ -674,7 +674,7 @@ public float RetractSpeed get => _retractSpeed; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value <= 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomRetractSpeed, SlicerFile.RetractSpeed); if (!RaiseAndSetIfChanged(ref _retractSpeed, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -687,7 +687,7 @@ public float RetractSpeed public float RetractAcceleration { get => _retractAcceleration; - set => RaiseAndSetIfChanged(ref _retractAcceleration, (float)Math.Round(Math.Max(value, 0), 2)); + set => RaiseAndSetIfChanged(ref _retractAcceleration, MathF.Round(Math.Max(value, 0), 2)); } /// @@ -698,7 +698,7 @@ public float RetractHeight2 get => _retractHeight2; set { - value = Math.Clamp((float)Math.Round(value, 2), 0, RetractHeightTotal); + value = Math.Clamp(MathF.Round(value, 2), 0, RetractHeightTotal); RaiseAndSetIfChanged(ref _retractHeight2, value); RaisePropertyChanged(nameof(RetractHeight)); RaisePropertyChanged(nameof(RetractHeightTotal)); @@ -714,7 +714,7 @@ public float RetractSpeed2 get => _retractSpeed2; set { - value = (float)Math.Round(value, 2); + value = MathF.Round(value, 2); if (value <= 0) value = SlicerFile.GetBottomOrNormalValue(this, SlicerFile.BottomRetractSpeed2, SlicerFile.RetractSpeed2); if (!RaiseAndSetIfChanged(ref _retractSpeed2, value)) return; SlicerFile.UpdatePrintTimeQueued(); @@ -727,7 +727,7 @@ public float RetractSpeed2 public float RetractAcceleration2 { get => _retractAcceleration2; - set => RaiseAndSetIfChanged(ref _retractAcceleration2, (float)Math.Round(Math.Max(value, 0), 2)); + set => RaiseAndSetIfChanged(ref _retractAcceleration2, MathF.Round(Math.Max(value, 0), 2)); } /// @@ -839,7 +839,7 @@ public float MaterialMilliliters //var globalMilliliters = SlicerFile.MaterialMilliliters - _materialMilliliters; if (value < 0) { - value = (float) Math.Round(GetVolume() / 1000f, 4); + value = MathF.Round(GetVolume() / 1000f, 4); } if(!RaiseAndSetIfChanged(ref _materialMilliliters, value)) return; @@ -859,7 +859,7 @@ public float MaterialMilliliters /// /// Gets the time estimate in seconds it takes for this layer to be printed /// - public float PrintTime => (float)Math.Round(CalculatePrintTime(), 2, MidpointRounding.AwayFromZero); + public float PrintTime => MathF.Round(CalculatePrintTime(), 2, MidpointRounding.AwayFromZero); /// /// Gets the time estimate in minutes and seconds it takes for this layer to be printed @@ -869,7 +869,7 @@ public float MaterialMilliliters /// /// Get the start time estimate in seconds when this layer should start at /// - public float StartTime => (float)Math.Round(CalculateStartTime(30), 2, MidpointRounding.AwayFromZero); + public float StartTime => MathF.Round(CalculateStartTime(30), 2, MidpointRounding.AwayFromZero); /// /// Get the start time estimate in hours, minutes and seconds when this layer should start at @@ -879,7 +879,7 @@ public float MaterialMilliliters /// /// Get the end time estimate in seconds when this layer should end at /// - public float EndTime => (float)Math.Round(CalculateStartTime(30) + CalculatePrintTime(), 2, MidpointRounding.AwayFromZero); + public float EndTime => MathF.Round(CalculateStartTime(30) + CalculatePrintTime(), 2, MidpointRounding.AwayFromZero); /// /// Get the end time estimate in hours, minutes and seconds when this layer should end at @@ -1377,7 +1377,7 @@ public void ResetParameters() /// Gets the layer area (XY) in mm² /// Pixel size * number of pixels /// - public float GetArea(byte roundToDigits) => (float)Math.Round(GetArea(), roundToDigits); + public float GetArea(byte roundToDigits) => MathF.Round(GetArea(), roundToDigits); /// /// Gets the layer volume (XYZ) in mm^3 @@ -1389,7 +1389,7 @@ public void ResetParameters() /// Gets the layer volume (XYZ) in mm^3 /// Pixel size * number of pixels * layer height /// - public float GetVolume(byte roundToDigits) => (float)Math.Round(GetArea() * LayerHeight, roundToDigits); + public float GetVolume(byte roundToDigits) => MathF.Round(GetArea() * LayerHeight, roundToDigits); /// /// Calculates the time estimate in seconds it takes for this layer to be printed @@ -1857,7 +1857,7 @@ public static Rectangle GetBoundingRectangleUnion(params Layer[] layers) return rect; } - public static float RoundHeight(float height) => (float) Math.Round(height, HeightPrecision, MidpointRounding.AwayFromZero); + public static float RoundHeight(float height) => MathF.Round(height, HeightPrecision, MidpointRounding.AwayFromZero); public static double RoundHeight(double height) => Math.Round(height, HeightPrecision, MidpointRounding.AwayFromZero); public static decimal RoundHeight(decimal height) => Math.Round(height, HeightPrecision, MidpointRounding.AwayFromZero); diff --git a/UVtools.Core/Operations/Operation.cs b/UVtools.Core/Operations/Operation.cs index bc9a781e..e32caf29 100644 --- a/UVtools.Core/Operations/Operation.cs +++ b/UVtools.Core/Operations/Operation.cs @@ -8,6 +8,7 @@ using Emgu.CV; using System; +using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; @@ -119,7 +120,7 @@ public LayerRangeSelection LayerRangeSelection get => _layerRangeSelection; set { - if(!RaiseAndSetIfChanged(ref _layerRangeSelection, value)) return; + if (!RaiseAndSetIfChanged(ref _layerRangeSelection, value)) return; if(SlicerFile is not null) SelectLayers(_layerRangeSelection); } } diff --git a/UVtools.Core/Operations/OperationCalculator.cs b/UVtools.Core/Operations/OperationCalculator.cs index 15bf27b3..00c5a6f0 100644 --- a/UVtools.Core/Operations/OperationCalculator.cs +++ b/UVtools.Core/Operations/OperationCalculator.cs @@ -312,7 +312,7 @@ public static float CalculateSeconds(float liftHeight, float liftSpeed, float re time += remainingRetractHeight / (retractSpeed / 60f); } - return (float)Math.Round(time, 2); + return MathF.Round(time, 2); } @@ -331,8 +331,8 @@ public static uint CalculateMilliseconds(float liftHeight, float liftSpeed, floa public static float CalculateSecondsLiftOnly(float liftHeight, float liftSpeed, float liftHeight2 = 0, float liftSpeed2 = 0, float extraWaitTime = 0) { var time = extraWaitTime; - if (liftHeight > 0 && liftSpeed > 0) time += (float)Math.Round(liftHeight / (liftSpeed / 60f) + extraWaitTime, 2); - if (liftHeight2 > 0 && liftSpeed2 > 0) time += (float)Math.Round(liftHeight2 / (liftSpeed2 / 60f) + extraWaitTime, 2); + if (liftHeight > 0 && liftSpeed > 0) time += MathF.Round(liftHeight / (liftSpeed / 60f) + extraWaitTime, 2); + if (liftHeight2 > 0 && liftSpeed2 > 0) time += MathF.Round(liftHeight2 / (liftSpeed2 / 60f) + extraWaitTime, 2); return time; } diff --git a/UVtools.Core/Operations/OperationCalibrateElephantFoot.cs b/UVtools.Core/Operations/OperationCalibrateElephantFoot.cs index ea96d3ba..93dfe7ba 100644 --- a/UVtools.Core/Operations/OperationCalibrateElephantFoot.cs +++ b/UVtools.Core/Operations/OperationCalibrateElephantFoot.cs @@ -325,7 +325,7 @@ public byte DimmingStartBrightness } } - public float DimmingStartBrightnessPercent => (float) Math.Round(_dimmingStartBrightness * 100 / 255M, 2); + public float DimmingStartBrightnessPercent => MathF.Round(_dimmingStartBrightness * 100 / 255.0f, 2); public byte DimmingEndBrightness { @@ -339,7 +339,7 @@ public byte DimmingEndBrightness } } - public float DimmingEndBrightnessPercent => (float)Math.Round(_dimmingEndBrightness * 100 / 255M, 2); + public float DimmingEndBrightnessPercent => MathF.Round(_dimmingEndBrightness * 100 / 255.0f, 2); public byte DimmingBrightnessSteps { diff --git a/UVtools.Core/Operations/OperationCalibrateGrayscale.cs b/UVtools.Core/Operations/OperationCalibrateGrayscale.cs index 87a8707f..f701fa3c 100644 --- a/UVtools.Core/Operations/OperationCalibrateGrayscale.cs +++ b/UVtools.Core/Operations/OperationCalibrateGrayscale.cs @@ -230,7 +230,7 @@ public byte StartBrightness } } - public float StartBrightnessPercent => (float)Math.Round(_startBrightness * 100 / 255M, 2); + public float StartBrightnessPercent => MathF.Round(_startBrightness * 100 / 255.0f, 2); public byte EndBrightness { @@ -244,7 +244,7 @@ public byte EndBrightness } } - public float EndBrightnessPercent => (float)Math.Round(_endBrightness * 100 / 255M, 2); + public float EndBrightnessPercent => MathF.Round(_endBrightness * 100 / 255.0f, 2); public byte BrightnessSteps { @@ -306,7 +306,7 @@ public byte LineDivisionBrightness } } - public float LineDivisionBrightnessPercent => (float)Math.Round(_lineDivisionBrightness * 100 / 255M, 2); + public float LineDivisionBrightnessPercent => MathF.Round(_lineDivisionBrightness * 100 / 255.0f, 2); public short TextXOffset { diff --git a/UVtools.Core/Operations/OperationCalibrateStressTower.cs b/UVtools.Core/Operations/OperationCalibrateStressTower.cs index f490b8e5..8f0faaac 100644 --- a/UVtools.Core/Operations/OperationCalibrateStressTower.cs +++ b/UVtools.Core/Operations/OperationCalibrateStressTower.cs @@ -49,8 +49,6 @@ public sealed class OperationCalibrateStressTower : Operation public override bool CanROI => false; - public override bool CanCancel => false; - public override LayerRangeSelection StartLayerRangeSelection => LayerRangeSelection.None; public override string IconClass => "fa-solid fa-chess-rook"; public override string Title => "Stress tower"; @@ -291,122 +289,102 @@ public override bool Equals(object? obj) #endregion #region Methods - public Mat[] GetLayers() + public Mat GetThumbnail() { - var layers = new Mat[LayerCount]; - - Slicer.Slicer slicer = new(SlicerFile.Resolution, new SizeF((float) DisplayWidth, (float) DisplayHeight)); + Mat thumbnail = EmguExtensions.InitMat(new Size(400, 200), 3); + var fontFace = FontFace.HersheyDuplex; + var fontScale = 1; + var fontThickness = 2; + const byte xSpacing = 45; + const byte ySpacing = 45; + CvInvoke.PutText(thumbnail, "UVtools", new Point(140, 35), fontFace, fontScale, new MCvScalar(255, 27, 245), fontThickness + 1); + CvInvoke.Line(thumbnail, new Point(xSpacing, 0), new Point(xSpacing, ySpacing + 5), new MCvScalar(255, 27, 245), 3); + CvInvoke.Line(thumbnail, new Point(xSpacing, ySpacing + 5), new Point(thumbnail.Width - xSpacing, ySpacing + 5), new MCvScalar(255, 27, 245), 3); + CvInvoke.Line(thumbnail, new Point(thumbnail.Width - xSpacing, 0), new Point(thumbnail.Width - xSpacing, ySpacing + 5), new MCvScalar(255, 27, 245), 3); + CvInvoke.PutText(thumbnail, "Stress Tower", new Point(xSpacing, ySpacing * 2), fontFace, fontScale, new MCvScalar(0, 255, 255), fontThickness); + CvInvoke.PutText(thumbnail, $"{Microns}um @ {BottomExposure}s/{NormalExposure}s", new Point(xSpacing, ySpacing * 3), fontFace, fontScale, EmguExtensions.WhiteColor, fontThickness); + CvInvoke.PutText(thumbnail, $"{_spirals} Spirals @ {_spiralAngleStepPerLayer}deg", new Point(xSpacing, ySpacing * 4), fontFace, fontScale, EmguExtensions.WhiteColor, fontThickness); + return thumbnail; + } + + protected override bool ExecuteInternally(OperationProgress progress) + { + progress.ItemCount = LayerCount; + + Slicer.Slicer slicer = new(SlicerFile.Resolution, new SizeF((float)DisplayWidth, (float)DisplayHeight)); Point center = new(SlicerFile.Resolution.Width / 2, SlicerFile.Resolution.Height / 2); uint baseRadius = slicer.PixelsFromMillimeters(_baseDiameter) / 2; uint baseLayers = (ushort)(_baseHeight / _layerHeight); uint bodyLayers = (ushort)(_bodyHeight / _layerHeight); uint spiralLayers = (uint)(_spiralDiameter / _layerHeight); uint ceilLayers = (ushort)(_ceilHeight / _layerHeight); - uint currrentlayer = baseLayers; + + uint basePlusBodyLayers = baseLayers + bodyLayers; decimal spiralOffsetAngle = 360m / _spirals; uint spiralRadius = slicer.PixelsFromMillimeters(_spiralDiameter) / 2; + var flip = SlicerFile.DisplayMirror; + if (flip == FlipDirection.None) flip = FlipDirection.Horizontally; + /*const FontFace fontFace = FontFace.HersheyDuplex; const double fontScale = 1; const byte fontThickness = 2; LineType lineType = _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected; var kernel = CvInvoke.GetStructuringElement(ElementShape.Rectangle, new Size(3, 3), EmguExtensions.AnchorCenter);*/ - Parallel.For(0, LayerCount, CoreSettings.ParallelOptions, layerIndex => - { - layers[layerIndex] = EmguExtensions.InitMat(SlicerFile.Resolution); - }); - - Parallel.For(0, baseLayers, CoreSettings.ParallelOptions, layerIndex => - { - int chamferOffset = (int) Math.Max(0, _chamferLayers - layerIndex); - CvInvoke.Circle(layers[layerIndex], center, (int) baseRadius - chamferOffset, EmguExtensions.WhiteColor, -1, _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected); - }); - + SlicerFile.Init(LayerCount); - Parallel.For(0, baseLayers+bodyLayers, CoreSettings.ParallelOptions, layerIndex => + Parallel.For(0, LayerCount, CoreSettings.GetParallelDebugOptions(progress), layerIndex => { - decimal angle = (layerIndex * _spiralAngleStepPerLayer) % 360m; - for (byte spiral = 0; spiral < _spirals; spiral++) + progress.PauseIfRequested(); + using var mat = SlicerFile.CreateMat(); + + if (layerIndex < baseLayers) { - decimal spiralAngle = (spiralOffsetAngle * spiral + angle) % 360; - if (_spiralDirection == SpiralDirections.Alternate && spiral % 2 == 0) + int chamferOffset = (int)Math.Max(0, _chamferLayers - layerIndex); + CvInvoke.Circle(mat, center, (int)baseRadius - chamferOffset, EmguExtensions.WhiteColor, -1, _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected); + } + else if (layerIndex < basePlusBodyLayers) + { + decimal angle = (layerIndex * _spiralAngleStepPerLayer) % 360m; + + for (byte spiral = 0; spiral < _spirals; spiral++) { - spiralAngle = -spiralAngle; - } - Point location = center with {X = (int) (center.X - baseRadius + spiralRadius)}; - var locationCW = location.Rotate((double) spiralAngle, center); - var locationCCW = location.Rotate((double) -spiralAngle, center); + decimal spiralAngle = (spiralOffsetAngle * spiral + angle) % 360; + if (_spiralDirection == SpiralDirections.Alternate && spiral % 2 == 0) + { + spiralAngle = -spiralAngle; + } + Point location = center with { X = (int)(center.X - baseRadius + spiralRadius) }; + var locationCW = location.Rotate((double)spiralAngle, center); + var locationCCW = location.Rotate((double)-spiralAngle, center); - uint maxLayer = (uint) Math.Min(layerIndex + spiralLayers, baseLayers + bodyLayers); + uint maxLayer = (uint)Math.Min(layerIndex + spiralLayers, baseLayers + bodyLayers); - for (uint spiralLayerIndex = (uint) layerIndex; spiralLayerIndex < maxLayer; spiralLayerIndex++) - { - CvInvoke.Circle(layers[spiralLayerIndex], locationCW, (int)spiralRadius, EmguExtensions.WhiteColor, -1, _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected); + //for (uint spiralLayerIndex = (uint)layerIndex; spiralLayerIndex < maxLayer; spiralLayerIndex++) + //{ + + CvInvoke.Circle(mat, locationCW, (int)spiralRadius, EmguExtensions.WhiteColor, -1, _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected); if (_spiralDirection == SpiralDirections.Both) { spiralAngle = -spiralAngle; - CvInvoke.Circle(layers[spiralLayerIndex], locationCCW, (int)spiralRadius, EmguExtensions.WhiteColor, -1, _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected); + CvInvoke.Circle(mat, locationCCW, (int)spiralRadius, EmguExtensions.WhiteColor, -1, _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected); } + //} } } - }); - - currrentlayer += bodyLayers; - - Parallel.For(0, ceilLayers, CoreSettings.ParallelOptions, i => - { - uint layerIndex = (uint)(currrentlayer + i); - CvInvoke.Circle(layers[layerIndex], center, (int)baseRadius, EmguExtensions.WhiteColor, -1, _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected); - }); - - - - if (_mirrorOutput) - { - var flip = SlicerFile.DisplayMirror; - if (flip == FlipDirection.None) flip = FlipDirection.Horizontally; - Parallel.ForEach(layers, CoreSettings.ParallelOptions, mat => CvInvoke.Flip(mat, mat, (FlipType)flip)); - } - - return layers; - } - - public Mat GetThumbnail() - { - Mat thumbnail = EmguExtensions.InitMat(new Size(400, 200), 3); - var fontFace = FontFace.HersheyDuplex; - var fontScale = 1; - var fontThickness = 2; - const byte xSpacing = 45; - const byte ySpacing = 45; - CvInvoke.PutText(thumbnail, "UVtools", new Point(140, 35), fontFace, fontScale, new MCvScalar(255, 27, 245), fontThickness + 1); - CvInvoke.Line(thumbnail, new Point(xSpacing, 0), new Point(xSpacing, ySpacing + 5), new MCvScalar(255, 27, 245), 3); - CvInvoke.Line(thumbnail, new Point(xSpacing, ySpacing + 5), new Point(thumbnail.Width - xSpacing, ySpacing + 5), new MCvScalar(255, 27, 245), 3); - CvInvoke.Line(thumbnail, new Point(thumbnail.Width - xSpacing, 0), new Point(thumbnail.Width - xSpacing, ySpacing + 5), new MCvScalar(255, 27, 245), 3); - CvInvoke.PutText(thumbnail, "Stress Tower", new Point(xSpacing, ySpacing * 2), fontFace, fontScale, new MCvScalar(0, 255, 255), fontThickness); - CvInvoke.PutText(thumbnail, $"{Microns}um @ {BottomExposure}s/{NormalExposure}s", new Point(xSpacing, ySpacing * 3), fontFace, fontScale, EmguExtensions.WhiteColor, fontThickness); - CvInvoke.PutText(thumbnail, $"{_spirals} Spirals @ {_spiralAngleStepPerLayer}deg", new Point(xSpacing, ySpacing * 4), fontFace, fontScale, EmguExtensions.WhiteColor, fontThickness); - return thumbnail; - } - - protected override bool ExecuteInternally(OperationProgress progress) - { - progress.ItemCount = LayerCount; - var newLayers = new Layer[LayerCount]; + else + { + CvInvoke.Circle(mat, center, (int)baseRadius, EmguExtensions.WhiteColor, -1, _enableAntiAliasing ? LineType.AntiAlias : LineType.EightConnected); + } - var layers = GetLayers(); + if (_mirrorOutput) CvInvoke.Flip(mat, mat, (FlipType)flip); - Parallel.For(0, LayerCount, CoreSettings.GetParallelOptions(progress), layerIndex => - { - progress.PauseIfRequested(); - newLayers[layerIndex] = new Layer((uint)layerIndex, layers[layerIndex], SlicerFile) {IsModified = true}; - layers[layerIndex].Dispose(); + SlicerFile[layerIndex] = new Layer((uint)layerIndex, mat, SlicerFile); progress.LockAndIncrement(); }); - if (SlicerFile.ThumbnailsCount > 0) { using var thumbnail = GetThumbnail(); @@ -419,7 +397,6 @@ protected override bool ExecuteInternally(OperationProgress progress) SlicerFile.BottomExposureTime = (float)BottomExposure; SlicerFile.ExposureTime = (float)NormalExposure; SlicerFile.BottomLayerCount = BottomLayers; - SlicerFile.Layers = newLayers; }, true); return !progress.Token.IsCancellationRequested; diff --git a/UVtools.Core/Operations/OperationChangeResolution.cs b/UVtools.Core/Operations/OperationChangeResolution.cs index 0c91c6e9..662ab96b 100644 --- a/UVtools.Core/Operations/OperationChangeResolution.cs +++ b/UVtools.Core/Operations/OperationChangeResolution.cs @@ -157,10 +157,10 @@ public decimal NewDisplayHeight public SizeF NewPixelSizeMicrons => new (_newResolutionX <= 0 || SlicerFile.Display.Width <= 0 || _newDisplayWidth <= 0 ? SlicerFile.PixelWidthMicrons - : (float) Math.Round((float) _newDisplayWidth / _newResolutionX * 1000, 3), + : MathF.Round((float) _newDisplayWidth / _newResolutionX * 1000, 3), _newResolutionY <= 0 || SlicerFile.Display.Height <= 0 || _newDisplayHeight <= 0 ? SlicerFile.PixelHeightMicrons - : (float) Math.Round((float) _newDisplayHeight / _newResolutionY * 1000, 3)); + : MathF.Round((float) _newDisplayHeight / _newResolutionY * 1000, 3)); public double NewFixedRatioX { diff --git a/UVtools.Core/Operations/OperationDynamicLifts.cs b/UVtools.Core/Operations/OperationDynamicLifts.cs index e951879c..e16a67f7 100644 --- a/UVtools.Core/Operations/OperationDynamicLifts.cs +++ b/UVtools.Core/Operations/OperationDynamicLifts.cs @@ -137,49 +137,49 @@ public DynamicLiftsSetMethod SetMethod public float SmallestBottomLiftHeight { get => _smallestBottomLiftHeight; - set => RaiseAndSetIfChanged(ref _smallestBottomLiftHeight, (float)Math.Round(value, 2)); + set => RaiseAndSetIfChanged(ref _smallestBottomLiftHeight, MathF.Round(value, 2)); } public float LargestBottomLiftHeight { get => _largestBottomLiftHeight; - set => RaiseAndSetIfChanged(ref _largestBottomLiftHeight, (float)Math.Round(value, 2)); + set => RaiseAndSetIfChanged(ref _largestBottomLiftHeight, MathF.Round(value, 2)); } public float SmallestLiftHeight { get => _smallestLiftHeight; - set => RaiseAndSetIfChanged(ref _smallestLiftHeight, (float)Math.Round(value, 2)); + set => RaiseAndSetIfChanged(ref _smallestLiftHeight, MathF.Round(value, 2)); } public float LargestLiftHeight { get => _largestLiftHeight; - set => RaiseAndSetIfChanged(ref _largestLiftHeight, (float)Math.Round(value, 2)); + set => RaiseAndSetIfChanged(ref _largestLiftHeight, MathF.Round(value, 2)); } public float SlowestBottomLiftSpeed { get => _slowestBottomLiftSpeed; - set => RaiseAndSetIfChanged(ref _slowestBottomLiftSpeed, (float)Math.Round(value, 2)); + set => RaiseAndSetIfChanged(ref _slowestBottomLiftSpeed, MathF.Round(value, 2)); } public float FastestBottomLiftSpeed { get => _fastestBottomLiftSpeed; - set => RaiseAndSetIfChanged(ref _fastestBottomLiftSpeed, (float)Math.Round(value, 2)); + set => RaiseAndSetIfChanged(ref _fastestBottomLiftSpeed, MathF.Round(value, 2)); } public float SlowestLiftSpeed { get => _slowestLiftSpeed; - set => RaiseAndSetIfChanged(ref _slowestLiftSpeed, (float)Math.Round(value, 2)); + set => RaiseAndSetIfChanged(ref _slowestLiftSpeed, MathF.Round(value, 2)); } public float FastestLiftSpeed { get => _fastestLiftSpeed; - set => RaiseAndSetIfChanged(ref _fastestLiftSpeed, (float)Math.Round(value, 2)); + set => RaiseAndSetIfChanged(ref _fastestLiftSpeed, MathF.Round(value, 2)); } //public uint MinBottomLayerPixels => SlicerFile.Where(layer => layer.IsBottomLayer && !layer.IsEmpty && layer.Index >= LayerIndexStart && layer.Index <= LayerIndexEnd).Max(layer => layer.NonZeroPixelCount); @@ -341,8 +341,8 @@ protected override bool ExecuteInternally(OperationProgress progress) if (!float.IsNaN(liftHeight)) { setLayer.RetractHeight2 = 0; - setLayer.LiftHeightTotal = (float) Math.Round(liftHeight, 1); - if (!float.IsNaN(liftSpeed)) setLayer.LiftSpeed = (float)Math.Round(liftSpeed, 1); + setLayer.LiftHeightTotal = MathF.Round(liftHeight, 1); + if (!float.IsNaN(liftSpeed)) setLayer.LiftSpeed = MathF.Round(liftSpeed, 1); } diff --git a/UVtools.Core/Operations/OperationLayerExportGif.cs b/UVtools.Core/Operations/OperationLayerExportGif.cs index 8fa06f70..e8e84f18 100644 --- a/UVtools.Core/Operations/OperationLayerExportGif.cs +++ b/UVtools.Core/Operations/OperationLayerExportGif.cs @@ -161,7 +161,7 @@ public ushort Skip public uint TotalLayers => (uint)(LayerRangeCount / (float) (_skip + 1)); public uint GifDurationMilliseconds => (uint)(TotalLayers * FPSToMilliseconds); - public float GifDurationSeconds => (float)Math.Round(GifDurationMilliseconds / 1000.0, 2); + public float GifDurationSeconds => MathF.Round(GifDurationMilliseconds / 1000.0f, 2); public decimal Scale { diff --git a/UVtools.Core/Operations/OperationLightBleedCompensation.cs b/UVtools.Core/Operations/OperationLightBleedCompensation.cs index 65c5061f..534a359b 100644 --- a/UVtools.Core/Operations/OperationLightBleedCompensation.cs +++ b/UVtools.Core/Operations/OperationLightBleedCompensation.cs @@ -142,7 +142,7 @@ public string DimBy } public int MinimumBrightness => 255 - MaximumSubtraction; - public float MinimumBrightnessPercentage => (float)Math.Round(MinimumBrightness * 100.0 / 255.0, 2); + public float MinimumBrightnessPercentage => MathF.Round(MinimumBrightness * 100 / 255.0f, 2); public int MaximumSubtraction => DimByArray.Aggregate(0, (current, dim) => current + dim); public byte[] DimByArray diff --git a/UVtools.Core/Operations/OperationPCBExposure.cs b/UVtools.Core/Operations/OperationPCBExposure.cs index 796bfa45..38629346 100644 --- a/UVtools.Core/Operations/OperationPCBExposure.cs +++ b/UVtools.Core/Operations/OperationPCBExposure.cs @@ -305,14 +305,14 @@ public void AddFiles(string[] files, bool handleZipFiles = true) public void Sort() => _files.Sort(); - public Mat GetMat(PCBExposureFile file) + public Mat GetMat(PCBExposureFile file, bool canMirror = true) { var mat = SlicerFile.CreateMat(); - DrawMat(file, mat); + DrawMat(file, mat, canMirror); return mat; } - public void DrawMat(PCBExposureFile file, Mat mat) + public void DrawMat(PCBExposureFile file, Mat mat, bool canMirror = true) { if (!file.Exists) return; @@ -331,7 +331,7 @@ public void DrawMat(PCBExposureFile file, Mat mat) var cropped = mat.CropByBounds(); if (_invertColor) CvInvoke.BitwiseNot(cropped, cropped); - if (_mirror) + if (_mirror && canMirror) { var flip = SlicerFile.DisplayMirror; if (flip == FlipDirection.None) flip = FlipDirection.Horizontally; @@ -353,36 +353,13 @@ protected override bool ExecuteInternally(OperationProgress progress) for (var i = 0; i < orderFiles.Length; i++) { - /*using var mat = GetMat(file); - - if (mergeMat is null) - { - mergeMat = mat.Clone(); - } - else - { - CvInvoke.Max(mergeMat, mat, mergeMat); - }*/ - - DrawMat(orderFiles[i], mergeMat); - + DrawMat(orderFiles[i], mergeMat, false); if (!_mergeFiles) { - if (i == 0) + using var mat = GetMat(orderFiles[i]); + if (CvInvoke.HasNonZero(mat)) { - if (CvInvoke.HasNonZero(mergeMat)) - { - layers.Add(new Layer(mergeMat, SlicerFile)); - } - } - else - { - using var mat = SlicerFile.CreateMat(); - DrawMat(orderFiles[i], mat); - if (CvInvoke.HasNonZero(mat)) - { - layers.Add(new Layer(mat, SlicerFile)); - } + layers.Add(new Layer(mat, SlicerFile)); } } @@ -393,6 +370,12 @@ protected override bool ExecuteInternally(OperationProgress progress) { if (CvInvoke.HasNonZero(mergeMat)) { + if (_mirror) + { + var flip = SlicerFile.DisplayMirror; + if (flip == FlipDirection.None) flip = FlipDirection.Horizontally; + CvInvoke.Flip(mergeMat, mergeMat, (FlipType)flip); + } layers.Add(new Layer(mergeMat, SlicerFile)); } } @@ -443,12 +426,6 @@ protected override bool ExecuteInternally(OperationProgress progress) } using var croppedMat = mergeMat.CropByBounds(20); - /*if (_mirror) - { - var flip = SlicerFile.DisplayMirror; - if (flip == FlipDirection.None) flip = FlipDirection.Horizontally; - CvInvoke.Flip(croppedMat, croppedMat, (FlipType)flip); - }*/ using var bgrMat = new Mat(); CvInvoke.CvtColor(croppedMat, bgrMat, ColorConversion.Gray2Bgr); SlicerFile.SetThumbnails(bgrMat); diff --git a/UVtools.Core/Operations/OperationPixelArithmetic.cs b/UVtools.Core/Operations/OperationPixelArithmetic.cs index f43c7cc4..a5a6f53f 100644 --- a/UVtools.Core/Operations/OperationPixelArithmetic.cs +++ b/UVtools.Core/Operations/OperationPixelArithmetic.cs @@ -391,7 +391,7 @@ public byte Value // 255 - 100 //value - x - public float ValuePercent => (float) Math.Round(_value * 100f / byte.MaxValue, 2); + public float ValuePercent => MathF.Round(_value * 100f / byte.MaxValue, 2); public bool ValueEnabled => _operator is not PixelArithmeticOperators.BitwiseNot diff --git a/UVtools.Core/Operations/OperationPixelDimming.cs b/UVtools.Core/Operations/OperationPixelDimming.cs index 795371f1..c36e86d2 100644 --- a/UVtools.Core/Operations/OperationPixelDimming.cs +++ b/UVtools.Core/Operations/OperationPixelDimming.cs @@ -239,7 +239,7 @@ public byte Brightness } } - public float BrightnessPercent => (float)Math.Round(_brightness * 100 / 255.0, 2); + public float BrightnessPercent => MathF.Round(_brightness * 100 / 255.0f, 2); public ushort InfillGenThickness diff --git a/UVtools.Core/Printer/Machine.cs b/UVtools.Core/Printer/Machine.cs index f2cbb318..aad60e5d 100644 --- a/UVtools.Core/Printer/Machine.cs +++ b/UVtools.Core/Printer/Machine.cs @@ -151,12 +151,12 @@ public override string ToString() /// /// Gets the pixel width in millimeters /// - public float PixelWidth => DisplayWidth > 0 && ResolutionX > 0 ? (float)Math.Round(DisplayWidth / ResolutionX, 3) : 0; + public float PixelWidth => DisplayWidth > 0 && ResolutionX > 0 ? MathF.Round(DisplayWidth / ResolutionX, 3) : 0; /// /// Gets the pixel height in millimeters /// - public float PixelHeight => DisplayHeight > 0 && ResolutionY > 0 ? (float)Math.Round(DisplayHeight / ResolutionY, 3) : 0; + public float PixelHeight => DisplayHeight > 0 && ResolutionY > 0 ? MathF.Round(DisplayHeight / ResolutionY, 3) : 0; /// /// Gets the pixel size in millimeters @@ -176,12 +176,12 @@ public override string ToString() /// /// Gets the pixel width in microns /// - public float PixelWidthMicrons => DisplayWidth > 0 ? (float)Math.Round(DisplayWidth / ResolutionX * 1000, 3) : 0; + public float PixelWidthMicrons => DisplayWidth > 0 ? MathF.Round(DisplayWidth / ResolutionX * 1000, 3) : 0; /// /// Gets the pixel height in microns /// - public float PixelHeightMicrons => DisplayHeight > 0 ? (float)Math.Round(DisplayHeight / ResolutionY * 1000, 3) : 0; + public float PixelHeightMicrons => DisplayHeight > 0 ? MathF.Round(DisplayHeight / ResolutionY * 1000, 3) : 0; /// /// Gets the pixel size in microns diff --git a/UVtools.Core/Slicer/LinAlgUtils.cs b/UVtools.Core/Slicer/LinAlgUtils.cs index af07d6ca..0873a86f 100644 --- a/UVtools.Core/Slicer/LinAlgUtils.cs +++ b/UVtools.Core/Slicer/LinAlgUtils.cs @@ -84,7 +84,7 @@ public static float CalculateDimensionalValueAtIndex(PointF p1, PointF p2, float var slope = (p1.Y - p2.Y) / (p1.X - p2.X); var intercept = p1.Y - (slope * p1.X); var rawVal = slope * z + intercept; - return (float)Math.Round(rawVal, precision); + return MathF.Round(rawVal, precision); // using floats we end up with some infinitesimal rounding errors, // so we need to set the precision to something reasonable. Default is 1/100th of a micron // I'm sure there's a better way than converting it to a string and then back to a float, diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj index 6381ba9c..f9b3ebea 100644 --- a/UVtools.Core/UVtools.Core.csproj +++ b/UVtools.Core/UVtools.Core.csproj @@ -23,10 +23,10 @@ - + - - + + @@ -36,7 +36,7 @@ - + diff --git a/UVtools.UI/Controls/Tools/ToolScriptingControl.axaml.cs b/UVtools.UI/Controls/Tools/ToolScriptingControl.axaml.cs index e81c43c5..b373bc4d 100644 --- a/UVtools.UI/Controls/Tools/ToolScriptingControl.axaml.cs +++ b/UVtools.UI/Controls/Tools/ToolScriptingControl.axaml.cs @@ -417,7 +417,7 @@ public void ReloadGUI() valueProperty.Subscribe(new AnonymousObserver(value => { if(!value.HasValue) return; - numFLOAT.Value = (float)Math.Round((float)value, numFLOAT.DecimalPlates); + numFLOAT.Value = MathF.Round((float)value, numFLOAT.DecimalPlates); control.Value = (decimal)numFLOAT.Value; })); diff --git a/UVtools.UI/MainWindow.Information.cs b/UVtools.UI/MainWindow.Information.cs index 330adf03..6b7bb623 100644 --- a/UVtools.UI/MainWindow.Information.cs +++ b/UVtools.UI/MainWindow.Information.cs @@ -68,7 +68,7 @@ public void InitInformation() { if (e.EditAction == DataGridEditAction.Cancel) return; if (!(e.Row.DataContext is StringTag stringTag)) return; - if (float.TryParse(stringTag.TagString, out var result)) return; + if (float.TryParse(stringTag.TagString, CultureInfo.InvariantCulture, out var result)) return; e.Cancel = true; }; CurrentLayerGrid.RowEditEnded += (sender, e) => diff --git a/UVtools.UI/MainWindow.LayerPreview.cs b/UVtools.UI/MainWindow.LayerPreview.cs index 498361c8..8d2b8437 100644 --- a/UVtools.UI/MainWindow.LayerPreview.cs +++ b/UVtools.UI/MainWindow.LayerPreview.cs @@ -694,10 +694,10 @@ public RectangleF ROIMillimeters var pixelSize = SlicerFile!.PixelSize; if(roi.IsEmpty || pixelSize.IsEmpty) return RectangleF.Empty; return new RectangleF( - (float)Math.Round(roi.X * pixelSize.Width, 2), - (float)Math.Round(roi.Y * pixelSize.Height, 2), - (float)Math.Round(roi.Width * pixelSize.Width, 2), - (float)Math.Round(roi.Height * pixelSize.Height, 2)); + MathF.Round(roi.X * pixelSize.Width, 2), + MathF.Round(roi.Y * pixelSize.Height, 2), + MathF.Round(roi.Width * pixelSize.Width, 2), + MathF.Round(roi.Height * pixelSize.Height, 2)); } } diff --git a/UVtools.UI/MainWindow.axaml.cs b/UVtools.UI/MainWindow.axaml.cs index b8a434f8..cd7bc143 100644 --- a/UVtools.UI/MainWindow.axaml.cs +++ b/UVtools.UI/MainWindow.axaml.cs @@ -14,6 +14,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; @@ -1386,14 +1387,13 @@ private void UpdateTitle() Title = _titleStringBuilder.ToString(); } - public async void ProcessFiles(string[] files, bool openNewWindow = false, FileFormat.FileDecodeType fileDecodeType = FileFormat.FileDecodeType.Full) + public async Task ProcessFiles(string[] files, bool openNewWindow = false, FileFormat.FileDecodeType fileDecodeType = FileFormat.FileDecodeType.Full) { if (files.Length == 0) return; - if (files.All(s => OperationPCBExposure.ValidExtensions.Any(extension => s.EndsWith($".{extension}", StringComparison.OrdinalIgnoreCase)))) + if (IsFileLoaded && files.All(s => OperationPCBExposure.ValidExtensions.Any(extension => s.EndsWith($".{extension}", StringComparison.OrdinalIgnoreCase)))) { - if (!IsFileLoaded) return; - var operation = new OperationPCBExposure(); + var operation = new OperationPCBExposure(SlicerFile!); operation.AddFiles(files); if (operation.Count == 0) return; if ((_globalModifiers & KeyModifiers.Shift) != 0) await RunOperation(operation); diff --git a/build/cvextern.ps1 b/build/cvextern.ps1 index 5d83f7bb..bf690f45 100644 --- a/build/cvextern.ps1 +++ b/build/cvextern.ps1 @@ -12,7 +12,7 @@ $libFolder = 'emgucv' $buildFile = "platforms\windows\Build_Binary_x86.bat" $buildArgs = '64 mini commercial no-openni no-doc no-package build' -$customBuild = '-DWITH_EIGEN:BOOL=FALSE -DWITH_MSMF:BOOL=FALSE -DWITH_DSHOW:BOOL=FALSE -DWITH_FFMPEG:BOOL=FALSE -DWITH_GSTREAMER:BOOL=FALSE -DWITH_1394:BOOL=FALSE -DVIDEOIO_ENABLE_PLUGINS:BOOL=FALSE -DWITH_PROTOBUF:BOOL=FALSE -DBUILD_PROTOBUF:BOOL=FALSE' +$customBuild = '-DWITH_EIGEN:BOOL=FALSE -DWITH_MSMF:BOOL=FALSE -DWITH_DSHOW:BOOL=FALSE -DWITH_FFMPEG:BOOL=FALSE -DWITH_GSTREAMER:BOOL=FALSE -DWITH_1394:BOOL=FALSE -DVIDEOIO_ENABLE_PLUGINS:BOOL=FALSE -DBUILD_opencv_videoio:BOOL=FALSE -DBUILD_opencv_gapi:BOOL=FALSE -DWITH_PROTOBUF:BOOL=FALSE -DBUILD_PROTOBUF:BOOL=FALSE' if ($args.Count -gt 0){ if($args[0] -eq 'clean'){ diff --git a/build/libcvextern.sh b/build/libcvextern.sh index 3bfa6c53..1a3ef8f0 100644 --- a/build/libcvextern.sh +++ b/build/libcvextern.sh @@ -196,9 +196,7 @@ else # Linux -DBUILD_opencv_videoio:BOOL=FALSE \\\\\\ -DBUILD_opencv_gapi:BOOL=FALSE \\\\\\ -DWITH_PROTOBUF:BOOL=FALSE \\\\\\ - -DBUILD_PROTOBUF:BOOL=FALSE \\\\\\ - -DWITH_TBB:BOOL=TRUE \\\\\\ - -DBUILD_TBB:BOOL=TRUE/g" "$directory/platforms/ubuntu/24.04/cmake_configure" 2>/dev/null + -DBUILD_PROTOBUF:BOOL=FALSE /g" "$directory/platforms/ubuntu/24.04/cmake_configure" 2>/dev/null fi "$directory/platforms/ubuntu/24.04/cmake_configure" $build_package fi diff --git a/build/platforms/linux-arm64/libcvextern.so b/build/platforms/linux-arm64/libcvextern.so index ec5671cb..99375d87 100644 Binary files a/build/platforms/linux-arm64/libcvextern.so and b/build/platforms/linux-arm64/libcvextern.so differ diff --git a/build/platforms/linux-x64/libcvextern.so b/build/platforms/linux-x64/libcvextern.so index 2ccc6e68..18baa1f9 100644 Binary files a/build/platforms/linux-x64/libcvextern.so and b/build/platforms/linux-x64/libcvextern.so differ diff --git a/build/platforms/linux-x64/ubuntu_x64_version_string.inc b/build/platforms/linux-x64/ubuntu_x64_version_string.inc index 9ba8db03..9e55f01c 100644 --- a/build/platforms/linux-x64/ubuntu_x64_version_string.inc +++ b/build/platforms/linux-x64/ubuntu_x64_version_string.inc @@ -1,13 +1,13 @@ "\n" -"General configuration for OpenCV 4.9.0 =====================================\n" -" Version control: 4.9.0-265-g79534d600a\n" +"General configuration for OpenCV 4.10.0 =====================================\n" +" Version control: 3.4.2-10289-g3beff6e6c5\n" "\n" " Platform:\n" -" Timestamp: 2024-07-30T19:23:31Z\n" -" Host: Linux 5.15.0-94-generic x86_64\n" -" CMake: 3.16.3\n" +" Timestamp: 2025-01-18T05:18:45Z\n" +" Host: Linux 6.8.0-51-generic x86_64\n" +" CMake: 3.28.3\n" " CMake generator: Unix Makefiles\n" -" CMake build tool: /usr/bin/make\n" +" CMake build tool: /usr/bin/gmake\n" " Configuration: Release\n" "\n" " CPU/HW features:\n" @@ -25,7 +25,7 @@ " C/C++:\n" " Built as dynamic libs?: NO\n" " C++ standard: 17\n" -" C++ Compiler: /usr/bin/c++ (ver 9.4.0)\n" +" C++ Compiler: /usr/bin/c++ (ver 13.3.0)\n" " C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG\n" " C++ flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG\n" " C Compiler: /usr/bin/cc\n" @@ -39,10 +39,10 @@ " 3rdparty dependencies: ittnotify libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf zlib ippiw ippicv\n" "\n" " OpenCV modules:\n" -" To be built: core highgui imgcodecs imgproc videoio\n" -" Disabled: dnn features2d flann gapi ml photo python3 video world\n" +" To be built: core highgui imgcodecs imgproc\n" +" Disabled: dnn features2d flann gapi ml photo video videoio world\n" " Disabled by dependency: calib3d objdetect stitching\n" -" Unavailable: java python2 ts\n" +" Unavailable: java python2 python3 ts\n" " Applications: -\n" " Documentation: NO\n" " Non-free algorithms: NO\n" @@ -52,13 +52,15 @@ " VTK support: NO\n" "\n" " Media I/O: \n" -" ZLib: build (ver 1.3)\n" -" JPEG: build-libjpeg-turbo (ver 2.1.3-62)\n" +" ZLib: build (ver 1.3.1)\n" +" JPEG: build-libjpeg-turbo (ver 3.0.3-70)\n" " SIMD Support Request: YES\n" " SIMD Support: NO\n" " WEBP: build (ver encoder: 0x020f)\n" -" PNG: build (ver 1.6.37)\n" -" TIFF: build (ver 42 - 4.2.0)\n" +" PNG: build (ver 1.6.43)\n" +" SIMD Support Request: YES\n" +" SIMD Support: YES (Intel SSE)\n" +" TIFF: build (ver 42 - 4.6.0)\n" " JPEG 2000: build (ver 2.5.0)\n" " OpenEXR: build (ver 2.3.0)\n" " HDR: YES\n" @@ -73,21 +75,21 @@ " Trace: YES (with Intel ITT)\n" "\n" " Other third-party libraries:\n" -" Intel IPP: 2021.10.0 [2021.10.0]\n" -" at: /home/tiago/Desktop/emgucv-4.9.0/platforms/ubuntu/22.04/build/opencv/3rdparty/ippicv/ippicv_lnx/icv\n" -" Intel IPP IW: sources (2021.10.0)\n" -" at: /home/tiago/Desktop/emgucv-4.9.0/platforms/ubuntu/22.04/build/opencv/3rdparty/ippicv/ippicv_lnx/iw\n" +" Intel IPP: 2021.11.0 [2021.11.0]\n" +" at: /home/tiago/Desktop/emgucv/platforms/ubuntu/24.04/build/opencv/3rdparty/ippicv/ippicv_lnx/icv\n" +" Intel IPP IW: sources (2021.11.0)\n" +" at: /home/tiago/Desktop/emgucv/platforms/ubuntu/24.04/build/opencv/3rdparty/ippicv/ippicv_lnx/iw\n" " VA: NO\n" " Lapack: NO\n" " Custom HAL: NO\n" " Flatbuffers: builtin/3rdparty (23.5.9)\n" "\n" " OpenCL: YES (no extra features)\n" -" Include path: /home/tiago/Desktop/emgucv-4.9.0/opencv/3rdparty/include/opencl/1.2\n" +" Include path: /home/tiago/Desktop/emgucv/opencv/3rdparty/include/opencl/1.2\n" " Link libraries: Dynamic load\n" "\n" " Python (for build): /usr/bin/python3\n" "\n" -" Install to: /home/tiago/Desktop/emgucv-4.9.0/platforms/ubuntu/22.04/build/install\n" +" Install to: /home/tiago/Desktop/emgucv/platforms/ubuntu/24.04/build/install\n" "-----------------------------------------------------------------\n" "\n" diff --git a/build/platforms/osx-arm64/arm64_version_string.inc b/build/platforms/osx-arm64/Darwin_arm64_version_string.inc similarity index 69% rename from build/platforms/osx-arm64/arm64_version_string.inc rename to build/platforms/osx-arm64/Darwin_arm64_version_string.inc index fe4bdd73..6fdcd78a 100644 --- a/build/platforms/osx-arm64/arm64_version_string.inc +++ b/build/platforms/osx-arm64/Darwin_arm64_version_string.inc @@ -1,9 +1,9 @@ "\n" -"General configuration for OpenCV 4.9.0 =====================================\n" -" Version control: 3.4.2-9737-g79534d600a\n" +"General configuration for OpenCV 4.10.0 =====================================\n" +" Version control: 3.4.2-10289-g3beff6e6c5\n" "\n" " Platform:\n" -" Timestamp: 2024-05-10T19:00:51Z\n" +" Timestamp: 2025-01-27T19:56:05Z\n" " Host: Darwin 21.3.0 arm64\n" " CMake: 3.27.4\n" " CMake generator: Unix Makefiles\n" @@ -22,11 +22,11 @@ " Built as dynamic libs?: NO\n" " C++ standard: 11\n" " C++ Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ (ver 13.1.6.13160021)\n" -" C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG\n" -" C++ flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG\n" +" C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated-copy -O3 -DNDEBUG -DNDEBUG\n" +" C++ flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated-copy -g -O0 -DDEBUG -D_DEBUG\n" " C Compiler: /Library/Developer/CommandLineTools/usr/bin/cc\n" -" C flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG\n" -" C flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG\n" +" C flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG\n" +" C flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG\n" " Linker flags (Release): -Wl,-dead_strip \n" " Linker flags (Debug): -Wl,-dead_strip \n" " ccache: NO\n" @@ -48,12 +48,14 @@ " VTK support: NO\n" "\n" " Media I/O: \n" -" ZLib: build (ver 1.3)\n" -" JPEG: build-libjpeg-turbo (ver 2.1.3-62)\n" +" ZLib: build (ver 1.3.1)\n" +" JPEG: build-libjpeg-turbo (ver 3.0.3-70)\n" " SIMD Support Request: YES\n" " SIMD Support: YES\n" -" PNG: build (ver 1.6.37)\n" -" TIFF: build (ver 42 - 4.2.0)\n" +" PNG: build (ver 1.6.43)\n" +" SIMD Support Request: YES\n" +" SIMD Support: YES (Arm NEON)\n" +" TIFF: build (ver 42 - 4.6.0)\n" " JPEG 2000: build (ver 2.5.0)\n" " OpenEXR: build (ver 2.3.0)\n" " HDR: YES\n" @@ -95,6 +97,6 @@ " Java wrappers: NO\n" " Java tests: NO\n" "\n" -" Install to: /Users/carlospimenta/Desktop/emgucv/platforms/macos/build_arm64/install\n" +" Install to: /Users/carlospimenta/Desktop/emgucv-4.10.0/platforms/macos/build_arm64/install\n" "-----------------------------------------------------------------\n" "\n" diff --git a/build/platforms/osx-arm64/libcvextern.dylib b/build/platforms/osx-arm64/libcvextern.dylib index d0784a26..3adcf719 100644 Binary files a/build/platforms/osx-arm64/libcvextern.dylib and b/build/platforms/osx-arm64/libcvextern.dylib differ diff --git a/build/platforms/osx-x64/Darwin_x64_version_string.inc b/build/platforms/osx-x64/Darwin_x64_version_string.inc index d9f0528d..f6adcb1b 100644 --- a/build/platforms/osx-x64/Darwin_x64_version_string.inc +++ b/build/platforms/osx-x64/Darwin_x64_version_string.inc @@ -1,11 +1,11 @@ "\n" -"General configuration for OpenCV 4.9.0 =====================================\n" -" Version control: 3.4.2-9737-g79534d600a\n" +"General configuration for OpenCV 4.10.0 =====================================\n" +" Version control: 3.4.2-10289-g3beff6e6c5\n" "\n" " Platform:\n" -" Timestamp: 2024-05-10T19:41:29Z\n" -" Host: Darwin 19.6.0 x86_64\n" -" CMake: 3.20.5\n" +" Timestamp: 2025-01-17T23:11:46Z\n" +" Host: Darwin 21.6.0 x86_64\n" +" CMake: 3.31.4\n" " CMake generator: Unix Makefiles\n" " CMake build tool: /usr/bin/make\n" " Configuration: Release\n" @@ -24,12 +24,12 @@ " C/C++:\n" " Built as dynamic libs?: NO\n" " C++ standard: 11\n" -" C++ Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ (ver 12.0.0.12000032)\n" -" C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG\n" -" C++ flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG\n" +" C++ Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ (ver 14.0.0.14000029)\n" +" C++ flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated-copy -O3 -DNDEBUG -DNDEBUG\n" +" C++ flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -Wno-deprecated-copy -g -O0 -DDEBUG -D_DEBUG\n" " C Compiler: /Library/Developer/CommandLineTools/usr/bin/cc\n" -" C flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG\n" -" C flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winconsistent-missing-override -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG\n" +" C flags (Release): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG\n" +" C flags (Debug): -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Wno-long-long -Qunused-arguments -Wno-semicolon-before-method-body -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG\n" " Linker flags (Release): -Wl,-dead_strip \n" " Linker flags (Debug): -Wl,-dead_strip \n" " ccache: NO\n" @@ -51,12 +51,14 @@ " VTK support: NO\n" "\n" " Media I/O: \n" -" ZLib: build (ver 1.3)\n" -" JPEG: build-libjpeg-turbo (ver 2.1.3-62)\n" +" ZLib: build (ver 1.3.1)\n" +" JPEG: build-libjpeg-turbo (ver 3.0.3-70)\n" " SIMD Support Request: YES\n" " SIMD Support: NO\n" -" PNG: build (ver 1.6.37)\n" -" TIFF: build (ver 42 - 4.2.0)\n" +" PNG: build (ver 1.6.43)\n" +" SIMD Support Request: YES\n" +" SIMD Support: YES (Intel SSE)\n" +" TIFF: build (ver 42 - 4.6.0)\n" " JPEG 2000: build (ver 2.5.0)\n" " OpenEXR: build (ver 2.3.0)\n" " HDR: YES\n" @@ -98,6 +100,6 @@ " Java wrappers: NO\n" " Java tests: NO\n" "\n" -" Install to: /Users/tiago/Desktop/emgucv/platforms/macos/build_x86_64/install\n" +" Install to: /Users/tiago/Downloads/emgucv/platforms/macos/build_x86_64/install\n" "-----------------------------------------------------------------\n" "\n" diff --git a/build/platforms/osx-x64/libcvextern.dylib b/build/platforms/osx-x64/libcvextern.dylib index c37aea21..e247a4ad 100644 Binary files a/build/platforms/osx-x64/libcvextern.dylib and b/build/platforms/osx-x64/libcvextern.dylib differ diff --git a/build/platforms/win-x64/cvextern.dll b/build/platforms/win-x64/cvextern.dll index cebf2119..ea748a75 100644 Binary files a/build/platforms/win-x64/cvextern.dll and b/build/platforms/win-x64/cvextern.dll differ diff --git a/build/platforms/win-x64/version_string.inc b/build/platforms/win-x64/version_string.inc index 0d6b68f0..094abee1 100644 --- a/build/platforms/win-x64/version_string.inc +++ b/build/platforms/win-x64/version_string.inc @@ -1,14 +1,14 @@ "\n" -"General configuration for OpenCV 4.9.0 =====================================\n" -" Version control: 3.4.2-9737-g79534d600a\n" +"General configuration for OpenCV 4.10.0 =====================================\n" +" Version control: 3.4.2-10289-g3beff6e6c5\n" "\n" " Platform:\n" -" Timestamp: 2024-05-10T19:40:10Z\n" +" Timestamp: 2025-01-18T05:38:07Z\n" " Host: Windows 10.0.22631 AMD64\n" -" CMake: 3.28.0-msvc1\n" +" CMake: 3.29.5-msvc4\n" " CMake generator: Visual Studio 17 2022\n" " CMake build tool: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/MSBuild.exe\n" -" MSVC: 1939\n" +" MSVC: 1942\n" " Configuration: Debug Release MinSizeRel RelWithDebInfo\n" "\n" " CPU/HW features:\n" @@ -18,12 +18,12 @@ " C/C++:\n" " Built as dynamic libs?: NO\n" " C++ standard: 11\n" -" C++ Compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe (ver 19.39.33523.0)\n" -" C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /MD /O2 /Ob2 /DNDEBUG \n" -" C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /MDd /Zi /Ob0 /Od /RTC1 \n" -" C Compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe\n" -" C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /MP /MD /O2 /Ob2 /DNDEBUG \n" -" C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /MP /MDd /Zi /Ob0 /Od /RTC1 \n" +" C++ Compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe (ver 19.42.34436.0)\n" +" C++ flags (Release): /DWIN32 /D_WINDOWS /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /O2 /Ob2 /DNDEBUG \n" +" C++ flags (Debug): /DWIN32 /D_WINDOWS /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /wd4819 /MP /Zi /Ob0 /Od /RTC1 \n" +" C Compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe\n" +" C flags (Release): /DWIN32 /D_WINDOWS /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /MP /O2 /Ob2 /DNDEBUG \n" +" C flags (Debug): /DWIN32 /D_WINDOWS /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /MP /Zi /Ob0 /Od /RTC1 \n" " Linker flags (Release): /machine:x64 /INCREMENTAL:NO \n" " Linker flags (Debug): /machine:x64 /debug /INCREMENTAL \n" " ccache: NO\n" @@ -32,11 +32,11 @@ " 3rdparty dependencies: ittnotify libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf zlib ippiw ippicv\n" "\n" " OpenCV modules:\n" -" To be built: core highgui imgcodecs imgproc ts videoio\n" -" Disabled: dnn features2d flann gapi ml photo python3 python_bindings_generator python_tests video world\n" -" Disabled by dependency: calib3d objdetect stitching\n" +" To be built: core highgui imgcodecs imgproc\n" +" Disabled: dnn features2d flann gapi ml photo python3 python_bindings_generator python_tests video videoio world\n" +" Disabled by dependency: calib3d objdetect stitching ts\n" " Unavailable: java python2\n" -" Applications: perf_tests\n" +" Applications: -\n" " Documentation: NO\n" " Non-free algorithms: NO\n" "\n" @@ -47,13 +47,15 @@ " VTK support: NO\n" "\n" " Media I/O: \n" -" ZLib: build (ver 1.3)\n" -" JPEG: build-libjpeg-turbo (ver 2.1.3-62)\n" +" ZLib: build (ver 1.3.1)\n" +" JPEG: build-libjpeg-turbo (ver 3.0.3-70)\n" " SIMD Support Request: YES\n" " SIMD Support: NO\n" " WEBP: build (ver encoder: 0x020f)\n" -" PNG: build (ver 1.6.37)\n" -" TIFF: build (ver 42 - 4.2.0)\n" +" PNG: build (ver 1.6.43)\n" +" SIMD Support Request: YES\n" +" SIMD Support: YES (Intel SSE)\n" +" TIFF: build (ver 42 - 4.6.0)\n" " JPEG 2000: build (ver 2.5.0)\n" " OpenEXR: build (ver 2.3.0)\n" " HDR: YES\n" diff --git a/documentation/UVtools.Core.xml b/documentation/UVtools.Core.xml index ed206401..f5ad15c7 100644 --- a/documentation/UVtools.Core.xml +++ b/documentation/UVtools.Core.xml @@ -951,7 +951,7 @@ The Excellon drill format is a subset of RS274D and is used by the drilling and routing machines made by the Excellon corporation. Because of Excellon's long history and dominance of the PCB drilling business for many years their format is a defacto industry standard. - Almost every PCB layout software can produce this format.However we have noticed that many PCB layout tools do not take + Almost every PCB layout software can produce this format. However we have noticed that many PCB layout tools do not take full advantage of the header information which makes reading the drill file more difficult than it should be. https://www.artwork.com/gerber/drl2laser/excellon/index.htm https://gist.github.com/katyo/5692b935abc085b1037e