diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2020-07-26 04:46:18 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2020-07-26 04:46:18 +0300 |
commit | c76a68c29bc041c571b30995ec59c03d27b4ceea (patch) | |
tree | bbfae763102b4004a7b85a89170f76340e533926 | |
parent | bf0feb805caac533dac58da6df2077b82225eafa (diff) |
v0.6.3.3v0.6.3.3
* (Add) Allow to save properties to clipboard
* (Add) Tool: Layer Repair - Allow remove islands below or equal to a pixel count (Suggested by: Nicholas Taylor)
* (Add) Issues: Allow sort columns by click them (Suggested by: Nicholas Taylor)
* (Improvement) Tool: Pattern - Prevent open this tool when unable to pattern due lack of space
* (Fix) Tool: Layer Repair - When issues are not caculated before, they are computed but user settings are ignored
-rw-r--r-- | CHANGELOG.md | 10 | ||||
-rw-r--r-- | UVtools.Cmd/Program.cs | 38 | ||||
-rw-r--r-- | UVtools.Cmd/UVtools.Cmd.csproj | 2 | ||||
-rw-r--r-- | UVtools.Core/Extensions/MathExtensions.cs | 59 | ||||
-rw-r--r-- | UVtools.Core/Layer/LayerManager.cs | 49 | ||||
-rw-r--r-- | UVtools.Core/UVtools.Core.csproj | 2 | ||||
-rw-r--r-- | UVtools.GUI/App.config | 4 | ||||
-rw-r--r-- | UVtools.GUI/Controls/ListViewColumnSorter.cs | 76 | ||||
-rw-r--r-- | UVtools.GUI/Forms/FrmRepairLayers.Designer.cs | 47 | ||||
-rw-r--r-- | UVtools.GUI/Forms/FrmRepairLayers.cs | 7 | ||||
-rw-r--r-- | UVtools.GUI/Forms/FrmRepairLayers.resx | 3 | ||||
-rw-r--r-- | UVtools.GUI/Forms/FrmSettings.Designer.cs | 156 | ||||
-rw-r--r-- | UVtools.GUI/Forms/FrmSettings.cs | 2 | ||||
-rw-r--r-- | UVtools.GUI/Forms/FrmToolPattern.cs | 8 | ||||
-rw-r--r-- | UVtools.GUI/FrmMain.Designer.cs | 55 | ||||
-rw-r--r-- | UVtools.GUI/FrmMain.cs | 94 | ||||
-rw-r--r-- | UVtools.GUI/FrmMain.resx | 20 | ||||
-rw-r--r-- | UVtools.GUI/Properties/AssemblyInfo.cs | 4 | ||||
-rw-r--r-- | UVtools.GUI/Properties/Settings.Designer.cs | 12 | ||||
-rw-r--r-- | UVtools.GUI/Properties/Settings.settings | 3 | ||||
-rw-r--r-- | UVtools.GUI/UVtools.GUI.csproj | 3 | ||||
-rw-r--r-- | UVtools.GUI/packages.config | 2 |
22 files changed, 518 insertions, 138 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b203967..cbcb13d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 26/07/2020 - v0.6.3.3 + +* (Add) Allow to save properties to clipboard +* (Add) Tool: Layer Repair - Allow remove islands below or equal to a pixel count (Suggested by: Nicholas Taylor) +* (Add) Issues: Allow sort columns by click them (Suggested by: Nicholas Taylor) +* (Improvement) Tool: Pattern - Prevent open this tool when unable to pattern due lack of space +* (Fix) Tool: Layer Repair - When issues are not caculated before, they are computed but user settings are ignored + ## 24/07/2020 - v0.6.3.2 * (Add) Tool: Layer Re-Height - Allow change layer height @@ -179,7 +187,7 @@ ## 17/06/2020 - v0.5.1.2 -* (Add) Able to install only the desired profiles and not the whole lot (Suggested by: Ingo Strohmenger) +* (Add) Able to install only the desired profiles and not the whole lot (Suggested by: Ingo Strohmenger) * (Add) Update manager for PrusaSlicer profiles * (Add) If PrusaSlicer not installed on system it prompt for installation (By open the official website) * (Fix) Prevent profiles instalation when PrusaSlicer is not installed on system diff --git a/UVtools.Cmd/Program.cs b/UVtools.Cmd/Program.cs index 15cbff0..405411b 100644 --- a/UVtools.Cmd/Program.cs +++ b/UVtools.Cmd/Program.cs @@ -10,7 +10,9 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; using UVtools.Core; +using UVtools.Core.Extensions; using UVtools.Core.FileFormats; +using UVtools.Core.Operations; namespace UVtools.Cmd { @@ -19,13 +21,14 @@ namespace UVtools.Cmd public static async Task<int> Main(params string[] args) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB"); + OperationProgress progress = new OperationProgress(); Stopwatch sw = new Stopwatch(); uint count = 0; var rootCommand = new RootCommand("MSLA/DLP, file analysis, repair, conversion and manipulation") { new Option(new []{"-f", "--file"}, "Input file to read") { - Required = true, + IsRequired = true, Argument = new Argument<FileSystemInfo>("filepath").ExistingOnly() }, new Option(new []{"-o", "--output"}, "Output file to save the modifications, if aware, it saves to the same input file") @@ -38,19 +41,19 @@ namespace UVtools.Cmd }, new Option(new []{"-c", "--convert"}, "Converts input into a output file format by it extension") { - Argument = new Argument<FileSystemInfo>("filepath") + Argument = new Argument<FileSystemInfo>("filepath"), }, new Option(new []{"-p", "--properties"}, "Print a list of all properties/settings"), new Option(new []{"-gcode"}, "Print the GCode if available"), new Option(new []{"-i", "--issues"}, "Compute and print a list of all issues"), new Option(new []{"-r", "--repair"}, "Attempt to repair all issues"){ - Argument = new Argument<int[]>("[start layer index] [end layer index]") + Argument = new Argument<int[]>("[start layer index] [end layer index] [islands 0/1] [remove empty layers 0/1] [resin traps 0/1]"), }, new Option(new []{"-mr", "--mut-resize"}, "Resizes layer images in a X and/or Y factor, starting from 100% value") { - Argument = new Argument<double[]>("[x%] [y%] [start layer index] [end layer index] [fade 0/1]") + Argument = new Argument<decimal[]>("[x%] [y%] [start layer index] [end layer index] [fade 0/1]") }, new Option(new []{"-ms", "--mut-solidify"}, "Closes all inner holes") { @@ -77,7 +80,7 @@ namespace UVtools.Cmd Argument = new Argument<uint[]>("[kernel size] [start layer index] [end layer index] [fade 0/1]") }, - new Option(new []{"-mpy", "--mut-py"}, "Performs downsampling step of Gaussian pyramid decomposition") + new Option(new []{"-mpy", "--mut-py"}, "Performs down-sampling step of Gaussian pyramid decomposition") { Argument = new Argument<uint[]>("[start layer index] [end layer index]") }, @@ -99,7 +102,8 @@ namespace UVtools.Cmd bool properties, bool gcode, bool issues, - bool repair + int[] repair + //decimal[] mutResize ) => { var fileFormat = FileFormat.FindByExtension(file.FullName, true, true); @@ -111,7 +115,7 @@ namespace UVtools.Cmd { Console.Write($"Reading: {file}"); sw.Restart(); - fileFormat.Decode(file.FullName); + fileFormat.Decode(file.FullName, progress); sw.Stop(); Console.WriteLine($", in {sw.ElapsedMilliseconds}ms"); Console.WriteLine("----------------------"); @@ -135,7 +139,7 @@ namespace UVtools.Cmd { Console.Write($"Extracting to {extract.FullName}"); sw.Restart(); - fileFormat.Extract(extract.FullName); + fileFormat.Extract(extract.FullName, true, true, progress); sw.Stop(); Console.WriteLine($", finished in {sw.ElapsedMilliseconds}ms"); } @@ -183,7 +187,7 @@ namespace UVtools.Cmd { Console.WriteLine("Computing Issues, please wait."); sw.Restart(); - var issuesDict = fileFormat.LayerManager.GetAllIssues(); + var issuesDict = fileFormat.LayerManager.GetAllIssues(null, null, progress); sw.Stop(); Console.WriteLine("Issues:"); @@ -217,7 +221,7 @@ namespace UVtools.Cmd try { sw.Restart(); - fileFormat.Convert(fileConvert, convert.FullName); + fileFormat.Convert(fileConvert, convert.FullName, progress); sw.Stop(); Console.WriteLine($"Convertion done in {sw.ElapsedMilliseconds}ms"); } @@ -230,12 +234,22 @@ namespace UVtools.Cmd } + if (!ReferenceEquals(repair, null)) + { + uint layerStartIndex = (uint) (repair.Length >= 1 ? Math.Max(0, repair[0]) : 0); + uint layerEndIndex = repair.Length >= 2 ? (uint) repair[1].Clamp(0, (int) (fileFormat.LayerCount - 1)) : fileFormat.LayerCount-1; + bool repairIslands = repair.Length < 3 || repair[2] > 0 || repair[2] < 0; + bool removeEmptyLayers = repair.Length < 4 || repair[3] > 0 || repair[3] < 0; + bool repairResinTraps = repair.Length < 5 || repair[4] > 0 || repair[4] < 0; + + fileFormat.LayerManager.RepairLayers(layerStartIndex, layerEndIndex, 2, 1, 4, repairIslands, removeEmptyLayers, repairResinTraps, null, progress); + } }); - await rootCommand.InvokeAsync(args); - //await rootCommand.InvokeAsync("-f body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN.sl1 -i"); + //await rootCommand.InvokeAsync(args); + await rootCommand.InvokeAsync("-f body_Tough0.1mm_SL1_5h16m_HOLLOW_DRAIN.sl1 -r -1"); return 1; diff --git a/UVtools.Cmd/UVtools.Cmd.csproj b/UVtools.Cmd/UVtools.Cmd.csproj index f0a0f01..d4d22a5 100644 --- a/UVtools.Cmd/UVtools.Cmd.csproj +++ b/UVtools.Cmd/UVtools.Cmd.csproj @@ -20,7 +20,7 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20303.1" /> + <PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20371.2" /> </ItemGroup> <ItemGroup> diff --git a/UVtools.Core/Extensions/MathExtensions.cs b/UVtools.Core/Extensions/MathExtensions.cs new file mode 100644 index 0000000..72c33bc --- /dev/null +++ b/UVtools.Core/Extensions/MathExtensions.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace UVtools.Core.Extensions +{ + public static class MathExtensions + { + public static byte Clamp(this byte value, byte min, byte max) + { + return value <= min ? min : value >= max ? max : value; + } + + public static sbyte Clamp(this sbyte value, sbyte min, sbyte max) + { + return value <= min ? min : value >= max ? max : value; + } + + public static ushort Clamp(this ushort value, ushort min, ushort max) + { + return value <= min ? min : value >= max ? max : value; + } + + public static short Clamp(this short value, short min, short max) + { + return value <= min ? min : value >= max ? max : value; + } + + public static uint Clamp(this uint value, uint min, uint max) + { + return value <= min ? min : value >= max ? max : value; + } + + public static int Clamp(this int value, int min, int max) + { + return value <= min ? min : value >= max ? max : value; + } + + public static ulong Clamp(this ulong value, ulong min, ulong max) + { + return value <= min ? min : value >= max ? max : value; + } + + public static long Clamp(this long value, long min, long max) + { + return value <= min ? min : value >= max ? max : value; + } + + public static T Clamp<T>(T value, T min, T max) where T : IComparable<T> + { + if (value.CompareTo(min) < 0) + return min; + if (value.CompareTo(max) > 0) + return max; + + return value; + } + } +} diff --git a/UVtools.Core/Layer/LayerManager.cs b/UVtools.Core/Layer/LayerManager.cs index 4cea92e..d38383f 100644 --- a/UVtools.Core/Layer/LayerManager.cs +++ b/UVtools.Core/Layer/LayerManager.cs @@ -1120,7 +1120,7 @@ namespace UVtools.Core return result; } - public void RepairLayers(uint layerStart, uint layerEnd, uint closingIterations = 1, uint openingIterations = 1, + public void RepairLayers(uint layerStart, uint layerEnd, uint closingIterations = 1, uint openingIterations = 1, byte removeIslandsBelowEqualPixels = 4, bool repairIslands = true, bool removeEmptyLayers = true, bool repairResinTraps = true, Dictionary<uint, List<LayerIssue>> issues = null, OperationProgress progress = null) { @@ -1135,27 +1135,46 @@ namespace UVtools.Core Layer layer = this[layerIndex]; using (var image = layer.LayerMat) { - if (repairResinTraps && !ReferenceEquals(issues, null)) + if (!ReferenceEquals(issues, null)) { - if (issues.TryGetValue((uint) layerIndex, out var issueList)) + if (repairIslands && removeIslandsBelowEqualPixels > 0) { - foreach (var issue in issueList.Where(issue => - issue.Type == LayerIssue.IssueType.ResinTrap)) + if (issues.TryGetValue((uint)layerIndex, out var issueList)) { - using (var vec = new VectorOfVectorOfPoint(new VectorOfPoint(issue.Pixels))) + var bytes = image.GetPixelSpan<byte>(); + foreach (var issue in issueList.Where(issue => + issue.Type == LayerIssue.IssueType.Island && issue.Pixels.Length <= removeIslandsBelowEqualPixels)) { - CvInvoke.DrawContours(image, - vec, + foreach (var issuePixel in issue.Pixels) + { + bytes[image.GetPixelPos(issuePixel)] = 0; + } + } + } + } + + if (repairResinTraps) + { + if (issues.TryGetValue((uint) layerIndex, out var issueList)) + { + foreach (var issue in issueList.Where(issue => + issue.Type == LayerIssue.IssueType.ResinTrap)) + { + using (var vec = new VectorOfVectorOfPoint(new VectorOfPoint(issue.Pixels))) + { + CvInvoke.DrawContours(image, + vec, + -1, + new MCvScalar(255), + -1); + } + + /*CvInvoke.DrawContours(image, + new VectorOfVectorOfPoint(new VectorOfPoint(issue.Pixels)), -1, new MCvScalar(255), - -1); + 2);*/ } - - /*CvInvoke.DrawContours(image, - new VectorOfVectorOfPoint(new VectorOfPoint(issue.Pixels)), - -1, - new MCvScalar(255), - 2);*/ } } } diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj index d62a305..d3fb17f 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, repair, conversion and manipulation</Description> - <Version>0.6.3.2</Version> + <Version>0.6.3.3</Version> <Copyright>Copyright © 2020 PTRTECH</Copyright> <PackageIcon>UVtools.png</PackageIcon> <Platforms>AnyCPU;x64</Platforms> diff --git a/UVtools.GUI/App.config b/UVtools.GUI/App.config index 9e184a8..4dfee0b 100644 --- a/UVtools.GUI/App.config +++ b/UVtools.GUI/App.config @@ -189,6 +189,10 @@ <setting name="LayerRepairRemoveEmptyLayers" serializeAs="String"> <value>True</value> </setting> + <setting name="LayerRepairRemoveIslandsBelowEqualPixelsDefault" + serializeAs="String"> + <value>10</value> + </setting> </UVtools.GUI.Properties.Settings> </userSettings> </configuration> diff --git a/UVtools.GUI/Controls/ListViewColumnSorter.cs b/UVtools.GUI/Controls/ListViewColumnSorter.cs new file mode 100644 index 0000000..de0d344 --- /dev/null +++ b/UVtools.GUI/Controls/ListViewColumnSorter.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace UVtools.GUI.Controls +{ + /// <summary> + /// This class is an implementation of the 'IComparer' interface. + /// </summary> + public class ListViewColumnSorter : IComparer + { + /// <summary> + /// Case insensitive comparer object + /// </summary> + private readonly CaseInsensitiveComparer _objectCompare; + + /// <summary> + /// Gets or sets the number of the column to which to apply the sorting operation (Defaults to '0'). + /// </summary> + public int SortColumn { set; get; } + + /// <summary> + /// Gets or sets the order of sorting to apply (for example, 'Ascending' or 'Descending'). + /// </summary> + public SortOrder Order { set; get; } + + /// <summary> + /// Class constructor. Initializes various elements + /// </summary> + public ListViewColumnSorter() + { + // Initialize the column to '0' + SortColumn = 0; + + // Initialize the sort order to 'none' + Order = SortOrder.None; + + // Initialize the CaseInsensitiveComparer object + _objectCompare = new CaseInsensitiveComparer(); + } + + /// <summary> + /// This method is inherited from the IComparer interface. It compares the two objects passed using a case insensitive comparison. + /// </summary> + /// <param name="x">First object to be compared</param> + /// <param name="y">Second object to be compared</param> + /// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns> + public int Compare(object x, object y) + { + // Cast the objects to be compared to ListViewItem objects + var listviewX = (ListViewItem)x; + var listviewY = (ListViewItem)y; + + // Compare the two items + var compareResult = _objectCompare.Compare(listviewX.SubItems[SortColumn].Text, listviewY.SubItems[SortColumn].Text); + + switch (Order) + { + // Calculate correct return value based on object comparison + case SortOrder.Ascending: + // Ascending sort is selected, return normal result of compare operation + return compareResult; + case SortOrder.Descending: + // Descending sort is selected, return negative result of compare operation + return (-compareResult); + default: + // Return '0' to indicate they are equal + return 0; + } + } + } +} diff --git a/UVtools.GUI/Forms/FrmRepairLayers.Designer.cs b/UVtools.GUI/Forms/FrmRepairLayers.Designer.cs index ffe6fbb..1f9f440 100644 --- a/UVtools.GUI/Forms/FrmRepairLayers.Designer.cs +++ b/UVtools.GUI/Forms/FrmRepairLayers.Designer.cs @@ -53,11 +53,15 @@ namespace UVtools.GUI.Forms this.cbRepairResinTraps = new System.Windows.Forms.CheckBox(); this.btnLayerRangeSelect = new UVtools.GUI.Controls.SplitButton(); this.cbRemoveEmptyLayers = new System.Windows.Forms.CheckBox(); + this.nmRemoveIslandsBelowEqualPixels = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.numClosingIterations)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).BeginInit(); this.cmLayerRange.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numOpeningIterations)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nmRemoveIslandsBelowEqualPixels)).BeginInit(); this.SuspendLayout(); // // lbDescription @@ -193,7 +197,7 @@ namespace UVtools.GUI.Forms this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnCancel.Image = global::UVtools.GUI.Properties.Resources.Cancel_24x24; this.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btnCancel.Location = new System.Drawing.Point(447, 278); + this.btnCancel.Location = new System.Drawing.Point(447, 286); this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(150, 48); @@ -208,7 +212,7 @@ namespace UVtools.GUI.Forms this.btnRepair.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btnRepair.Image = global::UVtools.GUI.Properties.Resources.Ok_24x24; this.btnRepair.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btnRepair.Location = new System.Drawing.Point(289, 278); + this.btnRepair.Location = new System.Drawing.Point(289, 286); this.btnRepair.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.btnRepair.Name = "btnRepair"; this.btnRepair.Size = new System.Drawing.Size(150, 48); @@ -297,12 +301,45 @@ namespace UVtools.GUI.Forms this.cbRemoveEmptyLayers.Text = "Remove empty layers"; this.cbRemoveEmptyLayers.UseVisualStyleBackColor = true; // + // nmRemoveIslandsBelowEqual + // + this.nmRemoveIslandsBelowEqualPixels.Location = new System.Drawing.Point(505, 245); + this.nmRemoveIslandsBelowEqualPixels.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.nmRemoveIslandsBelowEqualPixels.Name = "nmRemoveIslandsBelowEqualPixels"; + this.nmRemoveIslandsBelowEqualPixels.Size = new System.Drawing.Size(58, 26); + this.nmRemoveIslandsBelowEqualPixels.TabIndex = 21; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(248, 248); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(249, 20); + this.label2.TabIndex = 22; + this.label2.Text = "Remove islands below or equal to:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(569, 248); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(25, 20); + this.label3.TabIndex = 23; + this.label3.Text = "px"; + // // FrmRepairLayers // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(606, 340); + this.ClientSize = new System.Drawing.Size(606, 348); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.nmRemoveIslandsBelowEqualPixels); this.Controls.Add(this.cbRemoveEmptyLayers); this.Controls.Add(this.cbRepairResinTraps); this.Controls.Add(this.numOpeningIterations); @@ -335,6 +372,7 @@ namespace UVtools.GUI.Forms ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).EndInit(); this.cmLayerRange.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numOpeningIterations)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nmRemoveIslandsBelowEqualPixels)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -363,5 +401,8 @@ namespace UVtools.GUI.Forms private System.Windows.Forms.NumericUpDown numOpeningIterations; private System.Windows.Forms.CheckBox cbRepairResinTraps; private System.Windows.Forms.CheckBox cbRemoveEmptyLayers; + private System.Windows.Forms.NumericUpDown nmRemoveIslandsBelowEqualPixels; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; } }
\ No newline at end of file diff --git a/UVtools.GUI/Forms/FrmRepairLayers.cs b/UVtools.GUI/Forms/FrmRepairLayers.cs index b28d280..969bcd3 100644 --- a/UVtools.GUI/Forms/FrmRepairLayers.cs +++ b/UVtools.GUI/Forms/FrmRepairLayers.cs @@ -39,6 +39,12 @@ namespace UVtools.GUI.Forms set => numOpeningIterations.Value = value; } + public byte RemoveIslandsBelowEqualPixels + { + get => (byte)nmRemoveIslandsBelowEqualPixels.Value; + set => nmRemoveIslandsBelowEqualPixels.Value = value; + } + public bool RepairIslands { get => cbRepairIslands.Checked; @@ -70,6 +76,7 @@ namespace UVtools.GUI.Forms RepairIslands = Properties.Settings.Default.LayerRepairLayersIslands; RemoveEmptyLayers = Properties.Settings.Default.LayerRepairRemoveEmptyLayers; RepairResinTraps = Properties.Settings.Default.LayerRepairResinTraps; + nmRemoveIslandsBelowEqualPixels.Value = Properties.Settings.Default.LayerRepairRemoveIslandsBelowEqualPixelsDefault; numClosingIterations.Select(); nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1; diff --git a/UVtools.GUI/Forms/FrmRepairLayers.resx b/UVtools.GUI/Forms/FrmRepairLayers.resx index 8d221ec..b58bc91 100644 --- a/UVtools.GUI/Forms/FrmRepairLayers.resx +++ b/UVtools.GUI/Forms/FrmRepairLayers.resx @@ -138,6 +138,9 @@ Note: "Layer Start" start can't be higher than "Layer End".</value> <metadata name="cmLayerRange.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> + <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>148, 17</value> + </metadata> <data name="label1.ToolTip" xml:space="preserve"> <value>Selects the number of iterations/passes to perform on each layer. Choose 0 to disable this step. diff --git a/UVtools.GUI/Forms/FrmSettings.Designer.cs b/UVtools.GUI/Forms/FrmSettings.Designer.cs index ea5ee4b..31e0430 100644 --- a/UVtools.GUI/Forms/FrmSettings.Designer.cs +++ b/UVtools.GUI/Forms/FrmSettings.Designer.cs @@ -130,15 +130,17 @@ this.label24 = new System.Windows.Forms.Label(); this.label23 = new System.Windows.Forms.Label(); this.btnPixelEditorAddPixelColor = new System.Windows.Forms.Button(); - this.panel1 = new System.Windows.Forms.Panel(); this.tabPage5 = new System.Windows.Forms.TabPage(); - this.cbLayerRepairLayersIslands = new System.Windows.Forms.CheckBox(); - this.cbLayerRepairRemoveEmptyLayers = new System.Windows.Forms.CheckBox(); - this.cbLayerRepairResinTraps = new System.Windows.Forms.CheckBox(); - this.nmLayerRepairDefaultClosingIterations = new System.Windows.Forms.NumericUpDown(); - this.label33 = new System.Windows.Forms.Label(); this.nmLayerRepairDefaultOpeningIterations = new System.Windows.Forms.NumericUpDown(); this.label34 = new System.Windows.Forms.Label(); + this.nmLayerRepairDefaultClosingIterations = new System.Windows.Forms.NumericUpDown(); + this.label33 = new System.Windows.Forms.Label(); + this.cbLayerRepairResinTraps = new System.Windows.Forms.CheckBox(); + this.cbLayerRepairRemoveEmptyLayers = new System.Windows.Forms.CheckBox(); + this.cbLayerRepairLayersIslands = new System.Windows.Forms.CheckBox(); + this.panel1 = new System.Windows.Forms.Panel(); + this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault = new System.Windows.Forms.NumericUpDown(); + this.label35 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.nmOutlineHollowAreasLineThickness)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmOutlineLayerBoundsLineThickness)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmOutlinePrintVolumeBoundsLineThickness)).BeginInit(); @@ -161,10 +163,11 @@ this.tabPage2.SuspendLayout(); this.tabPage3.SuspendLayout(); this.tabPage4.SuspendLayout(); - this.panel1.SuspendLayout(); this.tabPage5.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nmLayerRepairDefaultClosingIterations)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmLayerRepairDefaultOpeningIterations)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nmLayerRepairDefaultClosingIterations)).BeginInit(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault)).BeginInit(); this.SuspendLayout(); // // label1 @@ -1442,19 +1445,10 @@ this.btnPixelEditorAddPixelColor.UseVisualStyleBackColor = false; this.btnPixelEditorAddPixelColor.Click += new System.EventHandler(this.EventClick); // - // panel1 - // - this.panel1.Controls.Add(this.btnCancel); - this.panel1.Controls.Add(this.btnSave); - this.panel1.Controls.Add(this.btnReset); - this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.panel1.Location = new System.Drawing.Point(0, 452); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(624, 77); - this.panel1.TabIndex = 19; - // // tabPage5 // + this.tabPage5.Controls.Add(this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault); + this.tabPage5.Controls.Add(this.label35); this.tabPage5.Controls.Add(this.nmLayerRepairDefaultOpeningIterations); this.tabPage5.Controls.Add(this.label34); this.tabPage5.Controls.Add(this.nmLayerRepairDefaultClosingIterations); @@ -1470,35 +1464,31 @@ this.tabPage5.Text = "Layer Repair"; this.tabPage5.UseVisualStyleBackColor = true; // - // cbLayerRepairLayersIslands - // - this.cbLayerRepairLayersIslands.AutoSize = true; - this.cbLayerRepairLayersIslands.Location = new System.Drawing.Point(6, 66); - this.cbLayerRepairLayersIslands.Name = "cbLayerRepairLayersIslands"; - this.cbLayerRepairLayersIslands.Size = new System.Drawing.Size(257, 22); - this.cbLayerRepairLayersIslands.TabIndex = 15; - this.cbLayerRepairLayersIslands.Text = "Repair layers and islands by default"; - this.cbLayerRepairLayersIslands.UseVisualStyleBackColor = true; - // - // cbLayerRepairRemoveEmptyLayers + // nmLayerRepairDefaultOpeningIterations // - this.cbLayerRepairRemoveEmptyLayers.AutoSize = true; - this.cbLayerRepairRemoveEmptyLayers.Location = new System.Drawing.Point(6, 94); - this.cbLayerRepairRemoveEmptyLayers.Name = "cbLayerRepairRemoveEmptyLayers"; - this.cbLayerRepairRemoveEmptyLayers.Size = new System.Drawing.Size(236, 22); - this.cbLayerRepairRemoveEmptyLayers.TabIndex = 16; - this.cbLayerRepairRemoveEmptyLayers.Text = "Remove empty layers by default"; - this.cbLayerRepairRemoveEmptyLayers.UseVisualStyleBackColor = true; + this.nmLayerRepairDefaultOpeningIterations.Location = new System.Drawing.Point(6, 36); + this.nmLayerRepairDefaultOpeningIterations.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.nmLayerRepairDefaultOpeningIterations.Name = "nmLayerRepairDefaultOpeningIterations"; + this.nmLayerRepairDefaultOpeningIterations.Size = new System.Drawing.Size(57, 24); + this.nmLayerRepairDefaultOpeningIterations.TabIndex = 32; + this.nmLayerRepairDefaultOpeningIterations.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); // - // cbLayerRepairResinTraps + // label34 // - this.cbLayerRepairResinTraps.AutoSize = true; - this.cbLayerRepairResinTraps.Location = new System.Drawing.Point(6, 122); - this.cbLayerRepairResinTraps.Name = "cbLayerRepairResinTraps"; - this.cbLayerRepairResinTraps.Size = new System.Drawing.Size(209, 22); - this.cbLayerRepairResinTraps.TabIndex = 17; - this.cbLayerRepairResinTraps.Text = "Repair resin traps by default"; - this.cbLayerRepairResinTraps.UseVisualStyleBackColor = true; + this.label34.AutoSize = true; + this.label34.Location = new System.Drawing.Point(69, 39); + this.label34.Name = "label34"; + this.label34.Size = new System.Drawing.Size(215, 18); + this.label34.TabIndex = 33; + this.label34.Text = "Noise removal default iterations"; // // nmLayerRepairDefaultClosingIterations // @@ -1526,31 +1516,72 @@ this.label33.TabIndex = 31; this.label33.Text = "Gap closing default iterations"; // - // nmLayerRepairDefaultOpeningIterations + // cbLayerRepairResinTraps // - this.nmLayerRepairDefaultOpeningIterations.Location = new System.Drawing.Point(6, 36); - this.nmLayerRepairDefaultOpeningIterations.Maximum = new decimal(new int[] { + this.cbLayerRepairResinTraps.AutoSize = true; + this.cbLayerRepairResinTraps.Location = new System.Drawing.Point(6, 152); + this.cbLayerRepairResinTraps.Name = "cbLayerRepairResinTraps"; + this.cbLayerRepairResinTraps.Size = new System.Drawing.Size(209, 22); + this.cbLayerRepairResinTraps.TabIndex = 17; + this.cbLayerRepairResinTraps.Text = "Repair resin traps by default"; + this.cbLayerRepairResinTraps.UseVisualStyleBackColor = true; + // + // cbLayerRepairRemoveEmptyLayers + // + this.cbLayerRepairRemoveEmptyLayers.AutoSize = true; + this.cbLayerRepairRemoveEmptyLayers.Location = new System.Drawing.Point(6, 124); + this.cbLayerRepairRemoveEmptyLayers.Name = "cbLayerRepairRemoveEmptyLayers"; + this.cbLayerRepairRemoveEmptyLayers.Size = new System.Drawing.Size(236, 22); + this.cbLayerRepairRemoveEmptyLayers.TabIndex = 16; + this.cbLayerRepairRemoveEmptyLayers.Text = "Remove empty layers by default"; + this.cbLayerRepairRemoveEmptyLayers.UseVisualStyleBackColor = true; + // + // cbLayerRepairLayersIslands + // + this.cbLayerRepairLayersIslands.AutoSize = true; + this.cbLayerRepairLayersIslands.Location = new System.Drawing.Point(6, 96); + this.cbLayerRepairLayersIslands.Name = "cbLayerRepairLayersIslands"; + this.cbLayerRepairLayersIslands.Size = new System.Drawing.Size(257, 22); + this.cbLayerRepairLayersIslands.TabIndex = 15; + this.cbLayerRepairLayersIslands.Text = "Repair layers and islands by default"; + this.cbLayerRepairLayersIslands.UseVisualStyleBackColor = true; + // + // panel1 + // + this.panel1.Controls.Add(this.btnCancel); + this.panel1.Controls.Add(this.btnSave); + this.panel1.Controls.Add(this.btnReset); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 452); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(624, 77); + this.panel1.TabIndex = 19; + // + // nmLayerRepairRemoveIslandsBelowEqualPixelsDefault + // + this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault.Location = new System.Drawing.Point(6, 66); + this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault.Maximum = new decimal(new int[] { 255, 0, 0, 0}); - this.nmLayerRepairDefaultOpeningIterations.Name = "nmLayerRepairDefaultOpeningIterations"; - this.nmLayerRepairDefaultOpeningIterations.Size = new System.Drawing.Size(57, 24); - this.nmLayerRepairDefaultOpeningIterations.TabIndex = 32; - this.nmLayerRepairDefaultOpeningIterations.Value = new decimal(new int[] { + this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault.Name = "nmLayerRepairRemoveIslandsBelowEqualPixelsDefault"; + this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault.Size = new System.Drawing.Size(57, 24); + this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault.TabIndex = 34; + this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault.Value = new decimal(new int[] { 1, 0, 0, 0}); // - // label34 + // label35 // - this.label34.AutoSize = true; - this.label34.Location = new System.Drawing.Point(69, 39); - this.label34.Name = "label34"; - this.label34.Size = new System.Drawing.Size(215, 18); - this.label34.TabIndex = 33; - this.label34.Text = "Noise removal default iterations"; + this.label35.AutoSize = true; + this.label35.Location = new System.Drawing.Point(69, 69); + this.label35.Name = "label35"; + this.label35.Size = new System.Drawing.Size(357, 18); + this.label35.TabIndex = 35; + this.label35.Text = "Remove islands below or equal to pixels default value"; // // FrmSettings // @@ -1598,11 +1629,12 @@ this.tabPage3.ResumeLayout(false); this.tabPage4.ResumeLayout(false); this.tabPage4.PerformLayout(); - this.panel1.ResumeLayout(false); this.tabPage5.ResumeLayout(false); this.tabPage5.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nmLayerRepairDefaultClosingIterations)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nmLayerRepairDefaultOpeningIterations)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nmLayerRepairDefaultClosingIterations)).EndInit(); + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.nmLayerRepairRemoveIslandsBelowEqualPixelsDefault)).EndInit(); this.ResumeLayout(false); } @@ -1719,5 +1751,7 @@ private System.Windows.Forms.Label label33; private System.Windows.Forms.NumericUpDown nmLayerRepairDefaultOpeningIterations; private System.Windows.Forms.Label label34; + private System.Windows.Forms.NumericUpDown nmLayerRepairRemoveIslandsBelowEqualPixelsDefault; + private System.Windows.Forms.Label label35; } }
\ No newline at end of file diff --git a/UVtools.GUI/Forms/FrmSettings.cs b/UVtools.GUI/Forms/FrmSettings.cs index d6033f9..4e0f7f1 100644 --- a/UVtools.GUI/Forms/FrmSettings.cs +++ b/UVtools.GUI/Forms/FrmSettings.cs @@ -87,6 +87,7 @@ namespace UVtools.GUI.Forms nmLayerRepairDefaultClosingIterations.Value = Settings.Default.LayerRepairDefaultClosingIterations; nmLayerRepairDefaultOpeningIterations.Value = Settings.Default.LayerRepairDefaultOpeningIterations; + nmLayerRepairRemoveIslandsBelowEqualPixelsDefault.Value = Settings.Default.LayerRepairRemoveIslandsBelowEqualPixelsDefault; cbLayerRepairLayersIslands.Checked = Settings.Default.LayerRepairLayersIslands; cbLayerRepairRemoveEmptyLayers.Checked = Settings.Default.LayerRepairRemoveEmptyLayers; cbLayerRepairResinTraps.Checked = Settings.Default.LayerRepairResinTraps; @@ -236,6 +237,7 @@ namespace UVtools.GUI.Forms Settings.Default.LayerRepairDefaultClosingIterations = (byte) nmLayerRepairDefaultClosingIterations.Value; Settings.Default.LayerRepairDefaultOpeningIterations = (byte) nmLayerRepairDefaultOpeningIterations.Value; + Settings.Default.LayerRepairRemoveIslandsBelowEqualPixelsDefault = (byte) nmLayerRepairRemoveIslandsBelowEqualPixelsDefault.Value; Settings.Default.LayerRepairLayersIslands = cbLayerRepairLayersIslands.Checked; Settings.Default.LayerRepairRemoveEmptyLayers = cbLayerRepairRemoveEmptyLayers.Checked; Settings.Default.LayerRepairResinTraps = cbLayerRepairResinTraps.Checked; diff --git a/UVtools.GUI/Forms/FrmToolPattern.cs b/UVtools.GUI/Forms/FrmToolPattern.cs index 96b4062..a1d3ac0 100644 --- a/UVtools.GUI/Forms/FrmToolPattern.cs +++ b/UVtools.GUI/Forms/FrmToolPattern.cs @@ -67,13 +67,15 @@ namespace UVtools.GUI.Forms #endregion #region Constructors - public FrmToolPattern(Rectangle srcRoi, uint imageWidth, uint imageHeight) + public FrmToolPattern(Rectangle srcRoi, uint imageWidth, uint imageHeight) : this(new OperationPattern(srcRoi, imageWidth, imageHeight)) {} + + public FrmToolPattern(OperationPattern operation) { InitializeComponent(); - _operation = new OperationPattern(srcRoi, imageWidth, imageHeight); + _operation = operation; DialogResult = DialogResult.Cancel; - nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1; + nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount - 1; EventClick(btnResetDefaults, null); //EventValueChanged(this, null); diff --git a/UVtools.GUI/FrmMain.Designer.cs b/UVtools.GUI/FrmMain.Designer.cs index 85c12c5..1c56218 100644 --- a/UVtools.GUI/FrmMain.Designer.cs +++ b/UVtools.GUI/FrmMain.Designer.cs @@ -119,7 +119,9 @@ this.tsPropertiesLabelCount = new System.Windows.Forms.ToolStripLabel(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.tsPropertiesLabelGroups = new System.Windows.Forms.ToolStripLabel(); - this.tsPropertiesButtonSave = new System.Windows.Forms.ToolStripButton(); + this.tsPropertiesExport = new System.Windows.Forms.ToolStripSplitButton(); + this.tsPropertiesExportFile = new System.Windows.Forms.ToolStripMenuItem(); + this.tsPropertiesExportClipboard = new System.Windows.Forms.ToolStripMenuItem(); this.tabPageGCode = new System.Windows.Forms.TabPage(); this.tbGCode = new System.Windows.Forms.TextBox(); this.tsGCode = new System.Windows.Forms.ToolStrip(); @@ -581,7 +583,6 @@ this.pbLayer.ShowPixelGrid = true; this.pbLayer.Size = new System.Drawing.Size(1228, 675); this.pbLayer.TabIndex = 7; - this.pbLayer.PanEnd += new System.EventHandler(this.pbLayer_PanEnd); this.pbLayer.Zoomed += new System.EventHandler<Cyotek.Windows.Forms.ImageBoxZoomEventArgs>(this.pbLayer_Zoomed); this.pbLayer.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.EventMouseDoubleClick); this.pbLayer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pbLayer_MouseMove); @@ -1106,7 +1107,7 @@ this.tsPropertiesLabelCount, this.toolStripSeparator4, this.tsPropertiesLabelGroups, - this.tsPropertiesButtonSave}); + this.tsPropertiesExport}); this.tsProperties.Location = new System.Drawing.Point(0, 0); this.tsProperties.Name = "tsProperties"; this.tsProperties.Size = new System.Drawing.Size(380, 25); @@ -1130,18 +1131,37 @@ this.tsPropertiesLabelGroups.Size = new System.Drawing.Size(45, 22); this.tsPropertiesLabelGroups.Text = "Groups"; // - // tsPropertiesButtonSave - // - this.tsPropertiesButtonSave.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; - this.tsPropertiesButtonSave.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.tsPropertiesButtonSave.Enabled = false; - this.tsPropertiesButtonSave.Image = global::UVtools.GUI.Properties.Resources.Save_16x16; - this.tsPropertiesButtonSave.ImageTransparentColor = System.Drawing.Color.Magenta; - this.tsPropertiesButtonSave.Name = "tsPropertiesButtonSave"; - this.tsPropertiesButtonSave.Size = new System.Drawing.Size(23, 22); - this.tsPropertiesButtonSave.Text = "Save Thumbnail"; - this.tsPropertiesButtonSave.ToolTipText = "Save properties to a file"; - this.tsPropertiesButtonSave.Click += new System.EventHandler(this.EventClick); + // tsPropertiesExport + // + this.tsPropertiesExport.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.tsPropertiesExport.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.tsPropertiesExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tsPropertiesExportFile, + this.tsPropertiesExportClipboard}); + this.tsPropertiesExport.Enabled = false; + this.tsPropertiesExport.Image = global::UVtools.GUI.Properties.Resources.Save_16x16; + this.tsPropertiesExport.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tsPropertiesExport.Name = "tsPropertiesExport"; + this.tsPropertiesExport.Size = new System.Drawing.Size(32, 22); + this.tsPropertiesExport.Text = "Save to"; + this.tsPropertiesExport.ToolTipText = "Save properties to a file or clipboard"; + this.tsPropertiesExport.Click += new System.EventHandler(this.EventClick); + // + // tsPropertiesExportFile + // + this.tsPropertiesExportFile.Image = global::UVtools.GUI.Properties.Resources.file_image_16x16; + this.tsPropertiesExportFile.Name = "tsPropertiesExportFile"; + this.tsPropertiesExportFile.Size = new System.Drawing.Size(180, 22); + this.tsPropertiesExportFile.Text = "To &File"; + this.tsPropertiesExportFile.Click += new System.EventHandler(this.EventClick); + // + // tsPropertiesExportClipboard + // + this.tsPropertiesExportClipboard.Image = global::UVtools.GUI.Properties.Resources.clipboard_16x16; + this.tsPropertiesExportClipboard.Name = "tsPropertiesExportClipboard"; + this.tsPropertiesExportClipboard.Size = new System.Drawing.Size(180, 22); + this.tsPropertiesExportClipboard.Text = "To &Clipboard"; + this.tsPropertiesExportClipboard.Click += new System.EventHandler(this.EventClick); // // tabPageGCode // @@ -1241,6 +1261,7 @@ this.lvIssues.TabIndex = 8; this.lvIssues.UseCompatibleStateImageBehavior = false; this.lvIssues.View = System.Windows.Forms.View.Details; + this.lvIssues.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.EventColumnClick); this.lvIssues.ItemActivate += new System.EventHandler(this.EventItemActivate); this.lvIssues.SelectedIndexChanged += new System.EventHandler(this.EventSelectedIndexChanged); this.lvIssues.KeyUp += new System.Windows.Forms.KeyEventHandler(this.EventKeyUp); @@ -2180,7 +2201,6 @@ private System.Windows.Forms.ToolStripLabel tsPropertiesLabelCount; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; private System.Windows.Forms.ToolStripLabel tsPropertiesLabelGroups; - private System.Windows.Forms.ToolStripButton tsPropertiesButtonSave; private System.Windows.Forms.ToolStripMenuItem menuFileOpenNewWindow; private System.Windows.Forms.ToolStripButton tsLayerImageRotate; private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; @@ -2303,6 +2323,9 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator21; private System.Windows.Forms.ToolStripSeparator toolStripSeparator22; private System.Windows.Forms.ToolStripMenuItem menuToolsLayerReHeight; + private System.Windows.Forms.ToolStripSplitButton tsPropertiesExport; + private System.Windows.Forms.ToolStripMenuItem tsPropertiesExportFile; + private System.Windows.Forms.ToolStripMenuItem tsPropertiesExportClipboard; } } diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index ab9cb37..27ddb1e 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -26,6 +26,7 @@ using UVtools.Core.Extensions; using UVtools.Core.FileFormats; using UVtools.Core.Operations; using UVtools.Core.PixelEditor; +using UVtools.GUI.Controls; using UVtools.GUI.Forms; using UVtools.GUI.Properties; @@ -142,6 +143,8 @@ namespace UVtools.GUI public uint SavesCount { get; set; } = 0; + private readonly ListViewColumnSorter lvIssuesColumnSorter; + #endregion #region Constructors @@ -206,6 +209,9 @@ namespace UVtools.GUI tbLayer.MouseWheel += TbLayerOnMouseWheel; + lvIssuesColumnSorter = new ListViewColumnSorter(); + this.lvIssues.ListViewItemSorter = lvIssuesColumnSorter; + if (Settings.Default.CheckForUpdatesOnStartup) { Task.Factory.StartNew(AppLoadTask); @@ -694,6 +700,7 @@ namespace UVtools.GUI uint layerEnd; uint closingIterations; uint openingIterations; + byte removeIslandsBelowEqualPixels; bool repairIslands; bool removeEmptyLayers; bool repairResinTraps; @@ -705,17 +712,23 @@ namespace UVtools.GUI layerEnd = frmRepairLayers.LayerRangeEnd; closingIterations = frmRepairLayers.ClosingIterations; openingIterations = frmRepairLayers.OpeningIterations; + removeIslandsBelowEqualPixels = frmRepairLayers.RemoveIslandsBelowEqualPixels; repairIslands = frmRepairLayers.RepairIslands; removeEmptyLayers = frmRepairLayers.RemoveEmptyLayers; repairResinTraps = frmRepairLayers.RepairResinTraps; } - if (repairResinTraps && ReferenceEquals(Issues, null)) + if (ReferenceEquals(Issues, null)) { - ComputeIssues(new IslandDetectionConfiguration - {Enabled = false}); // Ignore islands as we dont require it - } + var islandConfig = GetIslandDetectionConfiguration(); + islandConfig.Enabled = repairIslands && removeIslandsBelowEqualPixels > 0; + var resinTrapConfig = GetResinTrapDetectionConfiguration(); + resinTrapConfig.Enabled = repairResinTraps; + if(islandConfig.Enabled || resinTrapConfig.Enabled) + ComputeIssues(islandConfig, resinTrapConfig); + } + DisableGUI(); FrmLoading.SetDescription("Repairing Layers and Issues"); @@ -724,7 +737,7 @@ namespace UVtools.GUI try { SlicerFile.LayerManager.RepairLayers(layerStart, layerEnd, closingIterations, - openingIterations, repairIslands, removeEmptyLayers, repairResinTraps, Issues, + openingIterations, removeIslandsBelowEqualPixels, repairIslands, removeEmptyLayers, repairResinTraps, Issues, FrmLoading.RestartProgress()); } catch (OperationCanceledException) @@ -859,8 +872,17 @@ namespace UVtools.GUI if (ReferenceEquals(sender, menuToolsPattern)) { - using (var frm = new FrmToolPattern(SlicerFile.LayerManager.BoundingRectangle, - (uint) ActualLayerImage.Width, (uint) ActualLayerImage.Height)) + OperationPattern operation = new OperationPattern(SlicerFile.LayerManager.BoundingRectangle, + (uint)ActualLayerImage.Width, (uint)ActualLayerImage.Height); + + if (operation.MaxRows < 2 && operation.MaxCols < 2) + { + MessageBox.Show("The available free volume is not enough to pattern this object.\n" + + "To run this tool the free space must allow at least 1 copy.", "Unable to pattern", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + using (var frm = new FrmToolPattern(operation)) { if (frm.ShowDialog() != DialogResult.OK) return; @@ -1101,7 +1123,13 @@ namespace UVtools.GUI /************************ * Properties Menu * ***********************/ - if (ReferenceEquals(sender, tsPropertiesButtonSave)) + if (ReferenceEquals(sender, tsPropertiesExport)) + { + tsPropertiesExport.ShowDropDown(); + return; + } + + if (ReferenceEquals(sender, tsPropertiesExportFile)) { using (SaveFileDialog dialog = new SaveFileDialog()) { @@ -1143,6 +1171,24 @@ namespace UVtools.GUI } } + if (ReferenceEquals(sender, tsPropertiesExportClipboard)) + { + StringBuilder sb = new StringBuilder(); + foreach (var config in SlicerFile.Configs) + { + var type = config.GetType(); + sb.AppendLine($"[{type.Name}]"); + foreach (var property in type.GetProperties()) + { + sb.AppendLine($"{property.Name} = {property.GetValue(config)}"); + } + + sb.AppendLine(); + } + Clipboard.SetText(sb.ToString()); + return; + } + /************************ * GCode Menu * ***********************/ @@ -1714,7 +1760,6 @@ namespace UVtools.GUI private void pbLayer_Zoomed(object sender, Cyotek.Windows.Forms.ImageBoxZoomEventArgs e) { tsLayerImageZoom.Text = $"Zoom: {e.NewZoom}% ({e.NewZoom/100f}x)"; - pbLayer_PanEnd(pbLayer, null); } private void pbLayer_MouseUp(object sender, MouseEventArgs e) @@ -3374,9 +3419,36 @@ namespace UVtools.GUI }; } - private void pbLayer_PanEnd(object sender, EventArgs e) + + private void EventColumnClick(object sender, ColumnClickEventArgs e) { - //tsLayerImagePanLocation.Text = $"{pbLayer.AutoScrollPosition}"; + if (ReferenceEquals(sender, lvIssues)) + { + ListView myListView = (ListView)sender; + + // Determine if clicked column is already the column that is being sorted. + if (e.Column == lvIssuesColumnSorter.SortColumn) + { + // Reverse the current sort direction for this column. + if (lvIssuesColumnSorter.Order == SortOrder.Ascending) + { + lvIssuesColumnSorter.Order = SortOrder.Descending; + } + else + { + lvIssuesColumnSorter.Order = SortOrder.Ascending; + } + } + else + { + // Set the column number that is to be sorted; default to ascending. + lvIssuesColumnSorter.SortColumn = e.Column; + lvIssuesColumnSorter.Order = SortOrder.Ascending; + } + + // Perform the sort with these new sort options. + myListView.Sort(); + } } } } diff --git a/UVtools.GUI/FrmMain.resx b/UVtools.GUI/FrmMain.resx index c2b5f07..97a17db 100644 --- a/UVtools.GUI/FrmMain.resx +++ b/UVtools.GUI/FrmMain.resx @@ -152,12 +152,12 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAo - EQAAAk1TRnQBSQFMAgEBBQEAASABBgEgAQYBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA - AwABIAMAAQEBAAEgBgABIC4AAxgBIgMwAUsDMAFMAzIBUOgAAyIBMQNWAbkDXQHiAQEBBAEAAf8BAQEE + EQAAAk1TRnQBSQFMAgEBBQEAATgBBgE4AQYBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + AwABIAMAAQEBAAEgBgABIC4AAxgBIgMwAUsDMAFMAzIBUOgAAyIBMQNWAbkDXQHiAQABAQEAAf8BAAEB AQAB/wEqAS0BKAH+A1MBrANNAZUDAAEB2AADIQEwA1kB7AErAS4BKQH6A1EB9wNSAfQDUwHxA0gB9gNB - AfkBAQEEAQAB/wNPAZsDAAEB0AADHAEoA1kB6wEqAS0BKAH+A1YBtgNMAZIDSAGFA0gBhQNGAYADSAGF - ASoBLQEoAf4BAQEEAQAB/wNOAZTQAAMmATgBKgEtASgB/gNMAZMDSwGQA00BlgNKAYsDRQF/A0MBeAND - AXgDRwGCAz4B+ANTAbDQAANcAdQBAQEEAQAB/wNRAaADTgGYA1ABnwM6AWEDOAFdA0IBdANGAYADSAGE + AfkBAAEBAQAB/wNPAZsDAAEB0AADHAEoA1kB6wEqAS0BKAH+A1YBtgNMAZIDSAGFA0gBhQNGAYADSAGF + ASoBLQEoAf4BAAEBAQAB/wNOAZTQAAMmATgBKgEtASgB/gNMAZMDSwGQA00BlgNKAYsDRQF/A0MBeAND + AXgDRwGCAz4B+ANTAbDQAANcAdQBAAEBAQAB/wNRAaADTgGYA1ABnwM6AWEDOAFdA0IBdANGAYADSAGE A0wBkwNYAeMDMAFMyAADNgFZA0ABcANZAdcDRwGCA0wBkwNJAYkDAQECBAADMAFLA0QBeQNIAYcDSwGQ A1cB6AMwAUzIAAMtAUYDOAFeA0oBjQMSARgDUAGjEAADKQE+A0sBkANNAZUDWQHsAzABTMgAAxQBHAMw AU0DTwGcA1EBogNTAbAQAAMrAUMDTwGbA1ABngNWAbsDFQEdyAADRAF5Az8BbgMqAUADHgErAyoBQANV @@ -169,26 +169,26 @@ A1IBqQNSAakDUgGpA1IBqQNQAaNcAAMVAR0BQgJZAfUBUQJtAfcDQwF3A1sByAJCAVkB9QJYAV8B4wNK AYwDCgENBAADVQG0A1kBxwMvAUkDAAEBAxsBJgMcAScDHAEnAxwBJwMcAScDHAEnAxwBJwMcAScDHAEn AxwBJwMcAScDAgEDBAADUgGpMAADUgGpEAADJwE6AzABTAMwAUwDMAFMAzABTAMwAUwDMAFMAzABTAMw - AUwDJwE6FAADBQEHA0wBkgFWAlgBwQMVAR0DPQFpAQAByAHzAf8BAAGQAeYB/wIAAdwB/wIAAd0B/wIi + AUwDJwE6FAADBQEHA0wBkgFWAlgBwQMVAR0DPQFpAQAByAHzAf8BAAGQAeYB/wIAAdwB/wIAAd0B/wIf AeMB/wIAAd4B/wIAAd0B/wJYAVsBywMGAQgDAAH/AwAB/wNDAXcDKQE+AwAB/wMAAf8DAAH/AwAB/wMA Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DMgFRBAADUgGpBAADUAGdA1MBqgNTAaoDUwGqA1MBqgNT AaoDUwGqA1ABnQwAA1IBqRAAA04B+wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A04B+xQA ATACMQFNAQAByQHzAf8BAAHJAfQB/wFZAmAB6wFbAl4B2QEAAcAB8QH/AgAB3wH/AgAB4AH/AgAB4AH/ - AikB6QH/AgAB4gH/AgAB4AH/AgAB4AH/A0ABcQNRAaIDVgG2AyoBQAQAAxABFQMRARcDEQEXAxEBFwMR + AiYB6QH/AgAB4gH/AgAB4AH/AgAB4AH/A0ABcQNRAaIDVgG2AyoBQAQAAxABFQMRARcDEQEXAxEBFwMR ARcDEQEXAxEBFwMRARcDEQEXAxEBFwMQARYIAANSAakEAANQAZ0DUwGqA1MBqgMfASwcAANSAakTAAH/ AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/FAADBwEKAVkCZwHyAQABygH0Af8BAAHK AfQB/wEAAcoB9AH/AQABoQHuAf8CAAHjAf8CAAHjAf8CAAHjAf8CqQHvAf8CAAHjAf8CAAHjAf8CAAHj Af8CVgFYAbkDCgEOAxEBFwMAAQE4AANSAakwAANSAakTAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ AwAB/wMAAf8DAAH/DAADFQEdAz0BaQM6AWIBXAJgAdQBAAHLAfUB/wEAAcsB9QH/AQABywH1Af8BAAGg - AfAB/wIAAeYB/wIAAeYB/wIAAeYB/wLCAfYB/wIOAegB/wIAAeYB/wIAAeYB/wJXAVkBvwNSAfQDAAH/ + AfAB/wIAAeYB/wIAAeYB/wIAAeYB/wLCAfYB/wILAegB/wIAAeYB/wIAAeYB/wJXAVkBvwNSAfQDAAH/ Az4BbAMOARMDQgF2A0MBdwNDAXcDQwF3A0MBdwNDAXcDQwF3A0MBdwNDAXcDQwF3A0IBdgMUARsEAANS AakDIgEyA1IBqQNSAakDUgGpA1IBqQNSAakDUgGpA1IBqQNSAakDUgGpA1IBqQMiATIDUgGpEwAB/wMA Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wwAAUsCTAGQAQABywH2Af8BAAHLAfYB/wEA - AcsB9gH/AQABywH2Af8BKQJNAfoDQwF4AyIBMgJLAV8B+wIAAekB/wIAAekB/wLNAfgB/wIdAe0B/wIA + AcsB9gH/AQABywH2Af8BKQJNAfoDQwF4AyIBMgJLAV8B+wIAAekB/wIAAekB/wLNAfgB/wIaAe0B/wIA AekB/wIAAekB/wNQAZ4DAAH+AwAB/wNDAXcDHgErA1cBxQNZAccDWQHHA1kBxwNZAccDWQHHA1kBxwNZ AccDWQHHA1kBxwNYAcYDJgE5BAADUgGpAzQBVQM0AVUgAAM0AVUDNAFVA1IBqRMAAf8DAAH/AwAB/wMA Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8MAANRAaABAAHMAfcB/wEAAcwB9wH/AQABzAH3Af8BAAHM - AfcB/wNDAXcIAANKAY0CAAHsAf8CAAHsAf8CGAHvAf8CAAHsAf8CAAHsAf8BAAEJAe0B/wFSAlMBqAMz + AfcB/wNDAXcIAANKAY0CAAHsAf8CAAHsAf8CFQHvAf8CAAHsAf8CAAHsAf8BAAEGAe0B/wFSAlMBqAMz AVMDPAFnAxQBHDgAA1IBqQM0AVUDNAFVA0YBgANSAakDUgGpA1IBqQNSAakDUgGpA1IBqQNFAX8DNAFV AzQBVQNSAakTAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/DwABAQE/AkABbwE+ AlwB+AEAAc0B9wH/AQABzQH3Af8DEgEYCAADAQECA0YBfgJSAV0B8AIAAe4B/wIAAe4B/wJAAagB/QFF diff --git a/UVtools.GUI/Properties/AssemblyInfo.cs b/UVtools.GUI/Properties/AssemblyInfo.cs index 6a871c4..363d870 100644 --- a/UVtools.GUI/Properties/AssemblyInfo.cs +++ b/UVtools.GUI/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.6.3.2")] -[assembly: AssemblyFileVersion("0.6.3.2")] +[assembly: AssemblyVersion("0.6.3.3")] +[assembly: AssemblyFileVersion("0.6.3.3")] diff --git a/UVtools.GUI/Properties/Settings.Designer.cs b/UVtools.GUI/Properties/Settings.Designer.cs index 8f365ce..5cafb32 100644 --- a/UVtools.GUI/Properties/Settings.Designer.cs +++ b/UVtools.GUI/Properties/Settings.Designer.cs @@ -658,5 +658,17 @@ namespace UVtools.GUI.Properties { this["LayerRepairRemoveEmptyLayers"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("10")] + public byte LayerRepairRemoveIslandsBelowEqualPixelsDefault { + get { + return ((byte)(this["LayerRepairRemoveIslandsBelowEqualPixelsDefault"])); + } + set { + this["LayerRepairRemoveIslandsBelowEqualPixelsDefault"] = value; + } + } } } diff --git a/UVtools.GUI/Properties/Settings.settings b/UVtools.GUI/Properties/Settings.settings index 8da8227..f3dc6da 100644 --- a/UVtools.GUI/Properties/Settings.settings +++ b/UVtools.GUI/Properties/Settings.settings @@ -161,5 +161,8 @@ <Setting Name="LayerRepairRemoveEmptyLayers" Type="System.Boolean" Scope="User"> <Value Profile="(Default)">True</Value> </Setting> + <Setting Name="LayerRepairRemoveIslandsBelowEqualPixelsDefault" Type="System.Byte" Scope="User"> + <Value Profile="(Default)">10</Value> + </Setting> </Settings> </SettingsFile>
\ No newline at end of file diff --git a/UVtools.GUI/UVtools.GUI.csproj b/UVtools.GUI/UVtools.GUI.csproj index 8cc75cc..0c92564 100644 --- a/UVtools.GUI/UVtools.GUI.csproj +++ b/UVtools.GUI/UVtools.GUI.csproj @@ -135,7 +135,7 @@ <Private>True</Private> </Reference> <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> - <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0-preview.6.20305.6\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath> + <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0-preview.7.20364.11\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath> </Reference> <Reference Include="System.Runtime.Extensions, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <HintPath>..\packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll</HintPath> @@ -149,6 +149,7 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="Controls\ListViewColumnSorter.cs" /> <Compile Include="Controls\SplitButton.cs"> <SubType>Component</SubType> </Compile> diff --git a/UVtools.GUI/packages.config b/UVtools.GUI/packages.config index 1289075..c231e9a 100644 --- a/UVtools.GUI/packages.config +++ b/UVtools.GUI/packages.config @@ -11,7 +11,7 @@ <package id="System.Reflection.TypeExtensions" version="4.7.0" targetFramework="net48" /> <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net48" /> <package id="System.Runtime" version="4.3.1" targetFramework="net48" /> - <package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0-preview.6.20305.6" targetFramework="net48" /> + <package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0-preview.7.20364.11" targetFramework="net48" /> <package id="System.Runtime.Extensions" version="4.3.1" targetFramework="net48" /> <package id="System.Text.Encoding" version="4.3.0" targetFramework="net48" /> <package id="System.Threading" version="4.3.0" targetFramework="net48" /> |