- OFFSET 새 파일(offset-tool.ts) — 거리 <통과점> · 통과점(T) · 지우기(E) 예/아니오 · 객체 → 면의 점 되풀이 · 다중(M) <다음 객체> · 명령 취소(U) · 기억 OFFSETDIST · OFFSETERASE - FILLET · CHAMFER 한 꼴 — 객체 먼저 · 반지름(R) · 거리(D) 둘(둘째 기본 = 첫째) · 자르기(T) 모드 · 다중(M) · 명령 취소(U) · Shift = 구석 · 기억 FILLETRAD · CHAMFERA/B · TRIMMODE - TRIM · EXTEND 빠른 모드 한 꼴 — 되풀이 · Shift = 반대 일 · 집기 반경 밖 무시 · 지우기(R) · 숨은 U · 사각형 변 원래 층 · 꼴(N9) · 자른 선 꼴 유지 - BREAK — 누른 점 = 첫 끊기점 · 첫 번째 점(F) · @0,0 = 같은 점 · JOIN 물음 글 - 시험 resources/tester/cad/modify-acad.test.ts 13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013QyNXY2TUKXCFMwAca2APG
74 lines
2.2 KiB
TypeScript
74 lines
2.2 KiB
TypeScript
/** 연장·결합·분해·지우기 (조사표 2절) */
|
|
import { toast } from 'react-toastify';
|
|
import { SELECT_OBJECTS } from '../../commands/prompt';
|
|
import type { Entity } from '../../entities/Entity';
|
|
import { addEntities, deleteEntities, setSelectedEntityIds } from '../../state';
|
|
import { Tool } from '../../tools';
|
|
import { createSequenceTool } from '../factories/sequence-tool';
|
|
import { explodeEntity, joinEntities } from './modify.helpers';
|
|
|
|
/** EXTEND 빠른 모드는 TRIM 과 한 머신 꼴(eraser-tool.ts) */
|
|
export { extendToolStateMachine } from '../eraser-tool';
|
|
|
|
export const joinToolStateMachine = createSequenceTool({
|
|
tool: Tool.JOIN,
|
|
helpers: false,
|
|
steps: [
|
|
{
|
|
kind: 'selection',
|
|
prompt: {
|
|
text: '한 번에 결합할 원본 객체 또는 여러 객체 선택',
|
|
options: SELECT_OBJECTS.options,
|
|
},
|
|
},
|
|
],
|
|
commit: (input) => {
|
|
const entities = input.entities(0);
|
|
const joined = joinEntities(entities);
|
|
if (!joined) {
|
|
toast.warn('끝점이 맞닿는 객체가 없어 결합하지 못했습니다.');
|
|
return;
|
|
}
|
|
deleteEntities(entities, false);
|
|
addEntities([joined], true);
|
|
setSelectedEntityIds([]);
|
|
},
|
|
});
|
|
|
|
export const explodeToolStateMachine = createSequenceTool({
|
|
tool: Tool.EXPLODE,
|
|
helpers: false,
|
|
steps: [{ kind: 'selection', instructions: '분해할 객체를 선택한 뒤 ENTER.' }],
|
|
commit: (input) => {
|
|
const entities = input.entities(0);
|
|
const exploded: Entity[] = [];
|
|
const consumed: Entity[] = [];
|
|
for (const entity of entities) {
|
|
const parts = explodeEntity(entity);
|
|
if (parts.length) {
|
|
exploded.push(...parts);
|
|
consumed.push(entity);
|
|
}
|
|
}
|
|
if (!consumed.length) {
|
|
toast.info('분해할 수 있는 복합 객체가 없습니다.');
|
|
return;
|
|
}
|
|
deleteEntities(consumed, false);
|
|
addEntities(exploded, true);
|
|
setSelectedEntityIds([]);
|
|
},
|
|
});
|
|
|
|
export const eraseToolStateMachine = createSequenceTool({
|
|
tool: Tool.ERASE,
|
|
helpers: false,
|
|
steps: [{ kind: 'selection', instructions: '지울 객체를 선택한 뒤 ENTER.' }],
|
|
commit: (input) => {
|
|
const entities = input.entities(0);
|
|
if (!entities.length) return;
|
|
deleteEntities(entities, true);
|
|
setSelectedEntityIds([]);
|
|
},
|
|
});
|