feat(CAD): 331-1 각도 고정 <각도 → 길이 · 시퀀스 첫 점 숫자 무시
- 새 input-angle-lock — 다음 한 점만 고정 방향(동쪽 0° 반시계) · 커서 · 클릭은 고정 직선 위로 · 숫자는 그 방향 길이 · 한 점 · Esc · 새 명령이면 풂 · 커서 옆 안내 「각도 30° 고정 — 길이 입력」 - input-patterns — 숫자 음수 · .5 허용 · 각도 고정 꼴 · 점 글 해석 한 곳(parsePointText) - Enter 해석 차례 — 자유 글 단계만 원문 먼저 → 각도 고정 → 점 · 거리 → 단계 선택지 → 명령 이름 - 선 · 시퀀스 미리보기도 고정 방향 · 시퀀스 첫 점의 거리 · 상대 좌표는 무시(도구 멈춤 · 「Error in tool actor」 없앰) - 시험 resources/tester/cad/keyboard-chain.test.ts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013QyNXY2TUKXCFMwAca2APG
This commit is contained in:
@@ -44,14 +44,7 @@ import {
|
||||
} from '../state.ts';
|
||||
import { Tool } from '../tools.ts';
|
||||
import { SelectState, selectToolStateMachine } from '../tools/select-tool.ts';
|
||||
import {
|
||||
type AbsolutePointInputEvent,
|
||||
ActorEvent,
|
||||
type MouseClickEvent,
|
||||
type NumberInputEvent,
|
||||
type RelativePointInputEvent,
|
||||
type TextInputEvent,
|
||||
} from '../tools/tool.types.ts';
|
||||
import { ActorEvent, type MouseClickEvent, type TextInputEvent } from '../tools/tool.types.ts';
|
||||
import {
|
||||
activeToolAcceptsText,
|
||||
activeToolWantsFreeText,
|
||||
@@ -63,14 +56,8 @@ import { drawInputField } from './input-field-draw.ts';
|
||||
import { ctrlShortcut } from './input-shortcut.ts';
|
||||
import { wheelZoom } from './input-wheel.ts';
|
||||
import { attachTouch } from './input-touch.ts';
|
||||
import {
|
||||
ABSOLUTE_POINT_REGEXP,
|
||||
ABSOLUTE_POLAR_REGEXP,
|
||||
NUMBER_REGEXP,
|
||||
polarToPoint,
|
||||
RELATIVE_POINT_REGEXP,
|
||||
RELATIVE_POLAR_REGEXP,
|
||||
} from './input-patterns.ts';
|
||||
import { ANGLE_LOCK_REGEXP, parsePointText, type PointTextEvent } from './input-patterns.ts';
|
||||
import { angleLockHint, setAngleLock } from './input-angle-lock.ts';
|
||||
|
||||
/** 이만큼 넘게 끌면 클릭이 아니라 드래그로 본다 (화면 픽셀) */
|
||||
const DRAG_SELECT_MIN_PX = 4;
|
||||
@@ -135,6 +122,8 @@ export class InputController {
|
||||
const roundedY = round(drawController.getWorldMouseLocation().y, 2);
|
||||
texts.push(`${roundedX},${roundedY}`);
|
||||
}
|
||||
const lockHint = angleLockHint();
|
||||
if (lockHint) texts.push(lockHint);
|
||||
// 입력 중인 문자로 시작하는 명령 후보. 예: C => CIRCLE (C), COPY (CO)
|
||||
texts.push(...this.getCommandSuggestions());
|
||||
// 입력 글(조합 중인 한글도 함께)
|
||||
@@ -213,7 +202,7 @@ export class InputController {
|
||||
);
|
||||
const worldMouseLocation = closestSnapPoint ? closestSnapPoint.point : worldMouseLocationTemp;
|
||||
|
||||
getActiveToolActor()?.send({
|
||||
this.sendPointEvent({
|
||||
type: ActorEvent.MOUSE_CLICK,
|
||||
worldMouseLocation,
|
||||
screenMouseLocation: screenCanvasDrawController.worldToTarget(worldMouseLocation),
|
||||
@@ -448,6 +437,7 @@ export class InputController {
|
||||
}
|
||||
|
||||
public handleEscapeKey() {
|
||||
setAngleLock(null);
|
||||
if (getSelectedEntities().length > 0) {
|
||||
// Deselect entities
|
||||
setSelectedEntityIds([]);
|
||||
@@ -495,17 +485,20 @@ export class InputController {
|
||||
if (wasSelectTool && getActiveToolActor()?.getSnapshot()?.status === 'done') {
|
||||
setActiveToolActor(new Actor(selectToolStateMachine));
|
||||
}
|
||||
} else if (activeToolCanHandleTextInput) {
|
||||
console.log('TEXT_INPUT: ', {
|
||||
text: this.text,
|
||||
activeTool: getActiveToolActor(),
|
||||
});
|
||||
// Send the text to the active tool
|
||||
getActiveToolActor()?.send({
|
||||
type: ActorEvent.TEXT_INPUT,
|
||||
value: this.text,
|
||||
} as TextInputEvent);
|
||||
} else if (activeToolWantsFreeText()) {
|
||||
// 글 단계(TEXT · MTEXT · 표 칸 …)는 친 그대로 — 숫자 · 명령 이름도 글
|
||||
this.sendText();
|
||||
} else if (ANGLE_LOCK_REGEXP.test(this.text)) {
|
||||
// 각도 고정 `<30` — 다음 한 점만 그 방향
|
||||
setAngleLock(Number.parseFloat((ANGLE_LOCK_REGEXP.exec(this.text) as RegExpExecArray)[1]));
|
||||
this.text = '';
|
||||
} else if (this.pointEventFromText()) {
|
||||
// 거리 `100` · `x,y` · `@x,y` · `@d<a` · `d<a`
|
||||
this.sendPointEvent(this.pointEventFromText() as PointTextEvent);
|
||||
this.text = '';
|
||||
} else if (activeToolCanHandleTextInput) {
|
||||
// 지금 단계의 선택지(배열 L/R · 숫자 단계 글)
|
||||
this.sendText();
|
||||
} else if (resolveCommandInput(this.text)) {
|
||||
// 명령 이름 또는 AutoCAD 별칭을 입력했다. 예: L, LINE, REC
|
||||
const command = resolveCommandInput(this.text);
|
||||
@@ -513,91 +506,37 @@ export class InputController {
|
||||
runCommand(command);
|
||||
}
|
||||
this.text = '';
|
||||
} else if (NUMBER_REGEXP.test(this.text)) {
|
||||
console.log(' NUMBER_INPUT: ', {
|
||||
text: this.text,
|
||||
activeTool: getActiveToolActor(),
|
||||
});
|
||||
// User entered a number. eg: 100
|
||||
getActiveToolActor()?.send({
|
||||
type: ActorEvent.NUMBER_INPUT,
|
||||
value: Number.parseFloat(this.text),
|
||||
worldMouseLocation:
|
||||
getSnapPointOnAngleGuide()?.point ||
|
||||
getSnapPoint()?.point ||
|
||||
getScreenCanvasDrawController().getWorldMouseLocation(),
|
||||
} as NumberInputEvent);
|
||||
this.text = '';
|
||||
} else if (ABSOLUTE_POINT_REGEXP.test(this.text)) {
|
||||
console.log('ABSOLUTE_POINT_INPUT: ', {
|
||||
text: this.text,
|
||||
activeTool: getActiveToolActor(),
|
||||
});
|
||||
// User entered coordinates to an absolute point on the canvas. eg: 100, 200
|
||||
const match = ABSOLUTE_POINT_REGEXP.exec(this.text);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
const x = Number.parseFloat(match[1]);
|
||||
const y = Number.parseFloat(match[2]);
|
||||
getActiveToolActor()?.send({
|
||||
type: ActorEvent.ABSOLUTE_POINT_INPUT,
|
||||
value: new Point(x, y),
|
||||
} as AbsolutePointInputEvent);
|
||||
this.text = '';
|
||||
} else if (RELATIVE_POINT_REGEXP.test(this.text)) {
|
||||
console.log('RELATIVE_POINT_INPUT: ', {
|
||||
text: this.text,
|
||||
activeTool: getActiveToolActor(),
|
||||
});
|
||||
// User entered coordinates to a relative point on the canvas. eg: @100, 200
|
||||
const match = RELATIVE_POINT_REGEXP.exec(this.text);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
const x = Number.parseFloat(match[1]);
|
||||
const y = Number.parseFloat(match[2]);
|
||||
getActiveToolActor()?.send({
|
||||
type: ActorEvent.RELATIVE_POINT_INPUT,
|
||||
value: new Point(x, y),
|
||||
} as RelativePointInputEvent);
|
||||
this.text = '';
|
||||
} else if (RELATIVE_POLAR_REGEXP.test(this.text)) {
|
||||
// 직전 점에서 거리·각도로 이동. 예: @100<45
|
||||
const match = RELATIVE_POLAR_REGEXP.exec(this.text);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
getActiveToolActor()?.send({
|
||||
type: ActorEvent.RELATIVE_POINT_INPUT,
|
||||
value: polarToPoint(Number.parseFloat(match[1]), Number.parseFloat(match[2])),
|
||||
} as RelativePointInputEvent);
|
||||
this.text = '';
|
||||
} else if (ABSOLUTE_POLAR_REGEXP.test(this.text)) {
|
||||
// 원점에서 거리·각도로 지정한 점. 예: 100<45
|
||||
const match = ABSOLUTE_POLAR_REGEXP.exec(this.text);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
getActiveToolActor()?.send({
|
||||
type: ActorEvent.ABSOLUTE_POINT_INPUT,
|
||||
value: polarToPoint(Number.parseFloat(match[1]), Number.parseFloat(match[2])),
|
||||
} as AbsolutePointInputEvent);
|
||||
this.text = '';
|
||||
} else {
|
||||
console.log('TEXT_INPUT: ', {
|
||||
text: this.text,
|
||||
activeTool: getActiveToolActor(),
|
||||
});
|
||||
// Send the text to the active tool
|
||||
getActiveToolActor()?.send({
|
||||
type: ActorEvent.TEXT_INPUT,
|
||||
value: this.text,
|
||||
} as TextInputEvent);
|
||||
this.text = '';
|
||||
this.sendText();
|
||||
}
|
||||
}
|
||||
|
||||
private sendText() {
|
||||
console.log('TEXT_INPUT: ', { text: this.text, activeTool: getActiveToolActor() });
|
||||
getActiveToolActor()?.send({
|
||||
type: ActorEvent.TEXT_INPUT,
|
||||
value: this.text,
|
||||
} as TextInputEvent);
|
||||
this.text = '';
|
||||
}
|
||||
|
||||
/** 친 글을 점 · 거리 사건으로 — 거리의 방향 = 스냅 · 가이드 · 커서 */
|
||||
private pointEventFromText(): PointTextEvent | null {
|
||||
return parsePointText(
|
||||
this.text,
|
||||
() =>
|
||||
getSnapPointOnAngleGuide()?.point ||
|
||||
getSnapPoint()?.point ||
|
||||
getScreenCanvasDrawController().getWorldMouseLocation()
|
||||
);
|
||||
}
|
||||
|
||||
/** 점 하나를 도구에 보냄 — 각도 고정은 이 한 점으로 끝 */
|
||||
private sendPointEvent(event: PointTextEvent | MouseClickEvent) {
|
||||
getActiveToolActor()?.send(event);
|
||||
setAngleLock(null);
|
||||
}
|
||||
|
||||
public handleUndo(evt: KeyboardEvent) {
|
||||
evt.preventDefault();
|
||||
undo();
|
||||
|
||||
Reference in New Issue
Block a user