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);