This commit is contained in:
dong 2023-07-10 13:39:59 +08:00
commit 3aec34fd59

View File

@ -1,10 +1,4 @@
import {
FederatedPointerEvent,
IHitArea,
IPoint,
IPointData,
Point,
} from 'pixi.js';
import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js';
import {
AbsorbableLine,
AbsorbablePosition,
@ -23,14 +17,13 @@ import {
AxleCountingSectionConsts,
} from './AxleCountingSection';
import { AxleCounting } from '../axleCounting/AxleCounting';
import { Section } from '../section/Section';
import { Turnout } from '../turnout/Turnout';
import { createRelatedRefProto } from '../CommonGraphics';
function hasCommonElements(arr1: string[], arr2: string[]): boolean {
function hasCommonElements(arr1: string[], arr2: string[]) {
for (let i = 0; i < arr1.length; i++) {
if (arr2.includes(arr1[i])) {
return true;
return arr1[i];
}
}
return false;
@ -84,12 +77,6 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant<
return true;
}
draw(graphics: AxleCounting[]) {
/* const paRefPs = this.app.queryStore.queryById(
graphics[0].datas.axleCountingRef[0].id
);
const RepbRefPs = this.app.queryStore.queryById(
graphics[1].datas.axleCountingRef[0].id
); */
const axleCountingSection = new AxleCountingSection();
axleCountingSection.loadData(this.graphicTemplate.datas);
axleCountingSection.datas.points = [
@ -124,8 +111,32 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant<
const refDevice = axleCountings[i].datas.axleCountingRef.map(
(ref) => ref.id
);
if (hasCommonElements(refDeviceTarget, refDevice)) {
this.draw([axleCounting, axleCountings[i]]);
const commonElementId = hasCommonElements(refDeviceTarget, refDevice);
if (commonElementId) {
const commonElement = this.app.queryStore.queryById(commonElementId);
let draw = true;
if (commonElement.type == 'Turnout') {
let targetPort, port;
axleCounting.datas.axleCountingRef.forEach((ref) => {
if (ref.id == commonElementId) {
targetPort = ref.devicePort;
}
});
axleCountings[i].datas.axleCountingRef.forEach((ref) => {
if (ref.id == commonElementId) {
port = ref.devicePort;
}
});
if (
(targetPort == 1 && port == 2) ||
(targetPort == 2 && port == 1)
) {
draw = false;
}
}
if (draw) {
this.draw([axleCounting, axleCountings[i]]);
}
}
if (hasSamePosition(axleCounting, axleCountings[i])) {
hasfourTurnout.push([axleCounting, axleCountings[i]]);