mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-10 18:42:33 +02:00
4600e81b08
- **(Add) Suggestions:**
- A new module that detect bad or parameters out of a defined range and suggest a change on the file, those can be auto applied if configured to do so
- **Avaliable suggestions:**
- **Bottom layer count:** Bottom layers should be kept to a minimum, usually from 2 to 3, it function is to provide a good adhesion to the first layer on the build plate, using a high count have disadvantages.
- **Wait time before cure:** Rest some time before cure the layer is crucial to let the resin settle after the lift sequence and allow some time for the arm settle at the correct Z position as the resin will offer some resistance and push the structure.
This lead to better quality with more successful prints, less lamination problems, better first layers with more success of stick to the build plate and less elephant foot effect.
- **Wait time after cure:** Rest some time after cure the layer and before the lift sequence can be important to allow the layer to cooldown a bit and detach better from the FEP.
- **Layer height:** Using the right layer height is important to get successful prints:
Thin layers may cause problems on adhesion, lamination, will print much slower and have no real visual benefits.
Thick layers may not fully cure no matter the exposure time you use, causing lamination and other hazards. Read your resin dtasheet to know the limits.
Using layer height with too many decimal digits may produce a wrong positioning due stepper step loss and/or Z axis quality.
- **Core:**
- Convert the project to Nullable aware and "null-safe"
- **File Formats:**
- (Add) `Volume` property to get the total model volume
- (Add) `SanitizeLayers` method to reassign indexes and force attribute parent file
- (Improvement) Merge `LayerManager` into `FileFormat` and cleanup: This affects the whole project and external scripts.
If using scripts please update them, search for `.LayerManager.` and replace by `.`
- (Change) Chitubox encrypted format can now be saved as normal
- (Fix) Converted files layers was pointing to the source file and related to it
- **Layers:**
- (Add) Methods: `ResetParameters`, `CopyParametersTo`, `CopyExposureTo`, `CopyWaitTimesTo`
- (Improvement) `IsBottomLayer` property will also return true when the index is inside bottom layer count
- **Scripting:**
- (Add) Configuration variable: `MinimumVersionToRun` - Sets the minimum version able to run the script
- (Improvement) Allow run scripts written in C# 10 with the new namespace; style as well as nullables methods
- (Improvement) Convert scripts to use Nullable code
- **UI:**
- (Add) Fluent Dark theme
- (Add) Default Light theme
- (Add) Default Dark theme
- (Change) Use fontawesome and material design to render the icons instead of static png images
- (Change) Some icons
- (Change) Move log tab to clipboard tab
- (Change) Tooltip overlay default color
- (Improvement) Windows position for tool windows, sometimes framework can return negative values affecting positions, now limits to 0 (#387)
- (Fix) Center image icon for layer action button
- (Fix) Center image icon for save layer image button
- **Tools:**
- (Add) Layer re-height: Offset mode, change layers position by a defined offset (#423)
- (Improvement) Rotate: Unable to use an angle of 0
- (Improvement) Remove layers: Will not recalcualte and reset properties of layers anymore, allowing removing layers on dynamic layer height models and others
- (Improvement) Clone layers: Will not recalcualte and reset properties of layers anymore, allowing cloning layers on dynamic layer height models and others
- (Fix) Exposure time finder: Very small printers may not print the stock object as it is configured, lead to a unknown error while generating the test. It will now show a better error message and advice a solution (#426)
- **Terminal:**
- (Add) More default namespaces
- (Improvement) Set a MinHeight for the rows to prevent spliter from eat the elements
- (Change) Set working space to the MainWindow instead of TerminalWindow
- **(Upgrade) .NET from 5.0.14 to 6.0.3**
- This brings big performance improvements, better JIT, faster I/O operations and others
- Read more: https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-6
- Due this macOS requirement starts at 10.15 (Catalina)
- Read more: https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md
- (Add) Native support for MacOS ARM64 architecture (Mac M1 and upcomming Mac's) (#187)
- (Exchange) Dependency Newtonsoft Json by System.Text.Json to parse the json documents
- (Remove) "Automations - Light-off delay" in favor of new suggestion "wait time before cure" module
- (Fix) File - Send to: Winrar or 7zip have a wrong extension on the list (uvt) when should be (uvj)
- (Upgrade) AvaloniaUI from 0.10.12 to 0.10.13
125 lines
4.3 KiB
C#
125 lines
4.3 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UVtools.Core.Scripting;
|
|
using Emgu.CV;
|
|
using Emgu.CV.Structure;
|
|
using UVtools.Core;
|
|
using UVtools.Core.Extensions;
|
|
|
|
namespace UVtools.ScriptSample;
|
|
|
|
/// <summary>
|
|
/// Performs a black inset around objects
|
|
/// </summary>
|
|
public class ScriptLightBleedCompensationSample : ScriptGlobals
|
|
{
|
|
readonly ScriptTextBoxInput BrightnessesInput = new()
|
|
{
|
|
Label = "Brightnesses",
|
|
ToolTip = "Brightness to reduce each subsequent repeated pixels",
|
|
Unit = "1-255",
|
|
Value = "25,20,15,10,5"
|
|
};
|
|
|
|
|
|
public byte[] Levels
|
|
{
|
|
get
|
|
{
|
|
List<byte> levels = new();
|
|
var split = BrightnessesInput.Value!.Split(',', StringSplitOptions.TrimEntries);
|
|
foreach (var str in split)
|
|
{
|
|
if(!byte.TryParse(str, out var brightness)) continue;
|
|
if(brightness is byte.MinValue or byte.MaxValue) continue;
|
|
levels.Add(brightness);
|
|
}
|
|
|
|
return levels.ToArray();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set configurations here, this function trigger just after load a script
|
|
/// </summary>
|
|
public void ScriptInit()
|
|
{
|
|
Script.Name = "Light bleed compensation";
|
|
Script.Description = "Dim sequential pixels";
|
|
Script.Author = "Tiago Conceição";
|
|
Script.Version = new Version(0, 1);
|
|
Script.UserInputs.Add(BrightnessesInput);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate user inputs here, this function trigger when user click on execute
|
|
/// </summary>
|
|
/// <returns>A error message, empty or null if validation passes.</returns>
|
|
public string? ScriptValidate()
|
|
{
|
|
StringBuilder sb = new();
|
|
|
|
if (Levels.Length == 0)
|
|
{
|
|
sb.AppendLine($"No brightness levels are set");
|
|
}
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Execute the script, this function trigger when when user click on execute and validation passes
|
|
/// </summary>
|
|
/// <returns>True if executes successfully to the end, otherwise false.</returns>
|
|
public bool ScriptExecute()
|
|
{
|
|
Progress.Reset("Bleed compensation", Operation.LayerRangeCount); // Sets the progress name and number of items to process
|
|
var brightnesses = Levels;
|
|
|
|
// Loop user selected layers in parallel, this will put each core of CPU working here on parallel
|
|
Parallel.For(Operation.LayerIndexStart, Operation.LayerIndexEnd+1, CoreSettings.ParallelOptions, layerIndex =>
|
|
{
|
|
if (Progress.Token.IsCancellationRequested) return; // Abort operation, user requested cancellation
|
|
|
|
var layer = SlicerFile[layerIndex]; // Unpack and expose layer variable for easier use
|
|
using var mat = layer.LayerMat; // Gets this layer mat/image
|
|
var original = mat.Clone(); // Keep a original mat copy
|
|
|
|
var target = Operation.GetRoiOrDefault(mat); // Get ROI from mat if user selected an region
|
|
|
|
for (byte i = 0; i < brightnesses.Length; i++)
|
|
{
|
|
uint layerIndexNext = (uint) (layerIndex + i + 1);
|
|
if (layerIndexNext > Operation.LayerIndexEnd) break;
|
|
using var subtractMat = EmguExtensions.InitMat(target.Size, new MCvScalar(brightnesses[i]));
|
|
|
|
using var nextMat = SlicerFile[layerIndexNext].LayerMat;
|
|
var nextMatRoi = Operation.GetRoiOrDefault(nextMat);
|
|
|
|
CvInvoke.Subtract(target, subtractMat, target, nextMatRoi);
|
|
}
|
|
|
|
// Apply the results only to the selected masked area, if user selected one
|
|
Operation.ApplyMask(original, target);
|
|
|
|
// Set current layer image with the modified mat we just manipulated
|
|
layer.LayerMat = mat;
|
|
|
|
// Increment progress bar by 1
|
|
Progress.LockAndIncrement();
|
|
});
|
|
|
|
// return true if not cancelled by user
|
|
return !Progress.Token.IsCancellationRequested;
|
|
}
|
|
} |