From be4df532191c8d82f6ce6128ae22fc0ad6cc207c Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 15 Jul 2024 16:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=8C=97=E4=BA=AC=E9=83=A8?= =?UTF-8?q?=E5=88=86=E8=AE=A1=E8=BD=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../axleCounting/AxleCountingDrawAssistant.ts | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 519a30d..b1dbfe7 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -14,12 +14,12 @@ import { IAxleCountingData, AxleCounting, AxleCountingTemplate, - AxleCountingConsts, } from './AxleCounting'; import { Section, SectionPort } from '../section/Section'; import { Turnout, TurnoutPort } from '../turnout/Turnout'; import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics'; import { Signal } from '../signal/Signal'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; export interface IAxleCountingDrawOptions { newData: () => IAxleCountingData; @@ -112,14 +112,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< const refData2 = createRelatedRefProto(graphic.type, graphic.id, port); const axleCounting = new AxleCounting(direction); axleCounting.loadData(this.graphicTemplate.datas); - if (graphic.type == 'Turnout') { - axleCounting.position.set(ps.x, ps.y); - } else { - axleCounting.position.set( - ps.x, - ps.y - AxleCountingConsts.offsetSection * direction - ); - } + axleCounting.position.set(ps.x, ps.y); axleCounting.id = GraphicIdGenerator.next(); axleCounting.datas.axleCountingRef = [refData2, refData1]; axleCounting.datas.code = `${graphic.datas.code}-${port}+${refGraphic.datas.code}-${refPort}`; @@ -139,14 +132,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< const refData = createRelatedRefProto(graphic.type, graphic.id, port); const axleCounting = new AxleCounting(direction); axleCounting.loadData(this.graphicTemplate.datas); - if (graphic.type == 'Turnout') { - axleCounting.position.set(ps.x, ps.y); - } else { - axleCounting.position.set( - ps.x, - ps.y - AxleCountingConsts.offsetSection * direction - ); - } + axleCounting.position.set(ps.x, ps.y); axleCounting.id = GraphicIdGenerator.next(); axleCounting.datas.axleCountingRef = [refData]; axleCounting.datas.code = `${graphic.datas.code}-${port}`; @@ -156,9 +142,28 @@ export class AxleCountingDraw extends GraphicDrawAssistant< } oneGenerates(height: Point) { const map = new Map(); - const axleCountings = this.app.queryStore.queryByType( - AxleCounting.Type - ); + const needDelete: AxleCounting[] = []; + const axleCountings = this.app.queryStore + .queryByType(AxleCounting.Type) + .filter((axleCounting) => { + if (axleCounting.datas.axleCountingRef.length == 1) { + const refInfo = axleCounting.datas.axleCountingRef[0]; + if (refInfo.deviceType == graphicData.RelatedRef.DeviceType.Section) { + const refSection = this.app.queryStore.queryById
( + refInfo.id + ); + if ( + refSection.datas.paRef != undefined && + refSection.datas.pbRef != undefined + ) { + needDelete.push(axleCounting); + return false; + } + } + } + return true; + }); + this.app.deleteGraphics(...needDelete); const axleCountingRefs: IRelatedRefData[] = []; axleCountings.forEach((axleCounting) => { axleCountingRefs.push(...axleCounting.datas.axleCountingRef);