using System; using System.Collections.Generic; using System.Drawing; namespace AGVMapEditor.Models { /// /// 맵 노드 정보를 관리하는 클래스 /// 논리적 노드로서 실제 맵의 위치와 속성을 정의 /// public class MapNode { /// /// 논리적 노드 ID (맵 에디터에서 관리하는 고유 ID) /// 예: "N001", "N002", "LOADER1", "CHARGER1" /// public string NodeId { get; set; } = string.Empty; /// /// 노드 표시 이름 (사용자 친화적) /// 예: "로더1", "충전기1", "교차점A", "회전지점1" /// public string Name { get; set; } = string.Empty; /// /// 맵 상의 위치 좌표 (픽셀 단위) /// public Point Position { get; set; } = Point.Empty; /// /// 노드 타입 /// public NodeType Type { get; set; } = NodeType.Normal; /// /// 도킹 방향 (도킹/충전 노드인 경우만 사용) /// public DockingDirection? DockDirection { get; set; } = null; /// /// 연결된 노드 ID 목록 (경로 정보) /// public List ConnectedNodes { get; set; } = new List(); /// /// 회전 가능 여부 (180도 회전 가능한 지점) /// public bool CanRotate { get; set; } = false; /// /// 장비 ID (도킹/충전 스테이션인 경우) /// 예: "LOADER1", "CLEANER1", "BUFFER1", "CHARGER1" /// public string StationId { get; set; } = string.Empty; /// /// 장비 타입 (도킹/충전 스테이션인 경우) /// public StationType? StationType { get; set; } = null; /// /// 노드 생성 일자 /// public DateTime CreatedDate { get; set; } = DateTime.Now; /// /// 노드 수정 일자 /// public DateTime ModifiedDate { get; set; } = DateTime.Now; /// /// 노드 설명 (추가 정보) /// public string Description { get; set; } = string.Empty; /// /// 노드 활성화 여부 /// public bool IsActive { get; set; } = true; /// /// 노드 색상 (맵 에디터 표시용) /// public Color DisplayColor { get; set; } = Color.Blue; /// /// 기본 생성자 /// public MapNode() { } /// /// 매개변수 생성자 /// /// 노드 ID /// 노드 이름 /// 위치 /// 노드 타입 public MapNode(string nodeId, string name, Point position, NodeType type) { NodeId = nodeId; Name = name; Position = position; Type = type; CreatedDate = DateTime.Now; ModifiedDate = DateTime.Now; // 타입별 기본 색상 설정 SetDefaultColorByType(type); } /// /// 노드 타입에 따른 기본 색상 설정 /// /// 노드 타입 public void SetDefaultColorByType(NodeType type) { switch (type) { case NodeType.Normal: DisplayColor = Color.Blue; break; case NodeType.Rotation: DisplayColor = Color.Orange; break; case NodeType.Docking: DisplayColor = Color.Green; break; case NodeType.Charging: DisplayColor = Color.Red; break; } } /// /// 다른 노드와의 연결 추가 /// /// 연결할 노드 ID public void AddConnection(string nodeId) { if (!ConnectedNodes.Contains(nodeId)) { ConnectedNodes.Add(nodeId); ModifiedDate = DateTime.Now; } } /// /// 다른 노드와의 연결 제거 /// /// 연결 해제할 노드 ID public void RemoveConnection(string nodeId) { if (ConnectedNodes.Remove(nodeId)) { ModifiedDate = DateTime.Now; } } /// /// 도킹 스테이션 설정 /// /// 장비 ID /// 장비 타입 /// 도킹 방향 public void SetDockingStation(string stationId, StationType stationType, DockingDirection dockDirection) { Type = NodeType.Docking; StationId = stationId; StationType = stationType; DockDirection = dockDirection; SetDefaultColorByType(NodeType.Docking); ModifiedDate = DateTime.Now; } /// /// 충전 스테이션 설정 /// /// 충전기 ID public void SetChargingStation(string stationId) { Type = NodeType.Charging; StationId = stationId; StationType = Models.StationType.Charger; DockDirection = DockingDirection.Forward; // 충전기는 항상 전진 도킹 SetDefaultColorByType(NodeType.Charging); ModifiedDate = DateTime.Now; } /// /// 문자열 표현 /// public override string ToString() { return $"{NodeId}: {Name} ({Type}) at ({Position.X}, {Position.Y})"; } /// /// 노드 복사 /// /// 복사된 노드 public MapNode Clone() { var clone = new MapNode { NodeId = NodeId, Name = Name, Position = Position, Type = Type, DockDirection = DockDirection, ConnectedNodes = new List(ConnectedNodes), CanRotate = CanRotate, StationId = StationId, StationType = StationType, CreatedDate = CreatedDate, ModifiedDate = ModifiedDate, Description = Description, IsActive = IsActive, DisplayColor = DisplayColor }; return clone; } } }