Rewrite LayerPacker as skyline packer, add Extreme Points alternative, manual footprint tuning and reordering UI
- Replace the old layer-grid LayerPacker with a skyline (lowest-slot-first) algorithm: grows the footprint only when items truly can't fit within maxBox, lets shorter types stack multiple sub-layers into taller leftover space, cascades unfinished layers to later types, and allows a staircase profile to minimize wasted volume. - Fix ItemDatabaseEditor NumericUpDown crash (Value set before Minimum/Maximum) and ItemDatabase.Upsert doing INSERT instead of UPDATE (was keyed by Name, now by Id). - Add Packer3D as a working Extreme Points algorithm (was dead/commented-out code) behind a shared IPacker interface, selectable in the UI alongside Skyline. - Add manual footprint (Skyline) / box-size (Extreme Points) adjustment controls for the first box, with correct min/max clamping against the configured max box size. - Add a "Poradie" column with up/down buttons to reorder packing items; both packers now honor that manual order instead of re-sorting by volume. - Drop multi-box packing (single box only), add a pre-pack volume warning, and make unpacked items exportable to PDF / inspectable via a result-label tooltip, both grouped by type with dimensions, count and total volume. - Merge the min/max box dimension groups, hide the now-unused box navigation group, and misc UI cleanup (typo fix, group renames, wider item name column). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+19
-8
@@ -107,18 +107,29 @@ namespace BoxPacker3D
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Inserts or replaces a template (upsert by Name).</summary>
|
||||
/// <summary>
|
||||
/// Inserts a new template (Id == 0) or updates the existing row by Id (Id > 0).
|
||||
/// Using Id rather than Name for the update key means renaming an existing item
|
||||
/// during edit correctly updates that same row instead of leaving the old-named
|
||||
/// row behind and inserting a new one.
|
||||
/// </summary>
|
||||
public void Upsert(ItemTemplate item)
|
||||
{
|
||||
using var conn = Open();
|
||||
using var cmd = conn.CreateCommand();
|
||||
cmd.CommandText = @"
|
||||
INSERT INTO items (Name, Width, Height, Depth)
|
||||
VALUES ($n, $w, $h, $d)
|
||||
ON CONFLICT(Name) DO UPDATE SET
|
||||
Width = excluded.Width,
|
||||
Height = excluded.Height,
|
||||
Depth = excluded.Depth;";
|
||||
if (item.Id > 0)
|
||||
{
|
||||
cmd.CommandText = @"
|
||||
UPDATE items SET Name = $n, Width = $w, Height = $h, Depth = $d
|
||||
WHERE Id = $id;";
|
||||
cmd.Parameters.AddWithValue("$id", item.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.CommandText = @"
|
||||
INSERT INTO items (Name, Width, Height, Depth)
|
||||
VALUES ($n, $w, $h, $d);";
|
||||
}
|
||||
cmd.Parameters.AddWithValue("$n", item.Name);
|
||||
cmd.Parameters.AddWithValue("$w", item.Width);
|
||||
cmd.Parameters.AddWithValue("$h", item.Height);
|
||||
|
||||
Reference in New Issue
Block a user