Skip to content

Commit

Permalink
v4.2.3
Browse files Browse the repository at this point in the history
- (Add) Benchmark test: GC Memory Copy and Pooled Memory Copy
- (Add) Photon Mono M5s Pro (m5sp) support and corresponding PrusaSlicer printer (#842)
- (Add) Tool: Stir resin - Allow to stir the resin in the VAT by moving the build plate up and down multiple times (#839)
- (Improvement) Improve the dummy pixel location to match the first pixel of the layer (if possible)
- (Improvement) Better format for readable time from seconds, it now can show/hide days, hours, minutes and seconds when optimal
- (Improvement) The setting `MaxDegreeOfParallelism` is now used when calculating the batch size for the parallel operations under file decode and encode
- (Fix) Layer import: Unable to import layers from image files (#841)
  • Loading branch information
sn4k3 committed Feb 29, 2024
1 parent 64971d3 commit 5021e60
Show file tree
Hide file tree
Showing 70 changed files with 948 additions and 258 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 29/02/2024 - v4.2.3

- (Add) Benchmark test: GC Memory Copy and Pooled Memory Copy
- (Add) Photon Mono M5s Pro (m5sp) support and corresponding PrusaSlicer printer (#842)
- (Add) Tool: Stir resin - Allow to stir the resin in the VAT by moving the build plate up and down multiple times (#839)
- (Improvement) Improve the dummy pixel location to match the first pixel of the layer (if possible)
- (Improvement) Better format for readable time from seconds, it now can show/hide days, hours, minutes and seconds when optimal
- (Improvement) The setting `MaxDegreeOfParallelism` is now used when calculating the batch size for the parallel operations under file decode and encode
- (Fix) Layer import: Unable to import layers from image files (#841)

## 17/02/2024 - v4.2.2

- **UI:**
Expand Down
4 changes: 4 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

<PathMap>$(MSBuildProjectDirectory)=$(MSBuildProjectName)</PathMap>

<!-- Enable Build Acceleration in Visual Studio. -->
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>

<UVtoolsVersion>4.2.3</UVtoolsVersion>
<AvaloniaVersion>11.0.7</AvaloniaVersion>
</PropertyGroup>

Expand Down
44 changes: 44 additions & 0 deletions PrusaSlicer/printer/AnyCubic Photon Mono M5s Pro.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# generated by PrusaSlicer 2.7.1+win64 on 2024-02-29 at 00:07:42 UTC
absolute_correction = 0
area_fill = 50
bed_custom_model =
bed_custom_texture =
bed_shape = 0x0,223.64x0,223.64x126.976,0x126.976
default_sla_material_profile = Prusa Orange Tough 0.05
default_sla_print_profile = 0.05 Normal
display_height = 126.976
display_mirror_x = 1
display_mirror_y = 0
display_orientation = landscape
display_pixels_x = 13312
display_pixels_y = 5120
display_width = 223.642
elefant_foot_compensation = 0.2
elefant_foot_min_width = 0.2
fast_tilt_time = 5
gamma_correction = 1
high_viscosity_tilt_time = 10
host_type = octoprint
inherits = Original Prusa SL1
max_exposure_time = 120
max_initial_exposure_time = 300
max_print_height = 200
min_exposure_time = 1
min_initial_exposure_time = 1
print_host =
printer_model = SL1
printer_notes = Don't remove the following keywords! These keywords are used in the "compatible printer" condition of the print and filament profiles to link the particular print and filament profiles to this printer profile.\nPRINTER_VENDOR_PRUSA3D\nPRINTER_MODEL_SL1\nPRINTER_VENDOR_ANYCUBIC\nPRINTER_MODEL_PHOTON_MONO_M5S_PRO\nFILEVERSION_518\nFILEFORMAT_M5SP\n\nSTART_CUSTOM_VALUES\nWaitTimeBeforeCure_2.5\nBottomLiftHeight_8\nLiftHeight_8\nBottomLiftSpeed_120\nLiftSpeed_120\nRetractSpeed_120\nBottomLightPWM_255\nLightPWM_255\nEND_CUSTOM_VALUES
printer_settings_id =
printer_technology = SLA
printer_variant = default
printer_vendor =
printhost_apikey =
printhost_cafile =
relative_correction = 1,1
relative_correction_x = 1
relative_correction_y = 1
relative_correction_z = 1
sla_archive_format = SL1
sla_output_precision = 0.001
slow_tilt_time = 8
thumbnails = 224x168/PNG
22 changes: 7 additions & 15 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
- **UI:**
- (Add) Allow to drag and drop Gerber files into main window to open them in the PCB exposure tool (Hold SHIFT key to run the operation right away, without opening the tool dialog, it will run with the default settings)
- (Improvement) Drag and drop invalid files that are not recognized no longer closes the current file nor open new instances when multiple files are passed or when SHIFT is held
- **Pixel editor:**
- (Improvement) Line shape was producing one pixel more than required
- (Improvement) Make the shape preview more accurate with the actual real output and when defining a shape thickness instead of a fill
- (Improvement) Increase the accuracy of the shapes by passing float instead of int
- (Improvement) Make the square shape to be exactly the input brush size
- (Improvement) Dispose Skia drawing objects after draw the pixel editor shapes into the previewer
- (Improvement) Better performance and speed when rendering the layer image into the previewer
- (Improvement) Dispose cached data when layer changes into the previewer
- (Change) Layer image preview format from Bgr to Bgra (Added alpha channel, now 32 bits)
- (Fix) Calibration Blooming effect: All layers are being set with bottom exposure time (#481)
- (Upgrade) .NET from 6.0.26 to 6.0.27
- (Downgrade) AvaloniaUI from 11.0.9 to 11.0.7 (Fix #836 but may re-introduce others)
- (Add) Benchmark test: GC Memory Copy and Pooled Memory Copy
- (Add) Photon Mono M5s Pro (m5sp) support and corresponding PrusaSlicer printer (#842)
- (Add) Tool: Stir resin - Allow to stir the resin in the VAT by moving the build plate up and down multiple times (#839)
- (Improvement) Improve the dummy pixel location to match the first pixel of the layer (if possible)
- (Improvement) Better format for readable time from seconds, it now can show/hide days, hours, minutes and seconds when optimal
- (Improvement) The setting `MaxDegreeOfParallelism` is now used when calculating the batch size for the parallel operations under file decode and encode
- (Fix) Layer import: Unable to import layers from image files (#841)

8 changes: 6 additions & 2 deletions Scripts/UVtools.ScriptSample/ScriptVATClean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ public bool ScriptExecute()

Progress++;

SlicerFile.SetThumbnails(GetThumbnail());

if (SlicerFile.ThumbnailsCount > 0)
{
using var thumbnail = GetThumbnail();
SlicerFile.SetThumbnails(thumbnail);
}

// return true if not cancelled by user
return !Progress.Token.IsCancellationRequested;
}
Expand Down
2 changes: 1 addition & 1 deletion UVtools.Cmd/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal static void HandleGlobals()

if (arg == "--core-version")
{
Console.WriteLine(About.VersionStr);
Console.WriteLine(About.VersionString);
Environment.Exit(0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion UVtools.Cmd/Symbols/PrintIssuesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal static Command CreateCommand()
foreach (var issue in issues)
{
Console.WriteLine($"{issue.Type}, {issue.LayerInfoStr}, {issue.Area:F0}px{issue.AreaChar}, {issue.BoundingRectangle}");
Console.WriteLine($"{issue.Type}, {issue.LayerInfoString}, {issue.Area:F0}px{issue.AreaChar}, {issue.BoundingRectangle}");
}
});

Expand Down
6 changes: 3 additions & 3 deletions UVtools.Core/About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public static class About
{
public const string Software = "UVtools";
public static Version Version => CoreAssembly.GetName().Version!;
public static string VersionStr => Version.ToString(3);
public static string VersionArch => $"{VersionStr} {RuntimeInformation.ProcessArchitecture}";
public static string SoftwareWithVersion => $"{Software} v{VersionStr}";
public static string VersionString => Version.ToString(3);
public static string VersionArch => $"{VersionString} {RuntimeInformation.ProcessArchitecture}";
public static string SoftwareWithVersion => $"{Software} v{VersionString}";
public static string SoftwareWithVersionArch => $"{Software} v{VersionArch}";
public const string Author = "Tiago Conceição";
public const string License = "GNU Affero General Public License v3.0 (AGPL)";
Expand Down
17 changes: 17 additions & 0 deletions UVtools.Core/Extensions/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,21 @@ public static int Age(this DateTime birthDate, DateTime laterDate)

return age;
}

/// <summary>
/// Convert a <see cref="TimeSpan"/> to a string representation of the time
/// </summary>
/// <param name="timeSpan"></param>
/// <returns></returns>
public static string ToTimeString(this TimeSpan timeSpan)
{
var totalSeconds = timeSpan.TotalSeconds;
return totalSeconds switch
{
< 60 => $"{totalSeconds}s", // Less than a minute
< 3600 => timeSpan.ToString(@"mm\m\:ss\s"), // Less than an hour
< 86400 => timeSpan.ToString(@"hh\h\:mm\m\:ss\s"), // Less than a day
_ => timeSpan.ToString(@"dd\ \d\a\y\(\s\)\ hh\h\:mm\m\:ss\s")
};
}
}
22 changes: 16 additions & 6 deletions UVtools.Core/Extensions/EmguExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static class EmguExtensions
public static readonly MCvScalar BlackColor = new(0, 0, 0, 255);
//public static readonly MCvScalar TransparentColor = new();

public static readonly Point AnchorCenter = new (-1, -1);
public static readonly Point AnchorCenter = new(-1, -1);
public static readonly Mat Kernel3x3Rectangle = CvInvoke.GetStructuringElement(ElementShape.Rectangle, new Size(3, 3), AnchorCenter);

/// <summary>
Expand All @@ -56,19 +56,19 @@ public static class EmguExtensions
/// </summary>
/// <param name="mat"></param>
/// <returns>Blank byte array</returns>
public static byte[] CreateBlankByteArray(this Mat mat)
public static byte[] CreateByteArray(this Mat mat)
=> new byte[mat.GetLength()];

/// <summary>
/// Creates a new empty <see cref="Mat"/> with same size and type of the source
/// Creates a new <see cref="Mat"/> with same size and type of the source
/// </summary>
/// <param name="mat"></param>
/// <returns></returns>
public static Mat New(this Mat mat)
=> new(mat.Size, mat.Depth, mat.NumberOfChannels);

/// <summary>
/// Creates a new empty <see cref="Mat"/> with same size and type of the source
/// Creates a new <see cref="Mat"/> with same size and type of the source
/// </summary>
/// <param name="src"></param>
/// <param name="color"></param>
Expand Down Expand Up @@ -674,11 +674,21 @@ public static void CropByBounds(this Mat src, Mat dst)
/// <param name="destination">Destination address to copy data to</param>
public static void CopyTo(this Mat mat, IntPtr destination)
{
var totalBytes = (uint)mat.GetLength();
unsafe
{
Buffer.MemoryCopy(mat.DataPointer.ToPointer(), destination.ToPointer(), totalBytes, totalBytes);
if (mat.IsContinuous)
{
var totalBytes = (uint)mat.GetLength();
Buffer.MemoryCopy(mat.DataPointer.ToPointer(), destination.ToPointer(), totalBytes, totalBytes);
}
else
{
var srcSpan = mat.GetDataSpan2D<byte>();
var dstSpan = new Span<byte>(destination.ToPointer(), mat.GetLength());
srcSpan.CopyTo(dstSpan);
}
}

}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion UVtools.Core/Extensions/NetworkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class NetworkExtensions
{
public static readonly HttpClient HttpClient = new()
{
DefaultRequestHeaders = { UserAgent = { new ProductInfoHeaderValue(About.Software, About.VersionStr) } }
DefaultRequestHeaders = { UserAgent = { new ProductInfoHeaderValue(About.Software, About.VersionString) } }
};

public static async Task<HttpResponseMessage> DownloadAsync(this HttpClient client, string requestUri, Stream destination, IProgress<(long total, long bytes)>? progress = null, CancellationToken cancellationToken = default)
Expand Down
36 changes: 28 additions & 8 deletions UVtools.Core/FileFormats/FileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public abstract class FileFormat : BindableBase, IDisposable, IEquatable<FileFor
/// <summary>
/// Gets the default batch count to process layers in parallel
/// </summary>
public static int DefaultParallelBatchCount => Environment.ProcessorCount * 10;
public static int DefaultParallelBatchCount => (CoreSettings.MaxDegreeOfParallelism > 0 ? CoreSettings.MaxDegreeOfParallelism : Environment.ProcessorCount) * 10;

#endregion

Expand Down Expand Up @@ -3183,7 +3183,7 @@ public string PrintTimeString
/// <summary>
/// Gets the total time formatted in hours, minutes and seconds the display will remain on exposing the layers during the print
/// </summary>
public string DisplayTotalOnTimeString => TimeSpan.FromSeconds(DisplayTotalOnTime).ToString("hh\\hmm\\mss\\s");
public string DisplayTotalOnTimeString => TimeSpan.FromSeconds(DisplayTotalOnTime).ToTimeString();

/// <summary>
/// Gets the total time in seconds the display will remain off during the print.
Expand All @@ -3209,7 +3209,7 @@ public string DisplayTotalOffTimeString
get
{
var time = DisplayTotalOffTime;
return TimeSpan.FromSeconds(float.IsPositiveInfinity(time) || float.IsNaN(time) ? 0 : time).ToString("hh\\hmm\\mss\\s");
return TimeSpan.FromSeconds(float.IsPositiveInfinity(time) || float.IsNaN(time) ? 0 : time).ToTimeString();
}
}

Expand Down Expand Up @@ -6079,7 +6079,7 @@ public Rectangle GetBoundingRectangle(int marginX, int marginY, OperationProgres


/// <summary>
/// Creates a empty mat of file <see cref="Resolution"/> size and create a dummy pixel to prevent a empty layer detection
/// Creates an empty mat of file <see cref="Resolution"/> size and create a dummy pixel to prevent an empty layer detection
/// </summary>
/// <param name="dummyPixelLocation">Location to set the dummy pixel, use a negative value (-1,-1) to set to the bounding center</param>
/// <param name="dummyPixelBrightness">Dummy pixel brightness</param>
Expand All @@ -6097,25 +6097,45 @@ public Mat CreateMatWithDummyPixel(Point dummyPixelLocation, byte dummyPixelBrig
}

/// <summary>
/// Creates a empty mat of file <see cref="Resolution"/> size and create a dummy pixel to prevent a empty layer detection
/// Creates an empty mat of file <see cref="Resolution"/> size and create a dummy pixel to prevent an empty layer detection
/// </summary>
/// <param name="dummyPixelLocation">Location to set the dummy pixel, use a negative value (-1,-1) to set to the bounding center</param>
/// <returns></returns>
public Mat CreateMatWithDummyPixel(Point dummyPixelLocation) => CreateMatWithDummyPixel(dummyPixelLocation, SupportGCode ? (byte) 1 : (byte) 128);

/// <summary>
/// Creates a empty mat of file <see cref="Resolution"/> size
/// Creates an empty mat of file <see cref="Resolution"/> size
/// </summary>
/// <param name="dummyPixelBrightness">Dummy pixel brightness</param>
/// <returns></returns>
public Mat CreateMatWithDummyPixel(byte dummyPixelBrightness) => CreateMatWithDummyPixel(BoundingRectangle.Center(), dummyPixelBrightness);

/// <summary>
/// Creates a empty mat of file <see cref="Resolution"/> size
/// Creates an empty mat of file <see cref="Resolution"/> size
/// </summary>
/// <returns></returns>
public Mat CreateMatWithDummyPixel() => CreateMatWithDummyPixel(SupportGCode ? (byte)1 : (byte)128);


/// <summary>
/// Creates an empty mat of file <see cref="Resolution"/> size and create a dummy pixel on optimal position from layer information to prevent an empty layer detection
/// </summary>
/// <param name="layerIndex">The layer index to fetch better position of the dummy pixel</param>
/// <remarks>If the selected layer index does not exist, it will use the global <see cref="BoundingRectangle"/> instead</remarks>
/// <returns></returns>
public Mat CreateMatWithDummyPixelFromLayer(uint layerIndex)
{
SanitizeLayerIndex(ref layerIndex);
if (layerIndex >= LayerCount || this[layerIndex].IsEmpty)
{
return CreateMatWithDummyPixel();
}

var location = this[layerIndex].FirstPixelPosition;
if (location.X <= 0 || location.Y <= 0) location = new Point(-1, -1);

return CreateMatWithDummyPixel(location);
}

/// <summary>
/// Creates an empty mat of file <see cref="Resolution"/> size
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions UVtools.Core/FileFormats/GooFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public class FileHeader
[FieldEndianness(Endianness.Big)] [FieldOrder(0)] [FieldLength(4)] public string Version { get; set; } = FileVersion;
[FieldOrder(1)] [FieldCount(8)] public byte[] Magic { get; set; } = FileMagic;
[FieldOrder(2)] [FieldLength(32)] [SerializeAs(SerializedType.TerminatedString)] public string SoftwareName { get; set; } = About.Software;
[FieldOrder(3)] [FieldLength(24)] [SerializeAs(SerializedType.TerminatedString)] public string SoftwareVersion { get; set; } = About.VersionStr;
[FieldOrder(4)] [FieldLength(24)] [SerializeAs(SerializedType.TerminatedString)] public string FileCreateTime { get; set; } = DateTime.UtcNow.ToString("yyyy-mm-dd hh:mm:ss");
[FieldOrder(3)] [FieldLength(24)] [SerializeAs(SerializedType.TerminatedString)] public string SoftwareVersion { get; set; } = About.VersionString;
[FieldOrder(4)] [FieldLength(24)] [SerializeAs(SerializedType.TerminatedString)] public string FileCreateTime { get; set; } = DateTime.UtcNow.ToString("yyyy-mm-dd HH:mm:ss");
[FieldOrder(5)] [FieldLength(32)] [SerializeAs(SerializedType.TerminatedString)] public string MachineName { get; set; } = DefaultMachineName;
[FieldOrder(6)] [FieldLength(32)] [SerializeAs(SerializedType.TerminatedString)] public string MachineType { get; set; } = "DLP";
[FieldOrder(7)] [FieldLength(32)] [SerializeAs(SerializedType.TerminatedString)] public string ProfileName { get; set; } = About.Software;
Expand Down
Loading

0 comments on commit 5021e60

Please sign in to comment.