Skip to content

Commit

Permalink
v3.13.1
Browse files Browse the repository at this point in the history
- (Change) `Layer.IsBottomLayer` no longer calculate the value using the position of the layer, a new property `IsBottomLayerByHeight` is now used to get that result
- (Improvement) Tool - Double exposure: Increase the bottom layer count per cloned bottom layer
- (Improvement) Calibration - Exposure time finder: Set the absolute bottom layer count accordingly when also testing for bottom time
- (Improvement) Goo: Enforce Wait times or Light-off-delay flag based on property set
- (Fix) AnyCubic and Goo: `PerLayerSetting` flag was set inverted causing printer not to follow layer settings when it should and also the otherwise (#689)
- (Fix) Tool - Scripting: Prevent from reload UI multiple times when using profiles (#694)
  • Loading branch information
sn4k3 committed Apr 27, 2023
1 parent c3c952b commit 2c7ad09
Show file tree
Hide file tree
Showing 46 changed files with 260 additions and 124 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 27/04/2023 - v3.13.1

- (Change) `Layer.IsBottomLayer` no longer calculate the value using the position of the layer, a new property `IsBottomLayerByHeight` is now used to get that result
- (Improvement) Tool - Double exposure: Increase the bottom layer count per cloned bottom layer
- (Improvement) Calibration - Exposure time finder: Set the absolute bottom layer count accordingly when also testing for bottom time
- (Improvement) Goo: Enforce Wait times or Light-off-delay flag based on property set
- (Fix) AnyCubic and Goo: `PerLayerSetting` flag was set inverted causing printer not to follow layer settings when it should and also the otherwise (#689)
- (Fix) Tool - Scripting: Prevent from reload UI multiple times when using profiles (#694)

## 23/04/2023 - v3.13.0

- **Benchmark tool:**
Expand Down
17 changes: 6 additions & 11 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
- **Benchmark tool:**
- (Add) Reference machine Intel� Core� i9-13900K @ 5.5 GHz
- (Improvement) Layout and arrangement
- **Windows MSI:**
- (Improvement) Move registry keys from HKCU to HKLM
- (Improvement) Sign MSI package
- (Upgrade) Windows MSI: Wix 3 to 4
- (Fix) SL1: Change `SupportPillarWideningFactor` from ushort to float
- (Fix) PCB exposure: Implement G02 and G03 arcs (#692)
- (Upgrade) .NET from 6.0.15 to 6.0.16
- (Upgrade) openCV from 4.6.0 to 4.7.0
- (Change) `Layer.IsBottomLayer` no longer calculate the value using the position of the layer, a new property `IsBottomLayerByHeight` is now used to get that result
- (Improvement) Tool - Double exposure: Increase the bottom layer count per cloned bottom layer
- (Improvement) Calibration - Exposure time finder: Set the absolute bottom layer count accordingly when also testing for bottom time
- (Improvement) Goo: Enforce Wait times or Light-off-delay flag based on property set
- (Fix) AnyCubic and Goo: `PerLayerSetting` flag was set inverted causing printer not to follow layer settings when it should and also the otherwise (#689)
- (Fix) Tool - Scripting: Prevent from reload UI multiple times when using profiles (#694)

2 changes: 1 addition & 1 deletion Scripts/010 Editor/goo.bt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct HEADER {
float MachineZ <fgcolor=cBlack, bgcolor=cRed>;
float LayerHeight <fgcolor=cBlack, bgcolor=cRed>;
float ExposureTime <fgcolor=cBlack, bgcolor=cRed>;
enum <ubyte> { WaitTime, LightOffDelay } DelayMode <fgcolor=cBlack, bgcolor=cRed>; // 1: wait time mode , 0: light off delay mode
enum <ubyte> { LightOffDelay, WaitTime } DelayMode <fgcolor=cBlack, bgcolor=cRed>; // 0: light off delay mode | 1: wait time mode
float LightOffDelay <fgcolor=cBlack, bgcolor=cRed>;
float BottomWaitTimeAfterCure <fgcolor=cBlack, bgcolor=cRed>;
float BottomWaitTimeAfterLift <fgcolor=cBlack, bgcolor=cRed>;
Expand Down
5 changes: 1 addition & 4 deletions UVtools.Core/Extensions/EmguExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,7 @@ public static int GetPixelPos(this Mat mat, Point point)
/// <returns>Byte array </returns>
public static byte[] GetBytes(this Mat mat)
{
var data = new byte[mat.GetLength()];
//Marshal.Copy(mat.DataPointer, data, 0, data.Length);
mat.CopyTo(data);
return data;
return mat.GetRawData();
}

/// <summary>
Expand Down
23 changes: 22 additions & 1 deletion UVtools.Core/FileFormats/FileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,12 @@ public IEnumerable<Layer> GetLayersFromHeightRange(float endPositionZ)
/// </summary>
public bool AllLayersAreUsingGlobalParameters => this.All(layer => layer.IsUsingGlobalParameters);

/// <summary>
/// True if there are one or more layer(s) using different settings than the global settings, otherwise false
/// <remarks>Same as <see cref="AllLayersAreUsingGlobalParameters"/> negated</remarks>
/// </summary>
public bool UsingPerLayerSettings => !AllLayersAreUsingGlobalParameters;

/// <summary>
/// True if any layer is using TSMC, otherwise false when none of layers is using TSMC
/// </summary>
Expand Down Expand Up @@ -1849,7 +1855,7 @@ public virtual float PrintHeight

public bool IsReadOnly => false;

public int Count => _layers?.Length ?? 0;
public int Count => _layers.Length;

/// <summary>
/// Gets or sets the layer count
Expand Down Expand Up @@ -5554,6 +5560,21 @@ public void Add(IEnumerable<Layer> layers)
Layers = list.ToArray();
}

public bool ContainsLayer(int layerIndex)
{
return layerIndex >= 0 && layerIndex < Count;
}

public bool ContainsLayer(uint layerIndex)
{
return layerIndex < LayerCount;
}

public bool ContainsLayer(Layer layer)
{
return _layers.Contains(layer);
}

public bool Contains(Layer layer)
{
return _layers.Contains(layer);
Expand Down
49 changes: 43 additions & 6 deletions UVtools.Core/FileFormats/GooFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ public sealed class GooFile : FileFormat

#endregion

#region Enums
public enum DelayModes : byte
{
/// <summary>
/// Time with motor movement
/// </summary>
LightOff = 0,

/// <summary>
/// Absolute time to wait
/// </summary>
WaitTime = 1
}
#endregion

#region Sub Classes

public class FileHeader
Expand Down Expand Up @@ -64,7 +79,7 @@ public class FileHeader
/// <summary>
/// 0: Light off delay mode | 1:Wait time mode
/// </summary>
[FieldEndianness(Endianness.Big)] [FieldOrder(25)] public byte DelayMode { get; set; } = 1;
[FieldEndianness(Endianness.Big)] [FieldOrder(25)] public DelayModes DelayMode { get; set; } = DelayModes.WaitTime;
[FieldEndianness(Endianness.Big)] [FieldOrder(26)] public float LightOffDelay { get; set; }
[FieldEndianness(Endianness.Big)] [FieldOrder(27)] public float BottomWaitTimeAfterCure { get; set; }
[FieldEndianness(Endianness.Big)] [FieldOrder(28)] public float BottomWaitTimeAfterLift { get; set; }
Expand Down Expand Up @@ -670,13 +685,24 @@ public override ushort TransitionLayerCount
public override float LightOffDelay
{
get => Header.LightOffDelay;
set => base.LightOffDelay = Header.LightOffDelay = (float)Math.Round(value, 2);
set
{
base.LightOffDelay = Header.LightOffDelay = (float)Math.Round(value, 2);
if (value > 0)
{
Header.DelayMode = DelayModes.LightOff;
}
}
}

public override float BottomWaitTimeBeforeCure
{
get => base.BottomWaitTimeBeforeCure > 0 ? base.BottomWaitTimeBeforeCure : this.FirstOrDefault(layer => layer is { IsBottomLayer: true, IsDummy: false })?.WaitTimeBeforeCure ?? 0;
set => base.BottomWaitTimeBeforeCure = value;
set
{
base.BottomWaitTimeBeforeCure = value;
Header.DelayMode = DelayModes.WaitTime;
}
}


Expand All @@ -691,6 +717,7 @@ public override float WaitTimeBeforeCure
BottomLightOffDelay = 0;
LightOffDelay = 0;
}
Header.DelayMode = DelayModes.WaitTime;
}
}

Expand All @@ -703,7 +730,11 @@ public override float BottomExposureTime
public override float BottomWaitTimeAfterCure
{
get => base.BottomWaitTimeAfterCure > 0 ? base.BottomWaitTimeAfterCure : this.FirstOrDefault(layer => layer is { IsBottomLayer: true, IsDummy: false })?.WaitTimeAfterCure ?? 0;
set => base.BottomWaitTimeAfterCure = value;
set
{
base.BottomWaitTimeAfterCure = value;
Header.DelayMode = DelayModes.WaitTime;
}
}

public override float WaitTimeAfterCure
Expand All @@ -717,6 +748,7 @@ public override float WaitTimeAfterCure
BottomLightOffDelay = 0;
LightOffDelay = 0;
}
Header.DelayMode = DelayModes.WaitTime;
}
}

Expand Down Expand Up @@ -777,7 +809,11 @@ public override float LiftSpeed2
public override float BottomWaitTimeAfterLift
{
get => base.BottomWaitTimeAfterLift > 0 ? base.BottomWaitTimeAfterLift : this.FirstOrDefault(layer => layer is { IsBottomLayer: true, IsDummy: false })?.WaitTimeAfterLift ?? 0;
set => base.BottomWaitTimeAfterLift = value;
set
{
base.BottomWaitTimeAfterLift = value;
Header.DelayMode = DelayModes.WaitTime;
}
}

public override float WaitTimeAfterLift
Expand All @@ -791,6 +827,7 @@ public override float WaitTimeAfterLift
BottomLightOffDelay = 0;
LightOffDelay = 0;
}
Header.DelayMode = DelayModes.WaitTime;
}
}

