diff --git a/bj-rtss-message b/bj-rtss-message index 2a1a715..f0f4152 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit 2a1a7156c02ee902b1801f022ffd8aa6b763c66b +Subproject commit f0f415273f5e188db87ee361e6808e4ec90ceda1 diff --git a/graphic-pixi b/graphic-pixi index f89c8eb..0a0cb0a 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit f89c8eb48de7b2e39a93c4aab9b4e5ff1a9e91b4 +Subproject commit 0a0cb0a77afd9783081c2dc6ba19687b0b3aa0f7 diff --git a/src/components/draw-app/properties/SectionLinkProperty.vue b/src/components/draw-app/properties/SectionLinkProperty.vue index 1052c01..b3215bc 100644 --- a/src/components/draw-app/properties/SectionLinkProperty.vue +++ b/src/components/draw-app/properties/SectionLinkProperty.vue @@ -13,6 +13,53 @@ @blur="onUpdate" label="编号" /> + + + + + A端关联设备 +
+ + {{ aSimRef }} + +
+
+
+ + + B端关联设备 +
+ + {{ bSimRef }} + +
+
+
+ + + A端关联端口设备 +
+ + {{ aRef }} + +
+
+
+ + + B端关联端口设备 +
+ + {{ bRef }} + +
+
+
+
@@ -20,16 +67,61 @@ import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; import { SectionLinkData } from 'src/drawApp/graphics/SectionLinkInteraction'; import { useDrawStore } from 'src/stores/draw-store'; -import { shallowRef, watchEffect } from 'vue'; +import { shallowRef, watchEffect, ref } from 'vue'; +import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; +import { Turnout } from 'src/graphics/turnout/Turnout'; const drawStore = useDrawStore(); const sectionLinkModel = shallowRef(new SectionLinkData()); +const aSimRef = ref(''); +const bSimRef = ref(''); +const aRef = ref(''); +const bRef = ref(''); watchEffect(() => { const sectionLink = drawStore.selectedGraphic; + const portList = ['A', 'B', 'C']; if (sectionLink && sectionLink instanceof SectionLink) { sectionLinkModel.value = sectionLink.saveData(); + aSimRef.value = ''; + bSimRef.value = ''; + aRef.value = ''; + bRef.value = ''; + if (sectionLinkModel.value.aSimRef) { + const g = drawStore + .getDrawApp() + .queryStore.queryById(sectionLinkModel.value.aSimRef.id) as + | AxleCounting + | Turnout; + aSimRef.value = g.datas.code; + } + if (sectionLinkModel.value.bSimRef) { + const g = drawStore + .getDrawApp() + .queryStore.queryById(sectionLinkModel.value.bSimRef.id) as + | AxleCounting + | Turnout; + bSimRef.value = g.datas.code; + } + if (sectionLinkModel.value.aRef) { + const g = drawStore + .getDrawApp() + .queryStore.queryById(sectionLinkModel.value.aRef.id) as + | SectionLink + | Turnout; + aRef.value = + g.datas.code + '_' + portList[sectionLinkModel.value.aRef.devicePort]; + } + if (sectionLinkModel.value.bRef) { + const g = drawStore + .getDrawApp() + .queryStore.queryById(sectionLinkModel.value.bRef.id) as + | SectionLink + | Turnout; + bRef.value = + g.datas.code + '_' + portList[sectionLinkModel.value.bRef.devicePort]; + } } }); diff --git a/src/drawApp/graphics/SectionLinkInteraction.ts b/src/drawApp/graphics/SectionLinkInteraction.ts index c7d0d38..346bc50 100644 --- a/src/drawApp/graphics/SectionLinkInteraction.ts +++ b/src/drawApp/graphics/SectionLinkInteraction.ts @@ -39,11 +39,35 @@ export class SectionLinkData (p) => new graphicData.Point({ x: p.x, y: p.y }) ); } - get refDevice(): string { - return this.data.refDevice; + get up(): boolean { + return this.data.up; } - set refDevice(v: string) { - this.data.refDevice = v; + set up(v: boolean) { + this.data.up = v; + } + get aSimRef(): graphicData.SimpleRef { + return this.data.aSimRef; + } + set aSimRef(v: graphicData.SimpleRef) { + this.data.aSimRef = v; + } + get bSimRef(): graphicData.SimpleRef { + return this.data.bSimRef; + } + set bSimRef(v: graphicData.SimpleRef) { + this.data.bSimRef = v; + } + get aRef(): graphicData.RelatedRef { + return this.data.aRef; + } + set aRef(v: graphicData.RelatedRef) { + this.data.aRef = v; + } + get bRef(): graphicData.RelatedRef { + return this.data.bRef; + } + set bRef(v: graphicData.RelatedRef) { + this.data.bRef = v; } clone(): SectionLinkData { diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 6a3576c..a00aff1 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -9,6 +9,7 @@ import { GraphicApp, GraphicData, JlDrawApp, + JlGraphic, KeyListener, } from 'src/jl-graphic'; import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; @@ -77,6 +78,7 @@ import { LogicSectionTemplate, } from 'src/graphics/logicSection/LogicSection'; import { LogicSectionData } from './graphics/LogicSectionInteraction'; +import { Notify } from 'quasar'; // export function fromStoragePoint(p: graphicData.Point): Point { // return new Point(p.x, p.y); @@ -233,8 +235,18 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { ]; DrawSignalInteraction.init(app); } - - app.setOptions({ drawAssistants: drawAssistants }); + const isSupportDeletion = (g: JlGraphic) => { + if (g.type === LogicSection.Type && g.selected) { + Notify.create({ + type: 'warning', + message: '逻辑区段不支持删除', + timeout: 1000, + }); + return false; + } + return true; + }; + app.setOptions({ drawAssistants: drawAssistants, isSupportDeletion }); // 画布右键菜单 app.registerMenu(DefaultCanvasMenu); @@ -446,9 +458,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.axleCountingSections.forEach((axleCountingSection) => { datas.push(new AxleCountingSectionData(axleCountingSection)); }); - storage.logicSections.forEach((logicSection) => { - datas.push(new LogicSectionData(logicSection)); - }); + // storage.logicSections.forEach((logicSection) => { + // datas.push(new LogicSectionData(logicSection)); + // }); await app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/CommonGraphics.ts b/src/graphics/CommonGraphics.ts index 58777ff..8f1ffcf 100644 --- a/src/graphics/CommonGraphics.ts +++ b/src/graphics/CommonGraphics.ts @@ -114,3 +114,8 @@ export interface IRelatedRefData { id: string; //关联的设备ID devicePort: graphicData.RelatedRef.DevicePort; //关联的设备端口 } + +export interface ISimpleRefData { + deviceType: graphicData.SimpleRef.DeviceType; + id: string; +} diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 7ac26b5..0935ef6 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -15,7 +15,7 @@ import { AxleCounting, AxleCountingTemplate, } from './AxleCounting'; -import { Section, SectionPort, SectionType } from '../section/Section'; +import { Section, SectionPort } from '../section/Section'; import { Turnout, TurnoutPort } from '../turnout/Turnout'; import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics'; import { Signal } from '../signal/Signal'; @@ -191,12 +191,6 @@ export class AxleCountingDraw extends GraphicDrawAssistant< if (axleCountingPs.y > height.y) { direction = -1; } - if ( - section.datas.sectionType === SectionType.Logic || - section.datas.children.includes(refDevice.id) - ) { - return; - } if (refDevice.type == Section.Type || refDevice.type == Turnout.Type) this.draw( axleCountingPs, diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index 6d9e64e..0c54379 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -394,7 +394,6 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin @@ -407,9 +406,8 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin { + points.forEach((ps) => { const data = new LogicSectionData(); data.id = GraphicIdGenerator.next(); data.axleSectionId = axleCountingSection.id; diff --git a/src/graphics/sectionLink/SectionLink.ts b/src/graphics/sectionLink/SectionLink.ts index f085f74..e1f9479 100644 --- a/src/graphics/sectionLink/SectionLink.ts +++ b/src/graphics/sectionLink/SectionLink.ts @@ -9,14 +9,23 @@ import { movePointAlongNormal, } from 'src/jl-graphic'; import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin'; +import { IRelatedRefData, ISimpleRefData } from '../CommonGraphics'; export interface ISectionLinkData extends GraphicData { get code(): string; // 编号 set code(v: string); get points(): IPointData[]; set points(points: IPointData[]); - get refDevice(): string; - set refDevice(v: string); + get up(): boolean; + set up(v: boolean); + get aSimRef(): ISimpleRefData; + set aSimRef(v: ISimpleRefData); + get bSimRef(): ISimpleRefData; + set bSimRef(v: ISimpleRefData); + get aRef(): IRelatedRefData; + set aRef(v: IRelatedRefData); + get bRef(): IRelatedRefData; + set bRef(v: IRelatedRefData); clone(): ISectionLinkData; copyFrom(data: ISectionLinkData): void; eq(other: ISectionLinkData): boolean; diff --git a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts index 626b759..b21e671 100644 --- a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts +++ b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts @@ -25,7 +25,11 @@ import { Section } from '../section/Section'; import { Turnout } from '../turnout/Turnout'; import { AxleCounting } from '../axleCounting/AxleCounting'; import { IRelatedRefData } from '../CommonGraphics'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +const rrDevicePort = graphicData.RelatedRef.DevicePort; +const rrDeviceType = graphicData.RelatedRef.DeviceType; +const srDeviceType = graphicData.SimpleRef.DeviceType; export class SectionLinkDraw extends GraphicDrawAssistant< SectionLinkTemplate, ISectionLinkData @@ -59,15 +63,18 @@ export class SectionLinkDraw extends GraphicDrawAssistant< } }); this.graphic.lineTo(cp.x, cp.y); - console.log(cp, '000'); } prepareData(data: ISectionLinkData): boolean { - console.log(this.points, '000'); data.points = this.points; return true; } - generateBySection(section: Section) { + generateBySection( + section: Section, + refData: IRelatedRefData, + axle1: AxleCounting, + axle2: AxleCounting + ): SectionLink { const sectionLink = new SectionLink(); sectionLink.loadData(this.graphicTemplate.datas); sectionLink.id = GraphicIdGenerator.next(); @@ -76,31 +83,83 @@ export class SectionLinkDraw extends GraphicDrawAssistant< points.push(section.localToCanvasPoint(p)); }); sectionLink.datas.points = points; + const refAxle1 = this.buildSimpleRef(axle1.id, srDeviceType.AxleCounting); + const refAxle2 = this.buildSimpleRef(axle2.id, srDeviceType.AxleCounting); + /** + * 判断link AB端 A端一定在左侧(根据计轴关联区段判断区段AB端是否倒序) + */ + if (points[0].x > points[points.length - 1].x) { + if (refData.devicePort === 0) { + sectionLink.datas.aSimRef = refAxle2; + sectionLink.datas.bSimRef = refAxle1; + } else { + sectionLink.datas.aSimRef = refAxle1; + sectionLink.datas.bSimRef = refAxle2; + } + } else if (points[0].x < points[points.length - 1].x) { + if (refData.devicePort === 0) { + sectionLink.datas.aSimRef = refAxle1; + sectionLink.datas.bSimRef = refAxle2; + } else { + sectionLink.datas.aSimRef = refAxle2; + sectionLink.datas.bSimRef = refAxle1; + } + } else { + throw new Error('无法判断linkAB端'); + } this.storeGraphic(sectionLink); + return sectionLink; } - generateByTurnoutAxle(turnout: Turnout, port: number) { + generateByTurnoutAxle( + turnout: Turnout, + port: graphicData.RelatedRef.DevicePort, + axle: AxleCounting + ): SectionLink { const sectionLink = new SectionLink(); sectionLink.loadData(this.graphicTemplate.datas); sectionLink.id = GraphicIdGenerator.next(); const forkP = new Point(turnout.position.x, turnout.position.y); const points: IPointData[] = [forkP]; - if (port === 0) { + const refTurnout = this.buildRelatedRef( + turnout.id, + rrDeviceType.Turnout, + port + ); + const refSimTurnout = this.buildSimpleRef(turnout.id, srDeviceType.Turnout); + const refAxle = this.buildSimpleRef(axle.id, srDeviceType.AxleCounting); + if (port === rrDevicePort.A) { turnout.datas.pointA.forEach((p) => { points.push(turnout.localToCanvasPoint(p)); }); - } else if (port === 1) { + } else if (port === rrDevicePort.B) { turnout.datas.pointB.forEach((p) => { points.push(turnout.localToCanvasPoint(p)); }); - } else if (port === 2) { + } else if (port === rrDevicePort.C) { turnout.datas.pointC.forEach((p) => { points.push(turnout.localToCanvasPoint(p)); }); } + if (points[0].x > points[points.length - 1].x) { + sectionLink.datas.aSimRef = refAxle; + sectionLink.datas.bSimRef = refSimTurnout; + sectionLink.datas.bRef = refTurnout; + } else if (points[0].x < points[points.length - 1].x) { + sectionLink.datas.bSimRef = refAxle; + sectionLink.datas.aSimRef = refSimTurnout; + sectionLink.datas.aRef = refTurnout; + } else { + throw new Error('无法判断linkAB端'); + } sectionLink.datas.points = points; this.storeGraphic(sectionLink); + return sectionLink; } - generateByTurnout(turnout: Turnout, port: number, pRef: IRelatedRefData) { + generateByTurnout( + turnout: Turnout, + port: graphicData.RelatedRef.DevicePort, + pRef: IRelatedRefData + ) { const refg = this.app.queryStore.queryById(pRef.id) as Turnout; const sectionLink = new SectionLink(); sectionLink.loadData(this.graphicTemplate.datas); @@ -108,6 +167,31 @@ export class SectionLinkDraw extends GraphicDrawAssistant< const forkP1 = new Point(refg.position.x, refg.position.y); const forkP2 = new Point(turnout.position.x, turnout.position.y); const points: IPointData[] = [forkP1]; + const refTurnout1 = this.buildRelatedRef( + turnout.id, + rrDeviceType.Turnout, + port + ); + const refTurnout2 = this.buildRelatedRef( + pRef.id, + rrDeviceType.Turnout, + pRef.devicePort + ); + const refSimT1 = this.buildSimpleRef(turnout.id, srDeviceType.Turnout); + const refSimT2 = this.buildSimpleRef(pRef.id, srDeviceType.Turnout); + if (forkP1.x > forkP2.x) { + sectionLink.datas.aSimRef = refSimT2; + sectionLink.datas.bSimRef = refSimT1; + sectionLink.datas.aRef = refTurnout2; + sectionLink.datas.bRef = refTurnout1; + } else if (forkP1.x < forkP2.x) { + sectionLink.datas.aSimRef = refSimT1; + sectionLink.datas.bSimRef = refSimT2; + sectionLink.datas.aRef = refTurnout1; + sectionLink.datas.bRef = refTurnout2; + } else { + throw new Error('无法判断linkAB端'); + } if (pRef.devicePort === 0) { refg.datas.pointA.forEach((p) => { points.push(refg.localToCanvasPoint(p)); @@ -122,11 +206,11 @@ export class SectionLinkDraw extends GraphicDrawAssistant< }); } let dataPoint: IPointData[] = []; - if (port === 0) { + if (port === rrDevicePort.A) { dataPoint = turnout.datas.pointA; - } else if (port === 1) { + } else if (port === rrDevicePort.B) { dataPoint = turnout.datas.pointB; - } else if (port === 2) { + } else if (port === rrDevicePort.C) { dataPoint = turnout.datas.pointC; } const pLength = dataPoint.length; @@ -137,80 +221,208 @@ export class SectionLinkDraw extends GraphicDrawAssistant< sectionLink.datas.points = points; this.storeGraphic(sectionLink); } + /** + * 缓存计轴和link关系,为生成link关联关系提供数据依据 + * @param map + * @param axleId + * @param linkId + */ + cacheAxleLinkRelation( + map: Map, + axleId: string, + linkId: string + ) { + const list = map.get(axleId); + if (list) { + list.push(linkId); + map.set(axleId, list); + } else { + map.set(axleId, [linkId]); + } + } + /** + * 构建简单设备关联数据 + * @param id + * @param deviceType + * @returns + */ + buildSimpleRef(id: string, deviceType: graphicData.SimpleRef.DeviceType) { + return new graphicData.SimpleRef({ deviceType, id }); + } + /** + * 构建关系数据 + * @param id + * @param deviceType + * @param devicePort + * @returns + */ + buildRelatedRef( + id: string, + deviceType: graphicData.RelatedRef.DeviceType, + devicePort: graphicData.RelatedRef.DevicePort + ): IRelatedRefData { + return new graphicData.RelatedRef({ id, deviceType, devicePort }); + } + /**构建link之间的关联关系 */ + buildLinkRef(map: Map) { + map.forEach((value) => { + if (value.length === 2) { + const link1 = this.app.queryStore.queryById(value[0]) as SectionLink; + const link2 = this.app.queryStore.queryById(value[1]) as SectionLink; + if (link1.datas.aSimRef.id === link2.datas.bSimRef.id) { + link1.datas.aRef = this.buildRelatedRef( + link2.id, + rrDeviceType.SectionLink, + rrDevicePort.B + ); + link2.datas.bRef = this.buildRelatedRef( + link1.id, + rrDeviceType.SectionLink, + rrDevicePort.A + ); + } else if (link1.datas.bSimRef.id === link2.datas.aSimRef.id) { + link1.datas.bRef = this.buildRelatedRef( + link2.id, + rrDeviceType.SectionLink, + rrDevicePort.A + ); + link2.datas.aRef = this.buildRelatedRef( + link1.id, + rrDeviceType.SectionLink, + rrDevicePort.B + ); + } else if (link1.datas.aSimRef.id === link2.datas.aSimRef.id) { + link1.datas.aRef = this.buildRelatedRef( + link2.id, + rrDeviceType.SectionLink, + rrDevicePort.A + ); + link2.datas.aRef = this.buildRelatedRef( + link1.id, + rrDeviceType.SectionLink, + rrDevicePort.A + ); + } else if (link1.datas.bSimRef.id === link2.datas.bSimRef.id) { + link1.datas.bRef = this.buildRelatedRef( + link2.id, + rrDeviceType.SectionLink, + rrDevicePort.B + ); + link2.datas.bRef = this.buildRelatedRef( + link1.id, + rrDeviceType.SectionLink, + rrDevicePort.B + ); + } else { + throw new Error('构建link关联关系错误!'); + } + } + }); + } + /** + * 存储生成link的道岔端口 + * @param map + * @param deviceId + * @param devicePort + */ + cacheTurnoutPort( + map: Map, + deviceId: string, + devicePort: graphicData.RelatedRef.DevicePort + ) { + const pList = map.get(deviceId); + if (pList) { + pList.push(devicePort); + map.set(deviceId, pList); + } else { + map.set(deviceId, [devicePort]); + } + } + /** + * 一键生成link + */ oneGenerates() { const axleCountingList = this.app.queryStore.queryByType( AxleCounting.Type ); const turnoutList = this.app.queryStore.queryByType(Turnout.Type); - const generated = new Map(); + // 已生成link和计轴的关联关系数据 + const axleRefLink: Map = new Map(); + // 已生成link的道岔各个端口缓存数据 + const tpMap: Map = new Map(); + // 已生成link的section数据(两计轴之间的区段) + const gSectionList: string[] = []; axleCountingList.forEach((axleCounting) => { axleCounting.datas.axleCountingRef.forEach((device) => { const g = this.app.queryStore.queryById(device.id); - if (g.type === Section.Type && !generated.get(device.id)) { - const g1 = axleCountingList.find((axleCounting) => { - const s = axleCounting.datas.axleCountingRef.find( - (ref) => ref.id === device.id + if (g.type === Section.Type && !gSectionList.includes(device.id)) { + const axle1 = axleCountingList.find((axleCountingNew) => { + const s = axleCountingNew.datas.axleCountingRef.find( + (ref) => + ref.id === device.id && axleCountingNew.id !== axleCounting.id ); return s; }); - if (g1) { - this.generateBySection(g as Section); - generated.set(g.id, ['A', 'B']); + if (axle1) { + const link = this.generateBySection( + g as Section, + device, + axleCounting, + axle1 + ); + gSectionList.push(g.id); + this.cacheAxleLinkRelation(axleRefLink, axleCounting.id, link.id); + this.cacheAxleLinkRelation(axleRefLink, axle1.id, link.id); } } else if (g.type === Turnout.Type) { - this.generateByTurnoutAxle(g as Turnout, device.devicePort); - if (generated.get(g.id)) { - const pList = generated.get(g.id); - pList.push(device.devicePort); - generated.set(g.id, pList); - } else { - generated.set(g.id, [device.devicePort]); - } + const link = this.generateByTurnoutAxle( + g as Turnout, + device.devicePort, + axleCounting + ); + this.cacheAxleLinkRelation(axleRefLink, axleCounting.id, link.id); + this.cacheTurnoutPort(tpMap, g.id, device.devicePort); } }); }); turnoutList.forEach((turnout) => { - const pList = generated.get(turnout.id); + const pList = tpMap.get(turnout.id); if (!pList) { return; } let pRef = null; if ( - !pList.includes(0) && + !pList.includes(rrDevicePort.A) && turnout.datas.paRef && - turnout.datas.paRef.deviceType === 1 + turnout.datas.paRef.deviceType === rrDeviceType.Turnout ) { pRef = turnout.datas.paRef; - this.generateByTurnout(turnout, 0, pRef); + this.generateByTurnout(turnout, rrDevicePort.A, pRef); } if ( - !pList.includes(1) && + !pList.includes(rrDevicePort.B) && turnout.datas.pbRef && - turnout.datas.pbRef.deviceType === 1 + turnout.datas.pbRef.deviceType === rrDeviceType.Turnout ) { pRef = turnout.datas.pbRef; - this.generateByTurnout(turnout, 1, pRef); + this.generateByTurnout(turnout, rrDevicePort.B, pRef); } if ( - !pList.includes(2) && + !pList.includes(rrDevicePort.C) && turnout.datas.pcRef && - turnout.datas.pcRef.deviceType === 1 + turnout.datas.pcRef.deviceType === rrDeviceType.Turnout ) { pRef = turnout.datas.pcRef; - this.generateByTurnout(turnout, 2, pRef); + this.generateByTurnout(turnout, rrDevicePort.C, pRef); } - generated.set(turnout.id, [0, 1, 2]); + tpMap.set(turnout.id, [rrDevicePort.A, rrDevicePort.B, rrDevicePort.C]); if (pRef) { - if (generated.get(pRef.id)) { - const pListn = generated.get(pRef.id); - pListn.push(pRef.devicePort); - generated.set(pRef.id, pListn); - } else { - generated.set(pRef.id, [pRef.devicePort]); - } + this.cacheTurnoutPort(tpMap, pRef.id, pRef.devicePort); } }); + this.buildLinkRef(axleRefLink); } + clearCache(): void { this.points = []; this.graphic.clear(); diff --git a/src/graphics/separator/SeparatorDrawAssistant.ts b/src/graphics/separator/SeparatorDrawAssistant.ts index d1a1453..54482cd 100644 --- a/src/graphics/separator/SeparatorDrawAssistant.ts +++ b/src/graphics/separator/SeparatorDrawAssistant.ts @@ -74,10 +74,7 @@ export class SeparatorDraw extends GraphicDrawAssistant< allR.forEach((relation, index) => { const r = relation.getRelationParam(section); const other = relation.getOtherRelationParam(section); - if (!section.datas.children.includes(other.g.id)) { - // 排除物理区段和自身逻辑区段的关联关系 - port.push(r.param); - } + port.push(r.param); if (!rMap.has(setKey(r))) { rMap.set(setKey(r), { ...r }); } diff --git a/src/jl-graphic/app/JlGraphicApp.ts b/src/jl-graphic/app/JlGraphicApp.ts index 4be56ea..5cf08f3 100644 --- a/src/jl-graphic/app/JlGraphicApp.ts +++ b/src/jl-graphic/app/JlGraphicApp.ts @@ -737,7 +737,7 @@ export class GraphicApp extends EventEmitter { deleteGraphics(...graphics: JlGraphic[]): JlGraphic[] { const dels = graphics.filter((g) => { if ( - this._options?.isSupportDeletion && + this._options?.isSupportDeletion == undefined || this._options.isSupportDeletion(g) ) { this.doDeleteGraphics(g); diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index d91312b..31e8f66 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -3396,7 +3396,8 @@ export namespace graphicData { Section = 0, Turnout = 1, TrainWindow = 2, - AxleCounting = 3 + AxleCounting = 3, + SectionLink = 4 } export enum DevicePort { A = 0, @@ -3610,13 +3611,113 @@ export namespace graphicData { return Separator.deserialize(bytes); } } + export class SimpleRef extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + deviceType?: SimpleRef.DeviceType; + id?: string; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("deviceType" in data && data.deviceType != undefined) { + this.deviceType = data.deviceType; + } + if ("id" in data && data.id != undefined) { + this.id = data.id; + } + } + } + get deviceType() { + return pb_1.Message.getFieldWithDefault(this, 1, SimpleRef.DeviceType.Turnout) as SimpleRef.DeviceType; + } + set deviceType(value: SimpleRef.DeviceType) { + pb_1.Message.setField(this, 1, value); + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + deviceType?: SimpleRef.DeviceType; + id?: string; + }): SimpleRef { + const message = new SimpleRef({}); + if (data.deviceType != null) { + message.deviceType = data.deviceType; + } + if (data.id != null) { + message.id = data.id; + } + return message; + } + toObject() { + const data: { + deviceType?: SimpleRef.DeviceType; + id?: string; + } = {}; + if (this.deviceType != null) { + data.deviceType = this.deviceType; + } + if (this.id != null) { + data.id = this.id; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.deviceType != SimpleRef.DeviceType.Turnout) + writer.writeEnum(1, this.deviceType); + if (this.id.length) + writer.writeString(2, this.id); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SimpleRef { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SimpleRef(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.deviceType = reader.readEnum(); + break; + case 2: + message.id = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): SimpleRef { + return SimpleRef.deserialize(bytes); + } + } + export namespace SimpleRef { + export enum DeviceType { + Turnout = 0, + AxleCounting = 1 + } + } export class SectionLink extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { common?: CommonInfo; code?: string; points?: Point[]; - refDevice?: string; + up?: boolean; + aSimRef?: SimpleRef; + bSimRef?: SimpleRef; + aRef?: RelatedRef; + bRef?: RelatedRef; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); @@ -3630,8 +3731,20 @@ export namespace graphicData { if ("points" in data && data.points != undefined) { this.points = data.points; } - if ("refDevice" in data && data.refDevice != undefined) { - this.refDevice = data.refDevice; + if ("up" in data && data.up != undefined) { + this.up = data.up; + } + if ("aSimRef" in data && data.aSimRef != undefined) { + this.aSimRef = data.aSimRef; + } + if ("bSimRef" in data && data.bSimRef != undefined) { + this.bSimRef = data.bSimRef; + } + if ("aRef" in data && data.aRef != undefined) { + this.aRef = data.aRef; + } + if ("bRef" in data && data.bRef != undefined) { + this.bRef = data.bRef; } } } @@ -3656,17 +3769,57 @@ export namespace graphicData { set points(value: Point[]) { pb_1.Message.setRepeatedWrapperField(this, 3, value); } - get refDevice() { - return pb_1.Message.getFieldWithDefault(this, 4, "") as string; + get up() { + return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; } - set refDevice(value: string) { + set up(value: boolean) { pb_1.Message.setField(this, 4, value); } + get aSimRef() { + return pb_1.Message.getWrapperField(this, SimpleRef, 5) as SimpleRef; + } + set aSimRef(value: SimpleRef) { + pb_1.Message.setWrapperField(this, 5, value); + } + get has_aSimRef() { + return pb_1.Message.getField(this, 5) != null; + } + get bSimRef() { + return pb_1.Message.getWrapperField(this, SimpleRef, 6) as SimpleRef; + } + set bSimRef(value: SimpleRef) { + pb_1.Message.setWrapperField(this, 6, value); + } + get has_bSimRef() { + return pb_1.Message.getField(this, 6) != null; + } + get aRef() { + return pb_1.Message.getWrapperField(this, RelatedRef, 7) as RelatedRef; + } + set aRef(value: RelatedRef) { + pb_1.Message.setWrapperField(this, 7, value); + } + get has_aRef() { + return pb_1.Message.getField(this, 7) != null; + } + get bRef() { + return pb_1.Message.getWrapperField(this, RelatedRef, 8) as RelatedRef; + } + set bRef(value: RelatedRef) { + pb_1.Message.setWrapperField(this, 8, value); + } + get has_bRef() { + return pb_1.Message.getField(this, 8) != null; + } static fromObject(data: { common?: ReturnType; code?: string; points?: ReturnType[]; - refDevice?: string; + up?: boolean; + aSimRef?: ReturnType; + bSimRef?: ReturnType; + aRef?: ReturnType; + bRef?: ReturnType; }): SectionLink { const message = new SectionLink({}); if (data.common != null) { @@ -3678,8 +3831,20 @@ export namespace graphicData { if (data.points != null) { message.points = data.points.map(item => Point.fromObject(item)); } - if (data.refDevice != null) { - message.refDevice = data.refDevice; + if (data.up != null) { + message.up = data.up; + } + if (data.aSimRef != null) { + message.aSimRef = SimpleRef.fromObject(data.aSimRef); + } + if (data.bSimRef != null) { + message.bSimRef = SimpleRef.fromObject(data.bSimRef); + } + if (data.aRef != null) { + message.aRef = RelatedRef.fromObject(data.aRef); + } + if (data.bRef != null) { + message.bRef = RelatedRef.fromObject(data.bRef); } return message; } @@ -3688,7 +3853,11 @@ export namespace graphicData { common?: ReturnType; code?: string; points?: ReturnType[]; - refDevice?: string; + up?: boolean; + aSimRef?: ReturnType; + bSimRef?: ReturnType; + aRef?: ReturnType; + bRef?: ReturnType; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -3699,8 +3868,20 @@ export namespace graphicData { if (this.points != null) { data.points = this.points.map((item: Point) => item.toObject()); } - if (this.refDevice != null) { - data.refDevice = this.refDevice; + if (this.up != null) { + data.up = this.up; + } + if (this.aSimRef != null) { + data.aSimRef = this.aSimRef.toObject(); + } + if (this.bSimRef != null) { + data.bSimRef = this.bSimRef.toObject(); + } + if (this.aRef != null) { + data.aRef = this.aRef.toObject(); + } + if (this.bRef != null) { + data.bRef = this.bRef.toObject(); } return data; } @@ -3714,8 +3895,16 @@ export namespace graphicData { writer.writeString(2, this.code); if (this.points.length) writer.writeRepeatedMessage(3, this.points, (item: Point) => item.serialize(writer)); - if (this.refDevice.length) - writer.writeString(4, this.refDevice); + if (this.up != false) + writer.writeBool(4, this.up); + if (this.has_aSimRef) + writer.writeMessage(5, this.aSimRef, () => this.aSimRef.serialize(writer)); + if (this.has_bSimRef) + writer.writeMessage(6, this.bSimRef, () => this.bSimRef.serialize(writer)); + if (this.has_aRef) + writer.writeMessage(7, this.aRef, () => this.aRef.serialize(writer)); + if (this.has_bRef) + writer.writeMessage(8, this.bRef, () => this.bRef.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -3735,7 +3924,19 @@ export namespace graphicData { reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Point.deserialize(reader), Point)); break; case 4: - message.refDevice = reader.readString(); + message.up = reader.readBool(); + break; + case 5: + reader.readMessage(message.aSimRef, () => message.aSimRef = SimpleRef.deserialize(reader)); + break; + case 6: + reader.readMessage(message.bSimRef, () => message.bSimRef = SimpleRef.deserialize(reader)); + break; + case 7: + reader.readMessage(message.aRef, () => message.aRef = RelatedRef.deserialize(reader)); + break; + case 8: + reader.readMessage(message.bRef, () => message.bRef = RelatedRef.deserialize(reader)); break; default: reader.skipField(); }