@fmsim/machine 2.0.0-beta.104 → 2.0.0-beta.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/capacity-gauge-mixin.js +514 -0
- package/dist/features/capacity-gauge-mixin.js.map +1 -0
- package/dist/scene/root-container-override.js +3 -2
- package/dist/scene/root-container-override.js.map +1 -1
- package/dist/stocker-capacity-bar.js +12 -453
- package/dist/stocker-capacity-bar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/stocker-gauge.js +27 -5
- package/dist/utils/stocker-gauge.js.map +1 -1
- package/dist/zone-capacity-bar.js +13 -213
- package/dist/zone-capacity-bar.js.map +1 -1
- package/package.json +2 -2
- package/src/features/capacity-gauge-mixin.ts +628 -0
- package/src/scene/root-container-override.ts +3 -2
- package/src/stocker-capacity-bar.ts +16 -573
- package/src/utils/stocker-gauge.ts +28 -5
- package/src/zone-capacity-bar.ts +17 -282
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import { Component, POSITION } from '@hatiolab/things-scene'
|
|
2
|
+
import { themesColorRange } from '@fmsim/api'
|
|
3
|
+
import { LEGEND_CAPACITY, Legend, resolveCarrierLegend } from './mcs-status-default'
|
|
4
|
+
import { safeRound } from '../utils/safe-round'
|
|
5
|
+
import { getValueOnRanges } from '../utils/get-value-on-ranges'
|
|
6
|
+
import { carrierSegments, abnormalSegments, carrierColorsFromLegend, pickSegmentAt, GaugeSegment } from '../utils/stocker-gauge'
|
|
7
|
+
|
|
8
|
+
type Constructor<T = {}> = new (...args: any[]) => T
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 용량 게이지 (통합 로직).
|
|
12
|
+
*
|
|
13
|
+
* 하나의 컴포넌트가 mode 에 따라 3가지 게이지를 표현한다:
|
|
14
|
+
* - 'capacity' : 용량 사용률(usage%) 채움 게이지 + high/low watermark (기본)
|
|
15
|
+
* - 'carrier' : 캐리어 상태비율 세그먼트 (Full / Empty / EmptyEmpty)
|
|
16
|
+
* - 'abnormal' : 캐리어 정상/비정상 비율 세그먼트 (Normal / Abnormal)
|
|
17
|
+
*
|
|
18
|
+
* StockerCapacityBar(스토커 지붕 게이지)와 ZoneCapacityBar(존 게이지)가 이 로직을 공유한다.
|
|
19
|
+
* 두 컴포넌트는 base(스토커=Shape, 존=Container)·정체성(identifiable)·legend 폴백만 다르고,
|
|
20
|
+
* 게이지를 그리는 규칙은 완전히 동일하다 — 규칙을 이 믹스인 한 곳에 두어 drift 를 막는다.
|
|
21
|
+
*
|
|
22
|
+
* mode 소스: root.stockerGaugeMode (기본 'capacity'). RootContainer 의 런타임 전용
|
|
23
|
+
* transient 속성으로, 3D(machine-3d buildGauge)와도 동일 소스라 2D/3D 게이지가 항상 일치한다.
|
|
24
|
+
* (root-container-override.ts 정의. 모드가 바뀌면 _refreshStockerGauges 가 두 게이지를 갱신.)
|
|
25
|
+
*
|
|
26
|
+
* 데이터 필드(2D 기준, canonical):
|
|
27
|
+
* - capacity : CURRENTCAPACITY / MAXCAPACITY / HIGHWATERMARK / LOWWATERMARK / FULLUP
|
|
28
|
+
* - carrier : CARRIER_FULL / CARRIER_EMPTY / CARRIER_EMPTY_EMPTY
|
|
29
|
+
* - abnormal : CARRIER_NORMAL / CARRIER_ABNORMAL
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** 게이지 NATURE 속성 조각 (스토커/존 공통). 각 컴포넌트 NATURE 에 spread 로 합친다. */
|
|
33
|
+
export const CapacityGaugeMixinProperties = [
|
|
34
|
+
{
|
|
35
|
+
type: 'select',
|
|
36
|
+
label: 'legend-name',
|
|
37
|
+
name: 'legendName',
|
|
38
|
+
property: {
|
|
39
|
+
options: themesColorRange
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'number',
|
|
44
|
+
name: 'currentUsage',
|
|
45
|
+
label: 'current-usage'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'number',
|
|
49
|
+
name: 'highWatermark',
|
|
50
|
+
label: 'high-watermark'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: 'number',
|
|
54
|
+
name: 'lowWatermark',
|
|
55
|
+
label: 'low-watermark'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'number',
|
|
59
|
+
name: 'maxCapacity',
|
|
60
|
+
label: 'max-capacity'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'boolean',
|
|
64
|
+
name: 'fullup',
|
|
65
|
+
label: 'fullup'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: 'number',
|
|
69
|
+
name: 'carrierFull',
|
|
70
|
+
label: 'carrier-full'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: 'number',
|
|
74
|
+
name: 'carrierEmpty',
|
|
75
|
+
label: 'carrier-empty'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'number',
|
|
79
|
+
name: 'carrierEmptyEmpty',
|
|
80
|
+
label: 'carrier-empty-empty'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'number',
|
|
84
|
+
name: 'carrierNormal',
|
|
85
|
+
label: 'carrier-normal'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'number',
|
|
89
|
+
name: 'carrierAbnormal',
|
|
90
|
+
label: 'carrier-abnormal'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: 'number',
|
|
94
|
+
label: 'round',
|
|
95
|
+
name: 'round',
|
|
96
|
+
property: {
|
|
97
|
+
min: 0
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'hidden',
|
|
102
|
+
name: 'usage',
|
|
103
|
+
label: 'usage'
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
const controlHandler = {
|
|
108
|
+
ondragmove: function (point: POSITION, index: number, component: Component) {
|
|
109
|
+
var { left, top, width, height } = (component as any).model
|
|
110
|
+
|
|
111
|
+
var transcoorded = (component as any).transcoordP2S(point.x, point.y)
|
|
112
|
+
var round = ((transcoorded.x - left) / (width / 2)) * 100
|
|
113
|
+
|
|
114
|
+
round = safeRound(round, width, height)
|
|
115
|
+
|
|
116
|
+
;(component as any).set({
|
|
117
|
+
round
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function CapacityGaugeMixin<TBase extends Constructor<Component>>(Base: TBase): any {
|
|
123
|
+
return class extends Base {
|
|
124
|
+
/** 게이지 모드: RootContainer 런타임 transient 속성. 3D(machine-3d) 와 동일 소스. */
|
|
125
|
+
get gaugeMode(): string {
|
|
126
|
+
return (this as any).root?.stockerGaugeMode || 'capacity'
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get controls() {
|
|
130
|
+
var { left, top, width, round, height } = (this as any).state
|
|
131
|
+
round = round == undefined ? 0 : safeRound(round, width, height)
|
|
132
|
+
|
|
133
|
+
return [
|
|
134
|
+
{
|
|
135
|
+
x: left + (width / 2) * (round / 100),
|
|
136
|
+
y: top,
|
|
137
|
+
handler: controlHandler
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
getTheme() {
|
|
143
|
+
const { legendName } = (this as any).state
|
|
144
|
+
|
|
145
|
+
if (legendName) {
|
|
146
|
+
return (this as any).root?.style?.[legendName]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
get legend(): Legend {
|
|
151
|
+
return this.getTheme() || this.getLegendFallback()
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** legend 미지정 시 폴백 테마. 컴포넌트별로 override (스토커/존 각자 전역 테마). */
|
|
155
|
+
getLegendFallback(): Legend {
|
|
156
|
+
return LEGEND_CAPACITY
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
get statusColor(): string | undefined {
|
|
160
|
+
const { fullup } = (this as any).state
|
|
161
|
+
return fullup ? 'red' : getValueOnRanges(this.usage, this.legend)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get text() {
|
|
165
|
+
// usage% 값은 capacity 모드에서만 표시. carrier/abnormal 은 세그먼트별 자체 라벨을 그리므로
|
|
166
|
+
// base 의 value 텍스트를 억제한다.
|
|
167
|
+
if (this.gaugeMode !== 'capacity') {
|
|
168
|
+
return ''
|
|
169
|
+
}
|
|
170
|
+
return this.usage + '%'
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
render(context: CanvasRenderingContext2D) {
|
|
174
|
+
const mode = this.gaugeMode
|
|
175
|
+
|
|
176
|
+
if (mode === 'carrier' || mode === 'abnormal') {
|
|
177
|
+
this.renderSegmentGauge(context, this.segments(mode))
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// capacity (기본)
|
|
182
|
+
const { width, height } = (this as any).bounds
|
|
183
|
+
if (width >= height) {
|
|
184
|
+
this.renderLandscape(context)
|
|
185
|
+
} else {
|
|
186
|
+
this.renderPortrait(context)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* carrier/abnormal mode 의 세그먼트 목록 (공유 유틸 = 3D 와 동일 계산).
|
|
192
|
+
* 배열 순서 = portrait 아래→위 / landscape 왼→오.
|
|
193
|
+
*/
|
|
194
|
+
segments(mode: string): GaugeSegment[] {
|
|
195
|
+
if (mode === 'abnormal') {
|
|
196
|
+
const { carrierNormal = 0, carrierAbnormal = 0 } = (this as any).state
|
|
197
|
+
return abnormalSegments(carrierNormal, carrierAbnormal)
|
|
198
|
+
}
|
|
199
|
+
const { carrierFull = 0, carrierEmpty = 0, carrierEmptyEmpty = 0 } = (this as any).state
|
|
200
|
+
// 색상은 carrier 컴포넌트와 동일한 legend(테마)에서 취득 (carrierColorsFromLegend).
|
|
201
|
+
const colors = carrierColorsFromLegend(resolveCarrierLegend(this))
|
|
202
|
+
return carrierSegments(carrierFull, carrierEmpty, carrierEmptyEmpty, colors)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* 클릭(또는 hover) 지점이 어떤 세그먼트에 속하는지 판정. carrier/abnormal 모드 전용 —
|
|
207
|
+
* capacity 모드·데이터 없음·좌표 변환 실패 시 null.
|
|
208
|
+
*
|
|
209
|
+
* renderSegmentGauge 와 동일한 배치 규칙으로 매핑한다: landscape(가로) 는 왼→오(누적 x),
|
|
210
|
+
* portrait(세로) 는 아래→위(바닥부터 누적). ratio 0 세그먼트는 화면에 없으므로 건너뛴다.
|
|
211
|
+
*/
|
|
212
|
+
segmentAtEvent(event: MouseEvent): { mode: string; key: string; count: number } | null {
|
|
213
|
+
const mode = this.gaugeMode
|
|
214
|
+
if (mode !== 'carrier' && mode !== 'abnormal') return null
|
|
215
|
+
|
|
216
|
+
// 3D 게이지는 부모 STOCKER 의 real-object 가 그린다(이 컴포넌트가 아님) → 2D 세그먼트 판정 대상 아님.
|
|
217
|
+
if ((this as any).root?.is3dMode) return null
|
|
218
|
+
|
|
219
|
+
const ox = (event as any)?.offsetX
|
|
220
|
+
const oy = (event as any)?.offsetY
|
|
221
|
+
if (typeof ox !== 'number' || typeof oy !== 'number') return null
|
|
222
|
+
|
|
223
|
+
// 표면 픽셀(offsetX/offsetY) → 이 컴포넌트 로컬 프레임.
|
|
224
|
+
// 주의: transcoordP2S 는 '부모→로컬' 한 단계라 캔버스 픽셀로 단독 호출하면 안 된다.
|
|
225
|
+
// 엔진 capture() 와 동일하게 루트부터 전체 체인을 적용하는 helper 가 toLocal.
|
|
226
|
+
let local: { x: number; y: number } | undefined
|
|
227
|
+
try {
|
|
228
|
+
local = (this as any).toLocal(ox, oy)
|
|
229
|
+
} catch {
|
|
230
|
+
return null
|
|
231
|
+
}
|
|
232
|
+
if (!local) return null
|
|
233
|
+
|
|
234
|
+
const { left, top, width, height } = (this as any).bounds
|
|
235
|
+
if (!(width > 0) || !(height > 0)) return null
|
|
236
|
+
|
|
237
|
+
// 컴포넌트 로컬프레임 좌표 → bounds 기준 within-box. 경계 반올림 방어로 clamp.
|
|
238
|
+
const lx = Math.min(Math.max(local.x - left, 0), width)
|
|
239
|
+
const ly = Math.min(Math.max(local.y - top, 0), height)
|
|
240
|
+
|
|
241
|
+
const landscape = width >= height
|
|
242
|
+
const pos = landscape ? lx : height - ly // portrait 는 바닥 기준 거리
|
|
243
|
+
const span = landscape ? width : height
|
|
244
|
+
|
|
245
|
+
const picked = pickSegmentAt(this.segments(mode), pos, span)
|
|
246
|
+
if (!picked) return null
|
|
247
|
+
|
|
248
|
+
// label 은 key 로 도출 가능하고 로케일 의존이라 payload 에서 제외 — key(대문자 토큰)로 식별.
|
|
249
|
+
return { mode, key: picked.key, count: picked.count }
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** 세그먼트 게이지 렌더 (carrier/abnormal 공통). bounds 방향으로 landscape/portrait 자동. */
|
|
253
|
+
renderSegmentGauge(context: CanvasRenderingContext2D, segments: GaugeSegment[]) {
|
|
254
|
+
const { left, top, width, height } = (this as any).bounds
|
|
255
|
+
const { lineWidth, strokeStyle, round, fillStyle = 'white' } = (this as any).state
|
|
256
|
+
const landscape = width >= height
|
|
257
|
+
|
|
258
|
+
context.save()
|
|
259
|
+
context.translate(left, top)
|
|
260
|
+
|
|
261
|
+
// background
|
|
262
|
+
context.beginPath()
|
|
263
|
+
context.fillStyle = fillStyle
|
|
264
|
+
context.roundRect(0, 0, width, height, round)
|
|
265
|
+
context.fill()
|
|
266
|
+
context.clip()
|
|
267
|
+
|
|
268
|
+
if (landscape) {
|
|
269
|
+
// 왼→오
|
|
270
|
+
let x = 0
|
|
271
|
+
for (const seg of segments) {
|
|
272
|
+
const segWidth = width * seg.ratio
|
|
273
|
+
if (segWidth <= 0) continue
|
|
274
|
+
|
|
275
|
+
context.beginPath()
|
|
276
|
+
context.fillStyle = seg.color
|
|
277
|
+
context.rect(x, 0, segWidth, height)
|
|
278
|
+
context.fill()
|
|
279
|
+
|
|
280
|
+
this._drawSegmentLabel(context, seg, x, 0, segWidth, height)
|
|
281
|
+
x += segWidth
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
// 아래→위 (배열 첫 세그먼트가 바닥)
|
|
285
|
+
let y = height
|
|
286
|
+
for (const seg of segments) {
|
|
287
|
+
const segHeight = height * seg.ratio
|
|
288
|
+
if (segHeight <= 0) continue
|
|
289
|
+
|
|
290
|
+
y -= segHeight
|
|
291
|
+
|
|
292
|
+
context.beginPath()
|
|
293
|
+
context.fillStyle = seg.color
|
|
294
|
+
context.rect(0, y, width, segHeight)
|
|
295
|
+
context.fill()
|
|
296
|
+
|
|
297
|
+
this._drawSegmentLabel(context, seg, 0, y, width, segHeight)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// outline
|
|
302
|
+
context.beginPath()
|
|
303
|
+
context.setLineDash([])
|
|
304
|
+
context.strokeStyle = strokeStyle
|
|
305
|
+
context.lineWidth = lineWidth
|
|
306
|
+
context.roundRect(0, 0, width, height, round)
|
|
307
|
+
context.stroke()
|
|
308
|
+
|
|
309
|
+
context.translate(-left, -top)
|
|
310
|
+
context.restore()
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private _drawSegmentLabel(
|
|
314
|
+
context: CanvasRenderingContext2D,
|
|
315
|
+
seg: GaugeSegment,
|
|
316
|
+
x: number,
|
|
317
|
+
y: number,
|
|
318
|
+
w: number,
|
|
319
|
+
h: number
|
|
320
|
+
) {
|
|
321
|
+
// 이름 라벨(Full/Empty/Abnormal…)은 그리지 않는다. 각 세그먼트 영역 중심에 숫자(%)만 표시.
|
|
322
|
+
// 컴포넌트의 폰트 설정(fontFamily/fontSize/bold/italic)을 그대로 적용 — this.font.
|
|
323
|
+
const fontSize = (this as any).state.fontSize || 15
|
|
324
|
+
context.font = (this as any).font
|
|
325
|
+
|
|
326
|
+
// 공간에 따라 단계적 축소: 넉넉하면 '값%', 좁으면 '%' 떼고 값만, 더 좁으면 생략.
|
|
327
|
+
const value = `${Math.round(seg.ratio * 100)}`
|
|
328
|
+
const fits = (t: string) => fontSize <= h && context.measureText(t).width <= w
|
|
329
|
+
|
|
330
|
+
let text: string | null = null
|
|
331
|
+
if (fits(`${value}%`)) {
|
|
332
|
+
text = `${value}%`
|
|
333
|
+
} else if (fits(value)) {
|
|
334
|
+
text = value
|
|
335
|
+
}
|
|
336
|
+
if (text === null) {
|
|
337
|
+
return
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
context.fillStyle = '#333'
|
|
341
|
+
context.textAlign = 'center'
|
|
342
|
+
context.textBaseline = 'middle'
|
|
343
|
+
context.fillText(text, x + w / 2, y + h / 2)
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
renderLandscape(context: CanvasRenderingContext2D) {
|
|
347
|
+
const { left, top, width, height } = (this as any).bounds
|
|
348
|
+
const { highWatermark, lowWatermark, lineWidth, strokeStyle, round, fillStyle = 'white' } = (this as any).state
|
|
349
|
+
|
|
350
|
+
context.save()
|
|
351
|
+
context.translate(left, top)
|
|
352
|
+
|
|
353
|
+
// gauge background
|
|
354
|
+
context.beginPath()
|
|
355
|
+
|
|
356
|
+
context.fillStyle = fillStyle
|
|
357
|
+
context.roundRect(0, 0, width, height, round)
|
|
358
|
+
|
|
359
|
+
context.fill()
|
|
360
|
+
|
|
361
|
+
context.clip()
|
|
362
|
+
|
|
363
|
+
// gauge foreground
|
|
364
|
+
context.beginPath()
|
|
365
|
+
|
|
366
|
+
context.fillStyle = this.statusColor!
|
|
367
|
+
|
|
368
|
+
context.rect(0, 0, (width / 100) * this.usage, height)
|
|
369
|
+
context.fill()
|
|
370
|
+
|
|
371
|
+
// high-watermark level
|
|
372
|
+
|
|
373
|
+
if (highWatermark && highWatermark > 0 && highWatermark < 100) {
|
|
374
|
+
context.beginPath()
|
|
375
|
+
|
|
376
|
+
context.strokeStyle = 'black'
|
|
377
|
+
context.lineWidth = 1
|
|
378
|
+
context.setLineDash([3])
|
|
379
|
+
|
|
380
|
+
const x = (width / 100) * highWatermark
|
|
381
|
+
context.moveTo(x, 0)
|
|
382
|
+
context.lineTo(x, height)
|
|
383
|
+
|
|
384
|
+
context.stroke()
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// low-watermark level
|
|
388
|
+
|
|
389
|
+
if (lowWatermark && lowWatermark > 0 && lowWatermark < 100) {
|
|
390
|
+
context.beginPath()
|
|
391
|
+
|
|
392
|
+
context.strokeStyle = 'black'
|
|
393
|
+
context.lineWidth = 1
|
|
394
|
+
context.setLineDash([3])
|
|
395
|
+
|
|
396
|
+
const x = (width / 100) * lowWatermark
|
|
397
|
+
context.moveTo(x, 0)
|
|
398
|
+
context.lineTo(x, height)
|
|
399
|
+
|
|
400
|
+
context.stroke()
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// gauge outline
|
|
404
|
+
context.beginPath()
|
|
405
|
+
|
|
406
|
+
context.setLineDash([])
|
|
407
|
+
context.strokeStyle = strokeStyle
|
|
408
|
+
context.lineWidth = lineWidth
|
|
409
|
+
context.roundRect(0, 0, width, height, round)
|
|
410
|
+
context.stroke()
|
|
411
|
+
|
|
412
|
+
context.beginPath()
|
|
413
|
+
|
|
414
|
+
context.translate(-left, -top)
|
|
415
|
+
context.restore()
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
renderPortrait(context: CanvasRenderingContext2D) {
|
|
419
|
+
const { left, top, width, height } = (this as any).bounds
|
|
420
|
+
const { highWatermark, lowWatermark, lineWidth, strokeStyle, round, fillStyle = 'white' } = (this as any).state
|
|
421
|
+
|
|
422
|
+
context.save()
|
|
423
|
+
context.translate(left, top)
|
|
424
|
+
|
|
425
|
+
// gauge background
|
|
426
|
+
context.beginPath()
|
|
427
|
+
|
|
428
|
+
context.fillStyle = fillStyle
|
|
429
|
+
context.roundRect(0, 0, width, height, round)
|
|
430
|
+
|
|
431
|
+
context.fill()
|
|
432
|
+
|
|
433
|
+
context.clip()
|
|
434
|
+
|
|
435
|
+
// gauge foreground
|
|
436
|
+
context.beginPath()
|
|
437
|
+
|
|
438
|
+
context.fillStyle = this.statusColor!
|
|
439
|
+
|
|
440
|
+
context.rect(0, height - (height / 100) * this.usage, width, (height / 100) * this.usage)
|
|
441
|
+
context.fill()
|
|
442
|
+
|
|
443
|
+
// high-watermark level
|
|
444
|
+
|
|
445
|
+
if (highWatermark && highWatermark > 0 && highWatermark < 100) {
|
|
446
|
+
context.beginPath()
|
|
447
|
+
|
|
448
|
+
context.strokeStyle = 'black'
|
|
449
|
+
context.lineWidth = 1
|
|
450
|
+
context.setLineDash([3])
|
|
451
|
+
|
|
452
|
+
const y = height - (height / 100) * highWatermark
|
|
453
|
+
context.moveTo(0, y)
|
|
454
|
+
context.lineTo(width, y)
|
|
455
|
+
|
|
456
|
+
context.stroke()
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// low-watermark level
|
|
460
|
+
|
|
461
|
+
if (lowWatermark && lowWatermark > 0 && lowWatermark < 100) {
|
|
462
|
+
context.beginPath()
|
|
463
|
+
|
|
464
|
+
context.strokeStyle = 'black'
|
|
465
|
+
context.lineWidth = 1
|
|
466
|
+
context.setLineDash([3])
|
|
467
|
+
|
|
468
|
+
const y = height - (height / 100) * lowWatermark
|
|
469
|
+
context.moveTo(0, y)
|
|
470
|
+
context.lineTo(width, y)
|
|
471
|
+
|
|
472
|
+
context.stroke()
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// gauge outline
|
|
476
|
+
context.beginPath()
|
|
477
|
+
|
|
478
|
+
context.setLineDash([])
|
|
479
|
+
context.strokeStyle = strokeStyle
|
|
480
|
+
context.lineWidth = lineWidth
|
|
481
|
+
context.roundRect(0, 0, width, height, round)
|
|
482
|
+
context.stroke()
|
|
483
|
+
|
|
484
|
+
context.beginPath()
|
|
485
|
+
|
|
486
|
+
context.translate(-left, -top)
|
|
487
|
+
context.restore()
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
get usage() {
|
|
491
|
+
const { currentUsage = 0, maxCapacity = 100 } = (this as any).state
|
|
492
|
+
return Math.round((currentUsage / maxCapacity) * 100)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
set usage(usage: number) {
|
|
496
|
+
// intentionally have done nothing
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
onchangeData(after: Record<string, any>, before: Record<string, any>): void {
|
|
500
|
+
const data = (this as any).data && typeof (this as any).data == 'object' ? (this as any).data : {}
|
|
501
|
+
const {
|
|
502
|
+
CURRENTCAPACITY = 0,
|
|
503
|
+
MAXCAPACITY = 100,
|
|
504
|
+
HIGHWATERMARK = 100,
|
|
505
|
+
LOWWATERMARK = 0,
|
|
506
|
+
FULLUP = 'F',
|
|
507
|
+
CARRIER_FULL = 0,
|
|
508
|
+
CARRIER_EMPTY = 0,
|
|
509
|
+
CARRIER_EMPTY_EMPTY = 0,
|
|
510
|
+
CARRIER_NORMAL = 0,
|
|
511
|
+
CARRIER_ABNORMAL = 0
|
|
512
|
+
} = data
|
|
513
|
+
|
|
514
|
+
const currentUsage = Number(CURRENTCAPACITY) || 0
|
|
515
|
+
const maxCapacity = Number(MAXCAPACITY) || 100
|
|
516
|
+
const highWatermark = Number(HIGHWATERMARK) || 100
|
|
517
|
+
const lowWatermark = Number(LOWWATERMARK) || 0
|
|
518
|
+
|
|
519
|
+
;(this as any).setState({
|
|
520
|
+
currentUsage,
|
|
521
|
+
maxCapacity,
|
|
522
|
+
highWatermark,
|
|
523
|
+
lowWatermark,
|
|
524
|
+
fullup: FULLUP == 'T',
|
|
525
|
+
usage: Math.round((currentUsage / maxCapacity) * 100),
|
|
526
|
+
carrierFull: Number(CARRIER_FULL) || 0,
|
|
527
|
+
carrierEmpty: Number(CARRIER_EMPTY) || 0,
|
|
528
|
+
carrierEmptyEmpty: Number(CARRIER_EMPTY_EMPTY) || 0,
|
|
529
|
+
carrierNormal: Number(CARRIER_NORMAL) || 0,
|
|
530
|
+
carrierAbnormal: Number(CARRIER_ABNORMAL) || 0
|
|
531
|
+
})
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// ── hover 툴팁 (carrier/abnormal 모드 세그먼트별 수치) ───────────────────────────
|
|
535
|
+
// 색상만으로 타입 구분이 어려울 때, 마우스 hover 로 정확한 수치 확인. 뷰어 모드 전용
|
|
536
|
+
// (model-layer 가 편집 모드에선 hover dispatch 안 함).
|
|
537
|
+
|
|
538
|
+
async ready(): Promise<void> {
|
|
539
|
+
await super.ready()
|
|
540
|
+
// hover 이벤트 수신 opt-in: model-layer _onmouseenter_all guard(hasLegacyHover) 통과.
|
|
541
|
+
const ev = (this as any).model.event
|
|
542
|
+
if (!ev || !ev.hover) {
|
|
543
|
+
;(this as any).model.event = { ...(ev || {}), hover: true }
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
onMouseEnter(): void {
|
|
548
|
+
// capacity 는 값이 한 개(usage%)라 툴팁 불필요. carrier/abnormal 만.
|
|
549
|
+
if (this.gaugeMode === 'capacity') return
|
|
550
|
+
this._showGaugeTooltip()
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
onMouseLeave(): void {
|
|
554
|
+
this._hideGaugeTooltip()
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
dispose(): void {
|
|
558
|
+
this._hideGaugeTooltip()
|
|
559
|
+
super.dispose()
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
private _tooltipEl?: HTMLDivElement
|
|
563
|
+
private _tooltipMove?: (e: MouseEvent) => void
|
|
564
|
+
|
|
565
|
+
private _showGaugeTooltip(): void {
|
|
566
|
+
if (typeof document === 'undefined') return
|
|
567
|
+
const segments = this.segments(this.gaugeMode).filter(s => s.count > 0)
|
|
568
|
+
if (!segments.length) return
|
|
569
|
+
|
|
570
|
+
this._hideGaugeTooltip()
|
|
571
|
+
|
|
572
|
+
const el = document.createElement('div')
|
|
573
|
+
el.style.cssText = [
|
|
574
|
+
'position:fixed',
|
|
575
|
+
'left:-9999px',
|
|
576
|
+
'top:0',
|
|
577
|
+
'z-index:2147483647',
|
|
578
|
+
'pointer-events:none',
|
|
579
|
+
'background:rgba(30,30,30,0.92)',
|
|
580
|
+
'color:#fff',
|
|
581
|
+
'padding:6px 9px',
|
|
582
|
+
'border-radius:6px',
|
|
583
|
+
'font:12px/1.5 sans-serif',
|
|
584
|
+
'box-shadow:0 2px 10px rgba(0,0,0,0.35)',
|
|
585
|
+
'white-space:nowrap'
|
|
586
|
+
].join(';')
|
|
587
|
+
|
|
588
|
+
for (const seg of segments) {
|
|
589
|
+
const row = document.createElement('div')
|
|
590
|
+
row.style.cssText = 'display:flex;align-items:center;gap:6px'
|
|
591
|
+
|
|
592
|
+
const swatch = document.createElement('span')
|
|
593
|
+
swatch.style.cssText = `display:inline-block;width:10px;height:10px;border-radius:2px;background:${seg.color}`
|
|
594
|
+
|
|
595
|
+
const label = document.createElement('span')
|
|
596
|
+
label.textContent = seg.label.replace(/\n/g, ' ')
|
|
597
|
+
label.style.cssText = 'flex:1'
|
|
598
|
+
|
|
599
|
+
const value = document.createElement('span')
|
|
600
|
+
value.textContent = String(seg.count)
|
|
601
|
+
value.style.cssText = 'font-weight:700;margin-left:12px'
|
|
602
|
+
|
|
603
|
+
row.append(swatch, label, value)
|
|
604
|
+
el.appendChild(row)
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
document.body.appendChild(el)
|
|
608
|
+
this._tooltipEl = el
|
|
609
|
+
|
|
610
|
+
this._tooltipMove = (e: MouseEvent) => {
|
|
611
|
+
el.style.left = `${e.clientX + 14}px`
|
|
612
|
+
el.style.top = `${e.clientY + 14}px`
|
|
613
|
+
}
|
|
614
|
+
document.addEventListener('mousemove', this._tooltipMove, true)
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
private _hideGaugeTooltip(): void {
|
|
618
|
+
if (this._tooltipMove) {
|
|
619
|
+
document.removeEventListener('mousemove', this._tooltipMove, true)
|
|
620
|
+
this._tooltipMove = undefined
|
|
621
|
+
}
|
|
622
|
+
if (this._tooltipEl) {
|
|
623
|
+
this._tooltipEl.remove()
|
|
624
|
+
this._tooltipEl = undefined
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
@@ -369,8 +369,9 @@ RootContainer.prototype._refreshStockerGauges = function () {
|
|
|
369
369
|
if (type === 'STOCKER') {
|
|
370
370
|
// 3D 게이지는 스토커 자신의 real-object 가 그린다 → 재빌드 (2D 모드면 _realObject 없음)
|
|
371
371
|
c._realObject?.update?.()
|
|
372
|
-
} else if (type === 'StockerCapacityBar' || type === 'MCSGaugeCapacityBar') {
|
|
373
|
-
// 2D
|
|
372
|
+
} else if (type === 'StockerCapacityBar' || type === 'MCSGaugeCapacityBar' || type === 'ZoneCapacityBar') {
|
|
373
|
+
// 2D 게이지(스토커·존)는 자식 컴포넌트가 그린다 → 리드로우.
|
|
374
|
+
// 존 게이지도 스토커 게이지와 같은 stockerGaugeMode 스위치로 함께 전환된다.
|
|
374
375
|
c.invalidate?.()
|
|
375
376
|
}
|
|
376
377
|
walk(c)
|