From 9b73f9b502b2d7955d73ea3db24aedfb87f70a1c Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 5 Dec 2023 09:46:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E4=B8=AD=E5=88=86=E5=89=B2=E7=BA=BF?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=81=93=E5=B2=94=E3=80=81=E4=BF=A1=E5=8F=B7?= =?UTF-8?q?=E6=9C=BA=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConcentrationDividingLineProperty.vue | 4 +- .../ConcentrationDividingLine.ts | 80 ++++++++++++------- src/layouts/DrawLayout.vue | 49 +++++++++++- 3 files changed, 101 insertions(+), 32 deletions(-) diff --git a/src/components/draw-app/properties/ConcentrationDividingLineProperty.vue b/src/components/draw-app/properties/ConcentrationDividingLineProperty.vue index eaac650..9d32ea7 100644 --- a/src/components/draw-app/properties/ConcentrationDividingLineProperty.vue +++ b/src/components/draw-app/properties/ConcentrationDividingLineProperty.vue @@ -68,8 +68,8 @@ const centralizedStations = ref<{ label: string; value: string }[]>([]); const sectionRelations = computed(() => { const refSectionInfo: { label: string; refSectionInfo: string[] }[] = [ - { label: '左边关联的区段', refSectionInfo: [] }, - { label: '右边关联的区段', refSectionInfo: [] }, + { label: '左边关联的设备', refSectionInfo: [] }, + { label: '右边关联的设备', refSectionInfo: [] }, ]; enum devicePort { 'A', diff --git a/src/graphics/concentrationDividingLine/ConcentrationDividingLine.ts b/src/graphics/concentrationDividingLine/ConcentrationDividingLine.ts index 744b21d..40e206a 100644 --- a/src/graphics/concentrationDividingLine/ConcentrationDividingLine.ts +++ b/src/graphics/concentrationDividingLine/ConcentrationDividingLine.ts @@ -12,6 +12,7 @@ import { graphicData } from 'src/protos/stationLayoutGraphics'; import { Section, SectionPort, SectionType } from '../section/Section'; import { arePolylinesIntersect } from './ConcentrationDividingLineUtils'; import { createRelatedRefProto } from '../CommonGraphics'; +import { Turnout, TurnoutPort } from '../turnout/Turnout'; export interface IConcentrationDividingLineData extends GraphicData { get code(): string; // 编号 @@ -34,6 +35,12 @@ export const ConcentrationDividingLineConsts = { lineWidth: 2, }; +enum devicePort { + 'A', + 'B', + 'C', +} + export class ConcentrationDividingLine extends JlGraphic implements ILineGraphic @@ -101,44 +108,59 @@ export class ConcentrationDividingLine hasNode.segment2[1], section.localToCanvasPoint(section.getEndPoint()) ); - const relationParam = minA > minB ? 'B' : 'A'; - const sectionRelations = section.relationManage - .getRelationsOfGraphicAndOtherType(section, Section.Type) - .filter( - (relation) => - relation.getRelationParam(section).param == relationParam - ) - .map((relation) => relation.getOtherGraphic
(section)); - + const relationParam = minA > minB ? SectionPort.B : SectionPort.A; + const portRefOtherDevice = + relationParam == 'A' ? section.datas.paRef : section.datas.pbRef; if ( - sectionRelations.length == 1 && + portRefOtherDevice?.id && !hasNodeSection.get(section.id) && - !hasNodeSection.get(sectionRelations[0].id) + !hasNodeSection.get(portRefOtherDevice.id) ) { - const [leftSectionId, rightSectionId] = - relationParam === 'A' - ? [sectionRelations[0].id, section.id] - : [section.id, sectionRelations[0].id]; - hasNodeSection.set(leftSectionId, '1'); - hasNodeSection.set(rightSectionId, '1'); + const refDevice = this.queryStore.queryById( + portRefOtherDevice?.id + ); + const [leftDevice, rightDevice] = + refDevice.localToCanvasPoint( + getRectangleCenter(refDevice.getLocalBounds()) + ) < + section.localToCanvasPoint( + getRectangleCenter(section.getLocalBounds()) + ) + ? [ + { + device: refDevice, + port: devicePort[ + portRefOtherDevice.devicePort + ] as TurnoutPort, + }, + { device: section, port: relationParam }, + ] + : [ + { device: section, port: relationParam }, + { + device: refDevice, + port: devicePort[ + portRefOtherDevice.devicePort + ] as TurnoutPort, + }, + ]; + hasNodeSection.set(leftDevice.device.id, '1'); + hasNodeSection.set(rightDevice.device.id, '1'); nodeConWithSecs.push( new graphicData.NodeConWithSec({ leftSection: createRelatedRefProto( - Section.Type, - leftSectionId, - SectionPort.B + leftDevice.device.type, + leftDevice.device.id, + leftDevice.port ), rightSection: createRelatedRefProto( - Section.Type, - rightSectionId, - SectionPort.A + rightDevice.device.type, + rightDevice.device.id, + rightDevice.port ), }) ); - } else if ( - !hasNodeSection.get(section.id) && - sectionRelations.length == 0 - ) { + } else if (!hasNodeSection.get(section.id) && !portRefOtherDevice?.id) { const [leftSectionId, rightSectionId] = relationParam === 'A' ? ['', section.id] : [section.id, '']; hasNodeSection.set(section.id, '1'); @@ -162,10 +184,10 @@ export class ConcentrationDividingLine nodeConWithSecs.sort((a, b) => { const sectionAId = a.leftSection.id !== '' ? a.leftSection.id : a.rightSection.id; - const sectionA = this.queryStore.queryById
(sectionAId); + const sectionA = this.queryStore.queryById
(sectionAId); const sectionBId = b.leftSection.id !== '' ? b.leftSection.id : b.rightSection.id; - const sectionB = this.queryStore.queryById
(sectionBId); + const sectionB = this.queryStore.queryById
(sectionBId); return ( sectionA.localToCanvasPoint( getRectangleCenter(sectionA.getLocalBounds()) diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 896f778..c2b2bcd 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -262,6 +262,7 @@ import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; import OtherLineList from 'src/components/draw-app/dialogs/OtherLineList.vue'; import OtherLineConfig from 'src/components/draw-app/properties/OtherLineConfig.vue'; import SectionDirectionConfig from 'src/components/draw-app/properties/SectionDirectionConfig.vue'; +import { distance2 } from 'src/jl-graphic'; const $q = useQuasar(); const route = useRoute(); @@ -707,7 +708,7 @@ function oneClickRelateCentralizedStation() { handleContainDevices(containDeviceIds, [rightDatas.refRightStationId]); } } - //区段边界的计轴单独处理 + //区段边界的计轴和信号机单独处理 const axleCountings = drawApp.queryStore .queryByType(AxleCounting.Type) .filter( @@ -726,6 +727,52 @@ function oneClickRelateCentralizedStation() { } }); + const signals = drawApp.queryStore.queryByType(Signal.Type); + concentrationDividingLines.forEach((concentrationDividingLine) => { + concentrationDividingLine.datas.nodeConWithSecs.forEach( + (nodeConWithSec) => { + const ids = [ + nodeConWithSec.leftSection.id, + nodeConWithSec.rightSection.id, + ]; + if (ids[0] && ids[1]) { + if ( + nodeConWithSec.leftSection.deviceType == + graphicData.RelatedRef.DeviceType.Section + ) { + handleNodeConWithSec(nodeConWithSec.leftSection, ids); + } else { + handleNodeConWithSec(nodeConWithSec.rightSection, ids); + } + } + } + ); + }); + + function handleNodeConWithSec( + relatedRef: graphicData.RelatedRef, + ids: string[] + ) { + const section = drawApp.queryStore.queryById
(relatedRef.id); + const portPos = + relatedRef.devicePort == graphicData.RelatedRef.DevicePort.A + ? section.localToCanvasPoint(section.getStartPoint()) + : section.localToCanvasPoint(section.getEndPoint()); + signals.forEach((signal) => { + if ( + distance2(portPos, signal.position) < 100 && + ids.includes(signal.datas.refDev.id) + ) { + signal.datas.centralizedStations = + ids[0] == signal.datas.refDev.id + ? drawApp.queryStore.queryById
(ids[1]).datas + .centralizedStations + : drawApp.queryStore.queryById
(ids[0]).datas + .centralizedStations; + } + }); + } + function handleContainDevices( containDeviceIds: string[], centralizedStations: string[]