mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
Tune edit parameters
This commit is contained in:
+5
-2
@@ -13,14 +13,17 @@
|
||||
* (Add) Setting: Pixel editor can be configured to exit after each apply operation (#45)
|
||||
* (Add) More abstraction on GUI and operations
|
||||
* (Improvement) Redesign tools and mutator windows
|
||||
* (Improvement) Erode, dilate, gap closing and noise removal converted into one window (Morph model)
|
||||
* (Improvement) Convert add edit parameters into one tool window, edit all at once now
|
||||
* (Improvement) Some edit parameters will trigger an error if outside the min/max limit
|
||||
* (Improvement) Change some edit parameters to have decimals
|
||||
* (Improvement) Kernel option on some mutators is now hidden by default
|
||||
* (Improvement) When zoom into issue or drawing now it checks bounds of zoom rectangle and only performs ZoomToFit is it will be larger then the viewPort after zoom. Otherwise, it will zoom to the fixed zoom level (Auto zoom to region setting dropped as merged into this) (#42)
|
||||
* (Improvement) Layer and Issues Repair: Detailed description and warning text in this dialog has been moved from main form into tooltips. It's useful information for new users, but not needed to be visible each time repair is run.
|
||||
* (Improvement) Tool - Flip: Better performance on "make copy"
|
||||
* (Improvement) Tool - Rotate: Disallow operation when selecting an angle of -360, 0 and 360
|
||||
* (Improvement) Shortcuts: + and - to go up and down on layers were change to W and S keys. Reason: + and - are bound to zoom and can lead to problems
|
||||
Less frequently used settings for gap and noise removal iterations have been moved to an advanced settings group that is hidden by default, and can be shown if changes in those settings is desired. For many users, those advanced settings can be left on default and never adjusted. (#43)
|
||||
* (Change) Erode, dilate, gap closing and noise removal converted into one window (Morph model)
|
||||
* (Change) Shortcuts: + and - to go up and down on layers were change to W and S keys. Reason: + and - are bound to zoom and can lead to problems
|
||||
* (Upgrade) OpenCV from 4.2 to 4.3
|
||||
* (Upgrade) BinarySerializer from 8.5.2 to 8.5.3
|
||||
* (Remove) Menu - Tools - Layer Removal and Layer clone for redudancy they now home at layer preview toolbar under "Actions" dropdown button
|
||||
|
||||
@@ -52,6 +52,21 @@ namespace UVtools.Core.Extensions
|
||||
return value <= min ? min : value >= max ? max : value;
|
||||
}
|
||||
|
||||
public static float Clamp(this float value, float min, float max)
|
||||
{
|
||||
return value <= min ? min : value >= max ? max : value;
|
||||
}
|
||||
|
||||
public static double Clamp(this double value, double min, double max)
|
||||
{
|
||||
return value <= min ? min : value >= max ? max : value;
|
||||
}
|
||||
|
||||
public static decimal Clamp(this decimal value, decimal min, decimal 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)
|
||||
|
||||
@@ -59,16 +59,16 @@ namespace UVtools.Core.FileFormats
|
||||
public static PrintParameterModifier InitialExposureSeconds { get; } = new PrintParameterModifier("Initial Exposure Time", @"Modify 'Initial Exposure Time' seconds", "s", 0.1M, byte.MaxValue, 2);
|
||||
public static PrintParameterModifier ExposureSeconds { get; } = new PrintParameterModifier("Exposure Time", @"Modify 'Exposure Time' seconds", "s", 0.1M, byte.MaxValue, 2);
|
||||
|
||||
public static PrintParameterModifier BottomLayerOffTime { get; } = new PrintParameterModifier("Bottom Layer Off Time", @"Modify 'Bottom Layer Off Time' seconds", "s", 2);
|
||||
public static PrintParameterModifier BottomLayerOffTime { get; } = new PrintParameterModifier("Bottom Layer Off Time", @"Modify 'Bottom Layer Off Time' seconds", "s");
|
||||
public static PrintParameterModifier LayerOffTime { get; } = new PrintParameterModifier("Layer Off Time", @"Modify 'Layer Off Time' seconds", "s");
|
||||
public static PrintParameterModifier BottomLiftHeight { get; } = new PrintParameterModifier("Bottom Lift Height", @"Modify 'Bottom Lift Height' millimeters between bottom layers", "mm", 2);
|
||||
public static PrintParameterModifier BottomLiftSpeed { get; } = new PrintParameterModifier("Bottom Lift Speed", @"Modify 'Bottom Lift Speed' mm/min between bottom layers", "mm/min", 2);
|
||||
public static PrintParameterModifier LiftHeight { get; } = new PrintParameterModifier("Lift Height", @"Modify 'Lift Height' millimeters between layers", "mm", 2);
|
||||
public static PrintParameterModifier BottomLiftHeight { get; } = new PrintParameterModifier("Bottom Lift Height", @"Modify 'Bottom Lift Height' millimeters between bottom layers", "mm", 1);
|
||||
public static PrintParameterModifier BottomLiftSpeed { get; } = new PrintParameterModifier("Bottom Lift Speed", @"Modify 'Bottom Lift Speed' mm/min between bottom layers", "mm/min", 10);
|
||||
public static PrintParameterModifier LiftHeight { get; } = new PrintParameterModifier("Lift Height", @"Modify 'Lift Height' millimeters between layers", "mm", 1);
|
||||
public static PrintParameterModifier LiftSpeed { get; } = new PrintParameterModifier("Lift Speed", @"Modify 'Lift Speed' mm/min between layers", "mm/min", 10, 5000, 2);
|
||||
public static PrintParameterModifier RetractSpeed { get; } = new PrintParameterModifier("Retract Speed", @"Modify 'Retract Speed' mm/min between layers", "mm/min", 10, 5000, 2);
|
||||
|
||||
public static PrintParameterModifier BottomLightPWM { get; } = new PrintParameterModifier("Bottom Light PWM", @"Modify 'Bottom Light PWM' value", null, 50, byte.MaxValue, 0);
|
||||
public static PrintParameterModifier LightPWM { get; } = new PrintParameterModifier("Light PWM", @"Modify 'Light PWM' value", null, 50, byte.MaxValue, 0);
|
||||
public static PrintParameterModifier BottomLightPWM { get; } = new PrintParameterModifier("Bottom Light PWM", @"Modify 'Bottom Light PWM' value", null, 1, byte.MaxValue, 0);
|
||||
public static PrintParameterModifier LightPWM { get; } = new PrintParameterModifier("Light PWM", @"Modify 'Light PWM' value", null, 1, byte.MaxValue, 0);
|
||||
|
||||
public static PrintParameterModifier[] Parameters = {
|
||||
InitialLayerCount,
|
||||
@@ -133,7 +133,7 @@ namespace UVtools.Core.FileFormats
|
||||
/// <summary>
|
||||
/// Gets if the value has changed
|
||||
/// </summary>
|
||||
public bool HasChanged => OldValue == NewValue;
|
||||
public bool HasChanged => OldValue != NewValue;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
@@ -10,6 +10,7 @@ using System;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using UVtools.Core.Extensions;
|
||||
using UVtools.Core.FileFormats;
|
||||
using UVtools.Core.Operations;
|
||||
|
||||
@@ -18,7 +19,93 @@ namespace UVtools.GUI.Controls.Tools
|
||||
public partial class CtrlToolEditParameters : CtrlToolWindowContent
|
||||
{
|
||||
public OperationEditParameters Operation { get; }
|
||||
public NumericUpDown[] NumericUpDownProperties;
|
||||
public RowControl[] RowControls;
|
||||
|
||||
public sealed class RowControl
|
||||
{
|
||||
public FileFormat.PrintParameterModifier Modifier { get; }
|
||||
|
||||
public Label Name { get; }
|
||||
public Label OldValue { get; }
|
||||
public NumericUpDown NewValue { get; }
|
||||
public Label Unit { get; }
|
||||
public Button ResetButton { get; }
|
||||
|
||||
public RowControl(FileFormat.PrintParameterModifier modifier)
|
||||
{
|
||||
Modifier = modifier;
|
||||
modifier.OldValue = decimal.Parse(Program.SlicerFile.GetValueFromPrintParameterModifier(modifier).ToString());
|
||||
|
||||
Name = new Label
|
||||
{
|
||||
Text = $"{modifier.Name}:",
|
||||
TextAlign = ContentAlignment.MiddleLeft,
|
||||
AutoSize = true,
|
||||
Dock = DockStyle.Fill,
|
||||
Tag = this,
|
||||
};
|
||||
|
||||
OldValue = new Label
|
||||
{
|
||||
Text = modifier.OldValue.ToString(CultureInfo.InvariantCulture),
|
||||
TextAlign = ContentAlignment.MiddleCenter,
|
||||
AutoSize = true,
|
||||
Dock = DockStyle.Fill,
|
||||
Tag = this
|
||||
};
|
||||
|
||||
NewValue = new NumericUpDown
|
||||
{
|
||||
DecimalPlaces = modifier.DecimalPlates,
|
||||
Minimum = modifier.Minimum,
|
||||
Maximum = modifier.Maximum,
|
||||
Value = modifier.OldValue.Clamp(modifier.Minimum, modifier.Maximum),
|
||||
Tag = this,
|
||||
Width = 100,
|
||||
Dock = DockStyle.Fill,
|
||||
//AutoSize = true
|
||||
};
|
||||
NewValue.ValueChanged += NewValue_ValueChanged;
|
||||
|
||||
Unit = new Label
|
||||
{
|
||||
Text = modifier.ValueUnit,
|
||||
TextAlign = ContentAlignment.MiddleLeft,
|
||||
AutoSize = true,
|
||||
Dock = DockStyle.Fill,
|
||||
Tag = this
|
||||
};
|
||||
|
||||
ResetButton = new Button
|
||||
{
|
||||
Image = Properties.Resources.refresh_16x16,
|
||||
Dock = DockStyle.Fill,
|
||||
BackColor = Color.LightGray,
|
||||
Enabled = false,
|
||||
Tag = this
|
||||
};
|
||||
ResetButton.Click += ResetButton_Clicked;
|
||||
}
|
||||
|
||||
private void NewValue_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
Modifier.NewValue = NewValue.Value;
|
||||
ResetButton.Enabled = Modifier.HasChanged;
|
||||
}
|
||||
|
||||
private void ResetButton_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
/*if (!(sender is Button button)) return;
|
||||
if (!(button.Tag is NumericUpDown numericUpDown)) return;
|
||||
if (!(numericUpDown.Tag is FileFormat.PrintParameterModifier modifier)) return;
|
||||
numericUpDown.Value = modifier.OldValue;*/
|
||||
|
||||
NewValue.Value = Modifier.OldValue;
|
||||
NewValue.Select();
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public CtrlToolEditParameters()
|
||||
{
|
||||
@@ -33,66 +120,20 @@ namespace UVtools.GUI.Controls.Tools
|
||||
}
|
||||
|
||||
int rowIndex = 1;
|
||||
NumericUpDownProperties = new NumericUpDown[Operation.Modifiers.Length];
|
||||
RowControls = new RowControl[Operation.Modifiers.Length];
|
||||
foreach (var modifier in Operation.Modifiers)
|
||||
{
|
||||
modifier.OldValue = decimal.Parse(Program.SlicerFile.GetValueFromPrintParameterModifier(modifier).ToString());
|
||||
byte column = 0;
|
||||
table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||
|
||||
Label nameLabel = new Label
|
||||
{
|
||||
Text = $"{modifier.Name}:",
|
||||
TextAlign = ContentAlignment.MiddleLeft,
|
||||
AutoSize = true,
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
table.Controls.Add(nameLabel, 0, rowIndex);
|
||||
toolTip.SetToolTip(nameLabel, modifier.Description);
|
||||
var rowControl = new RowControl(modifier);
|
||||
table.Controls.Add(rowControl.Name, column++, rowIndex);
|
||||
table.Controls.Add(rowControl.OldValue, column++, rowIndex);
|
||||
table.Controls.Add(rowControl.NewValue, column++, rowIndex);
|
||||
table.Controls.Add(rowControl.Unit, column++, rowIndex);
|
||||
table.Controls.Add(rowControl.ResetButton, column++, rowIndex);
|
||||
|
||||
Label oldValueLabel = new Label
|
||||
{
|
||||
Text = modifier.OldValue.ToString(CultureInfo.InvariantCulture),
|
||||
TextAlign = ContentAlignment.MiddleCenter,
|
||||
AutoSize = true,
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
table.Controls.Add(oldValueLabel, 1, rowIndex);
|
||||
|
||||
NumericUpDown numericValue = new NumericUpDown
|
||||
{
|
||||
Value = modifier.OldValue,
|
||||
DecimalPlaces = modifier.DecimalPlates,
|
||||
Minimum = modifier.Minimum,
|
||||
Maximum = modifier.Maximum,
|
||||
Tag = modifier,
|
||||
Width = 100,
|
||||
Dock = DockStyle.Fill
|
||||
//AutoSize = true
|
||||
};
|
||||
NumericUpDownProperties[rowIndex - 1] = numericValue;
|
||||
table.Controls.Add(numericValue, 2, rowIndex);
|
||||
|
||||
if (!string.IsNullOrEmpty(modifier.ValueUnit))
|
||||
{
|
||||
Label unitLabel = new Label
|
||||
{
|
||||
Text = modifier.ValueUnit,
|
||||
TextAlign = ContentAlignment.MiddleLeft,
|
||||
AutoSize = true,
|
||||
Dock = DockStyle.Fill,
|
||||
};
|
||||
table.Controls.Add(unitLabel, 3, rowIndex);
|
||||
}
|
||||
|
||||
Button resetButton = new Button
|
||||
{
|
||||
Image = Properties.Resources.refresh_16x16,
|
||||
Dock = DockStyle.Fill,
|
||||
BackColor = Color.WhiteSmoke,
|
||||
Tag = numericValue
|
||||
};
|
||||
resetButton.Click += ResetClicked;
|
||||
table.Controls.Add(resetButton, 4, rowIndex);
|
||||
RowControls[rowIndex-1] = rowControl;
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
@@ -102,12 +143,11 @@ namespace UVtools.GUI.Controls.Tools
|
||||
{
|
||||
base.UpdateOperation();
|
||||
|
||||
foreach (var numUpDown in NumericUpDownProperties)
|
||||
foreach (var rowControl in RowControls)
|
||||
{
|
||||
if (!(numUpDown.Tag is FileFormat.PrintParameterModifier modifier)) continue;
|
||||
modifier.NewValue = modifier.NewValue;
|
||||
if(!modifier.HasChanged) continue;
|
||||
Program.SlicerFile.SetValueFromPrintParameterModifier(modifier, modifier.NewValue);
|
||||
rowControl.Modifier.NewValue = rowControl.NewValue.Value;
|
||||
//if(!modifier.HasChanged) continue;
|
||||
//Program.SlicerFile.SetValueFromPrintParameterModifier(modifier, modifier.NewValue);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -117,25 +157,12 @@ namespace UVtools.GUI.Controls.Tools
|
||||
{
|
||||
if (sender is Button button)
|
||||
{
|
||||
foreach (var numUpDown in NumericUpDownProperties)
|
||||
foreach (var rowControl in RowControls)
|
||||
{
|
||||
if (numUpDown.Tag is FileFormat.PrintParameterModifier modifier)
|
||||
{
|
||||
numUpDown.Value = modifier.OldValue;
|
||||
}
|
||||
rowControl.NewValue.Value = rowControl.Modifier.OldValue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (!(sender is Button button)) return;
|
||||
if (!(button.Tag is NumericUpDown numericUpDown)) return;
|
||||
if (!(numericUpDown.Tag is FileFormat.PrintParameterModifier modifier)) return;
|
||||
numericUpDown.Value = modifier.OldValue;
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+1
@@ -470,6 +470,7 @@ namespace UVtools.GUI
|
||||
this.menuEdit.Name = "menuEdit";
|
||||
this.menuEdit.Size = new System.Drawing.Size(39, 20);
|
||||
this.menuEdit.Text = "&Edit";
|
||||
this.menuEdit.Visible = false;
|
||||
//
|
||||
// menuTools
|
||||
//
|
||||
|
||||
+14
-4
@@ -2035,7 +2035,7 @@ namespace UVtools.GUI
|
||||
|
||||
private void RefreshInfo()
|
||||
{
|
||||
menuEdit.DropDownItems.Clear();
|
||||
/*menuEdit.DropDownItems.Clear();
|
||||
|
||||
if (!ReferenceEquals(SlicerFile.PrintParameterModifiers, null))
|
||||
{
|
||||
@@ -2052,7 +2052,7 @@ namespace UVtools.GUI
|
||||
|
||||
item.Click += EventClick;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
flvProperties.ClearObjects();
|
||||
|
||||
@@ -3976,10 +3976,19 @@ namespace UVtools.GUI
|
||||
{
|
||||
if (baseOperation is null) return false;
|
||||
|
||||
DisableGUI();
|
||||
|
||||
switch (baseOperation)
|
||||
{
|
||||
case OperationEditParameters operation:
|
||||
foreach (var modifier in operation.Modifiers.Where(modifier => modifier.HasChanged))
|
||||
{
|
||||
SlicerFile.SetValueFromPrintParameterModifier(modifier, modifier.NewValue);
|
||||
}
|
||||
RefreshInfo();
|
||||
|
||||
menuFileSave.Enabled =
|
||||
menuFileSaveAs.Enabled = true;
|
||||
|
||||
return false;
|
||||
case OperationRepairLayers operation:
|
||||
if (ReferenceEquals(Issues, null))
|
||||
{
|
||||
@@ -4002,6 +4011,7 @@ namespace UVtools.GUI
|
||||
break;
|
||||
}
|
||||
|
||||
DisableGUI();
|
||||
|
||||
FrmLoading.SetDescription(baseOperation.ProgressTitle);
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABk
|
||||
FAAAAk1TRnQBSQFMAgEBBgEAAZABCgGQAQoBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
|
||||
FAAAAk1TRnQBSQFMAgEBBgEAAZgBCgGYAQoBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
|
||||
AwABIAMAAQEBAAEgBgABIC4AAxgBIgMwAUsDMAFMAzIBUDMAAQEDJAE2AysBQqwAAyIBMQNWAbkDXQHi
|
||||
AwAB/wMAAf8BKgEtASgB/gNTAawDTQGVAwABARgAAwkBDAMzAVIDUAGdA1cB6AMAAf4DKwH8Ay8BSqQA
|
||||
AyEBMANZAewBKwEuASkB+gNRAfcDUgH0A1MB8QNIAfYDQQH5AwAB/wNPAZsDAAEBCAADFQEdAz8BbgNV
|
||||
|
||||
Reference in New Issue
Block a user