Expand Down Expand Up @@ -963,7 +1000,7 @@ protected override void DecodeInternally(OperationProgress progress)

protected override void OnBeforeEncode(bool isPartialEncode)
{
Header.PerLayerSettings = AllLayersAreUsingGlobalParameters;
Header.PerLayerSettings = UsingPerLayerSettings;
Header.Volume = Volume;
Header.MaterialGrams = MaterialMilliliters;
}
Expand Down
8 changes: 3 additions & 5 deletions UVtools.Core/FileFormats/PhotonWorkshopFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public class Header
/// <summary>
/// 80
/// </summary>
[FieldOrder(17)] public uint PerLayerOverride { get; set; } // bool
[FieldOrder(17)] [SerializeAs(SerializedType.UInt4)] public bool PerLayerOverride { get; set; } // bool

[FieldOrder(18)] public uint PrintTime { get; set; }

Expand Down Expand Up @@ -1292,11 +1292,9 @@ public override ushort BottomLayerCount
set => base.BottomLayerCount = (ushort) (HeaderSettings.BottomLayersCount = value);
}

public override TransitionLayerTypes TransitionLayerType => TransitionLayerTypes.Firmware;

public override ushort TransitionLayerCount
{
get => (ushort)(Version >= VERSION_516 ? HeaderSettings.TransitionLayerCount : 0);
get => (ushort)HeaderSettings.TransitionLayerCount;
set => base.TransitionLayerCount = (ushort)(HeaderSettings.TransitionLayerCount = Math.Min(value, MaximumPossibleTransitionLayerCount));
}

