diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-06-25 23:43:30 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-06-25 23:43:30 +0300 |
commit | 74b6335f64dbbbfb0dad62e08570aa04e69edc40 (patch) | |
tree | 4d6681927524b370f9af4ce20a7b8bbbebbb300f | |
parent | 57c4825d16508f91a3e217a5fd312cb6ebbae351 (diff) |
v2.13.4
- (Fix) ZCode: lcd.gcode was blank / not generating when converting from any file format
- (Fix) Zcodex: Change MaterialId from `uint` to `string` (#223, #224)
- (Fix) CXDLP: Set the default printer name to `CL-89` when creating new instance, was `null` before
- (Fix) Some tools were unable to pull certain settings from profiles and imported settings:
- Elephant foot
- Exposure finder
- Grayscale
- Stress tower
- Tolerance
- XYZ Accuracy
- Change resolution
- Dynamic lifts
- (Change) `Layer repair` icon at Issues tab and `Outline` icon on preview toolbar (#227)
- (Developers) Created `UVtools.AvaloniaControls` project with `AdvancedImageBox` control for AvaloniaUI
39 files changed, 421 insertions, 217 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 42c20aa..f65422b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 25/06/2021 - v2.13.4 + +- (Fix) ZCode: lcd.gcode was blank / not generating when converting from any file format +- (Fix) Zcodex: Change MaterialId from `uint` to `string` (#223, #224) +- (Fix) CXDLP: Set the default printer name to `CL-89` when creating new instance, was `null` before +- (Fix) Some tools were unable to pull certain settings from profiles and imported settings: + - Elephant foot + - Exposure finder + - Grayscale + - Stress tower + - Tolerance + - XYZ Accuracy + - Change resolution + - Dynamic lifts +- (Change) `Layer repair` icon at Issues tab and `Outline` icon on preview toolbar (#227) +- (Developers) Created `UVtools.AvaloniaControls` project with `AdvancedImageBox` control for AvaloniaUI + ## 12/06/2021 - v2.13.3 - **File formats:** diff --git a/Scripts/cxdlp_v1.bt b/Scripts/cxdlp_v1.bt index 6052b06..bc43eda 100644 --- a/Scripts/cxdlp_v1.bt +++ b/Scripts/cxdlp_v1.bt @@ -5,6 +5,8 @@ // Authors: Julien Delnatte //------------------------------------------------ +BigEndian(); + typedef struct { BitfieldDisablePadding();
ushort startY:13;
ushort endY:13;
ushort x:14; ubyte grey <fgcolor=cBlack, bgcolor=cWhite>; diff --git a/Scripts/cxdlp_v2.bt b/Scripts/cxdlp_v2.bt index 0c27e76..3a33f30 100644 --- a/Scripts/cxdlp_v2.bt +++ b/Scripts/cxdlp_v2.bt @@ -10,6 +10,8 @@ // Add byte offset[64] after resolutionY (Zeros) +BigEndian(); + typedef struct { BitfieldDisablePadding();
ushort startY:13;
ushort endY:13;
ushort x:14; ubyte grey <fgcolor=cBlack, bgcolor=cWhite>; diff --git a/Scripts/gr1.bt b/Scripts/gr1.bt index 308a637..c55b088 100644 --- a/Scripts/gr1.bt +++ b/Scripts/gr1.bt @@ -5,6 +5,8 @@ // Authors: Julien Delnatte //------------------------------------------------ +BigEndian(); + typedef struct { uint16 startY <fgcolor=cBlack, bgcolor=cWhite>; uint16 endY <fgcolor=cBlack, bgcolor=cWhite>; diff --git a/Scripts/lgs.bt b/Scripts/lgs.bt new file mode 100644 index 0000000..f98de94 --- /dev/null +++ b/Scripts/lgs.bt @@ -0,0 +1,74 @@ +//------------------------------------------------ +//--- 010 Editor v8.0.1 Binary Template +// +// File: Longer Orange 10, 30 +// Authors: Tiago Conceição +//------------------------------------------------ + +LittleEndian(); + +typedef struct() { + uint32 DataSize <fgcolor=cBlack, bgcolor=cWhite>; + BYTE LayerRLE[DataSize] <fgcolor=cBlack, bgcolor=cRed>; +} layerData; + +typedef struct(int size) { + BYTE layerDataBlock[size] <fgcolor=cBlack, bgcolor=0x00FF00>; +} rgbPreviewImageRawData; + +struct HEADER { + char name[8] <fgcolor=cBlack, bgcolor=cWhite>; + uint32 Uint_08 <fgcolor=cBlack, bgcolor=cRed>; + uint32 Uint_0C <fgcolor=cBlack, bgcolor=cRed>; + uint32 Uint_10 <fgcolor=cBlack, bgcolor=cRed>; + uint32 Uint_14 <fgcolor=cBlack, bgcolor=cRed>; + uint32 Uint_18 <fgcolor=cBlack, bgcolor=cRed>; + + float PixelPerMmX <fgcolor=cBlack, bgcolor=cRed>; + float PixelPerMmY <fgcolor=cBlack, bgcolor=cRed>; + float ResolutionX <fgcolor=cBlack, bgcolor=cRed>; + float ResolutionY <fgcolor=cBlack, bgcolor=cRed>; + float LayerHeight <fgcolor=cBlack, bgcolor=cRed>; + float ExposureTimeMs <fgcolor=cBlack, bgcolor=cRed>; + float BottomExposureTimeMs <fgcolor=cBlack, bgcolor=cRed>; + float Float_38 <fgcolor=cBlack, bgcolor=cRed>; + float LightOffDelayMs <fgcolor=cBlack, bgcolor=cRed>; + float BottomLightOffDelayMs <fgcolor=cBlack, bgcolor=cRed>; + float BottomHeight <fgcolor=cBlack, bgcolor=cRed>; + float Float_48 <fgcolor=cBlack, bgcolor=cRed>; + float BottomLiftHeight <fgcolor=cBlack, bgcolor=cRed>; + float LiftHeight <fgcolor=cBlack, bgcolor=cRed>; + float LiftSpeed <fgcolor=cBlack, bgcolor=cRed>; + float LiftSpeed_ <fgcolor=cBlack, bgcolor=cRed>; + float BottomLiftSpeed <fgcolor=cBlack, bgcolor=cRed>; + float BottomLiftSpeed_ <fgcolor=cBlack, bgcolor=cRed>; + float Float_64 <fgcolor=cBlack, bgcolor=cRed>; + float Float_68 <fgcolor=cBlack, bgcolor=cRed>; + float Float_6c <fgcolor=cBlack, bgcolor=cRed>; + float Float_70 <fgcolor=cBlack, bgcolor=cRed>; + float Float_74 <fgcolor=cBlack, bgcolor=cRed>; + float Float_78 <fgcolor=cBlack, bgcolor=cRed>; + float Float_7c <fgcolor=cBlack, bgcolor=cRed>; + float Float_80 <fgcolor=cBlack, bgcolor=cRed>; + float Float_84 <fgcolor=cBlack, bgcolor=cRed>; + float Float_88 <fgcolor=cBlack, bgcolor=cRed>; + float Float_8c <fgcolor=cBlack, bgcolor=cRed>; + float Float_90 <fgcolor=cBlack, bgcolor=cRed>; + float Float_94 <fgcolor=cBlack, bgcolor=cRed>; + uint32 Uint_98 <fgcolor=cBlack, bgcolor=cRed>; + uint32 Uint_9c <fgcolor=cBlack, bgcolor=cRed>; + uint32 Uint_a0 <fgcolor=cBlack, bgcolor=cRed>; + uint32 LayerCount <fgcolor=cBlack, bgcolor=cRed>; + uint32 Uint_a8 <fgcolor=cBlack, bgcolor=cRed>; + uint32 PreviewSizeX <fgcolor=cBlack, bgcolor=cRed>; + uint32 PreviewSizeY <fgcolor=cBlack, bgcolor=cRed>; + + rgbPreviewImageRawData preview(PreviewSizeX*PreviewSizeY*2); +} header; + +struct LAYERS { + local int i; + for( i = 0; i < header.LayerCount; i++ ){ + layerData lD(); + } +} layers; diff --git a/Scripts/mdlp.bt b/Scripts/mdlp.bt index 5886ee3..501b06e 100644 --- a/Scripts/mdlp.bt +++ b/Scripts/mdlp.bt @@ -5,6 +5,8 @@ // Authors: Julien Delnatte //------------------------------------------------ +BigEndian(); + typedef struct { uint16 startY <fgcolor=cBlack, bgcolor=cWhite>; uint16 endY <fgcolor=cBlack, bgcolor=cWhite>; diff --git a/Scripts/photons.bt b/Scripts/photons.bt new file mode 100644 index 0000000..bc04d37 --- /dev/null +++ b/Scripts/photons.bt @@ -0,0 +1,53 @@ +//------------------------------------------------ +//--- 010 Editor v8.0.1 Binary Template +// +// File: Anycubic PhotonS +// Authors: Tiago Conceição +//------------------------------------------------ + +BigEndian(); + +typedef struct() { + uint32 Unknown1 <fgcolor=cBlack, bgcolor=cWhite>; // 44944 + uint32 Unknown2 <fgcolor=cBlack, bgcolor=cWhite>; // 0 + uint32 Unknown3 <fgcolor=cBlack, bgcolor=cWhite>; // 0 + uint32 ResolutionX <fgcolor=cBlack, bgcolor=cWhite>; + uint32 ResolutionY <fgcolor=cBlack, bgcolor=cWhite>; + uint32 DataSize <fgcolor=cBlack, bgcolor=cWhite>; + uint32 Unknown4 <fgcolor=cBlack, bgcolor=cWhite>; // 2684702720 + BYTE LayerRLE[DataSize / 8 - 4] <fgcolor=cBlack, bgcolor=cRed>; +} layerData; + +typedef struct(int size) { + BYTE layerDataBlock[size] <fgcolor=cBlack, bgcolor=0x00FF00>; +} rgbPreviewImageRawData; + +struct HEADER { + uint32 Tag1 <fgcolor=cBlack, bgcolor=cRed>; // 2 + uint16 Tag2 <fgcolor=cBlack, bgcolor=cRed>; // 49 + double XYPixelSize <fgcolor=cBlack, bgcolor=cRed>; + double LayerHeight <fgcolor=cBlack, bgcolor=cRed>; + double ExposureSeconds <fgcolor=cBlack, bgcolor=cRed>; + double LightOffDelay <fgcolor=cBlack, bgcolor=cRed>; + + double BottomExposureSeconds <fgcolor=cBlack, bgcolor=cRed>; + uint32 BottomLayerCount <fgcolor=cBlack, bgcolor=cRed>; + double LiftHeight <fgcolor=cBlack, bgcolor=cRed>; // mm + double LiftSpeed <fgcolor=cBlack, bgcolor=cRed>; // mm/s + double RetractSpeed <fgcolor=cBlack, bgcolor=cRed>; // mm/s + double VolumeMl <fgcolor=cBlack, bgcolor=cRed>; // ml + uint32 PreviewResolutionX <fgcolor=cBlack, bgcolor=cRed>; + uint32 Unknown1 <fgcolor=cBlack, bgcolor=cRed>; // 42 + uint32 PreviewResolutionY <fgcolor=cBlack, bgcolor=cRed>; + uint32 Unknown2 <fgcolor=cBlack, bgcolor=cRed>; // 10 + + rgbPreviewImageRawData preview(PreviewResolutionX*PreviewResolutionY*2); + uint32 LayerCount <fgcolor=cBlack, bgcolor=cRed>; +} header; + +struct LAYERS { + local int i; + for( i = 0; i < header.LayerCount; i++ ){ + layerData lD(); + } +} layers; diff --git a/UVtools.Core/FileFormats/CWSFile.cs b/UVtools.Core/FileFormats/CWSFile.cs index 2a6da89..832628a 100644 --- a/UVtools.Core/FileFormats/CWSFile.cs +++ b/UVtools.Core/FileFormats/CWSFile.cs @@ -509,13 +509,16 @@ namespace UVtools.Core.FileFormats public CWSFile() { - GCode.UseComments = true; - GCode.GCodePositioningType = GCodeBuilder.GCodePositioningTypes.Partial; - GCode.GCodeSpeedUnit = GCodeBuilder.GCodeSpeedUnits.MillimetersPerMinute; - GCode.GCodeTimeUnit = GCodeBuilder.GCodeTimeUnits.Milliseconds; - GCode.GCodeShowImageType = GCodeBuilder.GCodeShowImageTypes.LayerIndexZero; - GCode.CommandShowImageM6054.Reset(";<Slice>", "{0}"); - GCode.CommandWaitG4.Reset(";<Delay>", "{0}"); + GCode = new GCodeBuilder + { + UseComments = true, + GCodePositioningType = GCodeBuilder.GCodePositioningTypes.Partial, + GCodeSpeedUnit = GCodeBuilder.GCodeSpeedUnits.MillimetersPerMinute, + GCodeTimeUnit = GCodeBuilder.GCodeTimeUnits.Milliseconds, + GCodeShowImageType = GCodeBuilder.GCodeShowImageTypes.LayerIndexZero + }; + GCode.CommandShowImageM6054.Set(";<Slice>", "{0}"); + GCode.CommandWaitG4.Set(";<Delay>", "{0}"); } #region Methods @@ -647,7 +650,7 @@ namespace UVtools.Core.FileFormats } RebuildGCode(); - outputFile.PutFileContent($"{filename}.gcode", GCode.ToString(), ZipArchiveMode.Create); + outputFile.PutFileContent($"{filename}.gcode", GCodeStr, ZipArchiveMode.Create); } protected override void DecodeInternally(string fileFullPath, OperationProgress progress) @@ -839,7 +842,7 @@ namespace UVtools.Core.FileFormats //GCode.Clear(); //GCode.AppendLine($"; {About.Website} {About.Software} {Assembly.GetExecutingAssembly().GetName().Version} {arch} {DateTime.Now}"); StringBuilder sb = new(); - sb.AppendLine(";(****Build and Slicing Parameters ****)"); + sb.AppendLine(";(**** Build and Slicing Parameters ****)"); foreach (var propertyInfo in OutputSettings.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) { @@ -987,7 +990,7 @@ namespace UVtools.Core.FileFormats break; } } - outputFile.PutFileContent($"{Path.GetFileNameWithoutExtension(FileFullPath)}.gcode", GCode.ToString(), ZipArchiveMode.Update); + outputFile.PutFileContent($"{Path.GetFileNameWithoutExtension(FileFullPath)}.gcode", GCodeStr, ZipArchiveMode.Update); /*foreach (var layer in this) { diff --git a/UVtools.Core/FileFormats/CXDLPFile.cs b/UVtools.Core/FileFormats/CXDLPFile.cs index 4e88af8..5d0d881 100644 --- a/UVtools.Core/FileFormats/CXDLPFile.cs +++ b/UVtools.Core/FileFormats/CXDLPFile.cs @@ -82,13 +82,17 @@ namespace UVtools.Core.FileFormats [FieldOrder(4)] [FieldLength(nameof(PrinterModelSize))] - public byte[] PrinterModelArray { get; set; } + public byte[] PrinterModelArray { get; set; } = { 0x43, 0x4C, 0x2D, 0x38, 0x39, 0x0 }; // CL-89 [Ignore] public string PrinterModel { get => Encoding.ASCII.GetString(PrinterModelArray).TrimEnd(char.MinValue); - set => PrinterModelArray = Encoding.ASCII.GetBytes(value+char.MinValue); + set + { + PrinterModelArray = Encoding.ASCII.GetBytes(value + char.MinValue); + PrinterModelSize = (uint) PrinterModelArray.Length; + } } /// <summary> diff --git a/UVtools.Core/FileFormats/ChituboxZipFile.cs b/UVtools.Core/FileFormats/ChituboxZipFile.cs index 4456db2..213ea1f 100644 --- a/UVtools.Core/FileFormats/ChituboxZipFile.cs +++ b/UVtools.Core/FileFormats/ChituboxZipFile.cs @@ -16,6 +16,7 @@ using System.Reflection; using Emgu.CV; using Emgu.CV.CvEnum; using Emgu.CV.Util; +using Microsoft.CodeAnalysis.CSharp.Syntax; using UVtools.Core.Extensions; using UVtools.Core.GCode; using UVtools.Core.Objects; @@ -73,7 +74,7 @@ namespace UVtools.Core.FileFormats #region Properties public Header HeaderSettings { get; } = new Header(); - + public override FileFormatType FileType => FileFormatType.Archive; public override FileExtension[] FileExtensions { get; } = { @@ -325,16 +326,21 @@ namespace UVtools.Core.FileFormats public override object[] Configs => new object[] { HeaderSettings }; + public override bool SupportsGCode => base.SupportsGCode && !IsPHZZip; + public bool IsPHZZip; #endregion public ChituboxZipFile() { - GCode.UseComments = true; - GCode.GCodePositioningType = GCodeBuilder.GCodePositioningTypes.Absolute; - GCode.GCodeSpeedUnit = GCodeBuilder.GCodeSpeedUnits.MillimetersPerMinute; - GCode.GCodeTimeUnit = GCodeBuilder.GCodeTimeUnits.Milliseconds; - GCode.GCodeShowImageType = GCodeBuilder.GCodeShowImageTypes.FilenameNonZeroPNG; + GCode = new GCodeBuilder + { + UseComments = true, + GCodePositioningType = GCodeBuilder.GCodePositioningTypes.Absolute, + GCodeSpeedUnit = GCodeBuilder.GCodeSpeedUnits.MillimetersPerMinute, + GCodeTimeUnit = GCodeBuilder.GCodeTimeUnits.Milliseconds, + GCodeShowImageType = GCodeBuilder.GCodeShowImageTypes.FilenameNonZeroPNG + }; } #region Methods @@ -372,7 +378,7 @@ namespace UVtools.Core.FileFormats if (!IsPHZZip) { RebuildGCode(); - outputFile.PutFileContent(GCodeFilename, GCode.ToString(), ZipArchiveMode.Create); + outputFile.PutFileContent(GCodeFilename, GCodeStr, ZipArchiveMode.Create); } for (uint layerIndex = 0; layerIndex < LayerCount; layerIndex++) @@ -444,7 +450,7 @@ namespace UVtools.Core.FileFormats progress.ItemCount = LayerCount; - var gcode = GCode?.ToString(); + var gcode = GCodeStr; float lastPostZ = LayerHeight; for (uint layerIndex = 0; layerIndex < LayerCount; layerIndex++) @@ -537,7 +543,7 @@ namespace UVtools.Core.FileFormats if (!IsPHZZip) { - outputFile.PutFileContent(GCodeFilename, GCode.ToString(), ZipArchiveMode.Update); + outputFile.PutFileContent(GCodeFilename, GCodeStr, ZipArchiveMode.Update); } } diff --git a/UVtools.Core/FileFormats/FileFormat.cs b/UVtools.Core/FileFormats/FileFormat.cs index 322073b..c98eef2 100644 --- a/UVtools.Core/FileFormats/FileFormat.cs +++ b/UVtools.Core/FileFormats/FileFormat.cs @@ -1175,7 +1175,7 @@ namespace UVtools.Core.FileFormats /// <summary> /// Gets the GCode, returns null if not supported /// </summary> - public GCodeBuilder GCode { get; set; } = new(); + public GCodeBuilder GCode { get; set; } /// <summary> /// Gets the GCode, returns null if not supported @@ -1183,9 +1183,14 @@ namespace UVtools.Core.FileFormats public string GCodeStr => GCode?.ToString(); /// <summary> - /// Gets if this file have available gcode + /// Gets if this file format supports gcode /// </summary> - public bool HaveGCode => !GCode?.IsEmpty ?? false; + public virtual bool SupportsGCode => GCode is not null; + + /// <summary> + /// Gets if this file have available gcode to read + /// </summary> + public bool HaveGCode => SupportsGCode && !GCode.IsEmpty; /// <summary> /// Get all configuration objects with properties and values @@ -1301,7 +1306,7 @@ namespace UVtools.Core.FileFormats { FileFullPath = null; LayerManager.Clear(); - GCode.Clear(); + GCode?.Clear(); if (Thumbnails is not null) { @@ -1984,7 +1989,7 @@ namespace UVtools.Core.FileFormats /// </summary> public virtual void RebuildGCode() { - if (GCode.IsEmpty) return; + if (!SupportsGCode) return; GCode.RebuildGCode(this); } diff --git a/UVtools.Core/FileFormats/PhotonSFile.cs b/UVtools.Core/FileFormats/PhotonSFile.cs index 6e6fe47..40e2602 100644 --- a/UVtools.Core/FileFormats/PhotonSFile.cs +++ b/UVtools.Core/FileFormats/PhotonSFile.cs @@ -6,8 +6,6 @@ * of this license document, but changing it is not allowed. */ -// https://github.com/cbiffle/catibo/blob/master/doc/cbddlp-ctb.adoc - using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/UVtools.Core/FileFormats/ZCodeFile.cs b/UVtools.Core/FileFormats/ZCodeFile.cs index 7559580..10556d3 100644 --- a/UVtools.Core/FileFormats/ZCodeFile.cs +++ b/UVtools.Core/FileFormats/ZCodeFile.cs @@ -426,14 +426,17 @@ namespace UVtools.Core.FileFormats #region Constructor public ZCodeFile() { - GCode.UseTailComma = true; - GCode.UseComments = false; - GCode.GCodePositioningType = GCodeBuilder.GCodePositioningTypes.Absolute; - GCode.GCodeSpeedUnit = GCodeBuilder.GCodeSpeedUnits.CentimetersPerMinute; - GCode.GCodeTimeUnit = GCodeBuilder.GCodeTimeUnits.Milliseconds; - GCode.GCodeShowImageType = GCodeBuilder.GCodeShowImageTypes.FilenameNonZeroPNG; - GCode.MaxLEDPower = MaxLEDPower; - GCode.CommandClearImage.Enabled = false; + GCode = new GCodeBuilder + { + UseTailComma = true, + UseComments = false, + GCodePositioningType = GCodeBuilder.GCodePositioningTypes.Absolute, + GCodeSpeedUnit = GCodeBuilder.GCodeSpeedUnits.CentimetersPerMinute, + GCodeTimeUnit = GCodeBuilder.GCodeTimeUnits.Milliseconds, + GCodeShowImageType = GCodeBuilder.GCodeShowImageTypes.FilenameNonZeroPNG, + MaxLEDPower = MaxLEDPower, + CommandClearImage = {Enabled = false} + }; } #endregion @@ -441,123 +444,119 @@ namespace UVtools.Core.FileFormats protected override void EncodeInternally(string fileFullPath, OperationProgress progress) { - using (ZipArchive outputFile = ZipFile.Open(fileFullPath, ZipArchiveMode.Create)) + using ZipArchive outputFile = ZipFile.Open(fileFullPath, ZipArchiveMode.Create); + if (Thumbnails.Length > 0 && Thumbnails[0] is not null) { - if (Thumbnails.Length > 0 && Thumbnails[0] is not null) - { - using var thumbnailsStream = outputFile.CreateEntry(PreviewFilename).Open(); - using var vec = new VectorOfByte(); - CvInvoke.Imencode(".png", Thumbnails[0], vec); - thumbnailsStream.WriteBytes(vec.ToArray()); - thumbnailsStream.Close(); - } - - for (uint layerIndex = 0; layerIndex < LayerCount; layerIndex++) - { - progress.Token.ThrowIfCancellationRequested(); - var layer = this[layerIndex]; - outputFile.PutFileContent($"{layerIndex + 1}.png", layer.CompressedBytes, ZipArchiveMode.Create); - progress++; - } + using var thumbnailsStream = outputFile.CreateEntry(PreviewFilename).Open(); + using var vec = new VectorOfByte(); + CvInvoke.Imencode(".png", Thumbnails[0], vec); + thumbnailsStream.WriteBytes(vec.ToArray()); + thumbnailsStream.Close(); + } - XmlSerializer serializer = new(ManifestFile.GetType()); - XmlSerializerNamespaces ns = new(); - ns.Add("", ""); - var entry = outputFile.CreateEntry(ManifestFilename); - using (var stream = entry.Open()) - { - serializer.Serialize(stream, ManifestFile, ns); - } + for (uint layerIndex = 0; layerIndex < LayerCount; layerIndex++) + { + progress.Token.ThrowIfCancellationRequested(); + var layer = this[layerIndex]; + outputFile.PutFileContent($"{layerIndex + 1}.png", layer.CompressedBytes, ZipArchiveMode.Create); + progress++; + } - outputFile.PutFileContent(GCodeFilename, EncryptGCode(progress), ZipArchiveMode.Create); + XmlSerializer serializer = new(ManifestFile.GetType()); + XmlSerializerNamespaces ns = new(); + ns.Add("", ""); + var entry = outputFile.CreateEntry(ManifestFilename); + using (var stream = entry.Open()) + { + serializer.Serialize(stream, ManifestFile, ns); } + + outputFile.PutFileContent(GCodeFilename, EncryptGCode(progress), ZipArchiveMode.Create); } protected override void DecodeInternally(string fileFullPath, OperationProgress progress) { - using (var inputFile = ZipFile.Open(FileFullPath, ZipArchiveMode.Read)) + using var inputFile = ZipFile.Open(FileFullPath, ZipArchiveMode.Read); + var entry = inputFile.GetEntry(ManifestFilename); + if (entry is null) { - var entry = inputFile.GetEntry(ManifestFilename); - if (entry is null) - { - Clear(); - throw new FileLoadException($"{ManifestFilename} not found", fileFullPath); - } + Clear(); + throw new FileLoadException($"{ManifestFilename} not found", fileFullPath); + } - try - { - var serializer = new XmlSerializer(ManifestFile.GetType()); - using var stream = entry.Open(); - ManifestFile = (ZCodePrint)serializer.Deserialize(stream); - } - catch (Exception e) - { - Clear(); - throw new FileLoadException($"Unable to deserialize '{entry.Name}'\n{e}", fileFullPath); - } + try + { + var serializer = new XmlSerializer(ManifestFile.GetType()); + using var stream = entry.Open(); + ManifestFile = (ZCodePrint)serializer.Deserialize(stream); + } + catch (Exception e) + { + Clear(); + throw new FileLoadException($"Unable to deserialize '{entry.Name}'\n{e}", fileFullPath); + } - entry = inputFile.GetEntry(GCodeFilename); - if (entry is null) - { - Clear(); - throw new FileLoadException($"{GCodeFilename} not found", fileFullPath); - } + entry = inputFile.GetEntry(GCodeFilename); + if (entry is null) + { + Clear(); + throw new FileLoadException($"{GCodeFilename} not found", fileFullPath); + } - var encryptEngine = new RsaEngine(); - using var txtreader = new StringReader(GCodeRSAPublicKey); - var keyParameter = (AsymmetricKeyParameter)new PemReader(txtreader).ReadObject(); - encryptEngine.Init(true, keyParameter); + var encryptEngine = new RsaEngine(); + using var txtreader = new StringReader(GCodeRSAPublicKey); + var keyParameter = (AsymmetricKeyParameter)new PemReader(txtreader).ReadObject(); + encryptEngine.Init(true, keyParameter); - using (TextReader tr = new StreamReader(entry.Open())) + using (TextReader tr = new StreamReader(entry.Open())) + { + string line; + progress.Reset("Decrypting GCode", (uint) (entry.Length / 88)); + while ((line = tr.ReadLine()) != null) { - string line; - progress.Reset("Decrypting GCode", (uint) (entry.Length / 88)); - while ((line = tr.ReadLine()) != null) - { - if (string.IsNullOrEmpty(line)) continue; - if (!line.EndsWith("==")) continue; + if (string.IsNullOrEmpty(line)) continue; + if (!line.EndsWith("==")) continue; - byte[] data = System.Convert.FromBase64String(line); - var decodedBytes = encryptEngine.ProcessBlock(data, 0, data.Length); - decodedBytes = decodedBytes.Skip(2).SkipWhile(b => b == 255 || b == 0).ToArray(); - GCode.AppendLine(Encoding.UTF8.GetString(decodedBytes)); + byte[] data = System.Convert.FromBase64String(line); + var decodedBytes = encryptEngine.ProcessBlock(data, 0, data.Length); + decodedBytes = decodedBytes.Skip(2).SkipWhile(b => b is 255 or 0).ToArray(); + GCode.AppendLine(Encoding.UTF8.GetString(decodedBytes)); - progress++; - } - - tr.Close(); + progress++; } - LayerManager.Init(ManifestFile.Job.LayerCount); - progress.Reset(OperationProgress.StatusDecodeLayers, LayerCount); + tr.Close(); + } + + LayerManager.Init(ManifestFile.Job.LayerCount); + progress.Reset(OperationProgress.StatusDecodeLayers, LayerCount); - //var gcode = GCode.ToString(); - //float lastPostZ = LayerHeight; + //var gcode = GCode.ToString(); + //float lastPostZ = LayerHeight; - for (uint layerIndex = 0; layerIndex < LayerCount; layerIndex++) + for (uint layerIndex = 0; layerIndex < LayerCount; layerIndex++) + { + if (progress.Token.IsCancellationRequested) break; + entry = inputFile.GetEntry($"{layerIndex+1}.png"); + if (entry is null) { - if (progress.Token.IsCancellationRequested) break; - entry = inputFile.GetEntry($"{layerIndex+1}.png"); - if (entry is null) - { - Clear(); - throw new FileLoadException($"Layer {layerIndex+1} not found", fileFullPath); - } + Clear(); + throw new FileLoadException($"Layer {layerIndex+1} not found", fileFullPath); + } - using var stream = entry.Open(); - this[layerIndex] = new Layer(layerIndex, stream, LayerManager); + using var stream = entry.Open(); + this[layerIndex] = new Layer(layerIndex, stream, LayerManager); - progress++; - } + progress++; + } - GCode.ParseLayersFromGCode(this); + GCode.ParseLayersFromGCode(this); - entry = inputFile.GetEntry(PreviewFilename); - if (entry is not null) - { - Thumbnails[0] = new Mat(); - CvInvoke.Imdecode(entry.Open().ToArray(), ImreadModes.AnyColor, Thumbnails[0]); - } + entry = inputFile.GetEntry(PreviewFilename); + if (entry is not null) + { + Thumbnails[0] = new Mat(); + CvInvoke.Imdecode(entry.Open().ToArray(), ImreadModes.AnyColor, Thumbnails[0]); } LayerManager.GetBoundingRectangle(progress); @@ -619,7 +618,7 @@ namespace UVtools.Core.FileFormats var keyParameter = (AsymmetricKeyParameter)new PemReader(txtreader).ReadObject(); encryptEngine.Init(true, keyParameter); - using StringReader sr = new(GCode.ToString()); + using StringReader sr = new(GCodeStr); string line; while ((line = sr.ReadLine()) != null) { diff --git a/UVtools.Core/FileFormats/ZCodexFile.cs b/UVtools.Core/FileFormats/ZCodexFile.cs index f0aa3e1..5b3967a 100644 --- a/UVtools.Core/FileFormats/ZCodexFile.cs +++ b/UVtools.Core/FileFormats/ZCodexFile.cs @@ -50,7 +50,7 @@ namespace UVtools.Core.FileFormats public string Guid { get; set; } = "07452AC2-7494-4576-BA60-BFEA8815F917"; public string Material { get; set; } - public uint MaterialId { get; set; } + public string MaterialId { get; set; } public float LayerThickness { get; set; } public uint PrintTime { get; set; } public uint LayerTime { get; set; } @@ -350,6 +350,15 @@ namespace UVtools.Core.FileFormats public override object[] Configs => new[] {(object) ResinMetadataSettings, UserSettings, ZCodeMetadataSettings}; #endregion + #region Constructor + + public ZCodexFile() + { + GCode = new(); + } + + #endregion + #region Methods public override void Clear() @@ -521,7 +530,7 @@ M106 S255 M106 S0 */ - var gcode = GCode.ToString(); + var gcode = GCodeStr; if (line.StartsWith(GCodeKeywordDelaySupportFull) || line.StartsWith(GCodeKeywordDelayModel)) { @@ -594,7 +603,7 @@ M106 S0 public override void RebuildGCode() { - var gcode = GCode.ToString(); + var gcode = GCodeStr; gcode = Regex.Replace(gcode, @"Z[+]?([0-9]*\.[0-9]+|[0-9]+) F[+]?([0-9]*\.[0-9]+|[0-9]+)", $"Z{UserSettings.ZLiftDistance} F{UserSettings.ZLiftFeedRate}"); @@ -629,7 +638,7 @@ M106 S0 outputFile.PutFileContent("ResinMetadata", JsonConvert.SerializeObject(ResinMetadataSettings, Formatting.Indented), ZipArchiveMode.Update); outputFile.PutFileContent("UserSettingsData", JsonConvert.SerializeObject(UserSettings, Formatting.Indented), ZipArchiveMode.Update); outputFile.PutFileContent("ZCodeMetadata", JsonConvert.SerializeObject(ZCodeMetadataSettings, Formatting.Indented), ZipArchiveMode.Update); - outputFile.PutFileContent("ResinGCodeData", GCode.ToString(), ZipArchiveMode.Update); + outputFile.PutFileContent("ResinGCodeData", GCodeStr, ZipArchiveMode.Update); } //Decode(FileFullPath, progress); diff --git a/UVtools.Core/GCode/GCodeCommand.cs b/UVtools.Core/GCode/GCodeCommand.cs index 98f8c61..e74fb4d 100644 --- a/UVtools.Core/GCode/GCodeCommand.cs +++ b/UVtools.Core/GCode/GCodeCommand.cs @@ -40,7 +40,7 @@ namespace UVtools.Core.GCode Comment = comment; } - public void Reset(string command, string arguments, string comment, bool enabled = true) + public void Set(string command, string arguments, string comment, bool enabled = true) { Enabled = enabled; Command = command; @@ -48,13 +48,13 @@ namespace UVtools.Core.GCode Comment = comment; } - public void Reset(string command, string arguments) + public void Set(string command, string arguments) { Command = command; Arguments = arguments; } - public void Reset(string command) + public void Set(string command) { Command = command; } diff --git a/UVtools.Core/Operations/OperationCalibrateElephantFoot.cs b/UVtools.Core/Operations/OperationCalibrateElephantFoot.cs index 2c3bc0a..f755e48 100644 --- a/UVtools.Core/Operations/OperationCalibrateElephantFoot.cs +++ b/UVtools.Core/Operations/OperationCalibrateElephantFoot.cs @@ -26,12 +26,12 @@ namespace UVtools.Core.Operations public sealed class OperationCalibrateElephantFoot : Operation { #region Members - private decimal _layerHeight = 0.05M; + private decimal _layerHeight; private bool _syncLayers; - private ushort _bottomLayers = 10; - private ushort _normalLayers = 70; - private decimal _bottomExposure = 60; - private decimal _normalExposure = 12; + private ushort _bottomLayers; + private ushort _normalLayers; + private decimal _bottomExposure; + private decimal _normalExposure; private decimal _partScale = 1; private byte _margin = 30; private bool _extrudeText = true; @@ -364,10 +364,12 @@ namespace UVtools.Core.Operations public override void InitWithSlicerFile() { base.InitWithSlicerFile(); - _layerHeight = (decimal)SlicerFile.LayerHeight; - //_bottomLayers = slicerFile.BottomLayerCount; - _bottomExposure = (decimal)SlicerFile.BottomExposureTime; - _normalExposure = (decimal)SlicerFile.ExposureTime; + if(_layerHeight <= 0) _layerHeight = (decimal)SlicerFile.LayerHeight; + if(_bottomExposure <= 0) _bottomExposure = (decimal)SlicerFile.BottomExposureTime; + if(_normalExposure <= 0) _normalExposure = (decimal)SlicerFile.ExposureTime; + if (_bottomLayers <= 0) _bottomLayers = (ushort) Slicer.Slicer.MillimetersToLayers(1M, _layerHeight); + if (_normalLayers <= 0) _normalLayers = (ushort) Slicer.Slicer.MillimetersToLayers(3.5M, _layerHeight); + _mirrorOutput = SlicerFile.MirrorDisplay; } diff --git a/UVtools.Core/Operations/OperationCalibrateExposureFinder.cs b/UVtools.Core/Operations/OperationCalibrateExposureFinder.cs index 2ce35f2..bdcc7ec 100644 --- a/UVtools.Core/Operations/OperationCalibrateExposureFinder.cs +++ b/UVtools.Core/Operations/OperationCalibrateExposureFinder.cs @@ -61,10 +61,10 @@ namespace UVtools.Core.Operations #region Members private decimal _displayWidth; private decimal _displayHeight; - private decimal _layerHeight = 0.05M; - private ushort _bottomLayers = 3; - private decimal _bottomExposure = 60; - private decimal _normalExposure = 12; + private decimal _layerHeight; + private ushort _bottomLayers; + private decimal _bottomExposure; + private decimal _normalExposure; private decimal _topBottomMargin = 5; private decimal _leftRightMargin = 10; private byte _chamferLayers = 0; @@ -960,10 +960,7 @@ namespace UVtools.Core.Operations public override void InitWithSlicerFile() { base.InitWithSlicerFile(); - _layerHeight = (decimal)SlicerFile.LayerHeight; - _bottomLayers = SlicerFile.BottomLayerCount; - _bottomExposure = (decimal)SlicerFile.BottomExposureTime; - _normalExposure = (decimal)SlicerFile.ExposureTime; + _mirrorOutput = SlicerFile.MirrorDisplay; if (SlicerFile.DisplayWidth > 0) @@ -971,14 +968,17 @@ namespace UVtools.Core.Operations if (SlicerFile.DisplayHeight > 0) DisplayHeight = (decimal)SlicerFile.DisplayHeight; + if(_layerHeight <= 0) _layerHeight = (decimal)SlicerFile.LayerHeight; + if(_bottomLayers <= 0) _bottomLayers = SlicerFile.BottomLayerCount; + if(_bottomExposure <= 0) _bottomExposure = (decimal)SlicerFile.BottomExposureTime; + if(_normalExposure <= 0) _normalExposure = (decimal)SlicerFile.ExposureTime; + if (_exposureGenManualBottom == 0) _exposureGenManualBottom = (decimal) SlicerFile.BottomExposureTime; if (_exposureGenManualNormal == 0) _exposureGenManualNormal = (decimal)SlicerFile.ExposureTime; if (_multipleBrightnessGenExposureTime == 0) - { _multipleBrightnessGenExposureTime = (decimal)SlicerFile.ExposureTime; - } if (!SlicerFile.HavePrintParameterPerLayerModifier(FileFormat.PrintParameterModifier.ExposureSeconds)) { diff --git a/UVtools.Core/Operations/OperationCalibrateGrayscale.cs b/UVtools.Core/Operations/OperationCalibrateGrayscale.cs index dd9e6b5..3085062 100644 --- a/UVtools.Core/Operations/OperationCalibrateGrayscale.cs +++ b/UVtools.Core/Operations/OperationCalibrateGrayscale.cs @@ -23,12 +23,12 @@ namespace UVtools.Core.Operations public sealed class OperationCalibrateGrayscale : Operation { #region Members - private decimal _layerHeight = 0.05M; - private ushort _bottomLayers = 10; + private decimal _layerHeight; + private ushort _bottomLayers; private ushort _interfaceLayers = 5; private ushort _normalLayers = 30; - private decimal _bottomExposure = 60; - private decimal _normalExposure = 12; + private decimal _bottomExposure; + private decimal _normalExposure; private ushort _outerMargin = 200; private ushort _innerMargin = 50; private bool _enableAntiAliasing = true; @@ -108,10 +108,10 @@ namespace UVtools.Core.Operations public override void InitWithSlicerFile() { base.InitWithSlicerFile(); - _layerHeight = (decimal)SlicerFile.LayerHeight; - _bottomLayers = SlicerFile.BottomLayerCount; - _bottomExposure = (decimal)SlicerFile.BottomExposureTime; - _normalExposure = (decimal)SlicerFile.ExposureTime; + if(_layerHeight <= 0) _layerHeight = (decimal)SlicerFile.LayerHeight; + if(_bottomLayers <= 0) _bottomLayers = SlicerFile.BottomLayerCount; + if(_bottomExposure <= 0) _bottomExposure = (decimal)SlicerFile.BottomExposureTime; + if(_normalExposure <= 0) _normalExposure = (decimal)SlicerFile.ExposureTime; _mirrorOutput = SlicerFile.MirrorDisplay; } diff --git a/UVtools.Core/Operations/OperationCalibrateStressTower.cs b/UVtools.Core/Operations/OperationCalibrateStressTower.cs index 058b7c6..7552782 100644 --- a/UVtools.Core/Operations/OperationCalibrateStressTower.cs +++ b/UVtools.Core/Operations/OperationCalibrateStressTower.cs @@ -25,10 +25,10 @@ namespace UVtools.Core.Operations #region Members private decimal _displayWidth; private decimal _displayHeight; - private decimal _layerHeight = 0.05M; - private ushort _bottomLayers = 3; - private decimal _bottomExposure = 60; - private decimal _normalExposure = 12; + private decimal _layerHeight; + private ushort _bottomLayers; + private decimal _bottomExposure; + private decimal _normalExposure; private decimal _baseDiameter = 30; private decimal _baseHeight = 3; private decimal _bodyHeight = 50; @@ -107,10 +107,10 @@ namespace UVtools.Core.Operations public override void InitWithSlicerFile() { base.InitWithSlicerFile(); - _layerHeight = (decimal)SlicerFile.LayerHeight; - _bottomLayers = SlicerFile.BottomLayerCount; - _bottomExposure = (decimal)SlicerFile.BottomExposureTime; - _normalExposure = (decimal)SlicerFile.ExposureTime; + if(_layerHeight <= 0) _layerHeight = (decimal)SlicerFile.LayerHeight; + if(_bottomLayers <= 0) _bottomLayers = SlicerFile.BottomLayerCount; + if(_bottomExposure <= 0) _bottomExposure = (decimal)SlicerFile.BottomExposureTime; + if(_normalExposure <= 0) _normalExposure = (decimal)SlicerFile.ExposureTime; _mirrorOutput = SlicerFile.MirrorDisplay; if (SlicerFile.DisplayWidth > 0) diff --git a/UVtools.Core/Operations/OperationCalibrateTolerance.cs b/UVtools.Core/Operations/OperationCalibrateTolerance.cs index 87f7f03..8bc3c5c 100644 --- a/UVtools.Core/Operations/OperationCalibrateTolerance.cs +++ b/UVtools.Core/Operations/OperationCalibrateTolerance.cs @@ -27,10 +27,10 @@ namespace UVtools.Core.Operations #region Members private decimal _displayWidth; private decimal _displayHeight; - private decimal _layerHeight = 0.05M; - private ushort _bottomLayers = 3; - private decimal _bottomExposure = 60; - private decimal _normalExposure = 12; + private decimal _layerHeight; + private ushort _bottomLayers; + private decimal _bottomExposure; + private decimal _normalExposure; private decimal _zSize = 10; private ushort _topBottomMargin = 100; private ushort _leftRightMargin = 100; @@ -427,10 +427,10 @@ namespace UVtools.Core.Operations public override void InitWithSlicerFile() { base.InitWithSlicerFile(); - _layerHeight = (decimal)SlicerFile.LayerHeight; - _bottomLayers = SlicerFile.BottomLayerCount; - _bottomExposure = (decimal)SlicerFile.BottomExposureTime; - _normalExposure = (decimal)SlicerFile.ExposureTime; + if (_layerHeight <= 0) _layerHeight = (decimal)SlicerFile.LayerHeight; + if (_bottomLayers <= 0) _bottomLayers = SlicerFile.BottomLayerCount; + if (_bottomExposure <= 0) _bottomExposure = (decimal)SlicerFile.BottomExposureTime; + if (_normalExposure <= 0) _normalExposure = (decimal)SlicerFile.ExposureTime; _mirrorOutput = SlicerFile.MirrorDisplay; if (SlicerFile.DisplayWidth > 0) diff --git a/UVtools.Core/Operations/OperationCalibrateXYZAccuracy.cs b/UVtools.Core/Operations/OperationCalibrateXYZAccuracy.cs index 00d78e3..3542ef4 100644 --- a/UVtools.Core/Operations/OperationCalibrateXYZAccuracy.cs +++ b/UVtools.Core/Operations/OperationCalibrateXYZAccuracy.cs @@ -22,10 +22,10 @@ namespace UVtools.Core.Operations public sealed class OperationCalibrateXYZAccuracy : Operation { #region Members - private decimal _layerHeight = 0.05M; - private ushort _bottomLayers = 3; - private decimal _bottomExposure = 60; - private decimal _normalExposure = 12; + private decimal _layerHeight; + private ushort _bottomLayers; + private decimal _bottomExposure; + private decimal _normalExposure; private ushort _topBottomMargin = 100; private ushort _leftRightMargin = 100; private decimal _displayWidth; @@ -459,10 +459,10 @@ namespace UVtools.Core.Operations public override void InitWithSlicerFile() { base.InitWithSlicerFile(); - _layerHeight = (decimal)SlicerFile.LayerHeight; - _bottomLayers = SlicerFile.BottomLayerCount; - _bottomExposure = (decimal)SlicerFile.BottomExposureTime; - _normalExposure = (decimal)SlicerFile.ExposureTime; + if (_layerHeight <= 0) _layerHeight = (decimal)SlicerFile.LayerHeight; + if (_bottomLayers <= 0) _bottomLayers = SlicerFile.BottomLayerCount; + if (_bottomExposure <= 0) _bottomExposure = (decimal)SlicerFile.BottomExposureTime; + if (_normalExposure <= 0) _normalExposure = (decimal)SlicerFile.ExposureTime; _mirrorOutput = SlicerFile.MirrorDisplay; if (SlicerFile.DisplayWidth > 0) diff --git a/UVtools.Core/Operations/OperationChangeResolution.cs b/UVtools.Core/Operations/OperationChangeResolution.cs index c40d3f7..a43fdbe 100644 --- a/UVtools.Core/Operations/OperationChangeResolution.cs +++ b/UVtools.Core/Operations/OperationChangeResolution.cs @@ -126,8 +126,8 @@ namespace UVtools.Core.Operations public override void InitWithSlicerFile() { base.InitWithSlicerFile(); - NewResolutionX = SlicerFile.ResolutionX; - NewResolutionY = SlicerFile.ResolutionY; + if(_newResolutionX <= 0) _newResolutionX = SlicerFile.ResolutionX; + if(_newResolutionY <= 0) _newResolutionY = SlicerFile.ResolutionY; } #endregion diff --git a/UVtools.Core/Operations/OperationDynamicLifts.cs b/UVtools.Core/Operations/OperationDynamicLifts.cs index 5fab1d9..37d8253 100644 --- a/UVtools.Core/Operations/OperationDynamicLifts.cs +++ b/UVtools.Core/Operations/OperationDynamicLifts.cs @@ -235,12 +235,26 @@ namespace UVtools.Core.Operations { } public OperationDynamicLifts(FileFormat slicerFile) : base(slicerFile) + { } + + public override void InitWithSlicerFile() { - _minBottomLiftHeight = _maxBottomLiftHeight = SlicerFile.BottomLiftHeight; - _minLiftHeight = _maxLiftHeight = SlicerFile.LiftHeight; + base.InitWithSlicerFile(); + + if(_minBottomLiftHeight <= 0) _minBottomLiftHeight = SlicerFile.BottomLiftHeight; + if (_maxBottomLiftHeight <= 0 || _maxBottomLiftHeight < _minBottomLiftHeight) _maxBottomLiftHeight = _minBottomLiftHeight; + + if (_minLiftHeight <= 0) _minLiftHeight = SlicerFile.LiftHeight; + if (_maxLiftHeight <= 0 || _maxLiftHeight < _minLiftHeight) _maxLiftHeight = _minLiftHeight; + + if (_minBottomLiftSpeed <= 0) _minBottomLiftSpeed = SlicerFile.BottomLiftSpeed; + if (_maxBottomLiftSpeed <= 0 || _maxBottomLiftSpeed < _minBottomLiftSpeed) _maxBottomLiftSpeed = _minBottomLiftSpeed; + + if(_minLiftSpeed <= 0) _minLiftSpeed = SlicerFile.LiftSpeed; + if (_maxLiftSpeed <= 0 || _maxLiftSpeed < _minLiftSpeed) _maxLiftSpeed = _minLiftSpeed; - _minBottomLiftSpeed = _maxBottomLiftSpeed = SlicerFile.BottomLiftSpeed; - _minLiftSpeed = _maxLiftSpeed = SlicerFile.LiftSpeed; + RaisePropertyChanged(nameof(IsBottomLayersEnabled)); + RaisePropertyChanged(nameof(IsNormalLayersEnabled)); } #endregion diff --git a/UVtools.Core/Operations/OperationIPrintedThisFile.cs b/UVtools.Core/Operations/OperationIPrintedThisFile.cs index 76c1348..36aec90 100644 --- a/UVtools.Core/Operations/OperationIPrintedThisFile.cs +++ b/UVtools.Core/Operations/OperationIPrintedThisFile.cs @@ -8,7 +8,6 @@ using System; using System.Text; -using System.Threading.Tasks; using UVtools.Core.FileFormats; using UVtools.Core.Managers; using UVtools.Core.Objects; diff --git a/UVtools.Core/Operations/OperationLayerExportGif.cs b/UVtools.Core/Operations/OperationLayerExportGif.cs index d0a0d24..69e496a 100644 --- a/UVtools.Core/Operations/OperationLayerExportGif.cs +++ b/UVtools.Core/Operations/OperationLayerExportGif.cs @@ -24,6 +24,7 @@ namespace UVtools.Core.Operations [Serializable] public sealed class OperationLayerExportGif : Operation { + #region Enums public enum ExportGifRotateDirection : byte { None = 9, @@ -45,7 +46,7 @@ namespace UVtools.Core.Operations Vertically, Both, } - + #endregion #region Members private string _filePath; diff --git a/UVtools.Core/Operations/OperationLayerImport.cs b/UVtools.Core/Operations/OperationLayerImport.cs index 035ec2e..6ecc629 100644 --- a/UVtools.Core/Operations/OperationLayerImport.cs +++ b/UVtools.Core/Operations/OperationLayerImport.cs @@ -10,8 +10,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Drawing; using System.IO; -using System.Linq; -using System.Runtime.InteropServices.ComTypes; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; diff --git a/UVtools.Core/Operations/OperationMove.cs b/UVtools.Core/Operations/OperationMove.cs index bac56b6..deb3829 100644 --- a/UVtools.Core/Operations/OperationMove.cs +++ b/UVtools.Core/Operations/OperationMove.cs @@ -12,7 +12,6 @@ using System.Threading.Tasks; using Emgu.CV; using Emgu.CV.Structure; using UVtools.Core.FileFormats; -using UVtools.Core.Objects; namespace UVtools.Core.Operations { diff --git a/UVtools.Core/Operations/OperationPattern.cs b/UVtools.Core/Operations/OperationPattern.cs index 95dc08d..fbe5efb 100644 --- a/UVtools.Core/Operations/OperationPattern.cs +++ b/UVtools.Core/Operations/OperationPattern.cs @@ -13,7 +13,6 @@ using System.Threading.Tasks; using Emgu.CV; using UVtools.Core.Extensions; using UVtools.Core.FileFormats; -using UVtools.Core.Objects; namespace UVtools.Core.Operations { diff --git a/UVtools.Core/Operations/OperationPixelDimming.cs b/UVtools.Core/Operations/OperationPixelDimming.cs index 7e86554..d2eac35 100644 --- a/UVtools.Core/Operations/OperationPixelDimming.cs +++ b/UVtools.Core/Operations/OperationPixelDimming.cs @@ -16,7 +16,6 @@ using Emgu.CV; using Emgu.CV.CvEnum; using UVtools.Core.Extensions; using UVtools.Core.FileFormats; -using UVtools.Core.Objects; namespace UVtools.Core.Operations { diff --git a/UVtools.Core/Operations/OperationRedrawModel.cs b/UVtools.Core/Operations/OperationRedrawModel.cs index 1e25b10..7017f64 100644 --- a/UVtools.Core/Operations/OperationRedrawModel.cs +++ b/UVtools.Core/Operations/OperationRedrawModel.cs @@ -16,7 +16,6 @@ using Emgu.CV.Structure; using Emgu.CV.Util; using UVtools.Core.Extensions; using UVtools.Core.FileFormats; -using UVtools.Core.Objects; namespace UVtools.Core.Operations { diff --git a/UVtools.Core/Operations/OperationResize.cs b/UVtools.Core/Operations/OperationResize.cs index 01e1c79..9d528f5 100644 --- a/UVtools.Core/Operations/OperationResize.cs +++ b/UVtools.Core/Operations/OperationResize.cs @@ -12,7 +12,6 @@ using System.Threading.Tasks; using Emgu.CV; using UVtools.Core.Extensions; using UVtools.Core.FileFormats; -using UVtools.Core.Objects; namespace UVtools.Core.Operations { @@ -55,6 +54,13 @@ namespace UVtools.Core.Operations return sb.ToString(); } + + public override string ToString() + { + var result = $"[X: {_x}%, Y: {_y}%] [Fade: {_isFade}] [Constrain: {_constrainXy}]" + LayerRangeString; + if (!string.IsNullOrEmpty(ProfileName)) result = $"{ProfileName}: {result}"; + return result; + } #endregion #region Properties @@ -111,13 +117,6 @@ namespace UVtools.Core.Operations #endregion - public override string ToString() - { - var result = $"[X: {_x}%, Y: {_y}%] [Fade: {_isFade}] [Constrain: {_constrainXy}]"+ LayerRangeString; - if (!string.IsNullOrEmpty(ProfileName)) result = $"{ProfileName}: {result}"; - return result; - } - #region Equality protected bool Equals(OperationResize other) diff --git a/UVtools.Core/Operations/OperationSolidify.cs b/UVtools.Core/Operations/OperationSolidify.cs index 0990182..b689799 100644 --- a/UVtools.Core/Operations/OperationSolidify.cs +++ b/UVtools.Core/Operations/OperationSolidify.cs @@ -10,7 +10,6 @@ using System; using System.Threading.Tasks; using Emgu.CV; using Emgu.CV.CvEnum; -using Emgu.CV.Structure; using Emgu.CV.Util; using UVtools.Core.Extensions; using UVtools.Core.FileFormats; diff --git a/UVtools.Core/Slicer/Slicer.cs b/UVtools.Core/Slicer/Slicer.cs index 9f30e86..1a488f3 100644 --- a/UVtools.Core/Slicer/Slicer.cs +++ b/UVtools.Core/Slicer/Slicer.cs @@ -205,5 +205,13 @@ namespace UVtools.Core.Slicer public static uint PixelsFromMillimetersX(Size resolution, SizeF display, decimal millimeters) => (uint)Math.Floor(resolution.Width / display.Width * (double) millimeters); public static uint PixelsFromMillimetersY(Size resolution, SizeF display, decimal millimeters) => (uint)Math.Floor(resolution.Height / display.Height * (double) millimeters); + + public static uint MillimetersToLayers(float millimeters, float layerHeight) => (uint) Math.Floor(millimeters / layerHeight); + public static uint MillimetersToLayers(double millimeters, double layerHeight) => (uint) Math.Floor(millimeters / layerHeight); + public static uint MillimetersToLayers(decimal millimeters, decimal layerHeight) => (uint) Math.Floor(millimeters / layerHeight); + + public static uint LayersToMillimeters(uint layers, float layerHeight) => (uint)Math.Floor(layers * layerHeight); + public static uint LayersToMillimeters(uint layers, double layerHeight) => (uint)Math.Floor(layers * layerHeight); + public static uint LayersToMillimeters(uint layers, decimal layerHeight) => (uint)Math.Floor(layers * layerHeight); } } diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj index e687d90..1b7ca18 100644 --- a/UVtools.Core/UVtools.Core.csproj +++ b/UVtools.Core/UVtools.Core.csproj @@ -10,7 +10,7 @@ <RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl> <PackageProjectUrl>https://github.com/sn4k3/UVtools</PackageProjectUrl> <Description>MSLA/DLP, file analysis, calibration, repair, conversion and manipulation</Description> - <Version>2.13.3</Version> + <Version>2.13.4</Version> <Copyright>Copyright © 2020 PTRTECH</Copyright> <PackageIcon>UVtools.png</PackageIcon> <Platforms>AnyCPU;x64</Platforms> diff --git a/UVtools.InstallerMM/UVtools.InstallerMM.wxs b/UVtools.InstallerMM/UVtools.InstallerMM.wxs index e924a15..dd0a02c 100644 --- a/UVtools.InstallerMM/UVtools.InstallerMM.wxs +++ b/UVtools.InstallerMM/UVtools.InstallerMM.wxs @@ -833,6 +833,12 @@ <Component Id="owc7382C9C8FF3A521BF6356335630BD375" Guid="aa17a4dd-086a-d8ca-2a94-5bed85c6d151"> <File Id="owf7382C9C8FF3A521BF6356335630BD375" Source="$(var.SourceDir)\ucrtbase.dll" KeyPath="yes" /> </Component> + <Component Id="owc569F1566ECE625286E8493EC67315736" Guid="c148e3e9-5880-6add-e3f9-b0bbc36f5071"> + <File Id="owf569F1566ECE625286E8493EC67315736" Source="$(var.SourceDir)\UVtools.AvaloniaControls.dll" KeyPath="yes" /> + </Component> + <Component Id="owc9783B2A71C9B9BA65282E5F7847AF853" Guid="5d8bba8d-dd57-3bf5-32a2-79feff36a7e0"> + <File Id="owf9783B2A71C9B9BA65282E5F7847AF853" Source="$(var.SourceDir)\UVtools.AvaloniaControls.pdb" KeyPath="yes" /> + </Component> <Component Id="owc540CF8CDBE6617C60879532E387E1716" Guid="bd0331df-7b7e-28be-f87a-809cdbfa07f0"> <File Id="owf540CF8CDBE6617C60879532E387E1716" Source="$(var.SourceDir)\UVtools.Core.dll" KeyPath="yes" /> </Component> diff --git a/UVtools.WPF/Assets/Icons/vector-square-16x16.png b/UVtools.WPF/Assets/Icons/vector-square-16x16.png Binary files differnew file mode 100644 index 0000000..a93e8ae --- /dev/null +++ b/UVtools.WPF/Assets/Icons/vector-square-16x16.png diff --git a/UVtools.WPF/MainWindow.GCode.cs b/UVtools.WPF/MainWindow.GCode.cs index 716864a..3ab6c65 100644 --- a/UVtools.WPF/MainWindow.GCode.cs +++ b/UVtools.WPF/MainWindow.GCode.cs @@ -17,7 +17,7 @@ namespace UVtools.WPF { public partial class MainWindow { - public bool HaveGCode => IsFileLoaded && SlicerFile.HaveGCode; + public bool HaveGCode => IsFileLoaded && SlicerFile.SupportsGCode; public string GCodeStr => SlicerFile?.GCodeStr; public uint GCodeLines => !HaveGCode ? 0 : SlicerFile.GCode.LineCount; diff --git a/UVtools.WPF/MainWindow.axaml b/UVtools.WPF/MainWindow.axaml index 5d53277..478ecd4 100644 --- a/UVtools.WPF/MainWindow.axaml +++ b/UVtools.WPF/MainWindow.axaml @@ -648,6 +648,7 @@ Spacing="2" VerticalAlignment="Center"> <RepeatButton + VerticalAlignment="Stretch" HotKey="Ctrl + Shift + Down" ToolTip.Tip="Go to the previous issue [Ctrl + Shift + Down]" IsEnabled="{Binding IssueCanGoPrevious}" @@ -659,7 +660,7 @@ <TextBlock VerticalAlignment="Center"> <TextBlock.Text> - <MultiBinding StringFormat="\{0\}/\{1\}"> + <MultiBinding StringFormat="{}{0}/{1}"> <Binding Path="IssueSelectedIndexStr"/> <Binding Path="Issues.Count"/> </MultiBinding> @@ -667,6 +668,7 @@ </TextBlock> <RepeatButton + VerticalAlignment="Stretch" HotKey="Ctrl + Shift + Up" ToolTip.Tip="Go to the next issue [Ctrl + Shift + Up]" IsEnabled="{Binding IssueCanGoNext}" @@ -677,6 +679,7 @@ </RepeatButton> <Button + VerticalAlignment="Stretch" ToolTip.Tip="Hides and ignores the selected issues, they won't be re-detected. 
ALT + Click to re-enable the ignored issues." IsEnabled="{Binding #IssuesGrid.SelectedItem, Converter={x:Static ObjectConverters.IsNotNull}}" @@ -685,6 +688,7 @@ </Button> <Button + VerticalAlignment="Stretch" ToolTip.Tip="Remove selected issue when possible. 
Islands: All pixels are removed (turn black). 
ResinTrap: All trap areas are filled with white pixels. @@ -709,14 +713,16 @@ <Button IsEnabled="{Binding IsFileLoaded}" ToolTip.Tip="Attempt to repair issues" + VerticalAlignment="Stretch" Command="{Binding OnClickRepairIssues}"> <StackPanel Orientation="Horizontal" Spacing="5"> - <Image Source="/Assets/Icons/wrench-16x16.png" /> + <Image Source="/Assets/Icons/toolbox-16x16.png" /> <!--<TextBlock VerticalAlignment="Center" Text="Repair"/>!--> </StackPanel> </Button> <Button + VerticalAlignment="Stretch" ToolTip.Tip="Compute Issues. 
Right click to access settings." Command="{Binding OnClickDetectIssues}"> @@ -1883,7 +1889,7 @@ </ContextMenu> </Button.ContextMenu> <StackPanel Orientation="Horizontal"> - <Image Source="/Assets/Icons/geometry-16x16.png"/> + <Image Source="/Assets/Icons/vector-square-16x16.png"/> <TextBlock Margin="5,0,5,0" Text="Outline ⮟"/> </StackPanel> </Button> diff --git a/UVtools.WPF/UVtools.WPF.csproj b/UVtools.WPF/UVtools.WPF.csproj index 4ed678e..8af7821 100644 --- a/UVtools.WPF/UVtools.WPF.csproj +++ b/UVtools.WPF/UVtools.WPF.csproj @@ -12,7 +12,7 @@ <PackageLicenseFile>LICENSE</PackageLicenseFile> <RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl> <RepositoryType>Git</RepositoryType> - <Version>2.13.3</Version> + <Version>2.13.4</Version> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> @@ -30,7 +30,7 @@ <PackageReference Include="Avalonia.Desktop" Version="0.10.6" /> <PackageReference Include="Avalonia.Diagnostics" Version="0.10.6" /> <PackageReference Include="Emgu.CV.runtime.windows" Version="4.5.1.4349" /> - <PackageReference Include="MessageBox.Avalonia" Version="1.5.0" /> + <PackageReference Include="MessageBox.Avalonia" Version="1.5.1" /> <PackageReference Include="ThemeEditor.Controls.ColorPicker" Version="0.10.4" /> </ItemGroup> <ItemGroup> |