From 3ddecf63eddb76f8f80e7c1fdb05bfc618008786 Mon Sep 17 00:00:00 2001 From: backuppc Date: Thu, 23 Oct 2025 10:12:04 +0900 Subject: [PATCH] fix: Correct background grid rendering at high zoom levels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix grid line coordinate transformation (world to screen) - Properly align grid with zoom and pan transformations - Calculate grid start position at GRID_SIZE multiples - Draw grid lines across entire visible canvas area - Ensure grid lines render completely regardless of zoom level - Grid now displays consistently at all zoom magnifications Fixes: Grid no longer disappears or renders incompletely when zoomed in ๐Ÿค– Generated with Claude Code Co-Authored-By: Claude --- .../Controls/UnifiedAGVCanvas.Events.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Cs_HMI/AGVLogic/AGVNavigationCore/Controls/UnifiedAGVCanvas.Events.cs b/Cs_HMI/AGVLogic/AGVNavigationCore/Controls/UnifiedAGVCanvas.Events.cs index 87b9399..c778544 100644 --- a/Cs_HMI/AGVLogic/AGVNavigationCore/Controls/UnifiedAGVCanvas.Events.cs +++ b/Cs_HMI/AGVLogic/AGVNavigationCore/Controls/UnifiedAGVCanvas.Events.cs @@ -72,20 +72,31 @@ namespace AGVNavigationCore.Controls if (gridSize < 5) return; // ๋„ˆ๋ฌด ์ž‘์œผ๋ฉด ๊ทธ๋ฆฌ์ง€ ์•Š์Œ - for (int x = bounds.Left; x < bounds.Right; x += GRID_SIZE) + // ๊ทธ๋ฆฌ๋“œ ์‹œ์ž‘ ์œ„์น˜ (์›”๋“œ ์ขŒํ‘œ์—์„œ GRID_SIZE์˜ ๋ฐฐ์ˆ˜ ์ฐพ๊ธฐ) + int startX = (bounds.Left / GRID_SIZE) * GRID_SIZE; + int startY = (bounds.Top / GRID_SIZE) * GRID_SIZE; + + // ์›”๋“œ ์ขŒํ‘œ๋กœ ๊ทธ๋ฆฌ๋“œ ๋ผ์ธ ๊ณ„์‚ฐ + for (int x = startX; x <= bounds.Right; x += GRID_SIZE) { + // ์›”๋“œ ์ขŒํ‘œ๋ฅผ ์Šคํฌ๋ฆฐ ์ขŒํ‘œ๋กœ ๋ณ€ํ™˜ + int screenX = x * (int)_zoomFactor + _panOffset.X; + if (x % (GRID_SIZE * 5) == 0) - g.DrawLine(new Pen(Color.Gray, 1), x, bounds.Top, x, bounds.Bottom); + g.DrawLine(new Pen(Color.Gray, 1), screenX, 0, screenX, Height); else - g.DrawLine(_gridPen, x, bounds.Top, x, bounds.Bottom); + g.DrawLine(_gridPen, screenX, 0, screenX, Height); } - for (int y = bounds.Top; y < bounds.Bottom; y += GRID_SIZE) + for (int y = startY; y <= bounds.Bottom; y += GRID_SIZE) { + // ์›”๋“œ ์ขŒํ‘œ๋ฅผ ์Šคํฌ๋ฆฐ ์ขŒํ‘œ๋กœ ๋ณ€ํ™˜ + int screenY = y * (int)_zoomFactor + _panOffset.Y; + if (y % (GRID_SIZE * 5) == 0) - g.DrawLine(new Pen(Color.Gray, 1), bounds.Left, y, bounds.Right, y); + g.DrawLine(new Pen(Color.Gray, 1), 0, screenY, Width, screenY); else - g.DrawLine(_gridPen, bounds.Left, y, bounds.Right, y); + g.DrawLine(_gridPen, 0, screenY, Width, screenY); } }