/** 특성 팔레트 본문 — 선택 객체의 값을 읽고 바로 고친다 (PROPERTIES) */ import type { FC } from 'react'; import type { Entity } from '../entities/Entity'; import { polylineLength, sampleEntityPoints } from '../helpers/geometry/sample-entity'; import { getEntities, getLayers, getSelectedEntities, setEntities, } from '../state'; import { dashToLineType, LINE_TYPES, LINE_WIDTHS } from './RibbonWidgets'; interface PropertiesEditorProps { compact?: boolean; } function applyToSelection(mutate: (entity: Entity) => void): void { const selected = getSelectedEntities(); if (!selected.length) return; for (const entity of selected) mutate(entity); setEntities([...getEntities()], true); } /** 여러 객체가 값이 다르면 '*가지각색' 대신 첫 객체 값을 보여 준다 (AutoCAD와 같은 관행) */ export const PropertiesEditor: FC = ({ compact = false }) => { const selected = getSelectedEntities(); const layers = getLayers(); const first = selected[0]; if (!first) { return

선택된 객체가 없습니다.

; } const points = sampleEntityPoints(first); const box = first.getBoundingBox(); return (
{selected.length === 1 ? first.getType() : `여러 객체 (${selected.length})`}
{!compact && (
길이
{polylineLength(points).toFixed(3)}
크기
{(box.xmax - box.xmin).toFixed(3)} × {(box.ymax - box.ymin).toFixed(3)}
시작점
{points[0] ? `${points[0].x.toFixed(2)}, ${points[0].y.toFixed(2)}` : '-'}
그룹
{first.groupId ? '있음' : '없음'}
)}
); };