mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-06 02:59:25 -05:00
feat(simulator): move inputs to a Settings tab and time with the nest's machine
The Cut Simulator had grown a row per input and was crowding the window. The slider now leads, with the time under it, then the transport and four equal jump buttons spanning exactly the slider's track. Part, drawing, motion and the heat view sit on a Status tab; the feeds, pierce, heat input and etch choice move to a Settings tab, so the window is shorter and the time stays visible while settings change. The Acceleration picker is gone: the simulator always times with the nest's machine (Nest > Machine), shown by name on the Settings tab, and falls back to full speed when the nest has none. Calculate Cut Time's remembered machine is left alone. The Avalonia simulator follows suit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c96666b59c
commit
d4dfde5126
6 files changed
+298
-57
No files matched your search
@@ -36,16 +36,18 @@ namespace OpenNest.Avalonia
|
||||
private readonly Slider track;
|
||||
private readonly TextBlock timeText, partText, drawingText, motionText;
|
||||
private readonly NumberField feed, holeFeed, rapid, pierce;
|
||||
private readonly ComboBox machineBox;
|
||||
private readonly MachineConfig machine;
|
||||
private readonly CheckBox skipEtch;
|
||||
private readonly Units units;
|
||||
private Plate plate;
|
||||
private bool updatingTrack;
|
||||
private bool rebuildQueued;
|
||||
|
||||
public CutSimulatorWindow(NestView view, IReadOnlyList<MachineConfig> machines)
|
||||
/// <param name="machine">The nest's machine, whose acceleration times the moves, or null for full speed.</param>
|
||||
public CutSimulatorWindow(NestView view, MachineConfig machine)
|
||||
{
|
||||
this.view = view;
|
||||
this.machine = machine;
|
||||
units = view.Tab.Document.Nest.Units;
|
||||
Title = "Cut Simulator";
|
||||
SizeToContent = SizeToContent.WidthAndHeight;
|
||||
@@ -95,7 +97,7 @@ namespace OpenNest.Avalonia
|
||||
status.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
|
||||
var saved = CutTimeSettingsFile.Read();
|
||||
var loaded = saved.ToCutParameters(units, SavedCutTimeSettings.ChooseMachine(machines, saved.Machine));
|
||||
var loaded = saved.ToCutParameters(units, machine);
|
||||
var rate = UnitsHelper.GetShortTimeUnitPair(units);
|
||||
feed = new NumberField("Feed", loaded.Feedrate, CutTimeEntry.MinimumRate, CutTimeEntry.MaximumRate, 0, rate, 130);
|
||||
holeFeed = new NumberField("HoleFeed", loaded.HoleFeedrate ?? loaded.Feedrate, CutTimeEntry.MinimumRate,
|
||||
@@ -116,16 +118,13 @@ namespace OpenNest.Avalonia
|
||||
AddRate(rates, 1, 0, "Rapid", rapid);
|
||||
AddRate(rates, 1, 2, "Pierce", pierce);
|
||||
|
||||
var choices = CutTimeMachineChoice.For(machines);
|
||||
machineBox = new ComboBox
|
||||
var machineText = new TextBlock
|
||||
{
|
||||
Name = "Machine",
|
||||
ItemsSource = choices,
|
||||
SelectedIndex = CutTimeMachineChoice.SavedIndex(choices, saved.Machine),
|
||||
MinWidth = 200,
|
||||
Text = machine?.Name ?? "None (full speed)",
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
ToolTip.SetTip(machineBox, "Machine whose acceleration limits time the moves (Tools > Machine Configuration)");
|
||||
ToolTip.SetTip(machineText, "The nest's machine, whose acceleration limits time the moves (Nest > Machine)");
|
||||
skipEtch = new CheckBox
|
||||
{
|
||||
Name = "SkipEtch",
|
||||
@@ -134,8 +133,8 @@ namespace OpenNest.Avalonia
|
||||
Margin = new Thickness(12, 0, 0, 0),
|
||||
};
|
||||
ToolTip.SetTip(skipEtch, "Leave out contours that only etch, as the CI Fiber post does by default");
|
||||
var motion = Row(new TextBlock { Text = "Acceleration", VerticalAlignment = VerticalAlignment.Center },
|
||||
machineBox, skipEtch);
|
||||
var motion = Row(new TextBlock { Text = "Machine", VerticalAlignment = VerticalAlignment.Center },
|
||||
machineText, skipEtch);
|
||||
|
||||
var layout = new StackPanel { Margin = new Thickness(10), Spacing = 8 };
|
||||
foreach (var part in new Control[] { transport, jumps, track, status, rates, motion })
|
||||
@@ -157,7 +156,6 @@ namespace OpenNest.Avalonia
|
||||
};
|
||||
foreach (var field in new[] { feed, holeFeed, rapid, pierce })
|
||||
field.Changed += (_, _) => Rebuild();
|
||||
machineBox.SelectionChanged += (_, _) => Rebuild();
|
||||
skipEtch.IsCheckedChanged += (_, _) => Rebuild();
|
||||
|
||||
timer.Tick += (_, _) => playback.Advance();
|
||||
@@ -177,7 +175,7 @@ namespace OpenNest.Avalonia
|
||||
/// <summary>The parameters the boxes time the cut with.</summary>
|
||||
private CutParameters GetCutParameters() =>
|
||||
CutTimeEntry.Parameters(feed.Value, holeFeed.Value, rapid.Value, pierce.Value, skipEtch.IsChecked == true,
|
||||
units, (machineBox.SelectedItem as CutTimeMachineChoice)?.Machine);
|
||||
units, machine);
|
||||
|
||||
private void ApplySpeed()
|
||||
{
|
||||
@@ -310,7 +308,7 @@ namespace OpenNest.Avalonia
|
||||
|
||||
private void OnClosed(object sender, EventArgs e)
|
||||
{
|
||||
CutTimeSettingsFile.Save(GetCutParameters(), (machineBox.SelectedItem as CutTimeMachineChoice)?.Machine);
|
||||
CutTimeSettingsFile.Save(GetCutParameters());
|
||||
timer.Stop();
|
||||
playback.Changed -= OnPlaybackChanged;
|
||||
playback.Clear();
|
||||
|
||||
@@ -193,6 +193,14 @@ namespace OpenNest.Avalonia
|
||||
public static SavedCutTimeSettings Read() =>
|
||||
SavedCutTimeSettings.Read(UserSettingsFile.Read(UserSettingsFile.DefaultPath));
|
||||
|
||||
/// <summary>
|
||||
/// Remembers the feeds, pierce and etch choice, leaving the remembered machine alone (the
|
||||
/// simulator times with the nest's machine, not a choice of its own).
|
||||
/// </summary>
|
||||
public static void Save(CutParameters parameters) =>
|
||||
UserSettingsFile.Update(UserSettingsFile.DefaultPath, settings =>
|
||||
SavedCutTimeSettings.Read(settings).With(parameters).WriteTo(settings));
|
||||
|
||||
/// <summary>Remembers the feeds, pierce, etch choice and machine (null for full speed).</summary>
|
||||
public static void Save(CutParameters parameters, MachineConfig machine) =>
|
||||
UserSettingsFile.Update(UserSettingsFile.DefaultPath, settings =>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
@@ -79,7 +80,9 @@ namespace OpenNest.Avalonia
|
||||
inspection = null;
|
||||
return;
|
||||
}
|
||||
simulator = new CutSimulatorWindow(view, machines);
|
||||
var nestMachine = view.Tab.Document.Nest.Machine;
|
||||
var machine = nestMachine == null ? null : machines.FirstOrDefault(m => m.Id == nestMachine.Id);
|
||||
simulator = new CutSimulatorWindow(view, machine);
|
||||
simulator.Closed += (_, _) =>
|
||||
{
|
||||
inspection?.Dispose();
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using OpenNest.Forms;
|
||||
using OpenNest.Geometry;
|
||||
|
||||
namespace OpenNest.WinForms.Tests.Forms;
|
||||
|
||||
public class CutSimulatorFormTests
|
||||
{
|
||||
[Fact]
|
||||
public void InputsSitOnTheSettingsTabAndBothTabsFitWithoutResizing() => RunSta(() =>
|
||||
{
|
||||
using var editor = Editor();
|
||||
editor.Show();
|
||||
editor.PlateManager.LoadAt(0);
|
||||
editor.SimulateCutting();
|
||||
var simulator = (CutSimulatorForm)typeof(EditNestForm)
|
||||
.GetField("cutSimulatorForm", BindingFlags.Instance | BindingFlags.NonPublic)!
|
||||
.GetValue(editor)!;
|
||||
try
|
||||
{
|
||||
var tabs = Field<TabControl>(simulator, "tabs");
|
||||
Assert.Equal(new[] { "Status", "Settings" }, tabs.TabPages.Cast<TabPage>().Select(p => p.Text));
|
||||
var settings = tabs.TabPages[1];
|
||||
foreach (var input in new[] { "feedBox", "holeFeedBox", "rapidBox", "pierceBox", "heatPowerBox", "skipEtchBox", "machineLabel" })
|
||||
Assert.Same(settings, PageOf(Field<Control>(simulator, input)));
|
||||
Assert.Same(tabs.TabPages[0], PageOf(Field<Control>(simulator, "heatBox")));
|
||||
// The time stays above the tabs so it can be read while settings change.
|
||||
Assert.Null(PageOf(Field<Control>(simulator, "timeLabel")));
|
||||
|
||||
var size = simulator.Size;
|
||||
foreach (TabPage page in tabs.TabPages)
|
||||
{
|
||||
tabs.SelectedTab = page;
|
||||
simulator.PerformLayout();
|
||||
Application.DoEvents();
|
||||
Assert.Equal(size, simulator.Size);
|
||||
foreach (var control in Descendants(page.Controls[0]).Where(c => c.Visible))
|
||||
{
|
||||
var bounds = page.RectangleToClient(control.RectangleToScreen(control.ClientRectangle));
|
||||
Assert.True(page.ClientRectangle.Contains(bounds),
|
||||
$"{control.GetType().Name} '{control.Text}' at {bounds} is clipped by the {page.Text} tab ({page.ClientRectangle}).");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
simulator.Close();
|
||||
}
|
||||
});
|
||||
|
||||
[Fact]
|
||||
public void TheSliderLeadsAndTheJumpButtonsSpanItsTrackEvenly() => RunSta(() =>
|
||||
{
|
||||
using var editor = Editor();
|
||||
editor.Show();
|
||||
editor.PlateManager.LoadAt(0);
|
||||
editor.SimulateCutting();
|
||||
var simulator = (CutSimulatorForm)typeof(EditNestForm)
|
||||
.GetField("cutSimulatorForm", BindingFlags.Instance | BindingFlags.NonPublic)!
|
||||
.GetValue(editor)!;
|
||||
try
|
||||
{
|
||||
Application.DoEvents();
|
||||
var track = Field<TrackBar>(simulator, "trackBar");
|
||||
var play = Field<Button>(simulator, "playButton");
|
||||
Assert.True(Screen(track).Bottom <= Screen(play).Top, "The slider sits above the transport buttons.");
|
||||
|
||||
var jumps = new[] { "previousPartButton", "previousContourButton", "nextContourButton", "nextPartButton" }
|
||||
.Select(name => Screen(Field<Button>(simulator, name))).ToArray();
|
||||
Assert.True(jumps.Max(b => b.Width) - jumps.Min(b => b.Width) <= 1,
|
||||
$"Jump buttons differ in width: {string.Join(", ", jumps.Select(b => b.Width))}");
|
||||
// Ordinary buttons: the row never stretches them taller than the play button.
|
||||
Assert.All(jumps, b => Assert.True(b.Height < Screen(play).Height, $"Jump button is {b.Height} px tall."));
|
||||
|
||||
var channel = new int[4];
|
||||
var handle = System.Runtime.InteropServices.GCHandle.Alloc(channel, System.Runtime.InteropServices.GCHandleType.Pinned);
|
||||
try
|
||||
{
|
||||
SendMessage(track.Handle, 0x0400 + 26, IntPtr.Zero, handle.AddrOfPinnedObject());
|
||||
}
|
||||
finally
|
||||
{
|
||||
handle.Free();
|
||||
}
|
||||
var start = track.PointToScreen(new System.Drawing.Point(channel[0], 0)).X;
|
||||
var end = track.PointToScreen(new System.Drawing.Point(channel[2], 0)).X;
|
||||
Assert.InRange(jumps[0].Left - start, -1, 1);
|
||||
Assert.InRange(jumps[^1].Right - end, -1, 1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
simulator.Close();
|
||||
}
|
||||
});
|
||||
|
||||
private static System.Drawing.Rectangle Screen(Control control) =>
|
||||
control.RectangleToScreen(control.ClientRectangle);
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
private static TabPage? PageOf(Control control)
|
||||
{
|
||||
for (var parent = control.Parent; parent != null; parent = parent.Parent)
|
||||
{
|
||||
if (parent is TabPage page)
|
||||
return page;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static IEnumerable<Control> Descendants(Control root)
|
||||
{
|
||||
foreach (Control child in root.Controls)
|
||||
{
|
||||
yield return child;
|
||||
foreach (var nested in Descendants(child))
|
||||
yield return nested;
|
||||
}
|
||||
}
|
||||
|
||||
private static T Field<T>(object owner, string name) where T : class =>
|
||||
(T)owner.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(owner)!;
|
||||
|
||||
private static EditNestForm Editor()
|
||||
{
|
||||
var nest = new Nest();
|
||||
var plate = nest.CreatePlate();
|
||||
plate.Size = new OpenNest.Geometry.Size(48, 48);
|
||||
var drawing = new Drawing("square", TestPrograms.Square(10));
|
||||
nest.Drawings.Add(drawing);
|
||||
plate.Parts.Add(new Part(drawing, new Vector(5, 5)));
|
||||
return new EditNestForm(nest);
|
||||
}
|
||||
|
||||
private static void RunSta(System.Action action) =>
|
||||
StaTestThread.Run(action, TimeSpan.FromSeconds(30), "Cut simulator form test timed out.");
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.Thermal;
|
||||
using OpenNest.Controls;
|
||||
using OpenNest.Data;
|
||||
using OpenNest.Desktop;
|
||||
using OpenNest.Desktop.Interaction;
|
||||
using OpenNest.Support;
|
||||
@@ -32,10 +33,13 @@ namespace OpenNest.Forms
|
||||
private readonly Label timeLabel, partLabel, drawingLabel, stateLabel;
|
||||
private readonly NumericUpDown feedBox, holeFeedBox, rapidBox, pierceBox;
|
||||
private readonly CheckBox skipEtchBox;
|
||||
private readonly CutTimeMachineBox machineBox;
|
||||
private readonly MachineConfig machine;
|
||||
private readonly Label machineLabel;
|
||||
private readonly ComboBox heatBox;
|
||||
private readonly NumericUpDown heatPowerBox;
|
||||
private readonly Label heatLabel;
|
||||
private readonly TabControl tabs;
|
||||
private readonly TableLayoutPanel jumps;
|
||||
private readonly ValidationInspectionScope scope;
|
||||
private Plate plate;
|
||||
private bool updatingTrack;
|
||||
@@ -70,7 +74,10 @@ namespace OpenNest.Forms
|
||||
previousContourButton = JumpButton("◀ Cutout");
|
||||
nextContourButton = JumpButton("Cutout ▶");
|
||||
nextPartButton = JumpButton("Part ▶▶");
|
||||
var jumps = new FlowLayoutPanel { AutoSize = true, Dock = DockStyle.Fill, WrapContents = false };
|
||||
// Four equal columns, inset in OnLoad so the row spans exactly the slider's track.
|
||||
jumps = new TableLayoutPanel { AutoSize = true, Dock = DockStyle.Fill, ColumnCount = 4 };
|
||||
for (var i = 0; i < 4; i++)
|
||||
jumps.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25));
|
||||
jumps.Controls.AddRange(new Control[] { previousPartButton, previousContourButton, nextContourButton, nextPartButton });
|
||||
|
||||
var transport = new FlowLayoutPanel { AutoSize = true, Dock = DockStyle.Fill, WrapContents = false };
|
||||
@@ -101,52 +108,68 @@ namespace OpenNest.Forms
|
||||
partLabel = StatusValue(1);
|
||||
drawingLabel = StatusValue(2);
|
||||
stateLabel = StatusValue(1);
|
||||
var status = new TableLayoutPanel { AutoSize = true, Dock = DockStyle.Fill, ColumnCount = 2 };
|
||||
status.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
|
||||
status.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
|
||||
heatBox = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Width = 110, Anchor = AnchorStyles.Left };
|
||||
heatBox.Items.AddRange(new object[] { "Off", "Now", "Peak so far" });
|
||||
heatBox.SelectedIndex = 0;
|
||||
heatLabel = StatusValue(2);
|
||||
var status = StatusTable();
|
||||
status.Controls.AddRange(new Control[]
|
||||
{
|
||||
StatusCaption("Time"), timeLabel,
|
||||
StatusCaption("Part"), partLabel,
|
||||
StatusCaption("Drawing"), drawingLabel,
|
||||
StatusCaption("Motion"), stateLabel,
|
||||
StatusCaption("Heat"), heatBox,
|
||||
});
|
||||
status.Controls.Add(heatLabel);
|
||||
status.SetColumnSpan(heatLabel, 2);
|
||||
|
||||
// The time stays in view on both tabs, so a new feed's effect shows as it is typed.
|
||||
var timeRow = StatusTable();
|
||||
timeRow.Controls.AddRange(new Control[] { StatusCaption("Time"), timeLabel });
|
||||
|
||||
// The inputs live on their own tab; the machine is the nest's (Nest > Machine).
|
||||
var units = nestForm.Nest.Units;
|
||||
var rateSuffix = " " + UnitsHelper.GetShortTimeUnitPair(units);
|
||||
var saved = SavedCutParameters.Load(units);
|
||||
machine = MachineSettings.FindMachine(nestForm.Nest.Machine);
|
||||
machineLabel = new Label
|
||||
{
|
||||
Text = machine?.Name ?? "None (full speed)",
|
||||
AutoSize = true,
|
||||
Margin = new Padding(3, 7, 3, 3),
|
||||
Anchor = AnchorStyles.Left,
|
||||
};
|
||||
feedBox = NewNumber((decimal)saved.Feedrate, 1, 9999, 0, rateSuffix);
|
||||
holeFeedBox = NewNumber((decimal)(saved.HoleFeedrate ?? saved.Feedrate), 1, 9999, 0, rateSuffix);
|
||||
rapidBox = NewNumber((decimal)saved.RapidTravelRate, 1, 9999, 0, rateSuffix);
|
||||
pierceBox = NewNumber((decimal)saved.PierceTime.TotalSeconds, 0, 999, 1, " s");
|
||||
var rates = new TableLayoutPanel { AutoSize = true, Dock = DockStyle.Fill, ColumnCount = 4 };
|
||||
rates.Controls.AddRange(new Control[]
|
||||
{
|
||||
RateLabel("Outside feed"), feedBox,
|
||||
RateLabel("Hole feed"), holeFeedBox,
|
||||
RateLabel("Rapid"), rapidBox,
|
||||
RateLabel("Pierce"), pierceBox,
|
||||
});
|
||||
|
||||
machineBox = new CutTimeMachineBox();
|
||||
heatPowerBox = NewNumber(1000, 50, 20000, 0, " W");
|
||||
heatPowerBox.Increment = 100;
|
||||
skipEtchBox = new CheckBox
|
||||
{
|
||||
Text = "Skip etch-only contours",
|
||||
Checked = saved.SkipScribe,
|
||||
AutoSize = true,
|
||||
Margin = new Padding(12, 6, 3, 3),
|
||||
Margin = new Padding(3, 6, 3, 3),
|
||||
};
|
||||
var motion = new FlowLayoutPanel { AutoSize = true, Dock = DockStyle.Fill, WrapContents = true };
|
||||
motion.Controls.AddRange(new Control[] { RateLabel("Acceleration"), machineBox, skipEtchBox });
|
||||
var settings = new TableLayoutPanel { AutoSize = true, ColumnCount = 4, Padding = new Padding(3, 6, 3, 3) };
|
||||
settings.Controls.Add(RateLabel("Machine"));
|
||||
settings.Controls.Add(machineLabel);
|
||||
settings.SetColumnSpan(machineLabel, 3);
|
||||
settings.Controls.AddRange(new Control[]
|
||||
{
|
||||
RateLabel("Outside feed"), feedBox,
|
||||
RateLabel("Hole feed"), holeFeedBox,
|
||||
RateLabel("Rapid"), rapidBox,
|
||||
RateLabel("Pierce"), pierceBox,
|
||||
RateLabel("Heat input"), heatPowerBox,
|
||||
});
|
||||
settings.Controls.Add(skipEtchBox);
|
||||
settings.SetColumnSpan(skipEtchBox, 2);
|
||||
|
||||
heatBox = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Width = 110, Anchor = AnchorStyles.Left };
|
||||
heatBox.Items.AddRange(new object[] { "Off", "Now", "Peak so far" });
|
||||
heatBox.SelectedIndex = 0;
|
||||
heatPowerBox = NewNumber(1000, 50, 20000, 0, " W");
|
||||
heatPowerBox.Increment = 100;
|
||||
var heatRow = new FlowLayoutPanel { AutoSize = true, Dock = DockStyle.Fill, WrapContents = true };
|
||||
heatRow.Controls.AddRange(new Control[] { RateLabel("Heat"), heatBox, RateLabel("Into plate"), heatPowerBox });
|
||||
heatLabel = StatusValue(2);
|
||||
status.Padding = new Padding(3, 6, 3, 3);
|
||||
tabs = new TabControl { Dock = DockStyle.Fill, Margin = new Padding(3, 6, 3, 3) };
|
||||
tabs.TabPages.AddRange(new[] { NewTabPage("Status", status), NewTabPage("Settings", settings) });
|
||||
|
||||
var layout = new TableLayoutPanel
|
||||
{
|
||||
@@ -156,14 +179,12 @@ namespace OpenNest.Forms
|
||||
Padding = new Padding(6),
|
||||
};
|
||||
layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
|
||||
// The timeline leads, as in a media player; the buttons that drive it sit below.
|
||||
layout.Controls.Add(trackBar);
|
||||
layout.Controls.Add(timeRow);
|
||||
layout.Controls.Add(transport);
|
||||
layout.Controls.Add(jumps);
|
||||
layout.Controls.Add(trackBar);
|
||||
layout.Controls.Add(status);
|
||||
layout.Controls.Add(rates);
|
||||
layout.Controls.Add(motion);
|
||||
layout.Controls.Add(heatRow);
|
||||
layout.Controls.Add(heatLabel);
|
||||
layout.Controls.Add(tabs);
|
||||
Controls.Add(layout);
|
||||
|
||||
restartButton.Click += (_, _) => overlay.Step(p => p.Restart());
|
||||
@@ -180,7 +201,6 @@ namespace OpenNest.Forms
|
||||
skipEtchBox.CheckedChanged += (_, _) => Rebuild();
|
||||
rapidBox.ValueChanged += (_, _) => Rebuild();
|
||||
pierceBox.ValueChanged += (_, _) => Rebuild();
|
||||
machineBox.SelectedIndexChanged += (_, _) => Rebuild();
|
||||
heatBox.SelectedIndexChanged += (_, _) =>
|
||||
{
|
||||
overlay.HeatMode = (HeatView)heatBox.SelectedIndex;
|
||||
@@ -199,7 +219,7 @@ namespace OpenNest.Forms
|
||||
tips.SetToolTip(feedBox, "Feed for outside contours and cut-offs (the CI Fiber post's exterior, L4)");
|
||||
tips.SetToolTip(holeFeedBox, "Feed for holes and other interior contours (the CI Fiber post's interior, L2)");
|
||||
tips.SetToolTip(skipEtchBox, "Leave out contours that only etch, as the CI Fiber post does by default");
|
||||
tips.SetToolTip(machineBox, "Machine whose acceleration limits time the moves (Tools > Machine Configuration)");
|
||||
tips.SetToolTip(machineLabel, "The nest's machine, whose acceleration limits time the moves (Nest > Machine)");
|
||||
tips.SetToolTip(heatBox, "Estimated heat in the sheet: now, or the hottest each area has been so far");
|
||||
tips.SetToolTip(heatPowerBox, "Torch power that stays in the sheet as heat (an estimate; most of the beam leaves with the melt)");
|
||||
tips.SetToolTip(trackBar, "Drag to scrub through the cut (Left/Right step one move)");
|
||||
@@ -237,8 +257,79 @@ namespace OpenNest.Forms
|
||||
Anchor = AnchorStyles.Left,
|
||||
};
|
||||
|
||||
private static Button JumpButton(string text) =>
|
||||
new() { Text = text, AutoSize = true, MinimumSize = new Size(80, 0) };
|
||||
// Stretched across an equal column; a fixed height so the row never grows to fill.
|
||||
private static Button JumpButton(string text)
|
||||
{
|
||||
var button = new Button { Text = text, AutoSize = false, Anchor = AnchorStyles.Left | AnchorStyles.Right };
|
||||
button.Size = new Size(80, button.GetPreferredSize(Size.Empty).Height);
|
||||
return button;
|
||||
}
|
||||
|
||||
private static TableLayoutPanel StatusTable()
|
||||
{
|
||||
var table = new TableLayoutPanel { AutoSize = true, Dock = DockStyle.Fill, ColumnCount = 2 };
|
||||
table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
|
||||
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
|
||||
return table;
|
||||
}
|
||||
|
||||
private static TabPage NewTabPage(string text, Control content)
|
||||
{
|
||||
var page = new TabPage(text) { UseVisualStyleBackColor = true };
|
||||
content.Dock = DockStyle.Top;
|
||||
page.Controls.Add(content);
|
||||
return page;
|
||||
}
|
||||
|
||||
// A tab control never sizes to its pages, so once the handle exists (and DPI scaling is
|
||||
// done) it is given room for the larger page. Fixed after that: switching tabs or new
|
||||
// status text never resizes the window.
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
var inner = tabs.DisplayRectangle.Size;
|
||||
var chrome = tabs.Size - inner;
|
||||
var width = 0;
|
||||
var height = 0;
|
||||
foreach (TabPage page in tabs.TabPages)
|
||||
{
|
||||
var size = page.Controls[0].GetPreferredSize(new Size(inner.Width, 0));
|
||||
width = System.Math.Max(width, size.Width);
|
||||
height = System.Math.Max(height, size.Height);
|
||||
}
|
||||
tabs.MinimumSize = new Size(width + chrome.Width, height + chrome.Height);
|
||||
tabs.Height = tabs.MinimumSize.Height;
|
||||
AlignJumpsToTrack();
|
||||
trackBar.SizeChanged += (_, _) => AlignJumpsToTrack();
|
||||
}
|
||||
|
||||
// Insets the jump row so its outer button edges meet the ends of the slider's track line.
|
||||
private void AlignJumpsToTrack()
|
||||
{
|
||||
if (!trackBar.IsHandleCreated)
|
||||
return;
|
||||
var channel = new NativeRect();
|
||||
SendMessage(trackBar.Handle, TbmGetChannelRect, IntPtr.Zero, ref channel);
|
||||
var start = trackBar.PointToScreen(new Point(channel.Left, 0)).X;
|
||||
var end = trackBar.PointToScreen(new Point(channel.Right, 0)).X;
|
||||
var row = jumps.RectangleToScreen(jumps.ClientRectangle);
|
||||
var margin = previousPartButton.Margin.Left;
|
||||
var left = System.Math.Max(0, start - row.Left - margin);
|
||||
var right = System.Math.Max(0, row.Right - end - margin);
|
||||
if (jumps.Padding.Left != left || jumps.Padding.Right != right)
|
||||
jumps.Padding = new Padding(left, 0, right, 0);
|
||||
}
|
||||
|
||||
private const int TbmGetChannelRect = 0x0400 + 26;
|
||||
|
||||
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
|
||||
private struct NativeRect
|
||||
{
|
||||
public int Left, Top, Right, Bottom;
|
||||
}
|
||||
|
||||
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref NativeRect lParam);
|
||||
|
||||
private static Label StatusCaption(string text) =>
|
||||
new() { Text = text, AutoSize = true, ForeColor = SystemColors.GrayText, Margin = new Padding(3, 2, 8, 2) };
|
||||
@@ -260,7 +351,7 @@ namespace OpenNest.Forms
|
||||
|
||||
private CutParameters GetCutParameters() =>
|
||||
CutTimeEntry.Parameters(feedBox.Value, holeFeedBox.Value, rapidBox.Value, pierceBox.Value,
|
||||
skipEtchBox.Checked, nestForm.Nest.Units, machineBox.Machine);
|
||||
skipEtchBox.Checked, nestForm.Nest.Units, machine);
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
@@ -453,7 +544,6 @@ namespace OpenNest.Forms
|
||||
protected override void OnFormClosed(FormClosedEventArgs e)
|
||||
{
|
||||
SavedCutParameters.Save(GetCutParameters());
|
||||
machineBox.SaveChoice();
|
||||
|
||||
overlay.Changed -= Overlay_Changed;
|
||||
nestForm.PlateChanged -= NestForm_PlateChanged;
|
||||
|
||||
@@ -13,9 +13,12 @@ both desktop apps read and write in the user settings. Both apps word the timing
|
||||
- **Skip etch-only contours** (on by default) leaves out contours that only scribe, as the
|
||||
CI Fiber post's `SkipScribe` does, and joins the travel around them.
|
||||
- **Acceleration** from a machine in Tools > Machine Configuration (`MachineConfig.Motion`,
|
||||
in the machine's units and converted to the nest's). The choice is remembered in the
|
||||
`CutTimeMachine` user setting. Until any machine is chosen, the first machine is used.
|
||||
"None (full speed)" gives the old constant-speed estimate.
|
||||
in the machine's units and converted to the nest's). The simulator always uses the nest's
|
||||
machine (Nest > Machine) and shows its name on the Settings tab; a nest with no machine, or
|
||||
one no longer on file, simulates at full speed. Calculate Cut Time picks a machine,
|
||||
remembered in the `CutTimeMachine` user setting that the nest report also uses (the
|
||||
simulator leaves it alone); until any machine is chosen, the first machine is used. "None (full speed)" gives the old
|
||||
constant-speed estimate.
|
||||
- A machine with no saved motion values uses `MotionConfig.Placeholder`: about 0.5 G cutting,
|
||||
1 G travel and a 0.001 in (0.025 mm) corner deviation. These are stand-ins, not measured
|
||||
values, and the picker labels such machines "(placeholder)".
|
||||
|
||||
Reference in new issue
Block a user