mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-12 19:42:32 +02:00
57b8a9dc84
- **Core:**
- (Add) Machine presets and able to load machine collection from PrusaSlicer
- (Improvement) Core: Reference EmguCV runtimes into core instead of the UI project
- **File formats:**
- **CXDLP:**
- (Add) Detection support for Halot One Pro
- (Add) Detection support for Halot One Plus
- (Add) Detection support for Halot Sky Plus
- (Add) Detection support for Halot Lite
- (Improvement) Better handling and detection of printer model when converting
- (Improvement) Discovered more fields meanings on format
- (Fix) Exposure time in format is `round(time * 10, 1)`
- (Fix) Speeds in format are in mm/s, was using mm/min before
- (Add) JXS format for Uniformation GKone [Zip+GCode]
- (Improvement) Saving and converting files now handle the file backup on Core instead on the UI, which prevents scripts and other projects lose the original file in case of error while saving
- (Fix) After load files they was flagged as requiring a full encode, preventing fast save a fresh file
- **UVtoolsCmd:**
- Bring back the commandline project
- Consult README to see the available commands and syntax
- Old terminal commands on UVtools still works for now, but consider switch to UVtoolsCmd or redirect the command using `UVtools --cmd "commands"`
- **Tools:**
- **Change print resolution:**
- (Add) Allow to change the display size to match the new printer
- (Add) Machine presets to help set both resolution and display size to a correct printer and auto set fix pixel ratio
- (Improvement) Real pixel pitch fixer due new display size information, this allow full transfers between different printers "without" invalidating the model size
- (Improvement) Better arrangement of the layout
- (Add) Infill: Option "Reinforce infill if possible", it was always on before, now default is off and configurable
- (Improvement) Always allow to export settings from tools
- **GCode:**
- (Improvement) After print the last layer, do one lift with the same layer settings before attempt a fast move to top
- (Improvement) Use the highest defined speed to send the build plate to top after finish print
- (Improvement) Append a wait sync command in the end of gcode if needed
- (Fix) When lift without a retract it still output the motor sync delay for the retract time and the wait time after retract
- **PrusaSlicer:**
- (Add) Printer: Creality Halot One Pro CL-70
- (Add) Printer: Creality Halot One Plus CL-79
- (Add) Printer: Creality Halot Sky Plus CL-92
- (Add) Printer: Creality Halot Lite CL-89L
- (Add) Printer: Creality Halot Lite CL-89L
- (Add) Printer: Creality CT133 Pro
- (Add) Printer: Creality CT-005 Pro
- (Add) Printer: Uniformation GKone
- (Add) Printer: FlashForge Foto 8.9S
- (Add) Printer: Elegoo Mars 2
- (Improvement) Rename all Creality printers
- (Fix) Creality model in print notes
203 lines
6.4 KiB
C#
203 lines
6.4 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 => "fas 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 => (_toExposureTime - _fromExposureTime) / (LayerRangeCount + 1);
|
|
|
|
#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 (_disableFirmwareTransitionLayers)
|
|
{
|
|
SlicerFile.TransitionLayerCount = 0;
|
|
}
|
|
|
|
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
|
|
} |