feat: show selected part bounding box in status bar
Add SelectionChanged event to PlateView and display the selected part's location and size in a new status bar label. Shows combined bounding box when multiple parts are selected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -171,6 +171,7 @@ namespace OpenNest.Actions
|
|||||||
part.IsSelected = true;
|
part.IsSelected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plateView.NotifySelectionChanged();
|
||||||
plateView.Invalidate();
|
plateView.Invalidate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -187,6 +188,8 @@ namespace OpenNest.Actions
|
|||||||
plateView.SelectedParts.Add(part);
|
plateView.SelectedParts.Add(part);
|
||||||
part.IsSelected = true;
|
part.IsSelected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plateView.NotifySelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateBrushAndPen()
|
private void UpdateBrushAndPen()
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ namespace OpenNest.Controls
|
|||||||
public event EventHandler<ItemAddedEventArgs<Part>> PartAdded;
|
public event EventHandler<ItemAddedEventArgs<Part>> PartAdded;
|
||||||
public event EventHandler<ItemRemovedEventArgs<Part>> PartRemoved;
|
public event EventHandler<ItemRemovedEventArgs<Part>> PartRemoved;
|
||||||
public event EventHandler StatusChanged;
|
public event EventHandler StatusChanged;
|
||||||
|
public event EventHandler SelectionChanged;
|
||||||
|
|
||||||
public PlateView()
|
public PlateView()
|
||||||
: this(ColorScheme.Default)
|
: this(ColorScheme.Default)
|
||||||
@@ -1017,12 +1018,19 @@ namespace OpenNest.Controls
|
|||||||
{
|
{
|
||||||
SelectedParts.ForEach(p => p.IsSelected = false);
|
SelectedParts.ForEach(p => p.IsSelected = false);
|
||||||
SelectedParts.Clear();
|
SelectedParts.Clear();
|
||||||
|
SelectionChanged?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectAll()
|
public void SelectAll()
|
||||||
{
|
{
|
||||||
parts.ForEach(p => p.IsSelected = true);
|
parts.ForEach(p => p.IsSelected = true);
|
||||||
SelectedParts.AddRange(parts);
|
SelectedParts.AddRange(parts);
|
||||||
|
SelectionChanged?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NotifySelectionChanged()
|
||||||
|
{
|
||||||
|
SelectionChanged?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ZoomToPoint(Vector pt, float zoomFactor, bool redraw = true)
|
public override void ZoomToPoint(Vector pt, float zoomFactor, bool redraw = true)
|
||||||
|
|||||||
Generated
+10
-1
@@ -132,6 +132,7 @@
|
|||||||
plateSizeStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
plateSizeStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
plateQtyStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
plateQtyStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
gpuStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
gpuStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
|
selectionStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||||
toolStrip1 = new System.Windows.Forms.ToolStrip();
|
toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||||
btnNew = new System.Windows.Forms.ToolStripButton();
|
btnNew = new System.Windows.Forms.ToolStripButton();
|
||||||
btnOpen = new System.Windows.Forms.ToolStripButton();
|
btnOpen = new System.Windows.Forms.ToolStripButton();
|
||||||
@@ -828,7 +829,7 @@
|
|||||||
//
|
//
|
||||||
// statusStrip1
|
// statusStrip1
|
||||||
//
|
//
|
||||||
statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { statusLabel1, locationStatusLabel, spacerLabel, plateIndexStatusLabel, plateSizeStatusLabel, plateQtyStatusLabel, gpuStatusLabel });
|
statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { statusLabel1, locationStatusLabel, selectionStatusLabel, spacerLabel, plateIndexStatusLabel, plateSizeStatusLabel, plateQtyStatusLabel, gpuStatusLabel });
|
||||||
statusStrip1.Location = new System.Drawing.Point(0, 630);
|
statusStrip1.Location = new System.Drawing.Point(0, 630);
|
||||||
statusStrip1.Name = "statusStrip1";
|
statusStrip1.Name = "statusStrip1";
|
||||||
statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0);
|
statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0);
|
||||||
@@ -851,6 +852,13 @@
|
|||||||
locationStatusLabel.Text = "Location : [0, 0]";
|
locationStatusLabel.Text = "Location : [0, 0]";
|
||||||
locationStatusLabel.Click += LocationStatusLabel_Click;
|
locationStatusLabel.Click += LocationStatusLabel_Click;
|
||||||
//
|
//
|
||||||
|
// selectionStatusLabel
|
||||||
|
//
|
||||||
|
selectionStatusLabel.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left;
|
||||||
|
selectionStatusLabel.Name = "selectionStatusLabel";
|
||||||
|
selectionStatusLabel.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||||
|
selectionStatusLabel.Size = new System.Drawing.Size(14, 19);
|
||||||
|
//
|
||||||
// spacerLabel
|
// spacerLabel
|
||||||
//
|
//
|
||||||
spacerLabel.Name = "spacerLabel";
|
spacerLabel.Name = "spacerLabel";
|
||||||
@@ -1181,6 +1189,7 @@
|
|||||||
private System.Windows.Forms.ToolStripButton btnSaveAs;
|
private System.Windows.Forms.ToolStripButton btnSaveAs;
|
||||||
private System.Windows.Forms.ToolStripMenuItem centerPartsToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem centerPartsToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripStatusLabel gpuStatusLabel;
|
private System.Windows.Forms.ToolStripStatusLabel gpuStatusLabel;
|
||||||
|
private System.Windows.Forms.ToolStripStatusLabel selectionStatusLabel;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||||
private System.Windows.Forms.ToolStripLabel engineLabel;
|
private System.Windows.Forms.ToolStripLabel engineLabel;
|
||||||
private System.Windows.Forms.ToolStripComboBox engineComboBox;
|
private System.Windows.Forms.ToolStripComboBox engineComboBox;
|
||||||
|
|||||||
@@ -221,10 +221,38 @@ namespace OpenNest.Forms
|
|||||||
activeForm.PlateView.Plate.Quantity);
|
activeForm.PlateView.Plate.Quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateSelectionStatus()
|
||||||
|
{
|
||||||
|
if (activeForm == null || activeForm.PlateView.SelectedParts.Count == 0)
|
||||||
|
{
|
||||||
|
selectionStatusLabel.Text = string.Empty;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var selected = activeForm.PlateView.SelectedParts;
|
||||||
|
|
||||||
|
if (selected.Count == 1)
|
||||||
|
{
|
||||||
|
var box = selected[0].BoundingBox;
|
||||||
|
selectionStatusLabel.Text = string.Format("Selected: [{0}, {1}] {2} x {3}",
|
||||||
|
box.X.ToString("n4"), box.Y.ToString("n4"),
|
||||||
|
box.Width.ToString("n4"), box.Length.ToString("n4"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var bounds = selected.Select(p => p.BasePart).ToList().GetBoundingBox();
|
||||||
|
selectionStatusLabel.Text = string.Format("Selected ({0}): [{1}, {2}] {3} x {4}",
|
||||||
|
selected.Count,
|
||||||
|
bounds.X.ToString("n4"), bounds.Y.ToString("n4"),
|
||||||
|
bounds.Width.ToString("n4"), bounds.Length.ToString("n4"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateStatus()
|
private void UpdateStatus()
|
||||||
{
|
{
|
||||||
UpdateLocationStatus();
|
UpdateLocationStatus();
|
||||||
UpdatePlateStatus();
|
UpdatePlateStatus();
|
||||||
|
UpdateSelectionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateGpuStatus()
|
private void UpdateGpuStatus()
|
||||||
@@ -313,6 +341,7 @@ namespace OpenNest.Forms
|
|||||||
activeForm.PlateView.MouseMove -= PlateView_MouseMove;
|
activeForm.PlateView.MouseMove -= PlateView_MouseMove;
|
||||||
activeForm.PlateView.MouseClick -= PlateView_MouseClick;
|
activeForm.PlateView.MouseClick -= PlateView_MouseClick;
|
||||||
activeForm.PlateView.StatusChanged -= PlateView_StatusChanged;
|
activeForm.PlateView.StatusChanged -= PlateView_StatusChanged;
|
||||||
|
activeForm.PlateView.SelectionChanged -= PlateView_SelectionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If nesting is in progress and the active form changed, cancel nesting
|
// If nesting is in progress and the active form changed, cancel nesting
|
||||||
@@ -330,11 +359,14 @@ namespace OpenNest.Forms
|
|||||||
if (activeForm == null)
|
if (activeForm == null)
|
||||||
{
|
{
|
||||||
statusLabel1.Text = "";
|
statusLabel1.Text = "";
|
||||||
|
selectionStatusLabel.Text = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateLocationMode();
|
UpdateLocationMode();
|
||||||
|
UpdateSelectionStatus();
|
||||||
activeForm.PlateView.StatusChanged += PlateView_StatusChanged;
|
activeForm.PlateView.StatusChanged += PlateView_StatusChanged;
|
||||||
|
activeForm.PlateView.SelectionChanged += PlateView_SelectionChanged;
|
||||||
mnuViewDrawRapids.Checked = activeForm.PlateView.DrawRapid;
|
mnuViewDrawRapids.Checked = activeForm.PlateView.DrawRapid;
|
||||||
mnuViewDrawBounds.Checked = activeForm.PlateView.DrawBounds;
|
mnuViewDrawBounds.Checked = activeForm.PlateView.DrawBounds;
|
||||||
statusLabel1.Text = activeForm.PlateView.Status;
|
statusLabel1.Text = activeForm.PlateView.Status;
|
||||||
@@ -1199,6 +1231,11 @@ namespace OpenNest.Forms
|
|||||||
statusLabel1.Text = activeForm.PlateView.Status;
|
statusLabel1.Text = activeForm.PlateView.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PlateView_SelectionChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateSelectionStatus();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion PlateView Events
|
#endregion PlateView Events
|
||||||
|
|
||||||
private void centerPartsToolStripMenuItem_Click(object sender, EventArgs e)
|
private void centerPartsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user