|
|
@@ -49,7 +49,7 @@ import {
|
|
|
// 票 83:几何读数(本体宽 / 绘制宽 / pad)与计划读数同一出口,走查不读 DOM 内部结构。
|
|
|
import { markerGeometryDataset } from '../domain/markerPlan.js'
|
|
|
// 本票:未关联设备的屏幕拥挤聚合(纯 domain;本层只负责投影/渲染/点击)。
|
|
|
-import { AGGREGATE_BADGE, AGGREGATE_KIND, aggregateBadge, canZoomAggregate, depthZIndex, groupMonitoringPointsByScreen, groupUnassociatedByScreen, labelOccludedByAggregates, planMemberList, stabilizeZIndex } from '../domain/pointAggregation.js'
|
|
|
+import { AGGREGATE_BADGE, AGGREGATE_KIND, aggregateBadge, canZoomAggregate, groupMonitoringPointsByScreen, groupUnassociatedByScreen, labelOccludedByAggregates, planMemberList, rankByDepth } from '../domain/pointAggregation.js'
|
|
|
|
|
|
/**
|
|
|
* 类名单源:注入的特效 CSS(下方模板串)与 DOM 构建(buildNode/mount)共用同一组常量。
|
|
|
@@ -907,11 +907,15 @@ function applyLabelState(record, visible, expanded) {
|
|
|
if (record.labelBox.style.maxWidth !== wantedWidth) record.labelBox.style.maxWidth = wantedWidth
|
|
|
}
|
|
|
|
|
|
-/** 深度 z 的迟滞出口:同一记录只有跨过缓冲才换层,避免相机微动时反复交换。 */
|
|
|
-function stableDepth(record, next) {
|
|
|
- const stable = stabilizeZIndex(record.zIndex, next)
|
|
|
- record.zIndex = stable
|
|
|
- return stable
|
|
|
+/** 上一帧的全局深度序号:近似同深时用它保持相对顺序。 */
|
|
|
+let depthRanks = new Map()
|
|
|
+
|
|
|
+/** 聚合组的深度取组内最近成员(显示入口靠近它代表的最近真实对象)。 */
|
|
|
+function groupDistanceOf(group) {
|
|
|
+ return (group.members || []).reduce((min, member) => {
|
|
|
+ const value = member.screen && Number.isFinite(member.screen.distance) ? member.screen.distance : Number.POSITIVE_INFINITY
|
|
|
+ return Math.min(min, value)
|
|
|
+ }, Number.POSITIVE_INFINITY)
|
|
|
}
|
|
|
|
|
|
/** 标签跟随节点位移(与节点同一次 transform;不逐帧读布局)。 */
|
|
|
@@ -1128,12 +1132,8 @@ function renderAggregates(groups, tones) {
|
|
|
aggregatePool.set(key, record)
|
|
|
hostNode.appendChild(record.root)
|
|
|
}
|
|
|
- // 深度排序:聚合徽章参与同一套画家算法,不再绝对置顶(近的图标可压住远的徽章)。
|
|
|
- const groupDistance = group.members.reduce((min, member) => {
|
|
|
- const value = member.screen && Number.isFinite(member.screen.distance) ? member.screen.distance : 1e8
|
|
|
- return Math.min(min, value)
|
|
|
- }, Infinity)
|
|
|
- const badgeZ = String(stableDepth(record, depthZIndex(groupDistance) * 2))
|
|
|
+ // 深度排序:徽章用本帧全局序号(组内最近成员的距离已参与排序),不再绝对置顶。
|
|
|
+ const badgeZ = String((depthRanks.get(group.groupKey) || 1) * 2)
|
|
|
if (record.root.style.zIndex !== badgeZ) record.root.style.zIndex = badgeZ
|
|
|
const transform = 'translate(' + group.screen.x + 'px, ' + group.screen.y + 'px) translate(-50%, -50%)'
|
|
|
if (record.root.style.transform !== transform) record.root.style.transform = transform
|
|
|
@@ -1451,6 +1451,44 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
|
|
|
const badgeCenters = badgeGroups.map((group) => group.screen)
|
|
|
const labelBlockedByAggregate = (pos) => labelOccludedByAggregates(pos, badgeCenters)
|
|
|
|
|
|
+ // 深度排序(2026-11-25):先收集本帧全部可见对象,一次全局排序分配**唯一**序号;
|
|
|
+ // 不再逐条算 z(同 z 会退回 DOM 顺序,徽章重建就会闪)。距离近似时沿用上一帧顺序。
|
|
|
+ const facilityPositions = new Map()
|
|
|
+ for (const facility of facilities || []) {
|
|
|
+ const key = facility.key || `facility-point|${facility.code}`
|
|
|
+ if (!Number.isFinite(facility.longitude) || !Number.isFinite(facility.latitude)) continue
|
|
|
+ const pos = projectToWindow(facility.longitude, facility.latitude)
|
|
|
+ if (pos && Number.isFinite(pos.x) && Number.isFinite(pos.y)) facilityPositions.set(key, pos)
|
|
|
+ }
|
|
|
+ const componentPositions = new Map()
|
|
|
+ for (const component of pipeComponentsVisible === false ? [] : (pipeComponents || [])) {
|
|
|
+ const key = component.key || `pipe-component|${component.code}`
|
|
|
+ if (!Number.isFinite(component.longitude) || !Number.isFinite(component.latitude)) continue
|
|
|
+ const pos = projectToWindow(component.longitude, component.latitude)
|
|
|
+ if (pos && Number.isFinite(pos.x) && Number.isFinite(pos.y)) componentPositions.set(key, pos)
|
|
|
+ }
|
|
|
+ const depthEntries = []
|
|
|
+ for (const marker of markers || []) {
|
|
|
+ if (!marker) continue
|
|
|
+ const key = `${marker.kind}|${marker.code}`
|
|
|
+ if (groupedMemberKeys.has(key)) continue
|
|
|
+ const pos = windowPositions.get(key)
|
|
|
+ if (!pos) continue
|
|
|
+ depthEntries.push({ key, distance: pos.distance })
|
|
|
+ }
|
|
|
+ for (const device of devices || []) {
|
|
|
+ if (!device || !device.code) continue
|
|
|
+ depthEntries.push({ key: device.key || `device|${device.code}`, distance: device.distance })
|
|
|
+ }
|
|
|
+ for (const [key, pos] of facilityPositions.entries()) depthEntries.push({ key, distance: pos.distance })
|
|
|
+ for (const [key, pos] of componentPositions.entries()) depthEntries.push({ key, distance: pos.distance })
|
|
|
+ for (const row of aggregates || []) {
|
|
|
+ if (row && row.key) depthEntries.push({ key: row.key, distance: row.distance })
|
|
|
+ }
|
|
|
+ for (const group of badgeGroups) depthEntries.push({ key: group.groupKey, distance: groupDistanceOf(group) })
|
|
|
+ depthRanks = rankByDepth(depthEntries, { previousRanks: depthRanks })
|
|
|
+ const depthZOf = (key) => (depthRanks.get(key) || 1) * 2
|
|
|
+
|
|
|
for (const marker of markers || []) {
|
|
|
const key = `${marker.kind}|${marker.code}`
|
|
|
// 聚合组成员不单独渲染(选中成员不在组里,仍会正常显示)。
|
|
|
@@ -1509,9 +1547,8 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
|
|
|
// 深度排序:图标 = 2z,标签 = 2z+1(标签略高于自身图标,低于更近的图标)。
|
|
|
// 04:已选中的监测点单独显示时置顶,且标签不被邻近聚合折叠 —— 否则「保持选择」只剩一个点。
|
|
|
const selectedPoint = marker.kind === 'monitoring-point' && marker.code === selectedPointCode
|
|
|
- // 901 > depthZIndex 上限 900:选中点连同标签压过所有徽章(图标 1802、标签 1803)。
|
|
|
- // 其余图标走 stableDepth:距离接近时不交换层级(深度迟滞)。
|
|
|
- const markerZNum = selectedPoint ? 1802 : stableDepth(record, depthZIndex(windowPos.distance) * 2)
|
|
|
+ // 选中点固定压过所有图标(9000/9001);其余用本帧全局唯一序号。
|
|
|
+ const markerZNum = selectedPoint ? 9000 : depthZOf(key)
|
|
|
const markerZ = String(markerZNum)
|
|
|
if (record.root.style.zIndex !== markerZ) record.root.style.zIndex = markerZ
|
|
|
if (record.labelWrap) {
|
|
|
@@ -1610,7 +1647,7 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
|
|
|
// · ④ 设备被选择的中心设备:隐藏(与 ② 聚合被选择态同性质)。
|
|
|
// · 非聚合设备点(k=1 关联设备):**始终显示** —— 聚合规则不得外溢到它们。
|
|
|
const devicePos = { x: device.x - hostOffset.x, y: device.y - hostOffset.y }
|
|
|
- const deviceZNum = stableDepth(record, depthZIndex(device.distance) * 2)
|
|
|
+ const deviceZNum = depthZOf('device|' + device.code)
|
|
|
const deviceZ = String(deviceZNum)
|
|
|
if (record.root.style.zIndex !== deviceZ) record.root.style.zIndex = deviceZ
|
|
|
if (record.labelWrap) {
|
|
|
@@ -1677,7 +1714,7 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
|
|
|
// 票 76(四态):① 的 hover 预览与 ② 的固定态都隐藏聚合标签(让出设备环);
|
|
|
// ③④ 中心已是设备点 → 整枚聚合节点让位(标签随之隐藏)。
|
|
|
// 2026-11-24:标签与图标同宿主、按相机距离交错层级。
|
|
|
- const aggZNum = stableDepth(record, depthZIndex(row.distance) * 2)
|
|
|
+ const aggZNum = depthZOf(row.key)
|
|
|
const aggZ = String(aggZNum)
|
|
|
if (record.root.style.zIndex !== aggZ) record.root.style.zIndex = aggZ
|
|
|
if (record.labelWrap) {
|
|
|
@@ -1699,8 +1736,8 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
|
|
|
const key = facility.key || `facility-point|${facility.code}`
|
|
|
wanted.add(key)
|
|
|
if (!Number.isFinite(facility.longitude) || !Number.isFinite(facility.latitude)) { hidePooledNode(key); continue }
|
|
|
- const windowPos = projectToWindow(facility.longitude, facility.latitude)
|
|
|
- if (!windowPos || !Number.isFinite(windowPos.x) || !Number.isFinite(windowPos.y)) { hidePooledNode(key); continue }
|
|
|
+ const windowPos = facilityPositions.get(key)
|
|
|
+ if (!windowPos) { hidePooledNode(key); continue }
|
|
|
|
|
|
const marker = { ...facility, kind: 'facility-point' }
|
|
|
const plan = facilityPlanOf(marker)
|
|
|
@@ -1738,7 +1775,7 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
|
|
|
const transform = `translate(${windowPos.x}px, ${windowPos.y}px)`
|
|
|
if (record.root.style.transform !== transform) record.root.style.transform = transform
|
|
|
if (record.root.style.display !== 'block') record.root.style.display = 'block'
|
|
|
- const facilityZNum = stableDepth(record, depthZIndex(windowPos.distance) * 2)
|
|
|
+ const facilityZNum = depthZOf(key)
|
|
|
const facilityZ = String(facilityZNum)
|
|
|
if (record.root.style.zIndex !== facilityZ) record.root.style.zIndex = facilityZ
|
|
|
if (record.labelWrap) {
|
|
|
@@ -1761,8 +1798,8 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
|
|
|
const key = component.key || `pipe-component|${component.code}`
|
|
|
wanted.add(key)
|
|
|
if (!Number.isFinite(component.longitude) || !Number.isFinite(component.latitude)) { hidePooledNode(key); continue }
|
|
|
- const windowPos = projectToWindow(component.longitude, component.latitude)
|
|
|
- if (!windowPos || !Number.isFinite(windowPos.x) || !Number.isFinite(windowPos.y)) { hidePooledNode(key); continue }
|
|
|
+ const windowPos = componentPositions.get(key)
|
|
|
+ if (!windowPos) { hidePooledNode(key); continue }
|
|
|
|
|
|
const marker = { ...component, kind: 'pipe-component' }
|
|
|
const plan = componentPlanOf(marker)
|
|
|
@@ -1791,7 +1828,7 @@ export function syncMarkerOverlay({ markers, devices, aggregates, facilities, se
|
|
|
const transform = `translate(${windowPos.x}px, ${windowPos.y}px)`
|
|
|
if (record.root.style.transform !== transform) record.root.style.transform = transform
|
|
|
if (record.root.style.display !== 'block') record.root.style.display = 'block'
|
|
|
- const componentZNum = stableDepth(record, depthZIndex(windowPos.distance) * 2)
|
|
|
+ const componentZNum = depthZOf(key)
|
|
|
const componentZ = String(componentZNum)
|
|
|
if (record.root.style.zIndex !== componentZ) record.root.style.zIndex = componentZ
|
|
|
if (record.labelWrap) {
|