This commit is contained in:
backuppc
2025-10-27 12:00:59 +09:00
parent 1d65531b11
commit dbf81bfc60
28 changed files with 301 additions and 5716 deletions

View File

@@ -207,6 +207,9 @@ namespace AGVNavigationCore.Controls
{
DrawPath(g, _currentPath, Color.Purple);
// 경로 내 교차로 강조 표시
HighlightJunctionsInPath(g, _currentPath);
// AGVPathResult의 모터방향 정보가 있다면 향상된 경로 그리기
// 현재는 기본 PathResult를 사용하므로 향후 AGVPathResult로 업그레이드 시 활성화
// TODO: AGVPathfinder 사용시 AGVPathResult로 업그레이드
@@ -282,7 +285,96 @@ namespace AGVNavigationCore.Controls
pathPen.Dispose();
}
/// <summary>
/// 경로에 포함된 교차로(3개 이상의 노드가 연결된 노드)를 파란색으로 강조 표시
/// </summary>
private void HighlightJunctionsInPath(Graphics g, AGVPathResult path)
{
if (path?.Path == null || _nodes == null || _nodes.Count == 0)
return;
const int JUNCTION_CONNECTIONS = 3; // 교차로 판정 기준: 3개 이상의 연결
foreach (var nodeId in path.Path)
{
var node = _nodes.FirstOrDefault(n => n.NodeId == nodeId);
if (node == null) continue;
// 교차로 판정: 3개 이상의 노드가 연결된 경우
if (node.ConnectedNodes != null && node.ConnectedNodes.Count >= JUNCTION_CONNECTIONS)
{
DrawJunctionHighlight(g, node);
}
}
}
/// <summary>
/// 교차로 노드를 파란색 반투명 배경으로 강조 표시
/// </summary>
private void DrawJunctionHighlight(Graphics g, MapNode junctionNode)
{
if (junctionNode == null) return;
const int JUNCTION_HIGHLIGHT_RADIUS = 25; // 강조 표시 반경
// 파란색 반투명 브러시로 배경 원 그리기
using (var highlightBrush = new SolidBrush(Color.FromArgb(80, 70, 130, 200))) // 파란색 (70, 130, 200) 알파 80
using (var highlightPen = new Pen(Color.FromArgb(150, 100, 150, 220), 2)) // 파란 테두리
{
g.FillEllipse(
highlightBrush,
junctionNode.Position.X - JUNCTION_HIGHLIGHT_RADIUS,
junctionNode.Position.Y - JUNCTION_HIGHLIGHT_RADIUS,
JUNCTION_HIGHLIGHT_RADIUS * 2,
JUNCTION_HIGHLIGHT_RADIUS * 2
);
g.DrawEllipse(
highlightPen,
junctionNode.Position.X - JUNCTION_HIGHLIGHT_RADIUS,
junctionNode.Position.Y - JUNCTION_HIGHLIGHT_RADIUS,
JUNCTION_HIGHLIGHT_RADIUS * 2,
JUNCTION_HIGHLIGHT_RADIUS * 2
);
}
// 교차로 라벨 추가
DrawJunctionLabel(g, junctionNode);
}
/// <summary>
/// 교차로 라벨을 표시 (선택사항)
/// </summary>
private void DrawJunctionLabel(Graphics g, MapNode junctionNode)
{
if (junctionNode == null) return;
using (var font = new Font("Arial", 9, FontStyle.Bold))
using (var brush = new SolidBrush(Color.Blue))
{
var text = "교차로";
var textSize = g.MeasureString(text, font);
// 노드 위쪽에 라벨 표시
var labelX = junctionNode.Position.X - textSize.Width / 2;
var labelY = junctionNode.Position.Y - 35;
// 배경 박스 그리기
using (var bgBrush = new SolidBrush(Color.FromArgb(220, 255, 255, 200)))
{
g.FillRectangle(
bgBrush,
labelX - 3,
labelY - 3,
textSize.Width + 6,
textSize.Height + 6
);
}
g.DrawString(text, font, brush, labelX, labelY);
}
}
private void DrawNodesOnly(Graphics g)