diff --git a/src/graphics/link/Link.ts b/src/graphics/link/Link.ts index 7dd72e3..0316a37 100644 --- a/src/graphics/link/Link.ts +++ b/src/graphics/link/Link.ts @@ -10,8 +10,9 @@ import { } from 'src/jl-graphic'; import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin'; import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { AxleCounting } from '../axleCounting/AxleCounting'; import { IRelatedRefData, DevicePosition } from '../CommonGraphics'; -import { Section } from '../section/Section'; +import { Section, SectionPort } from '../section/Section'; import { Turnout } from '../turnout/Turnout'; export interface ILinkData extends GraphicData { @@ -95,11 +96,14 @@ export class Link extends JlGraphic implements ILineGraphic { getDevicePoint(id: string, devicePort: number) { const device = this.queryStore.queryById(id); - if (device.type === Section.Type) { - if (devicePort === graphicData.RelatedRef.DevicePort.A) { - return device.localToCanvasPoint((device as Section).getStartPoint()); - } else if (devicePort === graphicData.RelatedRef.DevicePort.B) { - return device.localToCanvasPoint((device as Section).getEndPoint()); + if (device.type === AxleCounting.Type) { + const relations = device.queryRelationByType(Section.Type); + const relation = relations[0].getOtherRelationParam(device); + const section = relations[0].getOtherGraphic
(device); + if (relation.param === SectionPort.A) { + return section.localToCanvasPoint(section.getStartPoint()); + } else if (relation.param === SectionPort.B) { + return section.localToCanvasPoint(section.getEndPoint()); } else { console.error(devicePort, device); throw new Error('Link关联设备端口错误!');