集中分割线关联道岔、信号机特殊处理

This commit is contained in:
joylink_zhaoerwei 2023-12-05 09:46:52 +08:00
parent 0d97067e0b
commit 9b73f9b502
3 changed files with 101 additions and 32 deletions

View File

@ -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',

View File

@ -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>(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<Turnout | Section>(
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<Section>(sectionAId);
const sectionA = this.queryStore.queryById<Section | Turnout>(sectionAId);
const sectionBId =
b.leftSection.id !== '' ? b.leftSection.id : b.rightSection.id;
const sectionB = this.queryStore.queryById<Section>(sectionBId);
const sectionB = this.queryStore.queryById<Section | Turnout>(sectionBId);
return (
sectionA.localToCanvasPoint(
getRectangleCenter(sectionA.getLocalBounds())

View File

@ -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>(AxleCounting.Type)
.filter(
@ -726,6 +727,52 @@ function oneClickRelateCentralizedStation() {
}
});
const signals = drawApp.queryStore.queryByType<Signal>(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<Section>(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<Section>(ids[1]).datas
.centralizedStations
: drawApp.queryStore.queryById<Section>(ids[0]).datas
.centralizedStations;
}
});
}
function handleContainDevices(
containDeviceIds: string[],
centralizedStations: string[]