From a5fba047780f4f89d482fb8613e7add96447af96 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Wed, 2 Sep 2026 08:50:02 +0900 Subject: [PATCH] =?UTF-8?q?fix(B07):=20=EA=B7=B8=EB=A6=BC=20=ED=85=8C?= =?UTF-8?q?=EB=91=90=EB=A6=AC=EB=8A=94=20=EC=A7=91=EC=97=88=EC=9D=84=20?= =?UTF-8?q?=EB=95=8C=EB=A7=8C=20=EA=B7=B8=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 도각의 로고·서명 자리에 흰 사각형이 남던 것 — `ImageEntity.draw()` 가 폴리곤 네 변을 선택·강조 여부와 무관하게 늘 그렸음. 출력·내보내기가 같은 `draw()` 를 다른 DrawController 로 타므로 화면만의 문제가 아니라 산출물에도 실렸음. - 도각층만 특례로 두지 않고 `ImageEntity` 전체에서 뺌. 일반 CAD 관행대로 **집었을 때만**(강조·선택) 테두리를 보임 — 앞으로 붙일 그림(현황사진 등)에도 같은 규칙. - 자리 표시가 필요하면 도각 편집 화면에서 집으면 보임. 검증: `ImageEntity.test.ts` 신규 2건 — 안 집은 그림은 `drawLine` 0회·`drawImage` 1회, 집은 그림은 4회·1회. `npx vitest run` 89 passed / 0 failed, check-types·build 통과. 화면 실측(5174, wdw 표준도): 두 슬롯 사각형 안 흰 픽셀(RGB>200) **0**, 그림 픽셀은 그대로(로고 56 · 서명 106). Co-Authored-By: Claude Opus 5 (1M context) --- .../src/entities/ImageEntity.test.ts | 40 +++++++++++++++++++ .../openwebcad/src/entities/ImageEntity.ts | 14 +++++-- 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 B07_DesignDetail/openwebcad/src/entities/ImageEntity.test.ts diff --git a/B07_DesignDetail/openwebcad/src/entities/ImageEntity.test.ts b/B07_DesignDetail/openwebcad/src/entities/ImageEntity.test.ts new file mode 100644 index 00000000..63310b39 --- /dev/null +++ b/B07_DesignDetail/openwebcad/src/entities/ImageEntity.test.ts @@ -0,0 +1,40 @@ +import { Point } from '@flatten-js/core'; +import { describe, expect, it } from 'vitest'; +import type { DrawController } from '../drawControllers/DrawController'; +import { ImageEntity } from './ImageEntity'; + +/** drawLine·drawImage 호출만 세는 최소 컨트롤러. */ +function countingController() { + const calls = { lines: 0, images: 0 }; + const controller = { + setLineStyles: () => {}, + drawLine: () => { + calls.lines += 1; + }, + drawImage: () => { + calls.images += 1; + }, + } as unknown as DrawController; + return { controller, calls }; +} + +function entity(): ImageEntity { + const image = { currentSrc: 'data:image/png;base64,AAAA' } as HTMLImageElement; + return new ImageEntity('b08-frame', image, new Point(0, 0), new Point(10, 5)); +} + +describe('ImageEntity.draw', () => { + it('집지 않은 그림은 테두리를 그리지 않는다', () => { + const { controller, calls } = countingController(); + entity().draw(controller, false, false); + expect(calls.lines).toBe(0); + expect(calls.images).toBe(1); + }); + + it('집은 그림만 테두리를 보인다', () => { + const { controller, calls } = countingController(); + entity().draw(controller, false, true); + expect(calls.lines).toBe(4); + expect(calls.images).toBe(1); + }); +}); diff --git a/B07_DesignDetail/openwebcad/src/entities/ImageEntity.ts b/B07_DesignDetail/openwebcad/src/entities/ImageEntity.ts index 058439f4..3476aa8b 100644 --- a/B07_DesignDetail/openwebcad/src/entities/ImageEntity.ts +++ b/B07_DesignDetail/openwebcad/src/entities/ImageEntity.ts @@ -53,15 +53,21 @@ export class ImageEntity implements Entity { parentHighlighted?: boolean, parentSelected?: boolean ): void { + const highlighted = parentHighlighted ?? isEntityHighlighted(this); + const selected = parentSelected ?? isEntitySelected(this); drawController.setLineStyles( - parentHighlighted ?? isEntityHighlighted(this), - parentSelected ?? isEntitySelected(this), + highlighted, + selected, this.lineColor, this.lineWidth, this.lineDash ); - for (const edge of polygonToSegments(this.polygon)) { - drawController.drawLine(edge.start, edge.end); + // 테두리는 **집었을 때만** 그린다. 늘 그리면 도각의 로고·서명 자리에 흰 사각형이 + // 남고, 출력·내보내기가 같은 draw()를 타므로 산출물에도 실린다(2026-09-02). + if (highlighted || selected) { + for (const edge of polygonToSegments(this.polygon)) { + drawController.drawLine(edge.start, edge.end); + } } const width = this.polygon.box.width;