import type { Box, Point, Segment } from '@flatten-js/core'; import type { Shape, SnapPoint } from '../App.types'; import type { DrawController } from '../drawControllers/DrawController.ts'; import type { ArcJsonData } from './ArcEntity'; import type { ArrowHeadJsonData } from './ArrowHeadEntity.ts'; import type { CircleJsonData } from './CircleEntity'; import type { HatchJsonData } from './HatchEntity'; import type { ImageJsonData } from './ImageEntity'; import type { LineEntity, LineJsonData } from './LineEntity'; import type { PointJsonData } from './PointEntity'; import type { RectangleJsonData } from './RectangleEntity'; import type { TableJsonData } from './TableEntity.ts'; import type { TextJsonData } from './TextEntity.ts'; export interface Entity { // Random uuid generated when the Entity is created // Used for comparing entities id: string; lineColor: string; lineWidth: number; lineDash: number[] | undefined; layerId: string; /** 0~1 객체 투명도. 없으면 도면층 값을 따른다 */ opacity?: number; /** GROUP으로 묶인 객체가 공유하는 식별자 */ groupId?: string; draw(drawController: DrawController, highlighted?: boolean, selected?: boolean): void; /** * Translate an entity by x and y amount * @param x * @param y */ move(x: number, y: number): void; scale(scaleOrigin: Point, scaleFactor: number): void; rotate(rotateOrigin: Point, angle: number): void; mirror(mirrorAxis: LineEntity): void; clone(): Entity; getBoundingBox(): Box; intersectsWithBox(box: Box): boolean; isContainedInBox(box: Box): boolean; getBoundingBox(): Box; getFirstPoint(): Point | null; getShape(): Shape | null; getSnapPoints(): SnapPoint[]; getIntersections(entity: Entity): Point[]; distanceTo(shape: Shape): [number, Segment] | null; getSvgString(): string | null; getType(): EntityName; containsPointOnShape(point: Point): boolean; toJson(): Promise; // static fromJson(jsonEntity: JsonEntity): Promise; } export enum EntityName { Line = 'Line', Circle = 'Circle', Arc = 'Arc', Rectangle = 'Rectangle', Point = 'Point', Image = 'Image', Measurement = 'Measurement', ArrowHead = 'ArrowHead', Text = 'Text', PolyLine = 'PolyLine', Hatch = 'Hatch', Table = 'Table', } export type ShapeJsonData = | RectangleJsonData | CircleJsonData | ArcJsonData | LineJsonData | PointJsonData | ImageJsonData | ArrowHeadJsonData | HatchJsonData | TableJsonData | TextJsonData; export interface JsonEntity { id: string; type: EntityName; lineColor: string; lineWidth: number; lineDash?: number[]; layerId: string; /** GROUP 묶음 식별자 — 저장·복원에서 그대로 실어 나른다 */ groupId?: string; shapeData: TShapeJsonData | null; children?: JsonEntity[]; }