mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-11 11:02:32 +02:00
9f7722d369
- **File formats:** - (Add) `TransitionLayerCount` modifier to: Chitubox Zip, CWS, JXS, OSLA, PW*, UVJ, ZCodex, ZCode - (Add) Utility methods for transition layers calculation/parse - (Improvement) Calculate and set `TransitionLayerCount` property in file decode based on layer exposure time configuration - **GCode:** - (Improvement) GCode: Able to parse layer image file with appended numbers on the filename (Afecting CWS) (#577) - (Fix) Bad parsing of the file when it comes from Lychee or NovaMaker slicer (Afecting CWS) - (Fix) Incorrect parse of "Wait time before cure" from layers when printer require wait sync moves (Afecting CWS) - **Tools:** - (Add) External tests: The Complete Resin 3D Printing Settings Guide for Beginners - (Add) External tests: 9 settings for faster printing - (Improvement) Fade exposure time: Set `TransitionLayerCount` property with the affected layer count - **Suggestions:** - (Add) Transition layers: If you are printing flat on the build plate your model will print better when using a smooth transition exposure time instead of a harsh variation, resulting in reduced layer line effect and avoid possible problems due the large exposure difference. This is not so important when your model print raised under a raft/supports unaffected by the bottom exposure, in that case, it's fine to ignore this. - (Add) Model position: Printing on a corner will reduce the FEP stretch forces when detaching from the model during a lift sequence, benefits are: Reduced lift height and faster printing, less stretch, less FEP marks, better FEP lifespan, easier to peel, less prone to failure and use the screen pixels more evenly. If the model is too large to fit within the margin(s) on the screen, it will attempt to center it on that same axis to avoid touching on screen edge(s) and to give a sane margin from it. - **Status bar:** - (Add) Transition layers: 0/-0.00s - (Improvement) Change "Layer Height: 0.000mm" to "Layers: count @ 0.000mm" - (Improvement) Change "Bottom layers: 0" to "Bottom layers: 0/0.000mm" - (Change) Show user informative message about CTB Encrypted file format once per ten file loads - (Upgrade) .NET from 6.0.9 to 6.0.10 - (Fix) Windows MSI installation not upgrading well when downgrade libraries
210 lines
6.7 KiB
C#
210 lines
6.7 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.ComponentModel;
|
|
using System.Text;
|
|
using UVtools.Core.FileFormats;
|
|
|
|
namespace UVtools.Core.Operations;
|
|
|
|
[Serializable]
|
|
public class OperationFadeExposureTime : Operation
|
|
{
|
|
#region Members
|
|
|
|
private uint _layerCount = 10;
|
|
private decimal _fromExposureTime;
|
|
private decimal _toExposureTime;
|
|
private bool _disableFirmwareTransitionLayers = true;
|
|
|
|
#endregion
|
|
|
|
#region Overrides
|
|
public override bool CanRunInPartialMode => true;
|
|
public override LayerRangeSelection StartLayerRangeSelection => LayerRangeSelection.Normal;
|
|
public override bool LayerIndexEndEnabled => false;
|
|
public override string IconClass => "fa-solid fa-history";
|
|
public override string Title => "Fade exposure time";
|
|
|
|
public override string Description =>
|
|
"Fade the exposure time in increments from a start to a end value on the selected layer range.";
|
|
|
|
public override string ConfirmationText =>
|
|
$"fade exposure time model layers {LayerIndexStart} through {LayerIndexEnd} with increments of {IncrementValue}s";
|
|
|
|
public override string ProgressTitle =>
|
|
$"Fading exposure time from layers {LayerIndexStart} to {LayerIndexEnd} with increments of {IncrementValue}s";
|
|
|
|
public override string ProgressAction => "Faded layers";
|
|
|
|
public override string? ValidateSpawn()
|
|
{
|
|
if (!SlicerFile.CanUseLayerExposureTime)
|
|
{
|
|
return NotSupportedMessage;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public override string? ValidateInternally()
|
|
{
|
|
var sb = new StringBuilder();
|
|
|
|
if (_layerCount == 0) sb.AppendLine("The layer count must be higher than 0.");
|
|
if(_fromExposureTime == _toExposureTime) sb.AppendLine("The starting exposure time can't be the same as the ending exposure time.");
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
var result = $"[Layers: {LayerRangeCount} From: {_fromExposureTime}s To: {_toExposureTime}s @ {IncrementValue}s] " + LayerRangeString;
|
|
if (!string.IsNullOrEmpty(ProfileName)) result = $"{ProfileName}: {result}";
|
|
return result;
|
|
}
|
|
|
|
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName == nameof(LayerIndexStart))
|
|
{
|
|
LayerCount = _layerCount; // Sanitize
|
|
LayerIndexEnd = LayerIndexStart + _layerCount - 1 ; // Sync
|
|
RaisePropertyChanged(nameof(MaximumLayerCount));
|
|
RaisePropertyChanged(nameof(IncrementValue));
|
|
}
|
|
/*else if (e.PropertyName == nameof(LayerIndexEnd))
|
|
{
|
|
LayerCount = LayerRangeCount;
|
|
RaisePropertyChanged(nameof(IncrementValue));
|
|
}*/
|
|
|
|
base.OnPropertyChanged(e);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public uint LayerCount
|
|
{
|
|
get => _layerCount;
|
|
set
|
|
{
|
|
if (!RaiseAndSetIfChanged(ref _layerCount, Math.Min(value, SlicerFile.LayerCount - LayerIndexStart))) return;
|
|
LayerIndexEnd = LayerIndexStart + _layerCount - 1;
|
|
RaisePropertyChanged(nameof(MaximumLayerCount));
|
|
RaisePropertyChanged(nameof(IncrementValue));
|
|
}
|
|
}
|
|
|
|
public uint MaximumLayerCount => Math.Max(LayerCount, SlicerFile.LayerCount - LayerIndexStart);
|
|
|
|
public decimal FromExposureTime
|
|
{
|
|
get => _fromExposureTime;
|
|
set
|
|
{
|
|
if(!RaiseAndSetIfChanged(ref _fromExposureTime, Math.Round(value, 2))) return;
|
|
RaisePropertyChanged(nameof(IncrementValue));
|
|
}
|
|
}
|
|
|
|
public decimal ToExposureTime
|
|
{
|
|
get => _toExposureTime;
|
|
set
|
|
{
|
|
if(!RaiseAndSetIfChanged(ref _toExposureTime, Math.Round(value, 2))) return;
|
|
RaisePropertyChanged(nameof(IncrementValue));
|
|
}
|
|
}
|
|
|
|
public bool DisableFirmwareTransitionLayers
|
|
{
|
|
get => _disableFirmwareTransitionLayers;
|
|
set => RaiseAndSetIfChanged(ref _disableFirmwareTransitionLayers, value);
|
|
}
|
|
|
|
public decimal IncrementValue => Math.Round(IncrementValueRaw, 2);
|
|
public decimal IncrementValueRaw => (decimal)FileFormat.GetTransitionStepTime((float) _toExposureTime, (float)_fromExposureTime, (ushort) LayerRangeCount);
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public OperationFadeExposureTime() { }
|
|
|
|
public OperationFadeExposureTime(FileFormat slicerFile) : base(slicerFile) { }
|
|
|
|
public override void InitWithSlicerFile()
|
|
{
|
|
base.InitWithSlicerFile();
|
|
if (_fromExposureTime <= 0) _fromExposureTime = (decimal)SlicerFile.BottomExposureTime;
|
|
if (_toExposureTime <= 0) _toExposureTime = (decimal)SlicerFile.ExposureTime;
|
|
|
|
LayerIndexEnd = LayerIndexStart + _layerCount - 1; // Sync
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Equality
|
|
|
|
protected bool Equals(OperationFadeExposureTime other)
|
|
{
|
|
return _layerCount == other._layerCount && _fromExposureTime == other._fromExposureTime && _toExposureTime == other._toExposureTime && _disableFirmwareTransitionLayers == other._disableFirmwareTransitionLayers;
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
if (ReferenceEquals(null, obj)) return false;
|
|
if (ReferenceEquals(this, obj)) return true;
|
|
if (obj.GetType() != this.GetType()) return false;
|
|
return Equals((OperationFadeExposureTime) obj);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(_layerCount, _fromExposureTime, _toExposureTime, _disableFirmwareTransitionLayers);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
protected override bool ExecuteInternally(OperationProgress progress)
|
|
{
|
|
LayerIndexEnd = LayerIndexStart + _layerCount - 1; // Sanitize
|
|
|
|
if (SlicerFile.TransitionLayerType == FileFormat.TransitionLayerTypes.Firmware && _disableFirmwareTransitionLayers)
|
|
{
|
|
SlicerFile.TransitionLayerCount = 0;
|
|
}
|
|
else
|
|
{
|
|
if (SlicerFile.BottomLayerCount == LayerIndexStart)
|
|
{
|
|
SlicerFile.TransitionLayerCount = (ushort) LayerRangeCount;
|
|
}
|
|
}
|
|
|
|
var increment = IncrementValueRaw;
|
|
var exposure = _fromExposureTime;
|
|
for (uint layerIndex = LayerIndexStart; layerIndex <= LayerIndexEnd; layerIndex++)
|
|
{
|
|
progress.ThrowIfCancellationRequested();
|
|
exposure += increment;
|
|
SlicerFile[layerIndex].ExposureTime = (float)exposure;
|
|
}
|
|
|
|
return !progress.Token.IsCancellationRequested;
|
|
}
|
|
|
|
#endregion
|
|
} |