* (Add) Tool - Layer repair: Allow remove islands recursively (#74)
* (Fix) Pixel Editor: Cursor dimentions when using brushes with thickness > 1 (#73)
This commit is contained in:
Tiago Conceição
2020-10-13 02:04:05 +01:00
parent 4721a52565
commit 1a0229a654
19 changed files with 420 additions and 103 deletions
+5 -1
View File
@@ -216,7 +216,8 @@
<setting name="LayerRepairRemoveEmptyLayers" serializeAs="String">
<value>True</value>
</setting>
<setting name="LayerRepairRemoveIslandsBelowEqualPixelsDefault" serializeAs="String">
<setting name="LayerRepairRemoveIslandsBelowEqualPixelsDefault"
serializeAs="String">
<value>10</value>
</setting>
<setting name="PartialUpdateIslandsOnEditing" serializeAs="String">
@@ -267,6 +268,9 @@
<setting name="OverhangIndependentFromIslands" serializeAs="String">
<value>True</value>
</setting>
<setting name="LayerRepairRemoveIslandsRecursiveIterations" serializeAs="String">
<value>4</value>
</setting>
</UVtools.GUI.Properties.Settings>
</userSettings>
</configuration>
+53 -9
View File
@@ -40,10 +40,14 @@
this.cbRemoveEmptyLayers = new System.Windows.Forms.CheckBox();
this.cbRepairResinTraps = new System.Windows.Forms.CheckBox();
this.cbRepairIslands = new System.Windows.Forms.CheckBox();
this.label4 = new System.Windows.Forms.Label();
this.nmRemoveIslandsRecursiveIterations = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.groupAdvancedSettings.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nmOpeningIterations)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nmClosingIterations)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nmRemoveIslandsBelowEqualPixels)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nmRemoveIslandsRecursiveIterations)).BeginInit();
this.SuspendLayout();
//
// groupAdvancedSettings
@@ -52,7 +56,7 @@
this.groupAdvancedSettings.Controls.Add(this.label1);
this.groupAdvancedSettings.Controls.Add(this.nmClosingIterations);
this.groupAdvancedSettings.Controls.Add(this.lbIterationsStart);
this.groupAdvancedSettings.Location = new System.Drawing.Point(3, 87);
this.groupAdvancedSettings.Location = new System.Drawing.Point(3, 111);
this.groupAdvancedSettings.Name = "groupAdvancedSettings";
this.groupAdvancedSettings.Size = new System.Drawing.Size(601, 110);
this.groupAdvancedSettings.TabIndex = 31;
@@ -106,7 +110,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(319, 46);
this.label3.Location = new System.Drawing.Point(341, 46);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(25, 20);
this.label3.TabIndex = 30;
@@ -117,15 +121,16 @@
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 46);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(250, 20);
this.label2.Size = new System.Drawing.Size(276, 20);
this.label2.TabIndex = 29;
this.label2.Text = "Do not remove islands larger than:";
this.label2.Text = "Remove islands equal or smaller than:";
this.toolTip.SetToolTip(this.label2, "The pixel area theshold above which islands will not be removed by this repair. " +
" Islands remaining after repair will require supports to be added manually.");
" Islands remaining after repair will require supports to be added manually.\r\n0 =" +
" Disable: Do not remove any island");
//
// nmRemoveIslandsBelowEqualPixels
//
this.nmRemoveIslandsBelowEqualPixels.Location = new System.Drawing.Point(259, 43);
this.nmRemoveIslandsBelowEqualPixels.Location = new System.Drawing.Point(281, 43);
this.nmRemoveIslandsBelowEqualPixels.Maximum = new decimal(new int[] {
255,
0,
@@ -135,7 +140,8 @@
this.nmRemoveIslandsBelowEqualPixels.Size = new System.Drawing.Size(58, 26);
this.nmRemoveIslandsBelowEqualPixels.TabIndex = 28;
this.toolTip.SetToolTip(this.nmRemoveIslandsBelowEqualPixels, "The pixel area theshold above which islands will not be removed by this repair. " +
" Islands remaining after repair will require supports to be added manually.");
" Islands remaining after repair will require supports to be added manually.\r\n0 =" +
" Disable: Do not remove any island\r\n");
//
// cbRemoveEmptyLayers
//
@@ -179,12 +185,46 @@
" area removal threshold, and then runs the “gap closure” technique.\r\n");
this.cbRepairIslands.UseVisualStyleBackColor = true;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(3, 77);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(265, 20);
this.label4.TabIndex = 32;
this.label4.Text = "Recursively remove islands for up to:";
this.toolTip.SetToolTip(this.label4, resources.GetString("label4.ToolTip"));
//
// nmRemoveIslandsRecursiveIterations
//
this.nmRemoveIslandsRecursiveIterations.Location = new System.Drawing.Point(281, 74);
this.nmRemoveIslandsRecursiveIterations.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.nmRemoveIslandsRecursiveIterations.Name = "nmRemoveIslandsRecursiveIterations";
this.nmRemoveIslandsRecursiveIterations.Size = new System.Drawing.Size(58, 26);
this.nmRemoveIslandsRecursiveIterations.TabIndex = 33;
this.toolTip.SetToolTip(this.nmRemoveIslandsRecursiveIterations, resources.GetString("nmRemoveIslandsRecursiveIterations.ToolTip"));
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(341, 77);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(50, 20);
this.label5.TabIndex = 34;
this.label5.Text = "layers";
//
// CtrlToolRepairLayers
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.Controls.Add(this.label5);
this.Controls.Add(this.nmRemoveIslandsRecursiveIterations);
this.Controls.Add(this.label4);
this.Controls.Add(this.groupAdvancedSettings);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
@@ -197,12 +237,13 @@
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.LayerRangeVisible = false;
this.Name = "CtrlToolRepairLayers";
this.Size = new System.Drawing.Size(607, 200);
this.Size = new System.Drawing.Size(607, 224);
this.groupAdvancedSettings.ResumeLayout(false);
this.groupAdvancedSettings.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nmOpeningIterations)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nmClosingIterations)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nmRemoveIslandsBelowEqualPixels)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nmRemoveIslandsRecursiveIterations)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -221,5 +262,8 @@
private System.Windows.Forms.CheckBox cbRemoveEmptyLayers;
private System.Windows.Forms.CheckBox cbRepairResinTraps;
private System.Windows.Forms.CheckBox cbRepairIslands;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.NumericUpDown nmRemoveIslandsRecursiveIterations;
private System.Windows.Forms.Label label5;
}
}
@@ -25,6 +25,7 @@ namespace UVtools.GUI.Controls.Tools
cbRepairResinTraps.Checked = Properties.Settings.Default.LayerRepairResinTraps;
cbRemoveEmptyLayers.Checked = Properties.Settings.Default.LayerRepairRemoveEmptyLayers;
nmRemoveIslandsBelowEqualPixels.Value = Properties.Settings.Default.LayerRepairRemoveIslandsBelowEqualPixelsDefault;
nmRemoveIslandsRecursiveIterations.Value = Properties.Settings.Default.LayerRepairRemoveIslandsRecursiveIterations;
nmClosingIterations.Value = Properties.Settings.Default.LayerRepairDefaultClosingIterations;
nmOpeningIterations.Value = Properties.Settings.Default.LayerRepairDefaultOpeningIterations;
@@ -39,6 +40,7 @@ namespace UVtools.GUI.Controls.Tools
Operation.RepairResinTraps = cbRepairResinTraps.Checked;
Operation.RemoveEmptyLayers = cbRemoveEmptyLayers.Checked;
Operation.RemoveIslandsBelowEqualPixelCount = (byte) nmRemoveIslandsBelowEqualPixels.Value;
Operation.RemoveIslandsRecursiveIterations = (ushort) nmRemoveIslandsRecursiveIterations.Value;
Operation.GapClosingIterations = (uint) nmClosingIterations.Value;
Operation.NoiseRemovalIterations = (uint) nmOpeningIterations.Value;
@@ -131,4 +131,18 @@ WARNING: Even at low settings this operation has the potential to introduce new
Set iterations to 0 to disable.
WARNING: Using high iteration values can destroy your model. Low values recomended.</value>
</data>
<data name="label4.ToolTip" xml:space="preserve">
<value>If the removal of an island in the current layer results in a new island being introduce in the layer above, the island in the layer above will also be automatically removed.
This process will repeat for up to the number of layers specified. Set to 0 to repeat until there are no more valid islands to remove.
NOTE: Use with caution as this can remove large portions of your model if proper supports have not been added beforehand.
Using this function with high values can be extremely slow depending on resolution and issue count.</value>
</data>
<data name="nmRemoveIslandsRecursiveIterations.ToolTip" xml:space="preserve">
<value>If the removal of an island in the current layer results in a new island being introduce in the layer above, the island in the layer above will also be automatically removed.
This process will repeat for up to the number of layers specified. Set to 0 to repeat until there are no more valid islands to remove.
NOTE: Use with caution as this can remove large portions of your model if proper supports have not been added beforehand.
Using this function with high values can be extremely slow depending on resolution and issue count.</value>
</data>
</root>
+6 -3
View File
@@ -4259,6 +4259,7 @@ namespace UVtools.GUI
{
// Tools
case OperationRepairLayers operation:
operation.IslandDetectionConfig = GetIslandDetectionConfiguration();
SlicerFile.LayerManager.RepairLayers(operation, FrmLoading.RestartProgress(operation.CanCancel));
break;
case OperationMove operation:
@@ -4378,7 +4379,9 @@ namespace UVtools.GUI
? 1
: nmPixelEditorDrawingThickness.Value);
int diameter = (brushSize * pbLayer.Zoom / 100);
var cursorSize = thickness > 1 ? brushSize + thickness : brushSize;
int diameter = (int) (cursorSize * pbLayer.ZoomFactor);
if (brushSize > 1 && diameter >= _pixelEditorCursorMinDiamater)
{
bitmap = new Bitmap(diameter, diameter, PixelFormat.Format32bppArgb);
@@ -4392,7 +4395,7 @@ namespace UVtools.GUI
case PixelDrawing.BrushShapeType.Rectangle:
if (thickness >= 1)
{
gr.DrawRectangle(new Pen(_pixelEditorCursorBrush, thickness), 0, 0, diameter, diameter);
gr.DrawRectangle(new Pen(_pixelEditorCursorBrush, (int)(thickness * 2 * pbLayer.ZoomFactor)), 0, 0, diameter, diameter);
}
else
{
@@ -4402,7 +4405,7 @@ namespace UVtools.GUI
case PixelDrawing.BrushShapeType.Circle:
if (thickness >= 1)
{
gr.DrawEllipse(new Pen(_pixelEditorCursorBrush, thickness), 0, 0, diameter, diameter);
gr.DrawEllipse(new Pen(_pixelEditorCursorBrush, (int)(thickness * 2 * pbLayer.ZoomFactor)), 0, 0, diameter, diameter);
}
else
{
+2 -2
View File
@@ -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.8.4.2")]
[assembly: AssemblyFileVersion("0.8.4.2")]
[assembly: AssemblyVersion("0.8.4.3")]
[assembly: AssemblyFileVersion("0.8.4.3")]
+12
View File
@@ -970,5 +970,17 @@ namespace UVtools.GUI.Properties {
this["OverhangIndependentFromIslands"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("4")]
public short LayerRepairRemoveIslandsRecursiveIterations {
get {
return ((short)(this["LayerRepairRemoveIslandsRecursiveIterations"]));
}
set {
this["LayerRepairRemoveIslandsRecursiveIterations"] = value;
}
}
}
}
+3
View File
@@ -239,5 +239,8 @@
<Setting Name="OverhangIndependentFromIslands" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="LayerRepairRemoveIslandsRecursiveIterations" Type="System.Int16" Scope="User">
<Value Profile="(Default)">4</Value>
</Setting>
</Settings>
</SettingsFile>