fix: assign part colors to drawings created by BOM importer and MCP
Drawings created by BomImportForm and MCP InputTools were missing color assignments, causing them to render with default empty color instead of the standard part color palette. Moved PartColors and GetNextColor() to Drawing in Core so all consumers share one definition. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+1
-15
@@ -13,21 +13,7 @@ namespace OpenNest
|
||||
private Color edgeSpacingColor;
|
||||
private Color previewPartColor;
|
||||
|
||||
public static readonly Color[] PartColors = new Color[]
|
||||
{
|
||||
Color.FromArgb(205, 92, 92), // Indian Red
|
||||
Color.FromArgb(148, 103, 189), // Medium Purple
|
||||
Color.FromArgb(75, 180, 175), // Teal
|
||||
Color.FromArgb(210, 190, 75), // Goldenrod
|
||||
Color.FromArgb(190, 85, 175), // Orchid
|
||||
Color.FromArgb(185, 115, 85), // Sienna
|
||||
Color.FromArgb(120, 100, 190), // Slate Blue
|
||||
Color.FromArgb(200, 100, 140), // Rose
|
||||
Color.FromArgb(80, 175, 155), // Sea Green
|
||||
Color.FromArgb(195, 160, 85), // Dark Khaki
|
||||
Color.FromArgb(175, 95, 160), // Plum
|
||||
Color.FromArgb(215, 130, 130), // Light Coral
|
||||
};
|
||||
public static Color[] PartColors => Drawing.PartColors;
|
||||
|
||||
public static readonly ColorScheme Default = new ColorScheme
|
||||
{
|
||||
|
||||
@@ -420,6 +420,7 @@ namespace OpenNest.Forms
|
||||
|
||||
var drawingName = Path.GetFileNameWithoutExtension(part.DxfPath);
|
||||
var drawing = new Drawing(drawingName);
|
||||
drawing.Color = Drawing.GetNextColor();
|
||||
drawing.Source.Path = part.DxfPath;
|
||||
drawing.Quantity.Required = part.Qty ?? 1;
|
||||
drawing.Material = new Material(material);
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenNest.Forms
|
||||
{
|
||||
public partial class CadConverterForm : Form
|
||||
{
|
||||
private static int colorIndex;
|
||||
|
||||
private SimplifierViewerForm simplifierViewer;
|
||||
private bool staleProgram = true;
|
||||
|
||||
@@ -622,7 +622,7 @@ namespace OpenNest.Forms
|
||||
continue;
|
||||
|
||||
var drawing = new Drawing(item.Name);
|
||||
drawing.Color = GetNextColor();
|
||||
drawing.Color = Drawing.GetNextColor();
|
||||
drawing.Customer = item.Customer;
|
||||
drawing.Source.Path = item.Path;
|
||||
drawing.Quantity.Required = item.Quantity;
|
||||
@@ -671,12 +671,7 @@ namespace OpenNest.Forms
|
||||
}
|
||||
|
||||
|
||||
private static Color GetNextColor()
|
||||
{
|
||||
var color = ColorScheme.PartColors[colorIndex % ColorScheme.PartColors.Length];
|
||||
colorIndex++;
|
||||
return color;
|
||||
}
|
||||
private static Color GetNextColor() => Drawing.GetNextColor();
|
||||
|
||||
private static bool IsDirectoryWritable(string path)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user