diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2020-08-18 00:01:06 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2020-08-18 00:01:06 +0300 |
commit | fa5073e68fa8c917a9b9bd13671092b94116963b (patch) | |
tree | aa05c0b7bc0eefe0e14cec170bf9b76563c209ff | |
parent | 06598b7523158a4b5c3fcb6a009ea65c826fd9a2 (diff) |
v0.6.6.1v0.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
20 files changed, 235 insertions, 152 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc505a..cf4cae9 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 0b01831..4eb9bed 100644 --- a/UVtools.Core/Layer/LayerIssue.cs +++ b/UVtools.Core/Layer/LayerIssue.cs @@ -59,7 +59,6 @@ namespace UVtools.Core /// individual components on the layer, if false only 4 neighbors (right, left, above, below) /// will be considered.. /// </summary> - /// public bool AllowDiagonalBonds { get; set; } = false; } diff --git a/UVtools.Core/Layer/LayerManager.cs b/UVtools.Core/Layer/LayerManager.cs index 976d915..b6df9b0 100644 --- a/UVtools.Core/Layer/LayerManager.cs +++ b/UVtools.Core/Layer/LayerManager.cs @@ -10,6 +10,7 @@ using System; 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 @@ namespace UVtools.Core 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 @@ namespace UVtools.Core //stats[i][3]: Height of Connected Component //stats[i][4]: Total Area (in pixels) in Connected Component - Span<int> labelSpan = MemoryMarshal.Cast<byte, int>(labels.GetPixelSpan<byte>()); + Span<int> labelSpan = labels.GetPixelSpan<int>(); Mat previousImage = null; Span<byte> previousSpan = null; @@ -900,16 +901,14 @@ namespace UVtools.Core 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 @@ namespace UVtools.Core 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<LayerIssue> issues = null, OperationProgress progress = null) { @@ -1219,79 +1218,95 @@ namespace UVtools.Core { 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<byte> 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<byte>(); + + foreach (var issuePixel in issue.Pixels) + { + bytes[image.GetPixelPos(issuePixel)] = 0; + } + } + /*if (issues.TryGetValue((uint)layerIndex, out var issueList)) { var bytes = image.GetPixelSpan<byte>(); - 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<byte>(); - 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 4b7006f..9dcf111 100644 --- a/UVtools.Core/UVtools.Core.csproj +++ b/UVtools.Core/UVtools.Core.csproj @@ -10,12 +10,12 @@ <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.6.0</Version> + <Version>0.6.6.1</Version> <Copyright>Copyright © 2020 PTRTECH</Copyright> <PackageIcon>UVtools.png</PackageIcon> <Platforms>AnyCPU;x64</Platforms> - <AssemblyVersion>0.6.6.0</AssemblyVersion> - <FileVersion>0.6.6.0</FileVersion> + <AssemblyVersion>0.6.6.1</AssemblyVersion> + <FileVersion>0.6.6.1</FileVersion> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> diff --git a/UVtools.GUI/App.config b/UVtools.GUI/App.config index c0dba46..409ad19 100644 --- a/UVtools.GUI/App.config +++ b/UVtools.GUI/App.config @@ -196,6 +196,9 @@ <setting name="PartialUpdateIslandsOnEditing" serializeAs="String"> <value>True</value> </setting> + <setting name="IslandAllowDiagonalBonds" serializeAs="String"> + <value>False</value> + </setting> </UVtools.GUI.Properties.Settings> </userSettings> </configuration> diff --git a/UVtools.GUI/Controls/Log.cs b/UVtools.GUI/Controls/LogItem.cs index 80836f7..fe64262 100644 --- a/UVtools.GUI/Controls/Log.cs +++ b/UVtools.GUI/Controls/LogItem.cs @@ -6,24 +6,32 @@ using BrightIdeasSoftware; 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 @@ namespace UVtools.GUI.Controls 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 4ab9295..10fd236 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 @@ namespace UVtools.GUI.Forms get => _currentValue; set { _currentValue = value; tbCurrentValue.Text = value.ToString(CultureInfo.InvariantCulture)+ValueUint; } } + #endregion #region Constructors @@ -49,8 +50,6 @@ namespace UVtools.GUI.Forms 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 8bdaeef..fb4204a 100644 --- a/UVtools.GUI/Forms/FrmLoading.cs +++ b/UVtools.GUI/Forms/FrmLoading.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using UVtools.Core; using UVtools.Core.Operations; +using UVtools.GUI.Controls; namespace UVtools.GUI.Forms { @@ -12,6 +13,9 @@ namespace UVtools.GUI.Forms 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 @@ namespace UVtools.GUI.Forms timer.Stop(); StopWatch.Stop(); Progress = null; + OperationLog.ElapsedTime = (uint) StopWatch.ElapsedMilliseconds / 1000m; } public OperationProgress RestartProgress(bool canCancel = true) @@ -82,7 +87,8 @@ namespace UVtools.GUI.Forms { 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 af30674..6e44b74 100644 --- a/UVtools.GUI/Forms/FrmSettings.Designer.cs +++ b/UVtools.GUI/Forms/FrmSettings.Designer.cs @@ -28,6 +28,7 @@ /// </summary> 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 @@ 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 @@ 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 @@ 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 @@ // // 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 @@ 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 @@ 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 @@ // 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 @@ // // 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 @@ // 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 @@ // // 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 @@ // // 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 @@ // 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 @@ // 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 @@ // // 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 @@ 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 @@ 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 @@ 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 @@ 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 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 499a2bf..fe2309d 100644 --- a/UVtools.GUI/Forms/FrmSettings.cs +++ b/UVtools.GUI/Forms/FrmSettings.cs @@ -69,6 +69,7 @@ namespace UVtools.GUI.Forms 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 @@ namespace UVtools.GUI.Forms 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 ce1a023..1dfe5d2 100644 --- a/UVtools.GUI/Forms/FrmSettings.resx +++ b/UVtools.GUI/Forms/FrmSettings.resx @@ -120,6 +120,9 @@ <metadata name="colorDialog.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>131, 17</value> + </metadata> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> diff --git a/UVtools.GUI/Forms/FrmRepairLayers.Designer.cs b/UVtools.GUI/Forms/FrmToolRepairLayers.Designer.cs index 1f9f440..7fca11c 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 { /// <summary> /// Required designer variable. @@ -31,7 +31,7 @@ namespace UVtools.GUI.Forms 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 index 969bcd3..db7c0a4 100644 --- a/UVtools.GUI/Forms/FrmRepairLayers.cs +++ b/UVtools.GUI/Forms/FrmToolRepairLayers.cs @@ -11,7 +11,7 @@ using System.Windows.Forms; namespace UVtools.GUI.Forms { - public partial class FrmRepairLayers : Form + public partial class FrmToolRepairLayers : Form { #region Properties @@ -65,7 +65,7 @@ namespace UVtools.GUI.Forms #endregion #region Constructors - public FrmRepairLayers() + public FrmToolRepairLayers() { InitializeComponent(); DialogResult = DialogResult.Cancel; @@ -170,12 +170,12 @@ namespace UVtools.GUI.Forms 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 @@ namespace UVtools.GUI.Forms 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 index b58bc91..b58bc91 100644 --- a/UVtools.GUI/Forms/FrmRepairLayers.resx +++ b/UVtools.GUI/Forms/FrmToolRepairLayers.resx diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index f1eb0ce..b89055e 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -240,7 +240,7 @@ namespace UVtools.GUI 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 @@ namespace UVtools.GUI 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 @@ namespace UVtools.GUI ComputeIssues(islandConfig, resinTrapConfig); } - AddLog("Repair Layers and Issues"); - DisableGUI(); FrmLoading.SetDescription("Repairing Layers and Issues"); @@ -2319,7 +2317,7 @@ namespace UVtools.GUI { 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 @@ namespace UVtools.GUI 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 @@ namespace UVtools.GUI }; } - 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 45ebbf6..ed723a1 100644 --- a/UVtools.GUI/Program.cs +++ b/UVtools.GUI/Program.cs @@ -65,20 +65,6 @@ namespace UVtools.GUI }; } - public static Matrix<byte> KernelStar3x3 { get; } = new Matrix<byte>(new byte[,] - { - { 0, 1, 0 }, - { 1, 0, 1 }, - { 0, 1, 0 } - }); - - public static Matrix<sbyte> KernelFindIsolated { get; } = new Matrix<sbyte>(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 348ca16..bb424fc 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.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 b79750f..eb69bd2 100644 --- a/UVtools.GUI/Properties/Settings.Designer.cs +++ b/UVtools.GUI/Properties/Settings.Designer.cs @@ -682,5 +682,17 @@ namespace UVtools.GUI.Properties { 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 bf43d69..01016da 100644 --- a/UVtools.GUI/Properties/Settings.settings +++ b/UVtools.GUI/Properties/Settings.settings @@ -167,5 +167,8 @@ <Setting Name="PartialUpdateIslandsOnEditing" Type="System.Boolean" Scope="User"> <Value Profile="(Default)">True</Value> </Setting> + <Setting Name="IslandAllowDiagonalBonds" Type="System.Boolean" Scope="User"> + <Value Profile="(Default)">False</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 229ff2c..70f4542 100644 --- a/UVtools.GUI/UVtools.GUI.csproj +++ b/UVtools.GUI/UVtools.GUI.csproj @@ -151,7 +151,7 @@ <Compile Include="Controls\CtrlKernel.Designer.cs"> <DependentUpon>CtrlKernel.cs</DependentUpon> </Compile> - <Compile Include="Controls\Log.cs" /> + <Compile Include="Controls\LogItem.cs" /> <Compile Include="Controls\SlicerPropertyItem.cs" /> <Compile Include="Controls\SplitButton.cs"> <SubType>Component</SubType> @@ -228,11 +228,11 @@ <Compile Include="Forms\FrmMutationResize.Designer.cs"> <DependentUpon>FrmMutationResize.cs</DependentUpon> </Compile> - <Compile Include="Forms\FrmRepairLayers.cs"> + <Compile Include="Forms\FrmToolRepairLayers.cs"> <SubType>Form</SubType> </Compile> - <Compile Include="Forms\FrmRepairLayers.Designer.cs"> - <DependentUpon>FrmRepairLayers.cs</DependentUpon> + <Compile Include="Forms\FrmToolRepairLayers.Designer.cs"> + <DependentUpon>FrmToolRepairLayers.cs</DependentUpon> </Compile> <Compile Include="Forms\FrmMutation.cs"> <SubType>Form</SubType> @@ -316,8 +316,8 @@ <EmbeddedResource Include="Forms\FrmMutationResize.resx"> <DependentUpon>FrmMutationResize.cs</DependentUpon> </EmbeddedResource> - <EmbeddedResource Include="Forms\FrmRepairLayers.resx"> - <DependentUpon>FrmRepairLayers.cs</DependentUpon> + <EmbeddedResource Include="Forms\FrmToolRepairLayers.resx"> + <DependentUpon>FrmToolRepairLayers.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="Forms\FrmMutation.resx"> <DependentUpon>FrmMutation.cs</DependentUpon> |