mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-05 23:29:26 -05:00
fix(simulator): fill parts one gray under the heat map
The heat layer is translucent where it is cool, so each part's drawing color showed through and shifted the scale's hues: a green part under cool cyan read as the warm middle of the scale, and purple parts blended into the cool blue. The same temperature looked different on different parts. While the heat layer shows, cut and cutting parts are filled with one neutral gray set apart from the sheet color, so the hues mean only temperature and holes and dropped slugs still stand out. Outlines, numbers, pending parts and selection keep their usual look, and the drawing colors return when heat is off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c130985c92
commit
d45e5ff202
5 files changed
+77
-7
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System.Drawing;
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.Thermal;
|
||||
using OpenNest.Controls;
|
||||
using OpenNest.Geometry;
|
||||
using static OpenNest.WinForms.Tests.FormTesting;
|
||||
@@ -161,6 +162,53 @@ public class CutSimulationOverlayTests
|
||||
Assert.Single(view.SelectedParts);
|
||||
});
|
||||
|
||||
[Fact]
|
||||
public void PartsShareOneGrayUnderTheHeatLayer() => RunSta(() =>
|
||||
{
|
||||
var plate = TwoSquares();
|
||||
plate.Parts[0].BaseDrawing.Color = Color.FromArgb(60, 200, 60);
|
||||
using var view = new PlateView { Plate = plate, Size = new System.Drawing.Size(400, 400) };
|
||||
view.ZoomToFit();
|
||||
var sim = CutSimulation.Build(plate, Parameters);
|
||||
view.CutSimulation.Load(sim);
|
||||
view.CutSimulation.Time = sim.TotalTime; // both parts cut, so neither is muted
|
||||
var heat = new PlateHeatSimulation(plate, sim, new ThermalParameters
|
||||
{
|
||||
Thickness = 0.25,
|
||||
Units = Units.Inches,
|
||||
});
|
||||
// A scale no cell comes near keeps the layer clear, leaving the part fill to read.
|
||||
view.CutSimulation.LoadHeat(heat, 1e9f);
|
||||
var center = view.PointWorldToControl(new Vector(7, 7)); // clear of the number label
|
||||
|
||||
view.CutSimulation.HeatMode = HeatView.Now;
|
||||
var gray = CutSimulationOverlay.HeatPartFill(view.ColorScheme.LayoutFillColor);
|
||||
Assert.Equal(gray.ToArgb(), PaintedPixel(view, center).ToArgb());
|
||||
|
||||
view.CutSimulation.HeatMode = HeatView.Off;
|
||||
Assert.Equal(Color.FromArgb(60, 200, 60).ToArgb(), PaintedPixel(view, center).ToArgb());
|
||||
});
|
||||
|
||||
[Theory]
|
||||
[InlineData(242, 242, 242)]
|
||||
[InlineData(52, 48, 58)]
|
||||
public void HeatPartFillIsANeutralGrayApartFromTheSheet(int r, int g, int b)
|
||||
{
|
||||
var sheet = Color.FromArgb(r, g, b);
|
||||
var fill = CutSimulationOverlay.HeatPartFill(sheet);
|
||||
|
||||
Assert.True(fill.R == fill.G && fill.G == fill.B);
|
||||
Assert.True(System.Math.Abs(fill.R - sheet.G) >= 50);
|
||||
}
|
||||
|
||||
private static Color PaintedPixel(PlateView view, System.Drawing.Point at)
|
||||
{
|
||||
using var bitmap = new Bitmap(view.Width, view.Height);
|
||||
using (var graphics = Graphics.FromImage(bitmap))
|
||||
Raise(view, "OnPaint", new System.Windows.Forms.PaintEventArgs(graphics, view.ClientRectangle));
|
||||
return bitmap.GetPixel(at.X, at.Y);
|
||||
}
|
||||
|
||||
private static Color Pixel(PlateView view, Bitmap bitmap, Vector world)
|
||||
{
|
||||
var point = view.PointWorldToGraph(world);
|
||||
|
||||
Reference in new issue
Block a user