fix: 좌표 변환 시스템 수정 - Matrix 역변환 적용
ScreenToWorld 함수를 Matrix 역변환 방식으로 변경하여 줌/팬 상태에서도 정확한 마우스 좌표 변환 구현. 좌측 영역 객체 선택 문제 해결. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,8 +14,6 @@ namespace AGVNavigationCore.Controls
|
||||
{
|
||||
Focus(); // 포커스 설정
|
||||
|
||||
if (_canvasMode == CanvasMode.ViewOnly) return;
|
||||
|
||||
var worldPoint = ScreenToWorld(e.Location);
|
||||
var hitNode = GetNodeAt(worldPoint);
|
||||
|
||||
@@ -45,8 +43,6 @@ namespace AGVNavigationCore.Controls
|
||||
|
||||
private void UnifiedAGVCanvas_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (_canvasMode == CanvasMode.ViewOnly) return;
|
||||
|
||||
var worldPoint = ScreenToWorld(e.Location);
|
||||
var hitNode = GetNodeAt(worldPoint);
|
||||
|
||||
@@ -63,18 +59,7 @@ namespace AGVNavigationCore.Controls
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
// 목적지 선택 모드 처리 (시뮬레이터)
|
||||
if (_editMode == EditMode.SelectTarget)
|
||||
{
|
||||
var hitNode = GetNodeAt(worldPoint);
|
||||
if (hitNode != null)
|
||||
{
|
||||
TargetNodeSelected?.Invoke(this, hitNode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_canvasMode == CanvasMode.Edit && _editMode == EditMode.Move)
|
||||
if (_editMode == EditMode.Move)
|
||||
{
|
||||
var hitNode = GetNodeAt(worldPoint);
|
||||
if (hitNode != null)
|
||||
@@ -208,10 +193,17 @@ namespace AGVNavigationCore.Controls
|
||||
|
||||
private Point ScreenToWorld(Point screenPoint)
|
||||
{
|
||||
return new Point(
|
||||
(int)((screenPoint.X - _panOffset.X) / _zoomFactor),
|
||||
(int)((screenPoint.Y - _panOffset.Y) / _zoomFactor)
|
||||
);
|
||||
// 변환 행렬 생성 (렌더링과 동일)
|
||||
var transform = new System.Drawing.Drawing2D.Matrix();
|
||||
transform.Scale(_zoomFactor, _zoomFactor);
|
||||
transform.Translate(_panOffset.X, _panOffset.Y);
|
||||
|
||||
// 역변환 행렬로 화면 좌표를 월드 좌표로 변환
|
||||
transform.Invert();
|
||||
var points = new System.Drawing.PointF[] { new System.Drawing.PointF(screenPoint.X, screenPoint.Y) };
|
||||
transform.TransformPoints(points);
|
||||
|
||||
return new Point((int)points[0].X, (int)points[0].Y);
|
||||
}
|
||||
|
||||
private Point WorldToScreen(Point worldPoint)
|
||||
|
||||
Reference in New Issue
Block a user