From fa5073e68fa8c917a9b9bd13671092b94116963b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Concei=C3=A7=C3=A3o?= Date: Mon, 17 Aug 2020 22:01:06 +0100 Subject: [PATCH] v0.6.6.1 * (Add) Elapsed time to the Log list * (Add) Setting - Issues - Islands: Allow diagonal bonds with default to false (#22) * (Change) Tool - Repair Layers: Allow set both iterations to 0 to skip closing and opening operations and allow remove islands independently * (Change) Title - file open time from miliseconds to seconds * (Improvement) Tool - Repair Layers: Layer image will only read/save if required and if current layer got modified * (Fix) Setting - Issues - Islands: "Pixels below this value will turn black, otherwise white" (Threshold) was not using the set value and was forcing 1 * (Fix) Remove duplicated log for repair layers and issues --- CHANGELOG.md | 10 ++ UVtools.Core/Layer/LayerIssue.cs | 1 - UVtools.Core/Layer/LayerManager.cs | 149 ++++++++++-------- UVtools.Core/UVtools.Core.csproj | 6 +- UVtools.GUI/App.config | 3 + UVtools.GUI/Controls/{Log.cs => LogItem.cs} | 30 ++-- UVtools.GUI/Forms/FrmInputBox.cs | 5 +- UVtools.GUI/Forms/FrmLoading.cs | 8 +- UVtools.GUI/Forms/FrmSettings.Designer.cs | 84 ++++++---- UVtools.GUI/Forms/FrmSettings.cs | 2 + UVtools.GUI/Forms/FrmSettings.resx | 3 + ...ner.cs => FrmToolRepairLayers.Designer.cs} | 4 +- ...RepairLayers.cs => FrmToolRepairLayers.cs} | 12 +- ...irLayers.resx => FrmToolRepairLayers.resx} | 0 UVtools.GUI/FrmMain.cs | 25 ++- UVtools.GUI/Program.cs | 14 -- UVtools.GUI/Properties/AssemblyInfo.cs | 4 +- UVtools.GUI/Properties/Settings.Designer.cs | 12 ++ UVtools.GUI/Properties/Settings.settings | 3 + UVtools.GUI/UVtools.GUI.csproj | 12 +- 20 files changed, 235 insertions(+), 152 deletions(-) rename UVtools.GUI/Controls/{Log.cs => LogItem.cs} (59%) rename UVtools.GUI/Forms/{FrmRepairLayers.Designer.cs => FrmToolRepairLayers.Designer.cs} (99%) rename UVtools.GUI/Forms/{FrmRepairLayers.cs => FrmToolRepairLayers.cs} (95%) rename UVtools.GUI/Forms/{FrmRepairLayers.resx => FrmToolRepairLayers.resx} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc505a0..cf4cae99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 17/08/2020 - v0.6.6.1 + +* (Add) Elapsed time to the Log list +* (Add) Setting - Issues - Islands: Allow diagonal bonds with default to false (#22) +* (Change) Tool - Repair Layers: Allow set both iterations to 0 to skip closing and opening operations and allow remove islands independently +* (Change) Title - file open time from miliseconds to seconds +* (Improvement) Tool - Repair Layers: Layer image will only read/save if required and if current layer got modified +* (Fix) Setting - Issues - Islands: "Pixels below this value will turn black, otherwise white" (Threshold) was not using the set value and was forcing 1 +* (Fix) Remove duplicated log for repair layers and issues + ## 11/08/2020 - v0.6.6.0 * (Add) Pixel Editor: Eraser - Right click over a white pixel to remove it whole linked area (Fill with black) (#7) diff --git a/UVtools.Core/Layer/LayerIssue.cs b/UVtools.Core/Layer/LayerIssue.cs index 0b018310..4eb9bedd 100644 --- a/UVtools.Core/Layer/LayerIssue.cs +++ b/UVtools.Core/Layer/LayerIssue.cs @@ -59,7 +59,6 @@ public class IslandDetectionConfiguration /// individual components on the layer, if false only 4 neighbors (right, left, above, below) /// will be considered.. /// - /// public bool AllowDiagonalBonds { get; set; } = false; } diff --git a/UVtools.Core/Layer/LayerManager.cs b/UVtools.Core/Layer/LayerManager.cs index 976d9155..b6df9b05 100644 --- a/UVtools.Core/Layer/LayerManager.cs +++ b/UVtools.Core/Layer/LayerManager.cs @@ -10,6 +10,7 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; @@ -844,25 +845,25 @@ public List GetAllIssues( using (Mat stats = new Mat()) using (Mat centroids = new Mat()) { - - int numLabels; - if (islandConfig.BinaryThreshold > 0) { - using (var thresholdImage = new Mat()) + CvInvoke.Threshold(image, image, islandConfig.BinaryThreshold, 255, ThresholdType.Binary); + /*using (var thresholdImage = new Mat()) { - CvInvoke.Threshold(image, thresholdImage, 1, 255, ThresholdType.Binary); + CvInvoke.Threshold(image, thresholdImage, islandConfig.BinaryThreshold, 255, ThresholdType.Binary); // Evaluate number of connected components using the 4-connected neighbor approach numLabels = CvInvoke.ConnectedComponentsWithStats(thresholdImage, labels, stats, centroids, islandConfig.AllowDiagonalBonds ? LineType.EightConnected : LineType.FourConnected); - } + }*/ } - else + /*else { // Evaluate number of connected components 4-connected neighbor approach numLabels = CvInvoke.ConnectedComponentsWithStats(image, labels, stats, centroids, - islandConfig.AllowDiagonalBonds?LineType.EightConnected:LineType.FourConnected); - } + islandConfig.AllowDiagonalBonds ? LineType.EightConnected : LineType.FourConnected); + }*/ + var numLabels = CvInvoke.ConnectedComponentsWithStats(image, labels, stats, centroids, + islandConfig.AllowDiagonalBonds ? LineType.EightConnected : LineType.FourConnected); // Get array that contains details of each connected component var ccStats = stats.GetData(); @@ -872,7 +873,7 @@ public List GetAllIssues( //stats[i][3]: Height of Connected Component //stats[i][4]: Total Area (in pixels) in Connected Component - Span labelSpan = MemoryMarshal.Cast(labels.GetPixelSpan()); + Span labelSpan = labels.GetPixelSpan(); Mat previousImage = null; Span previousSpan = null; @@ -900,16 +901,14 @@ public List GetAllIssues( for (int x = rect.X; x < rect.Right; x++) { int pixel = step * y + x; - if (span[pixel] < islandConfig.RequiredPixelBrightnessToProcessCheck) - continue; // Low brightness, ignore - - if (labelSpan[pixel] != i) - continue; // Background pixel or a pixel from another component within the bounding rectangle + if ( + labelSpan[pixel] != i || // Background pixel or a pixel from another component within the bounding rectangle + span[pixel] < islandConfig.RequiredPixelBrightnessToProcessCheck // Low brightness, ignore + ) continue; points.Add(new Point(x, y)); - if (previousSpan[pixel] >= - islandConfig.RequiredPixelBrightnessToSupport) + if (previousSpan[pixel] >= islandConfig.RequiredPixelBrightnessToSupport) { pixelsSupportingIsland++; } @@ -1206,7 +1205,7 @@ in list return result.OrderBy(issue => issue.Type).ThenBy(issue => issue.LayerIndex).ThenBy(issue => issue.PixelsCount).ToList(); } - public void RepairLayers(uint layerStart, uint layerEnd, uint closingIterations = 1, uint openingIterations = 1, byte removeIslandsBelowEqualPixels = 4, + public void RepairLayers(uint layerStart, uint layerEnd, uint closingIterations = 1, uint openingIterations = 0, byte removeIslandsBelowEqualPixels = 4, bool repairIslands = true, bool removeEmptyLayers = true, bool repairResinTraps = true, List issues = null, OperationProgress progress = null) { @@ -1219,79 +1218,95 @@ public void RepairLayers(uint layerStart, uint layerEnd, uint closingIterations { if (progress.Token.IsCancellationRequested) return; Layer layer = this[layerIndex]; - using (var image = layer.LayerMat) + Mat image = null; + + void initImage() + { + if(ReferenceEquals(image, null)) + image = layer.LayerMat; + } + + if (!ReferenceEquals(issues, null)) { - if (!ReferenceEquals(issues, null)) + if (repairIslands && removeIslandsBelowEqualPixels > 0) { - if (repairIslands && removeIslandsBelowEqualPixels > 0) + Span bytes = null; + foreach (var issue in issues) + { + if ( + issue.LayerIndex != layerIndex || + issue.Type != LayerIssue.IssueType.Island || + issue.Pixels.Length > removeIslandsBelowEqualPixels) continue; + + initImage(); + if(bytes == null) + bytes = image.GetPixelSpan(); + + foreach (var issuePixel in issue.Pixels) + { + bytes[image.GetPixelPos(issuePixel)] = 0; + } + } + /*if (issues.TryGetValue((uint)layerIndex, out var issueList)) { var bytes = image.GetPixelSpan(); - foreach (var issue in issues) + foreach (var issue in issueList.Where(issue => + issue.Type == LayerIssue.IssueType.Island && issue.Pixels.Length <= removeIslandsBelowEqualPixels)) { - if ( - issue.LayerIndex != layerIndex || - issue.Type != LayerIssue.IssueType.Island || - issue.Pixels.Length > removeIslandsBelowEqualPixels) continue; - foreach (var issuePixel in issue.Pixels) { bytes[image.GetPixelPos(issuePixel)] = 0; } } - /*if (issues.TryGetValue((uint)layerIndex, out var issueList)) - { - var bytes = image.GetPixelSpan(); - foreach (var issue in issueList.Where(issue => - issue.Type == LayerIssue.IssueType.Island && issue.Pixels.Length <= removeIslandsBelowEqualPixels)) - { - foreach (var issuePixel in issue.Pixels) - { - bytes[image.GetPixelPos(issuePixel)] = 0; - } - } - }*/ - } + }*/ + } - if (repairResinTraps) + if (repairResinTraps) + { + foreach (var issue in issues.Where(issue => issue.LayerIndex == layerIndex && issue.Type == LayerIssue.IssueType.ResinTrap)) { - foreach (var issue in issues.Where(issue => issue.LayerIndex == layerIndex && issue.Type == LayerIssue.IssueType.ResinTrap)) + initImage(); + using (var vec = new VectorOfVectorOfPoint(new VectorOfPoint(issue.Pixels))) { - using (var vec = new VectorOfVectorOfPoint(new VectorOfPoint(issue.Pixels))) - { - CvInvoke.DrawContours(image, - vec, - -1, - new MCvScalar(255), - -1); - } + CvInvoke.DrawContours(image, + vec, + -1, + new MCvScalar(255), + -1); } } } + } - if (repairIslands) + if (repairIslands && (closingIterations > 0 || openingIterations > 0)) + { + initImage(); + using (Mat kernel = CvInvoke.GetStructuringElement(ElementShape.Rectangle, new Size(3, 3), + new Point(-1, -1))) { - using (Mat kernel = CvInvoke.GetStructuringElement(ElementShape.Rectangle, new Size(3, 3), - new Point(-1, -1))) + if (closingIterations > 0) { - if (closingIterations > 0) - { - CvInvoke.MorphologyEx(image, image, MorphOp.Close, kernel, new Point(-1, -1), - (int) closingIterations, BorderType.Default, new MCvScalar()); - } + CvInvoke.MorphologyEx(image, image, MorphOp.Close, kernel, new Point(-1, -1), + (int) closingIterations, BorderType.Default, new MCvScalar()); + } - if (openingIterations > 0) - { - CvInvoke.MorphologyEx(image, image, MorphOp.Open, kernel, new Point(-1, -1), - (int) closingIterations, BorderType.Default, new MCvScalar()); - } + if (openingIterations > 0) + { + CvInvoke.MorphologyEx(image, image, MorphOp.Open, kernel, new Point(-1, -1), + (int) closingIterations, BorderType.Default, new MCvScalar()); } } + } + if (!ReferenceEquals(image, null)) + { layer.LayerMat = image; - lock (progress.Mutex) - { - progress++; - } + image.Dispose(); + } + + lock (progress.Mutex) + { + progress++; } }); } diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj index 4b7006f0..9dcf1117 100644 --- a/UVtools.Core/UVtools.Core.csproj +++ b/UVtools.Core/UVtools.Core.csproj @@ -10,12 +10,12 @@ https://github.com/sn4k3/UVtools https://github.com/sn4k3/UVtools MSLA/DLP, file analysis, repair, conversion and manipulation - 0.6.6.0 + 0.6.6.1 Copyright © 2020 PTRTECH UVtools.png AnyCPU;x64 - 0.6.6.0 - 0.6.6.0 + 0.6.6.1 + 0.6.6.1 diff --git a/UVtools.GUI/App.config b/UVtools.GUI/App.config index c0dba46c..409ad195 100644 --- a/UVtools.GUI/App.config +++ b/UVtools.GUI/App.config @@ -196,6 +196,9 @@ True + + False + diff --git a/UVtools.GUI/Controls/Log.cs b/UVtools.GUI/Controls/LogItem.cs similarity index 59% rename from UVtools.GUI/Controls/Log.cs rename to UVtools.GUI/Controls/LogItem.cs index 80836f7b..fe64262f 100644 --- a/UVtools.GUI/Controls/Log.cs +++ b/UVtools.GUI/Controls/LogItem.cs @@ -6,24 +6,32 @@ namespace UVtools.GUI.Controls { - public sealed class Log : INotifyPropertyChanged + public sealed class LogItem : INotifyPropertyChanged { private int _index; - private string _time; + private string _startTime; + private decimal _elapsedTime; private string _description; - [OLVColumn(Width = 50, Title = "#")] + [OLVColumn(Width = 40, Title = "#")] public int Index { get => _index; set => SetField(ref _index, value); } - [OLVColumn(Width = 90)] - public string Time + [OLVColumn(Width = 80, Title = "Started")] + public string StartTime { - get => _time; - set => SetField(ref _time, value); + get => _startTime; + set => SetField(ref _startTime, value); + } + + [OLVColumn(Width = 70, Title = "Time(s)")] + public decimal ElapsedTime + { + get => _elapsedTime; + set => SetField(ref _elapsedTime, Math.Round(value, 2)); } [OLVColumn(Width = 0)] @@ -33,13 +41,17 @@ public string Description set => SetField(ref _description, value); } - public Log(int index, string description) + public LogItem(int index, string description, decimal elapsedTime = 0) { _index = index; _description = description; - _time = DateTime.Now.ToString("HH:mm:ss"); + _elapsedTime = elapsedTime; + _startTime = DateTime.Now.ToString("HH:mm:ss"); } + public LogItem(string description, uint elapsedTime = 0) : this(0, description, elapsedTime) + { } + public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged([CallerMemberName] string propertyName = null) diff --git a/UVtools.GUI/Forms/FrmInputBox.cs b/UVtools.GUI/Forms/FrmInputBox.cs index 4ab92958..10fd236f 100644 --- a/UVtools.GUI/Forms/FrmInputBox.cs +++ b/UVtools.GUI/Forms/FrmInputBox.cs @@ -7,11 +7,11 @@ */ using System; -using System.Diagnostics; using System.Globalization; using System.Windows.Forms; using UVtools.Core; using UVtools.Core.FileFormats; +using UVtools.GUI.Controls; namespace UVtools.GUI.Forms { @@ -41,6 +41,7 @@ public decimal CurrentValue get => _currentValue; set { _currentValue = value; tbCurrentValue.Text = value.ToString(CultureInfo.InvariantCulture)+ValueUint; } } + #endregion #region Constructors @@ -49,8 +50,6 @@ public FrmInputBox() InitializeComponent(); DialogResult = DialogResult.Cancel; numNewValue.Select(); - - } public FrmInputBox(FileFormat.PrintParameterModifier modifier, decimal currentValue) : this(modifier.Name, diff --git a/UVtools.GUI/Forms/FrmLoading.cs b/UVtools.GUI/Forms/FrmLoading.cs index 8bdaeef7..fb4204a2 100644 --- a/UVtools.GUI/Forms/FrmLoading.cs +++ b/UVtools.GUI/Forms/FrmLoading.cs @@ -4,6 +4,7 @@ using System.Windows.Forms; using UVtools.Core; using UVtools.Core.Operations; +using UVtools.GUI.Controls; namespace UVtools.GUI.Forms { @@ -12,6 +13,9 @@ public partial class FrmLoading : Form public Stopwatch StopWatch { get; } = new Stopwatch(); public OperationProgress Progress { get; set; } + private LogItem OperationLog; + + //public Task RunningTask { get; set; } public string Description @@ -70,6 +74,7 @@ protected override void OnClosed(EventArgs e) timer.Stop(); StopWatch.Stop(); Progress = null; + OperationLog.ElapsedTime = (uint) StopWatch.ElapsedMilliseconds / 1000m; } public OperationProgress RestartProgress(bool canCancel = true) @@ -82,7 +87,8 @@ public void SetDescription(string description) { Text = lbDescription.Text = description; - Program.FrmMain.AddLog(description); + OperationLog = new LogItem(description); + Program.FrmMain.AddLog(OperationLog); } public void SetProgress(int value) diff --git a/UVtools.GUI/Forms/FrmSettings.Designer.cs b/UVtools.GUI/Forms/FrmSettings.Designer.cs index af306741..6e44b74c 100644 --- a/UVtools.GUI/Forms/FrmSettings.Designer.cs +++ b/UVtools.GUI/Forms/FrmSettings.Designer.cs @@ -28,6 +28,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmSettings)); this.label1 = new System.Windows.Forms.Label(); this.btnPreviousNextLayerColor = new System.Windows.Forms.Button(); @@ -122,6 +123,7 @@ private void InitializeComponent() this.cbAutoZoomIssues = new System.Windows.Forms.CheckBox(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.tabPage4 = new System.Windows.Forms.TabPage(); + this.cbPartialUpdateIslandsOnEditing = new System.Windows.Forms.CheckBox(); this.btnPixelEditorDrainHoleColor = new System.Windows.Forms.Button(); this.label26 = new System.Windows.Forms.Label(); this.btnPixelEditorSupportColor = new System.Windows.Forms.Button(); @@ -141,7 +143,8 @@ private void InitializeComponent() this.cbLayerRepairRemoveEmptyLayers = new System.Windows.Forms.CheckBox(); this.cbLayerRepairLayersIslands = new System.Windows.Forms.CheckBox(); this.panel1 = new System.Windows.Forms.Panel(); - this.cbPartialUpdateIslandsOnEditing = new System.Windows.Forms.CheckBox(); + this.cbIslandAllowDiagonalBonds = new System.Windows.Forms.CheckBox(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); ((System.ComponentModel.ISupportInitialize)(this.nmOutlineHollowAreasLineThickness)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmOutlineLayerBoundsLineThickness)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nmOutlinePrintVolumeBoundsLineThickness)).BeginInit(); @@ -670,7 +673,7 @@ private void InitializeComponent() this.groupBox3.Controls.Add(this.nmResinTrapRequiredAreaToProcessCheck); this.groupBox3.Controls.Add(this.label11); this.groupBox3.Dock = System.Windows.Forms.DockStyle.Top; - this.groupBox3.Location = new System.Drawing.Point(3, 262); + this.groupBox3.Location = new System.Drawing.Point(3, 300); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(610, 152); this.groupBox3.TabIndex = 24; @@ -794,6 +797,7 @@ private void InitializeComponent() // // groupBox2 // + this.groupBox2.Controls.Add(this.cbIslandAllowDiagonalBonds); this.groupBox2.Controls.Add(this.nmIslandBinaryThreshold); this.groupBox2.Controls.Add(this.label21); this.groupBox2.Controls.Add(this.label10); @@ -807,14 +811,14 @@ private void InitializeComponent() this.groupBox2.Dock = System.Windows.Forms.DockStyle.Top; this.groupBox2.Location = new System.Drawing.Point(3, 86); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(610, 176); + this.groupBox2.Size = new System.Drawing.Size(610, 214); this.groupBox2.TabIndex = 23; this.groupBox2.TabStop = false; this.groupBox2.Text = "Islands"; // // nmIslandBinaryThreshold // - this.nmIslandBinaryThreshold.Location = new System.Drawing.Point(10, 23); + this.nmIslandBinaryThreshold.Location = new System.Drawing.Point(10, 51); this.nmIslandBinaryThreshold.Maximum = new decimal(new int[] { 254, 0, @@ -823,16 +827,11 @@ private void InitializeComponent() this.nmIslandBinaryThreshold.Name = "nmIslandBinaryThreshold"; this.nmIslandBinaryThreshold.Size = new System.Drawing.Size(57, 24); this.nmIslandBinaryThreshold.TabIndex = 28; - this.nmIslandBinaryThreshold.Value = new decimal(new int[] { - 1, - 0, - 0, - 0}); // // label21 // this.label21.AutoSize = true; - this.label21.Location = new System.Drawing.Point(73, 26); + this.label21.Location = new System.Drawing.Point(73, 54); this.label21.Name = "label21"; this.label21.Size = new System.Drawing.Size(512, 18); this.label21.TabIndex = 29; @@ -842,7 +841,7 @@ private void InitializeComponent() // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(73, 146); + this.label10.Location = new System.Drawing.Point(73, 174); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(507, 18); this.label10.TabIndex = 25; @@ -850,7 +849,7 @@ private void InitializeComponent() // // nmIslandRequiredPixelBrightnessToSupport // - this.nmIslandRequiredPixelBrightnessToSupport.Location = new System.Drawing.Point(10, 143); + this.nmIslandRequiredPixelBrightnessToSupport.Location = new System.Drawing.Point(10, 171); this.nmIslandRequiredPixelBrightnessToSupport.Maximum = new decimal(new int[] { 255, 0, @@ -873,7 +872,7 @@ private void InitializeComponent() // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(73, 116); + this.label9.Location = new System.Drawing.Point(73, 144); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(385, 18); this.label9.TabIndex = 23; @@ -881,7 +880,7 @@ private void InitializeComponent() // // nmIslandRequiredPixelsToSupport // - this.nmIslandRequiredPixelsToSupport.Location = new System.Drawing.Point(10, 113); + this.nmIslandRequiredPixelsToSupport.Location = new System.Drawing.Point(10, 141); this.nmIslandRequiredPixelsToSupport.Maximum = new decimal(new int[] { 255, 0, @@ -903,7 +902,7 @@ private void InitializeComponent() // // nmIslandRequiredAreaToProcessCheck // - this.nmIslandRequiredAreaToProcessCheck.Location = new System.Drawing.Point(10, 53); + this.nmIslandRequiredAreaToProcessCheck.Location = new System.Drawing.Point(10, 81); this.nmIslandRequiredAreaToProcessCheck.Maximum = new decimal(new int[] { 255, 0, @@ -926,7 +925,7 @@ private void InitializeComponent() // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(73, 56); + this.label7.Location = new System.Drawing.Point(73, 84); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(481, 18); this.label7.TabIndex = 19; @@ -935,7 +934,7 @@ private void InitializeComponent() // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(73, 86); + this.label8.Location = new System.Drawing.Point(73, 114); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(439, 18); this.label8.TabIndex = 21; @@ -943,7 +942,7 @@ private void InitializeComponent() // // nmIslandRequiredPixelBrightnessToProcessCheck // - this.nmIslandRequiredPixelBrightnessToProcessCheck.Location = new System.Drawing.Point(10, 83); + this.nmIslandRequiredPixelBrightnessToProcessCheck.Location = new System.Drawing.Point(10, 111); this.nmIslandRequiredPixelBrightnessToProcessCheck.Maximum = new decimal(new int[] { 255, 0, @@ -998,7 +997,7 @@ private void InitializeComponent() this.tabSettings.Location = new System.Drawing.Point(0, 0); this.tabSettings.Name = "tabSettings"; this.tabSettings.SelectedIndex = 0; - this.tabSettings.Size = new System.Drawing.Size(624, 529); + this.tabSettings.Size = new System.Drawing.Size(624, 577); this.tabSettings.TabIndex = 18; // // tabPage1 @@ -1327,7 +1326,7 @@ private void InitializeComponent() this.tabPage3.Location = new System.Drawing.Point(4, 27); this.tabPage3.Name = "tabPage3"; this.tabPage3.Padding = new System.Windows.Forms.Padding(3); - this.tabPage3.Size = new System.Drawing.Size(616, 498); + this.tabPage3.Size = new System.Drawing.Size(616, 546); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Issues"; this.tabPage3.UseVisualStyleBackColor = true; @@ -1351,6 +1350,17 @@ private void InitializeComponent() this.tabPage4.Text = "Pixel Editor"; this.tabPage4.UseVisualStyleBackColor = true; // + // cbPartialUpdateIslandsOnEditing + // + this.cbPartialUpdateIslandsOnEditing.AutoSize = true; + this.cbPartialUpdateIslandsOnEditing.Location = new System.Drawing.Point(9, 170); + this.cbPartialUpdateIslandsOnEditing.Name = "cbPartialUpdateIslandsOnEditing"; + this.cbPartialUpdateIslandsOnEditing.Size = new System.Drawing.Size(565, 40); + this.cbPartialUpdateIslandsOnEditing.TabIndex = 19; + this.cbPartialUpdateIslandsOnEditing.Text = "Partial update islands for the affected layers after apply the modifications and " + + "when\r\nremove a island"; + this.cbPartialUpdateIslandsOnEditing.UseVisualStyleBackColor = true; + // // btnPixelEditorDrainHoleColor // this.btnPixelEditorDrainHoleColor.BackColor = System.Drawing.Color.White; @@ -1580,27 +1590,37 @@ private void InitializeComponent() 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.Location = new System.Drawing.Point(0, 500); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(624, 77); this.panel1.TabIndex = 19; // - // cbPartialUpdateIslandsOnEditing + // cbIslandAllowDiagonalBonds // - this.cbPartialUpdateIslandsOnEditing.AutoSize = true; - this.cbPartialUpdateIslandsOnEditing.Location = new System.Drawing.Point(9, 170); - this.cbPartialUpdateIslandsOnEditing.Name = "cbPartialUpdateIslandsOnEditing"; - this.cbPartialUpdateIslandsOnEditing.Size = new System.Drawing.Size(565, 40); - this.cbPartialUpdateIslandsOnEditing.TabIndex = 19; - this.cbPartialUpdateIslandsOnEditing.Text = "Partial update islands for the affected layers after apply the modifications and " + - "when\r\nremove a island"; - this.cbPartialUpdateIslandsOnEditing.UseVisualStyleBackColor = true; + this.cbIslandAllowDiagonalBonds.AutoSize = true; + this.cbIslandAllowDiagonalBonds.Location = new System.Drawing.Point(10, 23); + this.cbIslandAllowDiagonalBonds.Name = "cbIslandAllowDiagonalBonds"; + this.cbIslandAllowDiagonalBonds.Size = new System.Drawing.Size(166, 22); + this.cbIslandAllowDiagonalBonds.TabIndex = 30; + this.cbIslandAllowDiagonalBonds.Text = "Allow diagonal bonds"; + this.toolTip.SetToolTip(this.cbIslandAllowDiagonalBonds, " If true, all 8 neighbors of a pixel (including diagonals) will be considered whe" + + "n finding individual components on the layer.\r\nif false only 4 neighbors (right," + + " left, above, below) will be considered"); + this.cbIslandAllowDiagonalBonds.UseVisualStyleBackColor = true; + // + // toolTip + // + this.toolTip.AutoPopDelay = 32767; + this.toolTip.InitialDelay = 500; + this.toolTip.ReshowDelay = 100; + this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; + this.toolTip.ToolTipTitle = "Information"; // // FrmSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(624, 529); + this.ClientSize = new System.Drawing.Size(624, 577); this.Controls.Add(this.panel1); this.Controls.Add(this.tabSettings); this.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); @@ -1767,5 +1787,7 @@ private void InitializeComponent() private System.Windows.Forms.NumericUpDown nmLayerRepairRemoveIslandsBelowEqualPixelsDefault; private System.Windows.Forms.Label label35; private System.Windows.Forms.CheckBox cbPartialUpdateIslandsOnEditing; + private System.Windows.Forms.CheckBox cbIslandAllowDiagonalBonds; + private System.Windows.Forms.ToolTip toolTip; } } \ No newline at end of file diff --git a/UVtools.GUI/Forms/FrmSettings.cs b/UVtools.GUI/Forms/FrmSettings.cs index 499a2bfd..fe2309df 100644 --- a/UVtools.GUI/Forms/FrmSettings.cs +++ b/UVtools.GUI/Forms/FrmSettings.cs @@ -69,6 +69,7 @@ public void Init() cbComputeResinTraps.Checked = Settings.Default.ComputeResinTraps; cbAutoComputeIssuesClickOnTab.Checked = Settings.Default.AutoComputeIssuesClickOnTab; + cbIslandAllowDiagonalBonds.Checked = Settings.Default.IslandAllowDiagonalBonds; nmIslandBinaryThreshold.Value = Settings.Default.IslandBinaryThreshold; nmIslandRequiredAreaToProcessCheck.Value = Settings.Default.IslandRequiredAreaToProcessCheck; nmIslandRequiredPixelBrightnessToProcessCheck.Value = Settings.Default.IslandRequiredPixelBrightnessToProcessCheck; @@ -220,6 +221,7 @@ private void EventClick(object sender, EventArgs e) Settings.Default.ComputeResinTraps = cbComputeResinTraps.Checked; Settings.Default.AutoComputeIssuesClickOnTab = cbAutoComputeIssuesClickOnTab.Checked; + Settings.Default.IslandAllowDiagonalBonds = cbIslandAllowDiagonalBonds.Checked; Settings.Default.IslandBinaryThreshold = (byte)nmIslandBinaryThreshold.Value; Settings.Default.IslandRequiredAreaToProcessCheck = (byte) nmIslandRequiredAreaToProcessCheck.Value; Settings.Default.IslandRequiredPixelBrightnessToProcessCheck = (byte)nmIslandRequiredPixelBrightnessToProcessCheck.Value; diff --git a/UVtools.GUI/Forms/FrmSettings.resx b/UVtools.GUI/Forms/FrmSettings.resx index ce1a0236..1dfe5d29 100644 --- a/UVtools.GUI/Forms/FrmSettings.resx +++ b/UVtools.GUI/Forms/FrmSettings.resx @@ -120,6 +120,9 @@ 17, 17 + + 131, 17 + diff --git a/UVtools.GUI/Forms/FrmRepairLayers.Designer.cs b/UVtools.GUI/Forms/FrmToolRepairLayers.Designer.cs similarity index 99% rename from UVtools.GUI/Forms/FrmRepairLayers.Designer.cs rename to UVtools.GUI/Forms/FrmToolRepairLayers.Designer.cs index 1f9f440b..7fca11c9 100644 --- a/UVtools.GUI/Forms/FrmRepairLayers.Designer.cs +++ b/UVtools.GUI/Forms/FrmToolRepairLayers.Designer.cs @@ -2,7 +2,7 @@ namespace UVtools.GUI.Forms { - partial class FrmRepairLayers + partial class FrmToolRepairLayers { /// /// Required designer variable. @@ -31,7 +31,7 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmRepairLayers)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmToolRepairLayers)); this.lbDescription = new System.Windows.Forms.Label(); this.lbIterationsStart = new System.Windows.Forms.Label(); this.numClosingIterations = new System.Windows.Forms.NumericUpDown(); diff --git a/UVtools.GUI/Forms/FrmRepairLayers.cs b/UVtools.GUI/Forms/FrmToolRepairLayers.cs similarity index 95% rename from UVtools.GUI/Forms/FrmRepairLayers.cs rename to UVtools.GUI/Forms/FrmToolRepairLayers.cs index 969bcd32..db7c0a4f 100644 --- a/UVtools.GUI/Forms/FrmRepairLayers.cs +++ b/UVtools.GUI/Forms/FrmToolRepairLayers.cs @@ -11,7 +11,7 @@ namespace UVtools.GUI.Forms { - public partial class FrmRepairLayers : Form + public partial class FrmToolRepairLayers : Form { #region Properties @@ -65,7 +65,7 @@ public bool RepairResinTraps #endregion #region Constructors - public FrmRepairLayers() + public FrmToolRepairLayers() { InitializeComponent(); DialogResult = DialogResult.Cancel; @@ -170,12 +170,12 @@ private void ItemClicked(object sender, EventArgs e) return; } - if (OpeningIterations == 0 && ClosingIterations == 0) + /*if (OpeningIterations == 0 && ClosingIterations == 0) { MessageBox.Show("Any of opening and closing iterations must be non 0.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); numClosingIterations.Select(); return; - } + }*/ if (!RepairIslands && !RemoveEmptyLayers && !RepairResinTraps) { @@ -187,10 +187,10 @@ private void ItemClicked(object sender, EventArgs e) MessageBoxIcon.Question) == DialogResult.Yes) { DialogResult = DialogResult.OK; - if (ClosingIterations <= 0) // Should never happen! + /*if (ClosingIterations <= 0) // Should never happen! { DialogResult = DialogResult.Cancel; - } + }*/ Close(); } diff --git a/UVtools.GUI/Forms/FrmRepairLayers.resx b/UVtools.GUI/Forms/FrmToolRepairLayers.resx similarity index 100% rename from UVtools.GUI/Forms/FrmRepairLayers.resx rename to UVtools.GUI/Forms/FrmToolRepairLayers.resx diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index f1eb0ce7..b89055e9 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -240,7 +240,7 @@ public FrmMain() flvIssues.SecondarySortColumn = flvIssuesColLayerIndex; flvIssues.SecondarySortOrder = SortOrder.Ascending; - Generator.GenerateColumns(lvLog, typeof(Log), true); + Generator.GenerateColumns(lvLog, typeof(LogItem), true); lvLog.PrimarySortColumn = lvLog.AllColumns[0]; lvLog.PrimarySortOrder = SortOrder.Descending; @@ -746,7 +746,7 @@ private void EventClick(object sender, EventArgs e) bool repairIslands; bool removeEmptyLayers; bool repairResinTraps; - using (var frmRepairLayers = new FrmRepairLayers()) + using (var frmRepairLayers = new FrmToolRepairLayers()) { if (frmRepairLayers.ShowDialog() != DialogResult.OK) return; @@ -771,8 +771,6 @@ private void EventClick(object sender, EventArgs e) ComputeIssues(islandConfig, resinTrapConfig); } - AddLog("Repair Layers and Issues"); - DisableGUI(); FrmLoading.SetDescription("Repairing Layers and Issues"); @@ -2319,7 +2317,7 @@ private void UpdateTitle() { Text = ReferenceEquals(SlicerFile, null) ? $"{FrmAbout.AssemblyTitle} Version: {FrmAbout.AssemblyVersion}" : - $"{FrmAbout.AssemblyTitle} File: {Path.GetFileName(SlicerFile.FileFullPath)} ({FrmLoading.StopWatch.ElapsedMilliseconds}ms) Version: {FrmAbout.AssemblyVersion}"; + $"{FrmAbout.AssemblyTitle} File: {Path.GetFileName(SlicerFile.FileFullPath)} ({Math.Round(FrmLoading.StopWatch.ElapsedMilliseconds/1000m, 2)}s) Version: {FrmAbout.AssemblyVersion}"; #if DEBUG Text += " [DEBUG]"; @@ -3503,6 +3501,7 @@ public IslandDetectionConfiguration GetIslandDetectionConfiguration() return new IslandDetectionConfiguration { Enabled = tsIssuesRefreshIslands.Checked, + AllowDiagonalBonds = Settings.Default.IslandAllowDiagonalBonds, BinaryThreshold = Settings.Default.IslandBinaryThreshold, RequiredAreaToProcessCheck = Settings.Default.IslandRequiredAreaToProcessCheck, RequiredPixelBrightnessToProcessCheck = Settings.Default.IslandRequiredPixelBrightnessToProcessCheck, @@ -3523,13 +3522,25 @@ public ResinTrapDetectionConfiguration GetResinTrapDetectionConfiguration() }; } - public void AddLog(string description) + public void AddLog(LogItem log) + { + int count = log.Index = lvLog.GetItemCount()+1; + lvLog.AddObject(log); + lbLogOperations.Text = $"Operations: {count}"; + } + + public void AddLog(string description, decimal elapsedTime = 0) { int count = lvLog.GetItemCount()+1; - lvLog.AddObject(new Log(count, description)); + lvLog.AddObject(new LogItem(count, description)); lbLogOperations.Text = $"Operations: {count}"; } + public void EditLastLogElapsedTime(decimal elapsedTime = 0) + { + if (lvLog.GetModelObject(lvLog.GetItemCount() - 1) is LogItem log) log.ElapsedTime = elapsedTime; + } + public void DrawModifications(bool exitEditor) { if (PixelHistory.Count == 0) diff --git a/UVtools.GUI/Program.cs b/UVtools.GUI/Program.cs index 45ebbf67..ed723a17 100644 --- a/UVtools.GUI/Program.cs +++ b/UVtools.GUI/Program.cs @@ -65,20 +65,6 @@ public static void SetAllControlsFontSize( }; } - public static Matrix KernelStar3x3 { get; } = new Matrix(new byte[,] - { - { 0, 1, 0 }, - { 1, 0, 1 }, - { 0, 1, 0 } - }); - - public static Matrix KernelFindIsolated { get; } = new Matrix(new sbyte[,] - { - { 0, 1, 0 }, - { 1, -1, 1 }, - { 0, 1, 0 } - }); - public static FileFormat SlicerFile { get; set; } public static FrmMain FrmMain { get; private set; } public static FrmAbout FrmAbout { get; private set; } diff --git a/UVtools.GUI/Properties/AssemblyInfo.cs b/UVtools.GUI/Properties/AssemblyInfo.cs index 348ca164..bb424fc6 100644 --- a/UVtools.GUI/Properties/AssemblyInfo.cs +++ b/UVtools.GUI/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // 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.6.0")] -[assembly: AssemblyFileVersion("0.6.6.0")] +[assembly: AssemblyVersion("0.6.6.1")] +[assembly: AssemblyFileVersion("0.6.6.1")] diff --git a/UVtools.GUI/Properties/Settings.Designer.cs b/UVtools.GUI/Properties/Settings.Designer.cs index b79750f8..eb69bd27 100644 --- a/UVtools.GUI/Properties/Settings.Designer.cs +++ b/UVtools.GUI/Properties/Settings.Designer.cs @@ -682,5 +682,17 @@ public bool PartialUpdateIslandsOnEditing { this["PartialUpdateIslandsOnEditing"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool IslandAllowDiagonalBonds { + get { + return ((bool)(this["IslandAllowDiagonalBonds"])); + } + set { + this["IslandAllowDiagonalBonds"] = value; + } + } } } diff --git a/UVtools.GUI/Properties/Settings.settings b/UVtools.GUI/Properties/Settings.settings index bf43d695..01016dab 100644 --- a/UVtools.GUI/Properties/Settings.settings +++ b/UVtools.GUI/Properties/Settings.settings @@ -167,5 +167,8 @@ True + + False + \ No newline at end of file diff --git a/UVtools.GUI/UVtools.GUI.csproj b/UVtools.GUI/UVtools.GUI.csproj index 229ff2c0..70f45429 100644 --- a/UVtools.GUI/UVtools.GUI.csproj +++ b/UVtools.GUI/UVtools.GUI.csproj @@ -151,7 +151,7 @@ CtrlKernel.cs - + Component @@ -228,11 +228,11 @@ FrmMutationResize.cs - + Form - - FrmRepairLayers.cs + + FrmToolRepairLayers.cs Form @@ -316,8 +316,8 @@ FrmMutationResize.cs - - FrmRepairLayers.cs + + FrmToolRepairLayers.cs FrmMutation.cs