diff --git a/B07_DesignDetail/openwebcad/src/inputController/ime-sink.ts b/B07_DesignDetail/openwebcad/src/inputController/ime-sink.ts index 327220356..ae60c87a3 100644 --- a/B07_DesignDetail/openwebcad/src/inputController/ime-sink.ts +++ b/B07_DesignDetail/openwebcad/src/inputController/ime-sink.ts @@ -9,12 +9,33 @@ import { getActiveToolActor } from '../state.ts'; export const isImeKey = (evt: KeyboardEvent): boolean => evt.isComposing || evt.keyCode === 229 || evt.key === 'Process'; +/** 활성 도구의 지금 단계 설정(평평한 단계만) */ +const activeStateConfig = () => { + const snapshot = getActiveToolActor()?.getSnapshot(); + return snapshot?.machine?.states?.[snapshot?.value]?.config; +}; + /** 활성 도구의 지금 단계가 TEXT_INPUT 을 받는가 */ export function activeToolAcceptsText(): boolean { - const snapshot = getActiveToolActor()?.getSnapshot(); - return !!snapshot?.machine?.states?.[snapshot?.value]?.config?.on?.TEXT_INPUT; + return !!activeStateConfig()?.on?.TEXT_INPUT; } +/** 지금 단계가 점(`x,y`)을 받는가 — 한 번 스냅 이름 · 선택지 판정 */ +export function activeToolWantsPoint(): boolean { + return !!activeStateConfig()?.on?.ABSOLUTE_POINT_INPUT; +} + +/** 지금 단계가 이 글을 받는가 — 점 단계는 선택지 글자(meta.options · 선 C · U)만 · 나머지는 명령 이름으로 */ +export function activeToolTakesText(text: string): boolean { + if (!activeToolAcceptsText()) return false; + if (!activeToolWantsPoint()) return true; + const options = (activeStateConfig()?.meta as { options?: string[] } | undefined)?.options; + return !!options?.includes(text); +} + +/** 한글 받개에 초점을 줄 단계 — 글은 받되 점 단계 선택지(영문 C · U)는 아님 */ +export const activeToolWantsIme = (): boolean => activeToolAcceptsText() && !activeToolWantsPoint(); + /** 지금 단계가 자유 글(TEXT · MTEXT · 표 칸 · 이름 …)을 받는가 — Space 가 띄어쓰기(아니면 Enter) */ export function activeToolWantsFreeText(): boolean { const meta = getActiveToolActor()?.getSnapshot()?.getMeta?.() as diff --git a/B07_DesignDetail/openwebcad/src/inputController/input-controller.ts b/B07_DesignDetail/openwebcad/src/inputController/input-controller.ts index 768d6fec9..5c257cfc6 100644 --- a/B07_DesignDetail/openwebcad/src/inputController/input-controller.ts +++ b/B07_DesignDetail/openwebcad/src/inputController/input-controller.ts @@ -17,6 +17,7 @@ import { getClosestSnapPointWithinRadius } from '../helpers/get-closest-snap-poi import { pickRadius } from '../helpers/pick-radius.ts'; import { getActiveToolActor, + getAngleGuideOriginPoint, getAngleStep, getCanvas, getPickableEntities, @@ -46,8 +47,10 @@ import { Tool } from '../tools.ts'; import { SelectState, selectToolStateMachine } from '../tools/select-tool.ts'; import { ActorEvent, type MouseClickEvent, type TextInputEvent } from '../tools/tool.types.ts'; import { - activeToolAcceptsText, + activeToolTakesText, activeToolWantsFreeText, + activeToolWantsIme, + activeToolWantsPoint, ImeSink, isImeKey, isPlainSpace, @@ -58,6 +61,13 @@ import { wheelZoom } from './input-wheel.ts'; import { attachTouch } from './input-touch.ts'; import { ANGLE_LOCK_REGEXP, parsePointText, type PointTextEvent } from './input-patterns.ts'; import { angleLockHint, setAngleLock } from './input-angle-lock.ts'; +import { + getSnapOverride, + isSnapName, + setSnapOverride, + snapOverrideHint, + snapOverridePoint, +} from './input-snap-override.ts'; /** 이만큼 넘게 끌면 클릭이 아니라 드래그로 본다 (화면 픽셀) */ const DRAG_SELECT_MIN_PX = 4; @@ -112,7 +122,7 @@ export class InputController { } public draw(drawController: ScreenCanvasDrawController) { - this.ime.sync(activeToolAcceptsText()); + this.ime.sync(activeToolWantsIme()); const toolInstruction = getLastStateInstructions(); const texts: string[] = []; if (toolInstruction) { @@ -122,8 +132,7 @@ export class InputController { const roundedY = round(drawController.getWorldMouseLocation().y, 2); texts.push(`${roundedX},${roundedY}`); } - const lockHint = angleLockHint(); - if (lockHint) texts.push(lockHint); + texts.push(...compact([angleLockHint(), snapOverrideHint()])); // 입력 중인 문자로 시작하는 명령 후보. 예: C => CIRCLE (C), COPY (CO) texts.push(...this.getCommandSuggestions()); // 입력 글(조합 중인 한글도 함께) @@ -173,7 +182,7 @@ export class InputController { return; } this.sendMouseClick(evt); - this.ime.sync(activeToolAcceptsText()); // 클릭으로 문자 단계에 들면 바로 한글 받개로 + this.ime.sync(activeToolWantsIme()); // 클릭으로 문자 단계에 들면 바로 한글 받개로 } } @@ -200,7 +209,12 @@ export class InputController { const worldMouseLocationTemp = screenCanvasDrawController.targetToWorld( this.getCanvasPoint(evt) ); - const worldMouseLocation = closestSnapPoint ? closestSnapPoint.point : worldMouseLocationTemp; + let worldMouseLocation = closestSnapPoint ? closestSnapPoint.point : worldMouseLocationTemp; + if (getSnapOverride()) { + const snapped = snapOverridePoint(worldMouseLocationTemp, getAngleGuideOriginPoint()); + if (!snapped) return; // 맞는 점 없음 — 다시 누르기를 기다림 + worldMouseLocation = snapped; + } this.sendPointEvent({ type: ActorEvent.MOUSE_CLICK, @@ -408,12 +422,12 @@ export class InputController { } else if (evt.key === 'Enter') { // User wants to submit the input or submit the action this.handleEnterKey(true); - this.ime.sync(activeToolAcceptsText()); + this.ime.sync(activeToolWantsIme()); } else if (evt.key === ' ' && !activeToolWantsFreeText()) { // Space = Enter(오토캐드) · 글 단계는 아래 띄어쓰기 · 수정키 · 길게 눌러 반복은 무시 if (isPlainSpace(evt)) { this.handleEnterKey(true); - this.ime.sync(activeToolAcceptsText()); + this.ime.sync(activeToolWantsIme()); } } else if (evt.key === 'ArrowDown') { // Move the screen down @@ -438,6 +452,7 @@ export class InputController { public handleEscapeKey() { setAngleLock(null); + setSnapOverride(null); if (getSelectedEntities().length > 0) { // Deselect entities setSelectedEntityIds([]); @@ -463,7 +478,6 @@ export class InputController { /** @param repeatIfIdle 키보드 Enter · Space — 빈 입력 + 선택 도구 대기면 마지막 명령 반복(우클릭은 확정만) */ public handleEnterKey(repeatIfIdle = false) { // submit the text as input to the active tool and clear the input field - const activeToolCanHandleTextInput = activeToolAcceptsText(); if (this.text === '') { console.log('ENTER: ', { @@ -496,8 +510,12 @@ export class InputController { // 거리 `100` · `x,y` · `@x,y` · `@d> = { + END: SnapPointType.LineEndPoint, + MID: SnapPointType.LineMidPoint, + CEN: SnapPointType.CircleCenter, +}; + +let override: SnapName | null = null; + +export const getSnapOverride = (): SnapName | null => override; +export const setSnapOverride = (name: SnapName | null) => { + override = name; +}; +export const isSnapName = (text: string): text is SnapName => text in SNAP_LABELS; + +/** 커서 옆 안내 줄 */ +export const snapOverrideHint = (): string | null => + override ? `${SNAP_LABELS[override]}(${override}) 한 번 — 점 지정` : null; + +const closest = (points: Point[], mouse: Point, radius: number): Point | null => { + let best: Point | null = null; + let bestDistance = radius; + for (const point of points) { + const distance = Math.hypot(point.x - mouse.x, point.y - mouse.y); + if (distance <= bestDistance) { + best = point; + bestDistance = distance; + } + } + return best; +}; + +/** 한 번 스냅이 고른 점 · 맞는 점 없으면 null. base = 앞 점(PER 기준) */ +export function snapOverridePoint(mouse: Point, base: Point | null): Point | null { + if (override === 'NON') return mouse; + // ponytail: 일반 스냅(15px)의 두 배 둘레 — 오토캐드 조준 상자 크기 설정이 필요하면 설정 모달로 + const radius = (SNAP_POINT_DISTANCE * 2) / getScreenCanvasDrawController().getScreenScale(); + const entities = queryEntitiesNearPoint(mouse.x, mouse.y, radius).filter( + (entity) => !getLayerById(entity.layerId)?.isLocked + ); + const type = override ? SNAP_TYPES[override] : undefined; + if (type) { + const points = entities.flatMap((entity) => + entity + .getSnapPoints() + .filter((snap) => snap.type === type) + .map((snap) => snap.point) + ); + return closest(points, mouse, radius); + } + if (override === 'INT') return closest(getIntersectionPoints(entities), mouse, radius); + const near = findClosestEntity(mouse, entities); + if (!near.entity || near.distance > radius) return null; + if (override === 'NEA') return near.segment.start; + // PER — 앞 점에서 커서 아래 객체로 내린 발(선분이면 수선의 발) + if (!base) return null; + return near.entity.distanceTo(base)?.[1].start ?? null; +} diff --git a/B07_DesignDetail/openwebcad/src/tools/align-tool.helpers.ts b/B07_DesignDetail/openwebcad/src/tools/align-tool.helpers.ts index 0f1c2c495..fac184b20 100644 --- a/B07_DesignDetail/openwebcad/src/tools/align-tool.helpers.ts +++ b/B07_DesignDetail/openwebcad/src/tools/align-tool.helpers.ts @@ -57,7 +57,7 @@ export function GET_ALIGN_TOOL_STATE(type: Tool): MachineContext { [AlignState.WAITING_FOR_SELECTION]: { description: 'Select what you want to align', meta: { - instructions: 'Select what you want to align, then ENTER', + instructions: '정렬할 객체 선택 뒤 Enter', }, invoke: { id: 'selectToolInsideTheAlignTool', diff --git a/B07_DesignDetail/openwebcad/src/tools/array-tool.ts b/B07_DesignDetail/openwebcad/src/tools/array-tool.ts index 2fd83edff..be817e7d2 100644 --- a/B07_DesignDetail/openwebcad/src/tools/array-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/array-tool.ts @@ -91,7 +91,7 @@ export const arrayToolStateMachine = createMachine( [ArrayState.WAITING_FOR_SELECTION]: { description: 'Select what you want to copy', meta: { - instructions: 'Select what you want to copy, then ENTER', + instructions: '배열할 객체 선택 뒤 Enter', }, invoke: { id: 'selectToolInsideTheCopyTool', @@ -145,7 +145,7 @@ export const arrayToolStateMachine = createMachine( ], }, [ArrayState.ASK_COPY_MODE]: { - meta: { instructions: 'Choose copy mode: Linear (L) or Radial (R), ENTER for Linear' }, + meta: { instructions: '배열 방식 [직선(L)/원형(R)] <직선>:' }, on: { TEXT_INPUT: { actions: assign(({ event }) => { @@ -168,7 +168,7 @@ export const arrayToolStateMachine = createMachine( }, }, [ArrayState.ASK_NUMBER_OF_COPIES]: { - meta: { instructions: 'Enter number of copies' }, + meta: { instructions: '복사 개수 입력:' }, on: { NUMBER_INPUT: [ { @@ -196,7 +196,7 @@ export const arrayToolStateMachine = createMachine( }, }, [ArrayState.LINEAR_WAITING_FOR_START_POINT]: { - meta: { instructions: 'Click to define the start of the distance vector' }, + meta: { instructions: '간격 시작점 지정:' }, on: { ABSOLUTE_POINT_INPUT: { actions: assign(({ event }) => ({ @@ -216,7 +216,7 @@ export const arrayToolStateMachine = createMachine( }, }, [ArrayState.LINEAR_WAITING_FOR_END_POINT]: { - meta: { instructions: 'Click to define the end of the distance vector' }, + meta: { instructions: '간격 끝점 지정:' }, on: { RELATIVE_POINT_INPUT: { actions: assign(({ event, context }) => ({ @@ -245,7 +245,7 @@ export const arrayToolStateMachine = createMachine( }, }, [ArrayState.RADIAL_WAITING_FOR_PIVOT_POINT]: { - meta: { instructions: 'Click to set pivot point' }, + meta: { instructions: '회전 중심점 지정:' }, on: { ABSOLUTE_POINT_INPUT: { actions: assign(({ event }) => ({ @@ -265,7 +265,7 @@ export const arrayToolStateMachine = createMachine( }, }, [ArrayState.RADIAL_WAITING_FOR_ANGLE]: { - meta: { instructions: 'Enter angle per step (in degrees)' }, + meta: { instructions: '한 칸 각도(도) 입력:' }, on: { NUMBER_INPUT: { target: ArrayState.EXECUTE_COPY, diff --git a/B07_DesignDetail/openwebcad/src/tools/circle-tool.ts b/B07_DesignDetail/openwebcad/src/tools/circle-tool.ts index cbd81db8f..8f992f6c9 100644 --- a/B07_DesignDetail/openwebcad/src/tools/circle-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/circle-tool.ts @@ -60,7 +60,7 @@ export const circleToolStateMachine = createMachine( [CircleState.WAITING_FOR_CENTER_POINT]: { description: 'Select the center point of the circle tool', meta: { - instructions: 'Select the center point of the circle', + instructions: '중심점 지정 (x,y):', }, on: { MOUSE_CLICK: { @@ -79,7 +79,7 @@ export const circleToolStateMachine = createMachine( [CircleState.WAITING_FOR_POINT_ON_CIRCLE]: { description: 'Select a point on the circle', meta: { - instructions: 'Select the point on the circle', + instructions: '원 위의 점 지정 또는 반지름 입력:', }, on: { DRAW: { diff --git a/B07_DesignDetail/openwebcad/src/tools/copy-tool.ts b/B07_DesignDetail/openwebcad/src/tools/copy-tool.ts index 25b7d8542..2a24a8503 100644 --- a/B07_DesignDetail/openwebcad/src/tools/copy-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/copy-tool.ts @@ -97,7 +97,7 @@ export const copyToolStateMachine = createMachine( [CopyState.WAITING_FOR_SELECTION]: { description: 'Select what you want to copy', meta: { - instructions: 'Select what you want to copy, then ENTER', + instructions: '복사할 객체 선택 뒤 Enter', }, invoke: { id: 'selectToolInsideTheCopyTool', @@ -136,9 +136,9 @@ export const copyToolStateMachine = createMachine( }, }, [CopyState.WAITING_FOR_START_COPY_POINT]: { - description: 'Select the start of the copy line', + description: '기준점 지정 (x,y):', meta: { - instructions: 'Select the start of the copy line', + instructions: '기준점 지정 (x,y):', }, always: { actions: CopyAction.ENABLE_HELPERS, @@ -159,9 +159,9 @@ export const copyToolStateMachine = createMachine( }, }, [CopyState.WAITING_FOR_END_COPY_POINT]: { - description: 'Select the end of the copy line', + description: '둘째 점 지정 (길이 · <각도 · @x,y):', meta: { - instructions: 'Select the end of the copy line', + instructions: '둘째 점 지정 (길이 · <각도 · @x,y):', }, on: { DRAW: { diff --git a/B07_DesignDetail/openwebcad/src/tools/eraser-tool.ts b/B07_DesignDetail/openwebcad/src/tools/eraser-tool.ts index 5aedd0898..933a54d2e 100644 --- a/B07_DesignDetail/openwebcad/src/tools/eraser-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/eraser-tool.ts @@ -60,9 +60,9 @@ export const eraserToolStateMachine = createMachine( }, }, [EraserState.WAITING_FOR_FIRST_CLICK]: { - description: 'Select a line segment to delete', + description: '지울 선 선택', meta: { - instructions: 'Select a line segment to delete', + instructions: '지울 선 선택', }, on: { // TODO implement a DRAW action to draw the segment that will be erased in dotted line diff --git a/B07_DesignDetail/openwebcad/src/tools/image-import-tool.ts b/B07_DesignDetail/openwebcad/src/tools/image-import-tool.ts index 81f9b313b..ab3070427 100644 --- a/B07_DesignDetail/openwebcad/src/tools/image-import-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/image-import-tool.ts @@ -70,9 +70,9 @@ export const imageImportToolStateMachine = createMachine( }, }, [ImageImportState.WAIT_FOR_IMAGE_DATA]: { - description: 'Select an image file to import', + description: '가져올 그림 파일 선택', meta: { - instructions: 'Select an image file to import', + instructions: '가져올 그림 파일 선택', }, on: { [ActorEvent.FILE_SELECTED]: { @@ -85,9 +85,9 @@ export const imageImportToolStateMachine = createMachine( }, }, [ImageImportState.WAITING_FOR_START_POINT]: { - description: 'Select the start point of the imageImport', + description: '그림 첫 모서리 지정:', meta: { - instructions: 'Select the start point of the imageImport', + instructions: '그림 첫 모서리 지정:', }, on: { MOUSE_CLICK: { @@ -101,9 +101,9 @@ export const imageImportToolStateMachine = createMachine( }, }, [ImageImportState.WAITING_FOR_END_POINT]: { - description: 'Select the end point of the imageImport', + description: '그림 맞은 모서리 지정:', meta: { - instructions: 'Select the end point of the imageImport', + instructions: '그림 맞은 모서리 지정:', }, on: { DRAW: { diff --git a/B07_DesignDetail/openwebcad/src/tools/line-tool.ts b/B07_DesignDetail/openwebcad/src/tools/line-tool.ts index 4ea1cb27a..2f02d7f85 100644 --- a/B07_DesignDetail/openwebcad/src/tools/line-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/line-tool.ts @@ -2,6 +2,7 @@ import type { Point } from '@flatten-js/core'; import { LineEntity } from '../entities/LineEntity'; import { addEntities, + deleteEntities, getActiveLayerId, getActiveLineColor, getActiveLineDash, @@ -14,12 +15,22 @@ import { } from '../state'; import { Tool } from '../tools'; import { Actor, assign, createMachine } from 'xstate'; -import type { DrawEvent, PointInputEvent, StateEvent, ToolContext } from './tool.types'; +import type { + DrawEvent, + PointInputEvent, + StateEvent, + TextInputEvent, + ToolContext, +} from './tool.types'; import { selectToolStateMachine } from './select-tool.ts'; import { getPointFromEvent } from '../helpers/get-point-from-event.ts'; export interface LineContext extends ToolContext { startPoint: Point | null; + /** 이번 이어 그리기의 첫 점 — 닫기(C) */ + firstPoint: Point | null; + /** 이번 이어 그리기에서 그린 구간 — 명령취소(U) */ + segments: LineEntity[]; } export enum LineState { @@ -33,6 +44,8 @@ export enum LineAction { RECORD_START_POINT = 'RECORD_START_POINT', DRAW_TEMP_LINE = 'DRAW_TEMP_LINE', DRAW_FINAL_LINE = 'DRAW_FINAL_LINE', + CLOSE_LINE = 'CLOSE_LINE', + UNDO_SEGMENT = 'UNDO_SEGMENT', SWITCH_TO_SELECT_TOOL = 'SWITCH_TO_SELECT_TOOL', } @@ -44,6 +57,8 @@ export const lineToolStateMachine = createMachine( }, context: { startPoint: null, + firstPoint: null, + segments: [], type: Tool.LINE, }, initial: LineState.INIT, @@ -58,7 +73,7 @@ export const lineToolStateMachine = createMachine( [LineState.WAITING_FOR_START_POINT]: { description: 'Select the start point of the line', meta: { - instructions: 'Select the start point of the line', + instructions: '첫 점 지정 (x,y):', }, on: { MOUSE_CLICK: { @@ -77,7 +92,8 @@ export const lineToolStateMachine = createMachine( [LineState.WAITING_FOR_END_POINT]: { description: 'Select the end point of the line', meta: { - instructions: 'Select the end point of the line', + instructions: '다음 점 지정 또는 [닫기(C)/명령취소(U)]:', + options: ['C', 'U'], }, on: { DRAW: { @@ -99,6 +115,21 @@ export const lineToolStateMachine = createMachine( actions: LineAction.DRAW_FINAL_LINE, target: LineState.WAITING_FOR_END_POINT, }, + TEXT_INPUT: [ + { + // 닫기 — 둘째 선부터 · 첫 점으로 잇고 끝 + guard: ({ context, event }) => + (event as TextInputEvent).value === 'C' && context.segments.length >= 2, + actions: LineAction.CLOSE_LINE, + target: LineState.INIT, + }, + { + // 명령취소 — 마지막 구간만 + guard: ({ context, event }) => + (event as TextInputEvent).value === 'U' && context.segments.length > 0, + actions: LineAction.UNDO_SEGMENT, + }, + ], ESC: { target: LineState.INIT, }, @@ -118,6 +149,8 @@ export const lineToolStateMachine = createMachine( setAngleGuideOriginPoint(null); return { startPoint: null, + firstPoint: null, + segments: [], }; }), [LineAction.RECORD_START_POINT]: assign(({ event }) => { @@ -125,6 +158,8 @@ export const lineToolStateMachine = createMachine( setAngleGuideOriginPoint(startPoint); return { startPoint, + firstPoint: startPoint, + segments: [], }; }), [LineAction.DRAW_TEMP_LINE]: ({ context, event }) => { @@ -159,8 +194,28 @@ export const lineToolStateMachine = createMachine( setAngleGuideOriginPoint(endPoint); return { startPoint: endPoint, + segments: [...context.segments, activeLine], }; }), + [LineAction.CLOSE_LINE]: ({ context }) => { + const closing = new LineEntity( + getActiveLayerId(), + context.startPoint as Point, + context.firstPoint as Point + ); + closing.lineColor = getActiveLineColor(); + closing.lineWidth = getActiveLineWidth(); + closing.lineDash = getActiveLineDash(); + addEntities([closing], true); + }, + [LineAction.UNDO_SEGMENT]: assign(({ context }) => { + const last = context.segments[context.segments.length - 1]; + deleteEntities([last], true); + const startPoint = last.getStartPoint(); + setGhostHelperEntities([new LineEntity(getActiveLayerId(), startPoint, startPoint)]); + setAngleGuideOriginPoint(startPoint); + return { startPoint, segments: context.segments.slice(0, -1) }; + }), [LineAction.SWITCH_TO_SELECT_TOOL]: () => { setActiveToolActor(new Actor(selectToolStateMachine)); }, diff --git a/B07_DesignDetail/openwebcad/src/tools/move-tool.ts b/B07_DesignDetail/openwebcad/src/tools/move-tool.ts index a2fe3cbfd..3517c1ce4 100644 --- a/B07_DesignDetail/openwebcad/src/tools/move-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/move-tool.ts @@ -98,7 +98,7 @@ export const moveToolStateMachine = createMachine( [MoveState.WAITING_FOR_SELECTION]: { description: 'Select what you want to move', meta: { - instructions: 'Select what you want to move, then ENTER', + instructions: '이동할 객체 선택 뒤 Enter', }, invoke: { id: 'selectToolInsideTheMoveTool', @@ -137,9 +137,9 @@ export const moveToolStateMachine = createMachine( }, }, [MoveState.WAITING_FOR_START_MOVE_POINT]: { - description: 'Select the start of the move line', + description: '기준점 지정 (x,y):', meta: { - instructions: 'Select the start of the move line', + instructions: '기준점 지정 (x,y):', }, always: { actions: MoveAction.ENABLE_HELPERS, @@ -160,9 +160,9 @@ export const moveToolStateMachine = createMachine( }, }, [MoveState.WAITING_FOR_END_MOVE_POINT]: { - description: 'Select the end of the move line', + description: '둘째 점 지정 (길이 · <각도 · @x,y):', meta: { - instructions: 'Select the end of the move line', + instructions: '둘째 점 지정 (길이 · <각도 · @x,y):', }, on: { DRAW: { diff --git a/B07_DesignDetail/openwebcad/src/tools/pedit-tool.ts b/B07_DesignDetail/openwebcad/src/tools/pedit-tool.ts index d00c3874f..83c7f330b 100644 --- a/B07_DesignDetail/openwebcad/src/tools/pedit-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/pedit-tool.ts @@ -75,7 +75,7 @@ export const peditToolStateMachine = createMachine( [PeditState.WAITING_FOR_SELECTION]: { description: 'Select the entities that you want to combine into a polyline', meta: { - instructions: 'Select what you want to combine into a polyline, then ENTER', + instructions: '폴리선으로 합칠 객체 선택 뒤 Enter', }, invoke: { id: 'selectToolInsideThePeditTool', diff --git a/B07_DesignDetail/openwebcad/src/tools/rectangle-tool.ts b/B07_DesignDetail/openwebcad/src/tools/rectangle-tool.ts index aa375f5d6..afee826d8 100644 --- a/B07_DesignDetail/openwebcad/src/tools/rectangle-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/rectangle-tool.ts @@ -53,9 +53,9 @@ export const rectangleToolStateMachine = createMachine( }, }, [RectangleState.WAITING_FOR_START_POINT]: { - description: 'Select the start point of the rectangle', + description: '첫 모서리 지정 (x,y):', meta: { - instructions: 'Select the start point of the rectangle', + instructions: '첫 모서리 지정 (x,y):', }, on: { MOUSE_CLICK: { @@ -69,9 +69,9 @@ export const rectangleToolStateMachine = createMachine( }, }, [RectangleState.WAITING_FOR_END_POINT]: { - description: 'Select the end point of the rectangle', + description: '맞은 모서리 지정 (@x,y):', meta: { - instructions: 'Select the end point of the rectangle', + instructions: '맞은 모서리 지정 (@x,y):', }, on: { DRAW: { diff --git a/B07_DesignDetail/openwebcad/src/tools/rotate-tool.ts b/B07_DesignDetail/openwebcad/src/tools/rotate-tool.ts index c2930e017..619c7e63e 100644 --- a/B07_DesignDetail/openwebcad/src/tools/rotate-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/rotate-tool.ts @@ -105,7 +105,7 @@ export const rotateToolStateMachine = createMachine( [RotateState.WAITING_FOR_SELECTION]: { description: 'Select what you want to rotate', meta: { - instructions: 'Select what you want to rotate, then ENTER', + instructions: '회전할 객체 선택 뒤 Enter', }, invoke: { id: 'selectToolInsideTheRotateTool', @@ -144,9 +144,9 @@ export const rotateToolStateMachine = createMachine( }, }, [RotateState.WAITING_FOR_ROTATION_ORIGIN]: { - description: 'Select the origin of the rotate operation', + description: '기준점 지정 (x,y):', meta: { - instructions: 'Select the origin of the rotate operation', + instructions: '기준점 지정 (x,y):', }, always: { actions: RotateAction.ENABLE_HELPERS, @@ -167,9 +167,9 @@ export const rotateToolStateMachine = createMachine( }, }, [RotateState.WAITING_FOR_ANGLE_START_POINT]: { - description: 'Select the end of the base rotate line', + description: '회전 각도 입력 또는 기준선 끝점 지정:', meta: { - instructions: 'Select the end of the base rotate line', + instructions: '회전 각도 입력 또는 기준선 끝점 지정:', }, on: { MOUSE_CLICK: { @@ -195,9 +195,9 @@ export const rotateToolStateMachine = createMachine( }, }, [RotateState.WAITING_FOR_ANGLE_END_POINT]: { - description: 'Select the end of the rotate line', + description: '회전 방향 점 지정:', meta: { - instructions: 'Select the end of the rotate line', + instructions: '회전 방향 점 지정:', }, on: { DRAW: { diff --git a/B07_DesignDetail/openwebcad/src/tools/select-tool.ts b/B07_DesignDetail/openwebcad/src/tools/select-tool.ts index 55a339266..62aa98e41 100644 --- a/B07_DesignDetail/openwebcad/src/tools/select-tool.ts +++ b/B07_DesignDetail/openwebcad/src/tools/select-tool.ts @@ -57,7 +57,7 @@ export const selectToolStateMachine = createMachine( [SelectState.WAITING_FOR_FIRST_SELECT_POINT]: { description: 'Select a line or select the first point of a selection rectangle', meta: { - instructions: 'Select a line or start drawing a selection rectangle', + instructions: '객체 선택 또는 선택 상자 시작', }, on: { MOUSE_CLICK: { @@ -79,7 +79,7 @@ export const selectToolStateMachine = createMachine( [SelectState.CHECK_SELECTION]: { description: 'Checking to select one line or start drawing a selection rectangle', meta: { - instructions: 'Select one line or start drawing a selection rectangle', + instructions: '객체 하나 선택 또는 선택 상자 시작', }, always: [ { @@ -95,9 +95,9 @@ export const selectToolStateMachine = createMachine( ], }, [SelectState.WAITING_FOR_SECOND_SELECT_POINT]: { - description: 'Select the second point of a selection rectangle', + description: '선택 상자 맞은 모서리 지정', meta: { - instructions: 'Select the second point of a selection rectangle', + instructions: '선택 상자 맞은 모서리 지정', }, on: { DRAW: { diff --git a/M02_MasterTemplete/M02_MasterTemplete_Hopyo.css b/M02_MasterTemplete/M02_MasterTemplete_Hopyo.css index 134403225..8e771bad7 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Hopyo.css +++ b/M02_MasterTemplete/M02_MasterTemplete_Hopyo.css @@ -227,3 +227,24 @@ .m02-hopyo-sheet__result:empty { display: none; } + +/* 고르기 창 근거(330) — 후보 꼬리표 · 엑셀 근거 줄 */ +.m02-hopyo__basis { + margin-left: var(--spacing-8); + padding: 0 var(--spacing-4); + border: 1px solid var(--color-border); + border-radius: var(--radius-sm); + color: var(--color-text-secondary); + font-size: var(--text-caption); + white-space: nowrap; +} + +.m02-hopyo__basis.is-ok { + border-color: var(--color-success); + color: var(--color-success); +} + +.m02-hopyo__source { + padding-bottom: var(--spacing-8); + border-bottom: 1px solid var(--color-border); +} diff --git a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_Api.ts b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_Api.ts index c4ef47641..12312fba2 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_Api.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_Api.ts @@ -59,6 +59,22 @@ export interface HopyoView extends HopyoFile { 맞춤: [number, number]; } +/** 후보가 단가산출 근거와 맞는 것(330-2) — 맞은 조항 글 · 겹친 직종 · 단위 같음 · 점수 · 까닭 꼬리표 */ +export interface HopyoBasisHit { + 조항: string[]; + 직종: string[]; + 단위: boolean; + 점수: number; + 까닭: string; +} + +/** 단산 줄 근거(330-1) — 단가산출 블록의 출처([책, 번호]) · 직종 · 엑셀 행 [시작, 끝] */ +export interface HopyoLineBasis { + 출처: [string, string][]; + 직종: string[]; + 행: [number, number]; +} + /** 맞춤 대상 — 로직 · 자재 · 다른 호표 */ export interface HopyoTarget { 로직?: string; @@ -68,6 +84,8 @@ export interface HopyoTarget { 규격?: string; 단위?: string | null; 점수?: number; + /** 근거 맞춤(330 · 옛 파일 · 근거 없는 줄은 없음) */ + 근거?: HopyoBasisHit; } export interface HopyoMatch { @@ -92,6 +110,8 @@ export interface HopyoLine { 금액: Money; 비고: string; 맞춤: HopyoMatch; + /** 단가산출 근거(330 · 「단산N참조」 줄만) */ + 근거?: HopyoLineBasis; } export interface HopyoOne extends HopyoFile { diff --git a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_View.ts b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_View.ts index 3aa5fe2c8..63a5eef75 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_View.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_View.ts @@ -3,7 +3,8 @@ * 일위대가 실무자료 본 화면(PLAN 324-4) — 파일 하나: 파일 · 시트 · 호표 수 · 검산 · 맞춤 n/m · 호표 표 + 찾기 · * [지우기] / 호표 하나: 줄 표(갈래 · 품명 · 규격 · 수량 · 단위 · 엑셀 단가 · 맞춤 · 대상 · 입력값 · 환산 · * [고르기] [확정] [빼기]) · [같음 모두 확정] · 빠진 줄 · [사전조합 만들기] → 값 비교 · 다시 씀이면 [새로 만들기] · - * [엑셀로 보기] · [엑셀에서 보기](329 엑셀 보기 창 · 늦게 불러옴 · 호표 화면은 그 호표 고른 채). + * [엑셀로 보기] · [엑셀에서 보기](329 엑셀 보기 창 · 늦게 불러옴 · 호표 화면은 그 호표 고른 채) · + * 고르기 창 후보 근거 꼬리표 · 엑셀 근거 줄 + [엑셀에서 보기](단가산출 그 행) · [근거 맞음 모두 확정](330). * 맞춤 · 만들기는 서버(`M02_Hopyo_Match` · `M02_Hopyo_Build`) · 쓰기 단추는 층 쓰기 권한만. * ========================================================================== */ @@ -17,9 +18,11 @@ import { readHopyo, readHopyoOne, saveHopyoMemory, + type HopyoBasisHit, type HopyoBuilt, type HopyoGuess, type HopyoLine, + type HopyoLineBasis, type HopyoMemory, type HopyoOne, type HopyoScope, @@ -114,6 +117,42 @@ export function memoryOf( return null; } +/** 근거 맞음 — 조항 · 직종 · 단위 모두 맞음(330 [근거 맞음 모두 확정]) */ +export const basisOk = (b: HopyoBasisHit | undefined): boolean => + !!b && b.조항.length > 0 && b.직종.length > 0 && b.단위; + +/** 후보 근거 꼬리표 — 「조항 건설 공통 3-2-1 · 직종 특별인부 · 단위 같음」 · 근거 없으면 "" */ +export const basisTag = (b: HopyoBasisHit | undefined): string => + b + ? [ + b.조항.length ? `조항 ${b.조항.join(", ")}` : "", + b.직종.length ? `직종 ${b.직종.join(", ")}` : "", + b.단위 ? "단위 같음" : "", + ] + .filter(Boolean) + .join(" · ") + : ""; + +/** 엑셀 근거 줄 — 「출처 건설표준품셈 3-2-1 · 직종 특별인부 · 단가산출 93–101행」 · 없으면 "" */ +export const sourceText = (b: HopyoLineBasis | undefined): string => + b + ? [ + b.출처.length ? `출처 ${b.출처.map((x) => x.join(" ").trim()).join(", ")}` : "", + b.직종.length ? `직종 ${b.직종.join(", ")}` : "", + `단가산출 ${b.행[0] === b.행[1] ? b.행[0] : `${b.행[0]}–${b.행[1]}`}행`, + ] + .filter(Boolean) + .join(" · ") + : ""; + +/** [근거 맞음 모두 확정] 대상 — 「후보」 줄의 지금 대상이 근거 맞으면 그것 · 아니면 근거 맞는 첫 후보 · 없으면 null */ +export function basisPick(line: HopyoLine): HopyoTarget | null { + const m = line.맞춤; + if (m.상태 !== "후보") return null; + if (m.대상 && basisOk(m.대상.근거)) return m.대상; + return (m.후보 ?? []).find((c) => basisOk(c.근거)) ?? null; +} + export function buildHopyoView(key: string, opt: HopyoViewOptions): HTMLElement { const view = el("div", { className: "m02-hopyo", attrs: { "data-hopyo-view": key } }); let nav = 0; // 늦게 온 응답 버림 @@ -236,9 +275,19 @@ export function buildHopyoView(key: string, opt: HopyoViewOptions): HTMLElement const all = createButton({ label: `같음 모두 확정 (${same.length})`, size: "sm" }); all.disabled = !same.length; all.addEventListener("click", () => void confirmAll(no, same)); + tools.push(all); + // 근거(330) — 옛 파일 · 근거 없는 호표면 단추 없음 + if (h.줄.some((x) => x.근거 || x.맞춤.후보?.some((c) => c.근거))) { + const fit = h.줄.filter((x) => basisPick(x)); + const ok = createButton({ label: `근거 맞음 모두 확정 (${fit.length})`, size: "sm" }); + ok.title = "조항 · 직종 · 단위가 모두 맞는 후보만"; + ok.disabled = !fit.length; + ok.addEventListener("click", () => void confirmBasis(no, fit)); + tools.push(ok); + } const make = createButton({ label: "사전조합 만들기", variant: "filled", size: "sm" }); make.addEventListener("click", () => void build(no, false)); - tools.push(all, make); + tools.push(make); } const missing = h.줄.filter((x) => !x.맞춤.들어감); view.replaceChildren( @@ -330,7 +379,7 @@ export function buildHopyoView(key: string, opt: HopyoViewOptions): HTMLElement variant: "ghost", size: "sm", onClick: () => - choose(line, (t) => + choose(line, got.파일, (t) => guessHopyo(opt.scope, key, got.호표.번, line.차례, t).then( (g) => (picked.set(line.차례, g), repaint()), fail, @@ -378,8 +427,8 @@ export function buildHopyoView(key: string, opt: HopyoViewOptions): HTMLElement }); } - /** 대상 고르기 — 후보 5 + 다른 로직 · 자재 찾기 */ - function choose(line: HopyoLine, done: (t: HopyoTarget) => void): void { + /** 대상 고르기 — 엑셀 근거 줄 · 후보 5(근거 꼬리표) + 다른 로직 · 자재 찾기 */ + function choose(line: HopyoLine, 파일: string, done: (t: HopyoTarget) => void): void { const material = MATERIAL.has(line.갈래); openModal({ title: `고르기 — ${line.이름} ${line.규격}`.trim(), @@ -390,14 +439,48 @@ export function buildHopyoView(key: string, opt: HopyoViewOptions): HTMLElement close(); done(t); }; - const list = (line.맞춤.후보 ?? []).map((c) => - createButton({ + const list = (line.맞춤.후보 ?? []).map((c) => { + const button = createButton({ label: `${targetText(c)} · ${c.로직 ?? c.자재 ?? ""}`, variant: "ghost", size: "sm", onClick: () => pick(c), - }), - ); + }); + const tag = basisTag(c.근거); + if (tag && c.근거) + button.append( + el("span", { + className: `m02-hopyo__basis${basisOk(c.근거) ? " is-ok" : ""}`, + text: tag, + attrs: { title: `${c.근거.까닭} · 점수 ${c.근거.점수}` }, + }), + ); + return button; + }); + const basis = line.근거; + const source = basis + ? [ + el("div", { + className: "m02-hopyo__bar m02-hopyo__source", + children: [ + note(`엑셀 근거 — ${sourceText(basis)}`), + createButton({ + label: "엑셀에서 보기", + variant: "ghost", + size: "sm", + onClick: () => + openSheet({ + scope: opt.scope, + key, + 파일, + canWrite: opt.canWrite, + 단산행: basis.행, + }), + }), + ], + }), + ] + : []; const more = createButton({ label: material ? "다른 자재 찾기…" : "다른 로직 찾기…", size: "sm", @@ -408,6 +491,7 @@ export function buildHopyoView(key: string, opt: HopyoViewOptions): HTMLElement }, }); body.append( + ...source, el("p", { className: "m02-hopyo__note", text: list.length ? "후보" : "가까운 것 없음" }), el("div", { className: "m02-hopyo__cands", children: list }), more, @@ -434,6 +518,24 @@ export function buildHopyoView(key: string, opt: HopyoViewOptions): HTMLElement await remember(no, body); } + /** 근거 맞는 후보로 확정 — 지금 대상이 아니면 입력값 · 환산을 서버에서 다시 읽음 */ + async function confirmBasis(no: number, lines: HopyoLine[]): Promise { + const body: Record = {}; + for (const x of lines) { + const c = basisPick(x); + const m = x.맞춤; + if (!c) continue; + const g = + c === m.대상 + ? { 대상: c, 입력값: m.입력값, 환산: m.환산 } + : await guessHopyo(opt.scope, key, no, x.차례, c).catch(() => null); + const one = g && memoryOf(g.대상, g.입력값, g.환산?.배 ?? null); + if (one) body[m.열쇠] = one; + } + if (!Object.keys(body).length) return showToast("확정할 줄 없음 — 환산을 못 읽음", "warning"); + await remember(no, body); + } + async function build(no: number, fresh: boolean): Promise { try { const from = { 층: opt.scope.layer, 주인: opt.scope.owner, 키: key, 번: no }; diff --git a/resources/tester/cad/keyboard-chain.test.ts b/resources/tester/cad/keyboard-chain.test.ts index af5d1a5d6..a10e808fc 100644 --- a/resources/tester/cad/keyboard-chain.test.ts +++ b/resources/tester/cad/keyboard-chain.test.ts @@ -13,9 +13,11 @@ vi.mock("react-toastify", () => ({ import { toast } from "react-toastify"; import { InputController } from "../../../B07_DesignDetail/openwebcad/src/inputController/input-controller"; import { getAngleLock } from "../../../B07_DesignDetail/openwebcad/src/inputController/input-angle-lock"; +import { getSnapOverride } from "../../../B07_DesignDetail/openwebcad/src/inputController/input-snap-override"; import { getActiveToolActor, getEntities, + getLastStateInstructions, setEntities, setSelectedEntityIds, } from "../../../B07_DesignDetail/openwebcad/src/state"; @@ -197,3 +199,83 @@ describe("331-2 이동 · 복사 · 회전 키보드 값", () => { expect(toast.error).not.toHaveBeenCalled(); }); }); + +describe("331-3 선 중 C · U · 한 번 스냅 · 한글 안내", () => { + const drawOpen = () => { + type(controller, "l"); + type(controller, "0,0"); + type(controller, "10,0"); + type(controller, "10,10"); + }; + + it("C = 첫 점으로 닫고 끝 · 안내 「[닫기(C)/명령취소(U)]」", () => { + drawOpen(); + expect(getLastStateInstructions()).toBe("다음 점 지정 또는 [닫기(C)/명령취소(U)]:"); + type(controller, "c"); + const drawn = lines(); + expect(drawn).toHaveLength(3); + expectXy(drawn[2].start, 10, 10); + expectXy(drawn[2].end, 0, 0); + expect(getActiveToolActor()?.getSnapshot()?.value).toBe("WAITING_FOR_START_POINT"); + expect(getLastStateInstructions()).toBe("첫 점 지정 (x,y):"); + }); + + it("C 는 둘째 선부터 — 한 구간이면 무시", () => { + type(controller, "l"); + type(controller, "0,0"); + type(controller, "10,0"); + type(controller, "c"); + expect(lines()).toHaveLength(1); + expect(getActiveToolActor()?.getSnapshot()?.value).toBe("WAITING_FOR_END_POINT"); + }); + + it("U = 마지막 한 구간만 취소 · 그 시작점에서 이어 그림", () => { + drawOpen(); + type(controller, "u"); + expect(lines()).toHaveLength(1); + type(controller, "20,0"); + const drawn = lines(); + expect(drawn).toHaveLength(2); + expectXy(drawn[1].start, 10, 0); + expectXy(drawn[1].end, 20, 0); + }); + + it("선 중 다른 명령 이름은 그대로 명령", () => { + drawOpen(); + type(controller, "circle"); + expect(getActiveToolActor()?.getSnapshot()?.context.type).toBe("CIRCLE"); + }); + + it("END 한 번 — 둘레 안 끝점으로 · 한 점 뒤 풂", () => { + type(controller, "l"); + type(controller, "0,0"); + type(controller, "100,0"); + key(controller, "Escape"); + type(controller, "end"); + expect(getSnapOverride()).toBe("END"); + clickAt(controller, 80, 20); // 끝점 (100, 0) 에서 28 — 일반 스냅(15)은 못 닿음 + expect(getSnapOverride()).toBeNull(); + type(controller, "@0,10"); + const drawn = lines(); + expect(drawn).toHaveLength(2); + expectXy(drawn[1].start, 100, 0); + expectXy(drawn[1].end, 100, 10); + }); + + it("END 둘레에 끝점 없으면 클릭 버림 · Esc 로 풂", () => { + type(controller, "l"); + type(controller, "end"); + clickAt(controller, 500, 500); + expect(getActiveToolActor()?.getSnapshot()?.value).toBe("WAITING_FOR_START_POINT"); + expect(getSnapOverride()).toBe("END"); + key(controller, "Escape"); + expect(getSnapOverride()).toBeNull(); + }); + + it("점 단계가 아니면 END 는 스냅 아님", () => { + key(controller, "Escape"); + key(controller, "Escape"); + type(controller, "end"); + expect(getSnapOverride()).toBeNull(); + }); +}); diff --git a/resources/tester/helper_m02_hopyo_pick.cjs b/resources/tester/helper_m02_hopyo_pick.cjs index 1a389f69f..78c8b60a9 100644 --- a/resources/tester/helper_m02_hopyo_pick.cjs +++ b/resources/tester/helper_m02_hopyo_pick.cjs @@ -88,6 +88,34 @@ function loadTs(file) { view.builtWord({ 다시씀: true }, true), ], }, + basis: (() => { + const hit = { + 조항: ["건설 공통 3-2-1"], + 직종: ["특별인부"], + 단위: true, + 점수: 1.65, + 까닭: "조항", + }; + const half = { ...hit, 직종: [] }; + const line = (상태, 대상, 후보) => ({ 맞춤: { 상태, 대상, 후보 } }); + const a = { 로직: "GF000101", 근거: half }; + const b = { 로직: "GC000083", 근거: hit }; + return { + ok: [hit, half, { ...hit, 단위: false }, undefined].map(view.basisOk), + tag: [hit, half, undefined].map(view.basisTag), + source: [ + view.sourceText({ 출처: [["건설표준품셈", "3-2-1"]], 직종: ["특별인부"], 행: [93, 101] }), + view.sourceText({ 출처: [], 직종: [], 행: [7, 7] }), + view.sourceText(undefined), + ], + pick: [ + line("후보", a, [a, b]), + line("후보", b, [b]), + line("같음", b, [b]), + line("후보", a, [a]), + ].map((x) => view.basisPick(x)?.로직 ?? null), + }; + })(), sheet: { at: [19, 20, 22, 24, 25, 30, 31].map((row) => sheet.hopyoAtRow(spans, row)), span: sheet.spanText([20, 24], sheet.lastColumn({ 칸: { A1: {}, N24: {} }, 열: { O: {} } })), diff --git a/resources/tester/test_m02_hopyo_screen.py b/resources/tester/test_m02_hopyo_screen.py index 804e09399..c844f2d7d 100644 --- a/resources/tester/test_m02_hopyo_screen.py +++ b/resources/tester/test_m02_hopyo_screen.py @@ -3,6 +3,7 @@ - 고르기 창 덧줄(Node · fetch 대역): 이 층 · 위 층 호표 줄(맞춤 n/m) · 종류 고르기 · 고르면 문서 층에 만들기 길 → `lib.pick` 참조 줄(별칭 = 호표 품명) · 프로젝트 층엔 없음 · 본 화면 글 도우미 +- 고르기 창 근거(330-3): 꼬리표 · 엑셀 근거 줄 · [근거 맞음 모두 확정] 대상 - 엑셀 보기 창(329): 행 → 호표 · 호표 영역 A1 · 격자 길 · 여는 자리 넷 · 늦게 불러옴 - 소스: 좌측 판 자리(사전조합 아래 · 구조물 조합 층 · 쓰기 권한 없으면 올리기 꺼짐 · 숨은 file 입력) · Labor_Detail 줄 수 그대로 · 새 파일 이름 · 700 줄 · 색 = 공용 토큰 @@ -188,3 +189,23 @@ def test_엑셀_보기_창_여는_자리와_늦게_불러옴(): r'^import \{[^}]*\} from "\.\./A00_Common/spreadsheet/spreadsheet"', sheet, re.M ) assert "readOnly: true" in sheet and "wide: true" in sheet + + +def test_고르기_창_근거_꼬리표와_근거_맞음(): + basis = _run()["basis"] + assert basis["ok"] == [True, False, False, False] # 조항 · 직종 · 단위 모두 + assert basis["tag"] == [ + "조항 건설 공통 3-2-1 · 직종 특별인부 · 단위 같음", + "조항 건설 공통 3-2-1 · 단위 같음", + "", + ] + assert basis["source"] == [ + "출처 건설표준품셈 3-2-1 · 직종 특별인부 · 단가산출 93–101행", + "단가산출 7행", + "", + ] + # 지금 대상이 근거 안 맞으면 근거 맞는 후보 · 「후보」 줄만 · 근거 맞는 것 없으면 없음 + assert basis["pick"] == ["GC000083", "GC000083", None, None] + view = _text("M02_MasterTemplete_Hopyo_View.ts") + assert "단산행: basis.행" in view and "근거 맞음 모두 확정" in view + assert "x.근거 || x.맞춤.후보?.some((c) => c.근거)" in view # 옛 파일 = 단추 없음