import { ComponentNature, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene' import { MCSStatusMixin } from './features/mcs-status-mixin' import { LEGEND_CAPACITY, Legend } from './features/mcs-status-default' import { ParentObjectMixin, ParentObjectMixinProperties } from './features/parent-object-mixin' import { CapacityGaugeMixin, CapacityGaugeMixinProperties } from './features/capacity-gauge-mixin' /** * 스토커 게이지 (통합). * * mode 에 따라 capacity / carrier / abnormal 3가지 게이지를 표현한다. 그리는 규칙은 * CapacityGaugeMixin 에 있으며 ZoneCapacityBar 와 완전히 공유한다(단일 소스). 스토커는 * STOCKER 내부에 놓이는 Shape 로, 부모 STOCKER 가 데이터를 push 한다(isIdentifiable=false). * * mode 소스: root.stockerGaugeMode. 3D(machine-3d buildGauge)와 동일 소스라 2D/3D 가 일치한다. */ const NATURE: ComponentNature = { mutable: false, resizable: true, rotatable: true, properties: [...ParentObjectMixinProperties, ...CapacityGaugeMixinProperties], 'value-property': 'usage' } @sceneComponent('StockerCapacityBar') @sceneComponent('MCSGaugeCapacityBar') export default class StockerCapacityBar extends CapacityGaugeMixin( ParentObjectMixin(MCSStatusMixin(RectPath(Shape))) ) { static get nature() { return NATURE } /** StockerCapacityBar / MCSGaugeCapacityBar 의 parentObject 는 STOCKER. */ get parentObjectTypes(): string[] { return ['STOCKER'] } /** 게이지는 자체 id 로 매핑하지 않는다 — 부모 STOCKER 가 데이터를 push. */ isIdentifiable() { return false } getLegendFallback(): Legend { return (this.root as any).stockerCapacityLegendTheme || LEGEND_CAPACITY } /** * Shape.postrender 의 drawFill/drawStroke 를 건너뛴다. * render 가 자체 배경(fillStyle)·외곽선(strokeStyle)을 이미 그리므로, base 가 * fillStyle 로 게이지 전체를 다시 덮는(각 모드 표현이 사라지는) 것을 방지한다. * 값 텍스트(drawText)는 Component.postrender 와 동일하게 유지한다. */ postrender(context: CanvasRenderingContext2D) { ;(this as any).drawText(context) } }