From d684043743e870189dea7569ea5013dc2d3bfa1e Mon Sep 17 00:00:00 2001 From: fan Date: Fri, 4 Aug 2023 15:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BD=A6=E8=AE=A1=E7=AE=97=E8=BD=A6?= =?UTF-8?q?=E6=AC=A1=E7=AA=97=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/train/Train.ts | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/graphics/train/Train.ts b/src/graphics/train/Train.ts index 67c165a..2e8f44f 100644 --- a/src/graphics/train/Train.ts +++ b/src/graphics/train/Train.ts @@ -13,6 +13,7 @@ import { state } from 'src/protos/device_status'; import { TrainWindow } from '../trainWindow/TrainWindow'; import { Turnout } from '../turnout/Turnout'; import { LogicSection } from '../logicSection/LogicSection'; +import { Section } from '../section/Section'; export interface ITrainData extends GraphicData { get code(): string; // 车号 @@ -201,7 +202,7 @@ export class TrainHead extends Container { aColor = DiriveModelColorEnum.RM; pColor = DiriveModelColorEnum.RM; } - if (states.mode?.ipModeTrainBerthed) { + if (states.mode?.ipModeTrainStoped) { this.pause.lineStyle(pauseW, pColor, 1); this.pause.moveTo(pausePoint[0], pausePoint[1]); this.pause.lineTo(pausePoint[2], pausePoint[3]); @@ -405,14 +406,28 @@ export class Train extends JlGraphic { this.states.devName, deviceTypeString.get(this.states.devType) ); - const windowRelations = dev?.queryRelationByType(TrainWindow.Type); - if (!windowRelations || !windowRelations.length || !dev) { + if (!dev) { return; } - const p = windowRelations[0] - ?.getOtherGraphic(dev) - .getPositionOnCanvas(); + let window = null; + if (dev.type === Turnout.Type) { + const sectionRelations = dev.queryRelationByType(Section.Type); + const sectionRel = sectionRelations.find((relation) => { + const sec = relation.getOtherGraphic
(dev); + return sec.datas.children.includes(dev.datas.id); + }); + const section = sectionRel?.getOtherGraphic
(dev); + if (section) { + const windowRelations = section.queryRelationByType(TrainWindow.Type); + window = windowRelations[0]?.getOtherGraphic(section); + } + } else { + const windowRelations = dev.queryRelationByType(TrainWindow.Type); + window = windowRelations[0]?.getOtherGraphic(dev); + } + const p = window?.getPositionOnCanvas(); if (!p) { + console.error('或获取到列车位置'); return; }