diff --git a/OpenNest/Controls/CutSimulationOverlay.cs b/OpenNest/Controls/CutSimulationOverlay.cs
index 9d5c0937..527cfbb8 100644
--- a/OpenNest/Controls/CutSimulationOverlay.cs
+++ b/OpenNest/Controls/CutSimulationOverlay.cs
@@ -350,6 +350,66 @@ internal sealed class CutSimulationOverlay : IDisposable
}
}
+ /// True while the heat layer is drawn, so the cursor reading applies.
+ public bool ShowsHeat => heat != null && heatMode != HeatView.Off && Simulation is { Steps.Count: > 0 };
+
+ // While playing, the reading would change every frame, too fast to read; it refreshes at
+ // most this often unless the cursor moves to another cell.
+ private const long ReadingIntervalMs = 1000;
+ private int readingCell = -1;
+ private long readingAt;
+ private string readingText;
+
+ ///
+ /// Draws the heat layer's value under (control pixels) just below
+ /// it; nothing off the plate or where material fell away. Call after .
+ ///
+ public void DrawHeatReading(Graphics graphics, Point cursor, Font font)
+ {
+ if (!ShowsHeat)
+ return;
+ var cell = heat.CellAt(view.PointControlToWorld(cursor));
+ if (cell < 0 || heat.IsRemoved(cell))
+ {
+ readingCell = -1;
+ return;
+ }
+
+ var now = Environment.TickCount64;
+ if (cell != readingCell || !IsPlaying || now - readingAt >= ReadingIntervalMs)
+ {
+ var values = heatMode == HeatView.Peak ? heat.Peaks : heat.Temperatures;
+ readingText = heatMode == HeatView.Peak ? $"Peak +{values[cell]:0} °C" : $"+{values[cell]:0} °C";
+ readingCell = cell;
+ readingAt = now;
+ }
+
+ var state = graphics.Save();
+ try
+ {
+ graphics.ResetTransform();
+ graphics.SmoothingMode = SmoothingMode.HighSpeed;
+ var size = graphics.MeasureString(readingText, font);
+ var width = size.Width + 6;
+ var height = size.Height + 4;
+ var client = view.ClientSize;
+ var x = System.Math.Clamp(cursor.X - width / 2, 0, System.Math.Max(0, client.Width - width - 1));
+ var y = cursor.Y + 22f * view.DeviceDpi / 96f;
+ if (y + height > client.Height)
+ y = cursor.Y - height - 6;
+
+ var rect = new RectangleF(x, y, width, height);
+ using (var background = new SolidBrush(Color.FromArgb(230, Color.White)))
+ graphics.FillRectangle(background, rect);
+ graphics.DrawRectangle(Pens.DimGray, rect.X, rect.Y, rect.Width, rect.Height);
+ graphics.DrawString(readingText, font, Brushes.Black, x + 3, y + 2);
+ }
+ finally
+ {
+ graphics.Restore(state);
+ }
+ }
+
private static readonly (float At, Color Color)[] HeatStops =
{
(0f, Color.FromArgb(40, 60, 200)),
diff --git a/OpenNest/Controls/PlateView.cs b/OpenNest/Controls/PlateView.cs
index 49ee14c2..28033228 100644
--- a/OpenNest/Controls/PlateView.cs
+++ b/OpenNest/Controls/PlateView.cs
@@ -448,6 +448,11 @@ namespace OpenNest.Controls
protected override void OnMouseLeave(EventArgs e)
{
ClearHover();
+ if (heatCursor != null)
+ {
+ heatCursor = null;
+ Invalidate();
+ }
base.OnMouseLeave(e);
}
@@ -632,10 +637,24 @@ namespace OpenNest.Controls
Invalidate();
}
+ // Where the cut simulator's heat reading follows the mouse, in control pixels.
+ private Point? heatCursor;
+
protected override void OnMouseMove(MouseEventArgs e)
{
if (e.Button != MouseButtons.None)
ClearHover();
+ if (cutSimulation.ShowsHeat)
+ {
+ heatCursor = e.Location;
+ // Playback repaints on its own timer.
+ if (!cutSimulation.IsPlaying)
+ Invalidate();
+ }
+ else
+ {
+ heatCursor = null;
+ }
if (e.Button == MouseButtons.Middle)
{
if (AllowPan)
@@ -885,6 +904,9 @@ namespace OpenNest.Controls
base.OnPaint(e);
+ if (heatCursor != null && !HasProposalDisplay)
+ cutSimulation.DrawHeatReading(e.Graphics, heatCursor.Value, Font);
+
if (!InspectionOnly && !overlapOverlay.DrawHover(e.Graphics) && hoveredPart != null && showTooltip)
{
e.Graphics.ResetTransform();