通过集中区分割线一键关联集中站

This commit is contained in:
joylink_zhaoerwei 2023-12-01 16:31:52 +08:00
parent 96c7c9212f
commit b274d20525
2 changed files with 63 additions and 8 deletions

View File

@ -649,13 +649,61 @@ function oneClickRelateCentralizedStation() {
containDeviceIds = Array.from(new Set(containDeviceIds));
});
const containDevices = containDeviceIds.map((id) => {
return drawApp.queryStore.queryById(id);
});
handleCentralizedStationsData(containDevices, [
rightDatas.refRightStationId,
]);
if (rightDatas.refRightStationId) {
const containDevices = containDeviceIds.map((id) => {
return drawApp.queryStore.queryById(id);
});
const signals = drawApp.queryStore
.queryByType<Signal>(Signal.Type)
.filter((g) => containDeviceIds.includes(g.datas.refDev.id));
const transponders = drawApp.queryStore
.queryByType<Transponder>(Transponder.Type)
.filter((g) => containDeviceIds.includes(g.datas.TransponderRef.id));
const axleCountings = drawApp.queryStore
.queryByType<AxleCounting>(AxleCounting.Type)
.filter((g) => {
const axleCountingRefId = g.datas.axleCountingRef.map(
(ref) => ref.id
);
if (
findCommonElements([axleCountingRefId, containDeviceIds]).length
) {
return true;
}
return false;
});
const allSetCentralizedStationsDevice = [
...containDevices,
...signals,
...transponders,
...axleCountings,
];
allSetCentralizedStationsDevice.forEach(
(g) => ((g as Signal).datas.centralizedStations = [])
);
handleCentralizedStationsData(allSetCentralizedStationsDevice, [
rightDatas.refRightStationId,
]);
}
}
//
const axleCountings = drawApp.queryStore
.queryByType<AxleCounting>(AxleCounting.Type)
.filter(
(g) =>
g.datas.type ==
graphicData.AxleCounting.TypeDetectionPoint.SectionBoundary
);
axleCountings.forEach((g) => {
if (g.datas.axleCountingRef.length == 2) {
const centralizedStations: string[] = [];
g.datas.axleCountingRef.forEach((ref) => {
const section = drawApp.queryStore.queryById<Section>(ref.id);
centralizedStations.push(...section.datas.centralizedStations);
});
g.datas.centralizedStations = Array.from(new Set(centralizedStations));
}
});
}
//-

View File

@ -4,6 +4,7 @@ import {
JlGraphic,
JlGraphicTemplate,
calculateDistanceFromPointToLine,
getRectangleCenter,
} from 'src/jl-graphic';
import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin';
import { SectionGraphic } from '../sectionGraphic/SectionGraphic';
@ -133,11 +134,17 @@ export class ConcentrationDividingLine
nodeConWithSecs.sort((a, b) => {
const sectionAId =
a.leftSectionId !== '' ? a.leftSectionId : a.rightSectionId;
const sectionA = this.queryStore.queryById<Section>(sectionAId);
const sectionBId =
b.leftSectionId !== '' ? b.leftSectionId : b.rightSectionId;
const sectionB = this.queryStore.queryById<Section>(sectionBId);
return (
this.queryStore.queryById<Section>(sectionAId).position.y -
this.queryStore.queryById<Section>(sectionBId).position.y
sectionA.localToCanvasPoint(
getRectangleCenter(sectionA.getLocalBounds())
).y -
sectionB.localToCanvasPoint(
getRectangleCenter(sectionB.getLocalBounds())
).y
);
});
this.datas.nodeConWithSecs = nodeConWithSecs;