Expand Down Expand Up @@ -2036,7 +2034,7 @@ protected override void PartialSaveInternally(OperationProgress progress)

protected override void OnBeforeEncode(bool isPartialEncode)
{
HeaderSettings.PerLayerOverride = System.Convert.ToUInt32(AllLayersAreUsingGlobalParameters);
HeaderSettings.PerLayerOverride = UsingPerLayerSettings;
MachineSettings.MaxFileVersion = PrinterModel switch
{
AnyCubicMachine.PhotonS => VERSION_1,
Expand Down
26 changes: 7 additions & 19 deletions UVtools.Core/Layers/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,29 +299,17 @@ public Point LastPixelPosition
/// <summary>
/// Gets if is in the bottom layer group
/// </summary>
public bool IsBottomLayer
public bool IsBottomLayer => _index < SlicerFile.BottomLayerCount;

/// <summary>
/// Gets if is in the bottom layer group by count and height
/// </summary>
public bool IsBottomLayerByHeight
{
get
{
var bottomLayers = SlicerFile.BottomLayerCount;
if (_index < bottomLayers) return true;

// For same positioned layers
/*uint layerCount = 1;
bool nullFallback = false;
for (uint layerIndex = 1; layerIndex < _index && layerCount < bottomLayers; layerIndex++)
{
if (SlicerFile[layerIndex] is null)
{
nullFallback = true;
break;
}
if (SlicerFile[layerIndex].RelativePositionZ != 0) layerCount++;
}
if (nullFallback) return PositionZ / SlicerFile.LayerHeight <= bottomLayers;
return layerCount <= bottomLayers;*/
return PositionZ / SlicerFile.LayerHeight <= bottomLayers;
return _index < bottomLayers || PositionZ / SlicerFile.LayerHeight <= bottomLayers;
}
}

Expand Down
8 changes: 3 additions & 5 deletions UVtools.Core/Managers/OperationSessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public class OperationSessionManager : IList<Operation>

private readonly List<Operation> _operations = new();

#endregion

#region Properties


#endregion

#region Constructor
Expand Down Expand Up @@ -73,6 +68,7 @@ public void Add(Operation item)
if (item is null) return;
_operations.RemoveAll(operation => operation.GetType() == item.GetType());
var operation = item.Clone();
operation.ClearPropertyChangedListeners();
operation.ClearROIandMasks();
operation.ImportedFrom = Operation.OperationImportFrom.Session;
_operations.Add(operation);
Expand Down Expand Up @@ -112,6 +108,8 @@ public void Insert(int index, Operation item)
if (item is null) return;
_operations.RemoveAll(operation => operation.GetType() == item.GetType());
var operation = item.Clone();
operation.ClearPropertyChangedListeners();
operation.ClearROIandMasks();
operation.ImportedFrom = Operation.OperationImportFrom.Session;
_operations.Insert(index, operation);
}
Expand Down
17 changes: 16 additions & 1 deletion UVtools.Core/Objects/BindableBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,25 @@ public abstract class BindableBase : INotifyPropertyChanged

public event PropertyChangedEventHandler? PropertyChanged
{
add => _propertyChanged += value;
add
{
_propertyChanged -= value;
_propertyChanged += value;
}
remove => _propertyChanged -= value;
}

public void ClearPropertyChangedListeners()
{
_propertyChanged = null;
/*var invocationList = _propertyChanged?.GetInvocationList();
if (invocationList is null) return;
foreach (var t in invocationList)
{
_propertyChanged -= (PropertyChangedEventHandler)t;
}*/
}

protected bool RaiseAndSetIfChanged<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
Expand Down
Loading

0 comments on commit 2c7ad09

Please sign in to comment.