mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-05 14:51:36 -05:00
Nobody tabs every part, but tabbing by size is useful even on a plate that has a support grid. Cutting Settings > Tabs now offers "Only tab parts the support grid can't hold level" or "Tab parts by size" (CuttingParameters.TabBySize), which ignores the bed and tabs each part whose minimum-area bounding rectangle's narrow side is in the range. The support grid choice still falls back to that range on plates with no bed, as before. The range fields become TabSizeMinWidth/TabSizeMaxWidth; their JSON keys stay noBedTabMinWidth/noBedTabMaxWidth so saved settings and nests read unchanged. TabsEnabled stays as the per-contour flag Plan Cutting, Place Lead-in and drawing pins set on the parts they tab. Saved user settings with "Tab every part" read as tabs by size from 0 to 9999, which tabs the same parts. Only the user's settings migrate; a plate's recorded parameters and pins replay as planned. Plan Cutting, Place Lead-in and the pre-post review all go through SupportTabSettings, so they agree on which parts need a tab. A size-tabbed part is held by any clear tab, so it is never a rapid obstacle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
92 lines
3.2 KiB
C#
92 lines
3.2 KiB
C#
using OpenNest.CNC.CuttingStrategy;
|
|
using OpenNest.Controls;
|
|
|
|
namespace OpenNest.WinForms.Tests.Controls;
|
|
|
|
public class CuttingPanelTests
|
|
{
|
|
[Fact]
|
|
public void BuildParameters_KeepsTheSettingsThePanelHasNoFieldFor()
|
|
{
|
|
StaTestThread.Run(() =>
|
|
{
|
|
using var panel = new CuttingPanel();
|
|
panel.LoadFromParameters(new CuttingParameters
|
|
{
|
|
MachineName = "CL-980",
|
|
MaterialName = "Stainless Steel",
|
|
Grade = "304",
|
|
Thickness = 0.075,
|
|
Kerf = 0.008,
|
|
ExternalLeadIn = new ArcLeadIn { Radius = 0.0625 },
|
|
ExternalLeadOut = new NoLeadOut(),
|
|
SupportTabs = true,
|
|
TabConfig = new NormalTab { Size = 0.25 },
|
|
});
|
|
|
|
var built = panel.BuildParameters();
|
|
|
|
// Without the stamp, the machine's leads would replace these edits on the next open.
|
|
Assert.Equal("CL-980", built.MachineName);
|
|
Assert.Equal("Stainless Steel", built.MaterialName);
|
|
Assert.Equal("304", built.Grade);
|
|
Assert.Equal(0.075, built.Thickness);
|
|
Assert.Equal(0.008, built.Kerf);
|
|
Assert.IsType<NoLeadOut>(built.ExternalLeadOut);
|
|
Assert.True(built.SupportTabs);
|
|
}, TimeSpan.FromSeconds(30), "The cutting panel did not build its parameters.");
|
|
}
|
|
|
|
[Fact]
|
|
public void TabBySize_RoundTripsWithItsRange()
|
|
{
|
|
StaTestThread.Run(() =>
|
|
{
|
|
using var panel = new CuttingPanel();
|
|
panel.LoadFromParameters(new CuttingParameters
|
|
{
|
|
SupportTabs = true,
|
|
TabBySize = true,
|
|
TabSizeMinWidth = 0.5,
|
|
TabSizeMaxWidth = 3,
|
|
TabConfig = new NormalTab { Size = 0.03 },
|
|
});
|
|
|
|
var built = panel.BuildParameters();
|
|
|
|
Assert.True(built.SupportTabs);
|
|
Assert.True(built.TabBySize);
|
|
Assert.False(built.TabsEnabled);
|
|
Assert.Equal(0.5, built.TabSizeMinWidth);
|
|
Assert.Equal(3, built.TabSizeMaxWidth);
|
|
}, TimeSpan.FromSeconds(30), "The cutting panel did not build tabs by size.");
|
|
}
|
|
|
|
[Fact]
|
|
public void TabEveryPart_LoadsAsTabsBySizeOverEveryWidth()
|
|
{
|
|
StaTestThread.Run(() =>
|
|
{
|
|
using var panel = new CuttingPanel();
|
|
var saved = new CuttingParameters
|
|
{
|
|
TabsEnabled = true,
|
|
TabConfig = new NormalTab { Size = 0.03 },
|
|
TabSizeMaxWidth = 2,
|
|
};
|
|
panel.LoadFromParameters(saved);
|
|
|
|
var built = panel.BuildParameters();
|
|
|
|
Assert.False(built.TabsEnabled);
|
|
Assert.True(built.SupportTabs);
|
|
Assert.True(built.TabBySize);
|
|
Assert.Equal(0, built.TabSizeMinWidth);
|
|
Assert.Equal(OpenNest.Support.SupportTabSettings.TabEveryPartMaxWidth, built.TabSizeMaxWidth);
|
|
// The caller's settings are not changed.
|
|
Assert.True(saved.TabsEnabled);
|
|
Assert.False(saved.SupportTabs);
|
|
}, TimeSpan.FromSeconds(30), "The cutting panel did not migrate Tab every part.");
|
|
}
|
|
}
|