Add bin grouping to consolidate identical bins in results
Implements grouping of identical bins (same items in same order) to reduce visual clutter in the results grid. Instead of showing 10 identical bins as separate rows, they now appear as a single row with a count. - Add BinComparer for deep equality comparison of bins - Add BinGroup to represent grouped bins with count - Update ResultsForm to display grouped bins in grid - Add Count column to show how many of each bin pattern - Maintain original bins list for file export This improves readability when the optimizer generates multiple identical cutting patterns. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
18
CutList/Forms/ResultsForm.Designer.cs
generated
18
CutList/Forms/ResultsForm.Designer.cs
generated
@@ -31,6 +31,7 @@
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.countDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.spacingDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.lengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.usedLengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
@@ -68,6 +69,7 @@
|
||||
this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
this.dataGridView1.ColumnHeadersHeight = 30;
|
||||
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.countDataGridViewTextBoxColumn,
|
||||
this.spacingDataGridViewTextBoxColumn,
|
||||
this.lengthDataGridViewTextBoxColumn,
|
||||
this.usedLengthDataGridViewTextBoxColumn,
|
||||
@@ -83,9 +85,16 @@
|
||||
this.dataGridView1.Size = new System.Drawing.Size(994, 253);
|
||||
this.dataGridView1.TabIndex = 0;
|
||||
this.dataGridView1.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_RowEnter);
|
||||
//
|
||||
//
|
||||
// countDataGridViewTextBoxColumn
|
||||
//
|
||||
this.countDataGridViewTextBoxColumn.DataPropertyName = "Count";
|
||||
this.countDataGridViewTextBoxColumn.HeaderText = "Count";
|
||||
this.countDataGridViewTextBoxColumn.Name = "countDataGridViewTextBoxColumn";
|
||||
this.countDataGridViewTextBoxColumn.Width = 60;
|
||||
//
|
||||
// spacingDataGridViewTextBoxColumn
|
||||
//
|
||||
//
|
||||
this.spacingDataGridViewTextBoxColumn.DataPropertyName = "Spacing";
|
||||
this.spacingDataGridViewTextBoxColumn.HeaderText = "Spacing";
|
||||
this.spacingDataGridViewTextBoxColumn.Name = "spacingDataGridViewTextBoxColumn";
|
||||
@@ -121,8 +130,8 @@
|
||||
this.utilizationDataGridViewTextBoxColumn.ReadOnly = true;
|
||||
//
|
||||
// binBindingSource
|
||||
//
|
||||
this.binBindingSource.DataSource = typeof(SawCut.Bin);
|
||||
//
|
||||
this.binBindingSource.DataSource = typeof(SawCut.BinGroup);
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
@@ -260,6 +269,7 @@
|
||||
private System.Windows.Forms.BindingSource binBindingSource;
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.BindingSource uIItemBindingSource;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn countDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn spacingDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn lengthDataGridViewTextBoxColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn usedLengthDataGridViewTextBoxColumn;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace CutList.Forms
|
||||
public partial class ResultsForm : Form
|
||||
{
|
||||
private string filename;
|
||||
private List<Bin> _originalBins = new List<Bin>();
|
||||
|
||||
public ResultsForm(string filename)
|
||||
{
|
||||
@@ -23,21 +24,27 @@ namespace CutList.Forms
|
||||
|
||||
private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
var selectedBin = dataGridView1.Rows[e.RowIndex].DataBoundItem as Bin;
|
||||
var selectedGroup = dataGridView1.Rows[e.RowIndex].DataBoundItem as BinGroup;
|
||||
|
||||
if (selectedBin == null)
|
||||
if (selectedGroup == null)
|
||||
return;
|
||||
|
||||
binLayoutView1.Bin = selectedBin;
|
||||
var representativeBin = selectedGroup.RepresentativeBin;
|
||||
binLayoutView1.Bin = representativeBin;
|
||||
binLayoutView1.Invalidate();
|
||||
|
||||
dataGridView2.DataSource = selectedBin.Items;
|
||||
dataGridView2.DataSource = representativeBin.Items;
|
||||
}
|
||||
|
||||
public List<Bin> Bins
|
||||
{
|
||||
get { return dataGridView1.DataSource as List<Bin>; }
|
||||
set { dataGridView1.DataSource = value; }
|
||||
get { return _originalBins; }
|
||||
set
|
||||
{
|
||||
_originalBins = value;
|
||||
var groupedBins = BinGroupingHelper.GroupIdenticalBins(value);
|
||||
dataGridView1.DataSource = groupedBins;
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@@ -47,7 +54,7 @@ namespace CutList.Forms
|
||||
|
||||
public void Save(string filepath)
|
||||
{
|
||||
var writer = new BinFileSaver(Bins);
|
||||
var writer = new BinFileSaver(_originalBins);
|
||||
writer.SaveBinsToFile(filepath);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user