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 ; 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 ; 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 ; uint16 endY ; 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 ; + BYTE LayerRLE[DataSize] ; +} layerData; + +typedef struct(int size) { + BYTE layerDataBlock[size] ; +} rgbPreviewImageRawData; + +struct HEADER { + char name[8] ; + uint32 Uint_08 ; + uint32 Uint_0C ; + uint32 Uint_10 ; + uint32 Uint_14 ; + uint32 Uint_18 ; + + float PixelPerMmX ; + float PixelPerMmY ; + float ResolutionX ; + float ResolutionY ; + float LayerHeight ; + float ExposureTimeMs ; + float BottomExposureTimeMs ; + float Float_38 ; + float LightOffDelayMs ; + float BottomLightOffDelayMs ; + float BottomHeight ; + float Float_48 ; + float BottomLiftHeight ; + float LiftHeight ; + float LiftSpeed ; + float LiftSpeed_ ; + float BottomLiftSpeed ; + float BottomLiftSpeed_ ; + float Float_64 ; + float Float_68 ; + float Float_6c ; + float Float_70 ; + float Float_74 ; + float Float_78 ; + float Float_7c ; + float Float_80 ; + float Float_84 ; + float Float_88 ; + float Float_8c ; + float Float_90 ; + float Float_94 ; + uint32 Uint_98 ; + uint32 Uint_9c ; + uint32 Uint_a0 ; + uint32 LayerCount ; + uint32 Uint_a8 ; + uint32 PreviewSizeX ; + uint32 PreviewSizeY ; + + 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 ; uint16 endY ; 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 ; // 44944 + uint32 Unknown2 ; // 0 + uint32 Unknown3 ; // 0 + uint32 ResolutionX ; + uint32 ResolutionY ; + uint32 DataSize ; + uint32 Unknown4 ; // 2684702720 + BYTE LayerRLE[DataSize / 8 - 4] ; +} layerData; + +typedef struct(int size) { + BYTE layerDataBlock[size] ; +} rgbPreviewImageRawData; + +struct HEADER { + uint32 Tag1 ; // 2 + uint16 Tag2 ; // 49 + double XYPixelSize ; + double LayerHeight ; + double ExposureSeconds ; + double LightOffDelay ; + + double BottomExposureSeconds ; + uint32 BottomLayerCount ; + double LiftHeight ; // mm + double LiftSpeed ; // mm/s + double RetractSpeed ; // mm/s + double VolumeMl ; // ml + uint32 PreviewResolutionX ; + uint32 Unknown1 ; // 42 + uint32 PreviewResolutionY ; + uint32 Unknown2 ; // 10 + + rgbPreviewImageRawData preview(PreviewResolutionX*PreviewResolutionY*2); + uint32 LayerCount ; +} 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(";", "{0}"); - GCode.CommandWaitG4.Reset(";", "{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(";", "{0}"); + GCode.CommandWaitG4.Set(";", "{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; + } } /// 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 /// /// Gets the GCode, returns null if not supported /// - public GCodeBuilder GCode { get; set; } = new(); + public GCodeBuilder GCode { get; set; } /// /// Gets the GCode, returns null if not supported @@ -1183,9 +1183,14 @@ namespace UVtools.Core.FileFormats public string GCodeStr => GCode?.ToString(); /// - /// Gets if this file have available gcode + /// Gets if this file format supports gcode /// - public bool HaveGCode => !GCode?.IsEmpty ?? false; + public virtual bool SupportsGCode => GCode is not null; + + /// + /// Gets if this file have available gcode to read + /// + public bool HaveGCode => SupportsGCode && !GCode.IsEmpty; /// /// 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 /// 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++; - } - - 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); + 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++; + } + + 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(); - } - - LayerManager.Init(ManifestFile.Job.LayerCount); - progress.Reset(OperationProgress.StatusDecodeLayers, LayerCount); - - //var gcode = GCode.ToString(); - //float lastPostZ = LayerHeight; - - for (uint layerIndex = 0; layerIndex < LayerCount; layerIndex++) - { - 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); - } - - using var stream = entry.Open(); - this[layerIndex] = new Layer(layerIndex, stream, LayerManager); - progress++; } - GCode.ParseLayersFromGCode(this); + tr.Close(); + } - entry = inputFile.GetEntry(PreviewFilename); - if (entry is not null) + LayerManager.Init(ManifestFile.Job.LayerCount); + progress.Reset(OperationProgress.StatusDecodeLayers, LayerCount); + + //var gcode = GCode.ToString(); + //float lastPostZ = LayerHeight; + + for (uint layerIndex = 0; layerIndex < LayerCount; layerIndex++) + { + if (progress.Token.IsCancellationRequested) break; + entry = inputFile.GetEntry($"{layerIndex+1}.png"); + if (entry is null) { - Thumbnails[0] = new Mat(); - CvInvoke.Imdecode(entry.Open().ToArray(), ImreadModes.AnyColor, Thumbnails[0]); + Clear(); + throw new FileLoadException($"Layer {layerIndex+1} not found", fileFullPath); } + + using var stream = entry.Open(); + this[layerIndex] = new Layer(layerIndex, stream, LayerManager); + + progress++; + } + + 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]); } 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) - { - _minBottomLiftHeight = _maxBottomLiftHeight = SlicerFile.BottomLiftHeight; - _minLiftHeight = _maxLiftHeight = SlicerFile.LiftHeight; + { } - _minBottomLiftSpeed = _maxBottomLiftSpeed = SlicerFile.BottomLiftSpeed; - _minLiftSpeed = _maxLiftSpeed = SlicerFile.LiftSpeed; + public override void InitWithSlicerFile() + { + 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; + + 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 @@ https://github.com/sn4k3/UVtools https://github.com/sn4k3/UVtools MSLA/DLP, file analysis, calibration, repair, conversion and manipulation - 2.13.3 + 2.13.4 Copyright © 2020 PTRTECH UVtools.png AnyCPU;x64 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 @@ + + + + + + diff --git a/UVtools.WPF/Assets/Icons/vector-square-16x16.png b/UVtools.WPF/Assets/Icons/vector-square-16x16.png new file mode 100644 index 0000000..a93e8ae Binary files /dev/null and b/UVtools.WPF/Assets/Icons/vector-square-16x16.png differ 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"> - + @@ -667,6 +668,7 @@ 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 @@ LICENSE https://github.com/sn4k3/UVtools Git - 2.13.3 + 2.13.4 @@ -30,7 +30,7 @@ - +