fix(B07): 그림 테두리는 집었을 때만 그림
도각의 로고·서명 자리에 흰 사각형이 남던 것 — `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) <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user