feat(reports): make material and thickness stand out

Operators read the part spacing beside the thickness as the thickness.
Material and thickness now sit in a larger, shaded band under each page
title, part spacing moves away from it, and the thickness reads
"3/8 (0.375 in)" like the rest of the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-30 20:02:41 -05:00
1 parent 6b161d7a8b
commit 97c80b2c9b
5 files changed
+62 -25

No files matched your search

+47 -14
View File
@@ -19,6 +19,8 @@ public static class NestPdfWriter
private const double HeaderFontSize = 7.5;
private const int MaxHeaderLines = 3;
private const double BodyFontSize = 9;
// The material and thickness band: larger than every other fact on the page.
private const double StockFontSize = 12;
private const double CellPadding = 3;
private const int CardsPerRow = 4;
private const double CardGap = 8;
@@ -187,15 +189,14 @@ public static class NestPdfWriter
title.Format.Font.Size = 14;
title.Format.Font.Bold = true;
title.Format.SpaceAfter = Unit.FromPoint(6);
AddStock(section, snapshot, PortraitWidth);
// Two key/value columns keep the header short so more part cards fit on the first page:
// the job and material on the left, the report's totals on the right.
// the job on the left, the report's totals on the right. No units row: every size,
// thickness and weight carries its own unit.
var left = new List<(string Key, string Value)> { ("Nest:", snapshot.Name) };
if (snapshot.Customer.Length > 0)
left.Add(("Customer:", snapshot.Customer));
left.Add(("Material:", Material(snapshot)));
// No units row: every size, thickness and weight carries its own unit.
left.Add(("Thickness:", Thickness(snapshot)));
var right = new List<(string Key, string Value)>
{
("Distinct layouts:", snapshot.Plates.Length.ToString(Invariant)),
@@ -206,12 +207,12 @@ public static class NestPdfWriter
var info = AddTable(section, 72, 182, 136, 150);
info.Borders.Visible = false;
// The left column always has at least as many rows as the right.
for (var index = 0; index < left.Count; index++)
for (var index = 0; index < System.Math.Max(left.Count, right.Count); index++)
{
var (leftKey, leftValue) = index < left.Count ? left[index] : ("", "");
string[] cells = index < right.Count
? [left[index].Key, left[index].Value, right[index].Key, right[index].Value]
: [left[index].Key, left[index].Value];
? [leftKey, leftValue, right[index].Key, right[index].Value]
: [leftKey, leftValue];
AddInfoRow(info, cells);
}
if (snapshot.Notes.Length > 0)
@@ -418,14 +419,16 @@ public static class NestPdfWriter
var title = section.AddParagraph(heading);
title.Format.Font.Size = 13;
title.Format.Font.Bold = true;
title.Format.SpaceAfter = Unit.FromPoint(3);
AddStock(section, snapshot, LandscapeWidth);
// Part spacing sits away from the thickness band: it was read as the thickness.
var info = AddTable(section, 100, 260, 90, 270);
info.Borders.Visible = false;
AddInfoRow(info, "Nest:", snapshot.Name, "Sheet size:", SheetSize(snapshot, plate));
AddInfoRow(info, "Material:", Material(snapshot), "Quantity:", plate.Copies.ToString(Invariant));
AddInfoRow(info, "Thickness:", Thickness(snapshot), "Part spacing:",
$"{Number(plate.PartSpacing)} {snapshot.Units}");
AddInfoRow(info, "Parts per plate:", plate.Parts.Length.ToString(Invariant), "Utilization:",
AddInfoRow(info, "Quantity:", plate.Copies.ToString(Invariant), "Parts per plate:",
plate.Parts.Length.ToString(Invariant));
AddInfoRow(info, "Part spacing:", $"{Number(plate.PartSpacing)} {snapshot.Units}", "Utilization:",
Percent(plate.Utilization) + " (net part area / full sheet)");
if (plate.CutTime is { } cutTime)
AddInfoRow(info, "Est. cut time:", Duration(cutTime) + " per plate", "Total cut time:",
@@ -954,6 +957,36 @@ public static class NestPdfWriter
AddLines(row.Cells[index].AddParagraph(), ReportText.Cell(text, BodyFont(bold), width, context));
}
/// <summary>
/// The material and thickness in a bordered, shaded band across the page, in a larger bold
/// font than the other facts, so neither is mistaken for another number on the page.
/// </summary>
private static void AddStock(Section section, NestReportSnapshot snapshot, double width)
{
var table = AddTable(section, width / 2, width / 2);
table.Borders.Width = 1;
table.Borders.Color = Colors.Black;
table.TopPadding = table.BottomPadding = Unit.FromPoint(3);
var row = table.AddRow();
row.VerticalAlignment = VerticalAlignment.Center;
row.Shading.Color = new Color(Fill.R, Fill.G, Fill.B);
AddStockCell(table, row, 0, "Material", Material(snapshot));
AddStockCell(table, row, 1, "Thickness", Thickness(snapshot));
var gap = section.AddParagraph();
gap.Format.Font.Size = 1;
gap.Format.SpaceAfter = Unit.FromPoint(4);
}
private static void AddStockCell(Table table, Row row, int index, string key, string value)
{
var width = table.Columns[index].Width.Point - table.LeftPadding.Point - table.RightPadding.Point;
var paragraph = row.Cells[index].AddParagraph();
paragraph.Format.Font.Size = StockFontSize;
paragraph.Format.Font.Bold = true;
var font = new XFont(ReportFonts.Family, StockFontSize, XFontStyleEx.Bold);
AddLines(paragraph, ReportText.Cell($"{key}: {value}", font, width, $"{key} field"));
}
private static void AddLines(Paragraph paragraph, IReadOnlyList<string> lines)
{
for (var line = 0; line < lines.Count; line++)
@@ -971,10 +1004,10 @@ public static class NestPdfWriter
}
// Zero thickness means "unset" in a new nest; never present it as a genuine value.
// The machine config's name for the thickness leads: "16 ga - 0.0598 in".
// The thickness's name leads, its decimal in parentheses: "16 ga (0.0598 in)".
private static string Thickness(NestReportSnapshot snapshot) =>
snapshot.Thickness <= 0 ? "Not specified"
: snapshot.ThicknessName.Length > 0 ? $"{snapshot.ThicknessName} - {Number(snapshot.Thickness)} {snapshot.Units}"
: snapshot.ThicknessName.Length > 0 ? $"{snapshot.ThicknessName} ({Number(snapshot.Thickness)} {snapshot.Units})"
: $"{Number(snapshot.Thickness)} {snapshot.Units}";
private static string SheetSize(NestReportSnapshot snapshot, ReportPlate plate) =>
+2 -2
View File
@@ -208,13 +208,13 @@ public static class PartPrintoutWriter
private static string Length(double value, string units, string format = "0.00") =>
units == "mm" ? $"{value.ToString(format, Invariant)} mm" : $"{value.ToString(format, Invariant)}\"";
/// <summary>The machine config's name for the thickness leads: 16 ga - 0.0598".</summary>
/// <summary>The thickness's name leads, its decimal in parentheses: 16 ga (0.0598").</summary>
private static string Thickness(PartPrintoutSnapshot snapshot)
{
if (snapshot.Thickness <= 0)
return "-";
var value = Length(snapshot.Thickness, snapshot.Units, "0.####");
return snapshot.ThicknessName.Length > 0 ? $"{snapshot.ThicknessName} - {value}" : value;
return snapshot.ThicknessName.Length > 0 ? $"{snapshot.ThicknessName} ({value})" : value;
}
private static string Number(double value) => value.ToString("0.00", Invariant);
@@ -96,8 +96,8 @@ public sealed class NestPdfWriterTests : IDisposable
{ ThicknessName = "1/8\"" };
NestPdfWriter.Write(snapshot, path);
Assert.Contains("1/8\" - 0.125 in", ReportPdf.Text(path, 1));
Assert.Contains("1/8\" - 0.125 in", ReportPdf.Text(path, 2));
Assert.Contains("1/8\" (0.125 in)", ReportPdf.Text(path, 1));
Assert.Contains("1/8\" (0.125 in)", ReportPdf.Text(path, 2));
}
[SkippableFact]
@@ -135,7 +135,7 @@ public sealed class PartPrintoutTests : IDisposable
with
{ ThicknessName = "11 ga" }, path);
Assert.Matches(@"THICKNESS\s+11 ga - 0\.125""\s+CUT LENGTH", ReportPdf.Text(path, 1));
Assert.Matches(@"THICKNESS\s+11 ga \(0\.125""\)\s+CUT LENGTH", ReportPdf.Text(path, 1));
}
[Fact]
+10 -6
View File
@@ -54,7 +54,7 @@ to its right, each line at least 18 pt out with arrows and a boxed label kept
itself (not its bounding box). The part and its dimensions are scaled and
centered together 28 pt inside the drawing border. The table shows the
bounding box (Y extent x X extent), nest material and thickness (led by the
machine config's thickness name, as in the nest report), cut length and
thickness name, as in the nest report), cut length and
pierce count, net area, weight
(the nest report's density rules) and required quantity. Cut length sums the moves the head cuts (cut, break, common-line and lead layers); each run of
them is one pierce, so scribe marks, tab spans, display moves and a display
@@ -142,11 +142,15 @@ short enough (50 pt) that a full page holds five rows of typical cards. Each
row being its own table keeps MigraDoc from drawing the next row's top edges
under the last row on a page.
The summary's header lists the job and material on the left and the totals on
the right, to leave room for part cards on the first page. When the nest
machine's config names the thickness (its **Name / Gauge**, matched as the
[machine cutting defaults](machine-cutting-defaults.md) match it), the name
leads the decimal: "16 ga - 0.0598 in". The desktop supplies it, since
The summary and every plate page open with a bordered, shaded band holding the
material and thickness in larger bold type, so neither is mistaken for another
number (part spacing was read as the thickness). Below it the summary lists the
job on the left and the totals on the right, to leave room for part cards on the
first page; a plate page lists part spacing in the left column, away from the
band. The thickness's name leads its decimal: "16 ga (0.0598 in)". The name is
the nest's own (`Nest.ThicknessName`), else the nest machine's **Name / Gauge**
(matched as the [machine cutting defaults](machine-cutting-defaults.md) match
it), else the nearest standard gauge or fraction. The desktop supplies it, since
Reporting does not read machine configs.
Stock sizes read **width x length** in job units. Plate tables use **Quantity**