mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 09:51:59 -05:00
CutTimeReport computes and words what Calculate Cut Time shows for a plate or nest (time from the simulation with acceleration plus clamp removal, distances and counts from the timing info) as the WinForms timing window. CutTimeEntry and CutTimeMachineChoice hold the dialog's box ranges, the entered values' cut parameters and the Acceleration list's entries. CutSimulationPlayback is the simulator's playhead without drawing: play, pause and speed, scrubbing, part, cutout and move stepping, retiming that keeps the torch in place and which parts it has not reached; CutSimulationStatus words its status rows. The WinForms timing window, cut parameters dialog, machine box, simulator and overlay now call them; their behavior is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
59 lines
2.3 KiB
C#
59 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using OpenNest.Data;
|
|
|
|
namespace OpenNest.Desktop;
|
|
|
|
/// <summary>
|
|
/// One entry of the cut-time Acceleration list: a machine whose acceleration limits time the
|
|
/// moves, or none for full speed everywhere. Named as the WinForms list names them: a machine
|
|
/// with no saved motion values is marked "(placeholder)".
|
|
/// </summary>
|
|
public sealed record CutTimeMachineChoice(MachineConfig Machine)
|
|
{
|
|
public const string FullSpeedText = "None (full speed)";
|
|
|
|
public override string ToString() =>
|
|
Machine == null ? FullSpeedText
|
|
: Machine.Motion == null ? $"{Machine.Name} (placeholder)"
|
|
: Machine.Name;
|
|
|
|
/// <summary>Full speed first, then <paramref name="machines"/> by name.</summary>
|
|
public static List<CutTimeMachineChoice> For(IEnumerable<MachineConfig> machines)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(machines);
|
|
var choices = new List<CutTimeMachineChoice> { new((MachineConfig)null) };
|
|
choices.AddRange(SavedCutTimeSettings.SortedByName(machines).Select(m => new CutTimeMachineChoice(m)));
|
|
return choices;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The index in <paramref name="choices"/> of the remembered choice (<see
|
|
/// cref="SavedCutTimeSettings.Machine"/>): the first machine until one is saved, full speed
|
|
/// when saved so or when there are no machines.
|
|
/// </summary>
|
|
public static int SavedIndex(IReadOnlyList<CutTimeMachineChoice> choices, string saved)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(choices);
|
|
var machine = SavedCutTimeSettings.ChooseMachine(
|
|
choices.Where(c => c.Machine != null).Select(c => c.Machine), saved);
|
|
for (var i = 0; i < choices.Count; i++)
|
|
{
|
|
if (ReferenceEquals(choices[i].Machine, machine))
|
|
return i;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>The machine's limits in <paramref name="units"/>, or null for full speed.</summary>
|
|
public MotionProfile GetMotion(Units units) => Motion(Machine, units);
|
|
|
|
/// <summary>
|
|
/// <paramref name="machine"/>'s limits (its placeholder without saved ones) in
|
|
/// <paramref name="units"/>, or null for full speed.
|
|
/// </summary>
|
|
public static MotionProfile Motion(MachineConfig machine, Units units) =>
|
|
machine?.GetMotionOrPlaceholder().ToProfile(machine.Units, units);
|
|
}
|