区段常规运行方向生成规则调整

This commit is contained in:
Yuan 2023-12-06 14:42:39 +08:00
parent 165c77f1e8
commit 6f8ea46425
13 changed files with 163 additions and 142 deletions

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import { QForm } from 'quasar';
import { Section } from 'src/graphics/section/Section';
import { Section, DevicePort } from 'src/graphics/section/Section';
import { Turnout } from 'src/graphics/turnout/Turnout';
import { graphicData } from 'src/protos/stationLayoutGraphics';
import { useDrawStore } from 'src/stores/draw-store';
@ -58,45 +58,36 @@ async function onSubmit() {
) => {
if (visited.includes(current.datas.id)) return;
visited.push(current.datas.id);
if (current instanceof Section) {
[
[current.datas.paRef?.id, 'A'],
[current.datas.pbRef?.id, 'B'],
]
.filter((item): item is [string, 'A' | 'B'] => !!item[0])
.forEach(([id, port]) => {
const target = current.queryStore.queryById<Section | Turnout>(id);
if (target instanceof Turnout) {
queue.push({
node: target,
runningDirection,
});
} else {
const isPortDiffrent =
(port === 'B' && target.datas.paRef?.id === current.datas.id) ||
(port === 'A' && target.datas.pbRef?.id === current.datas.id);
queue.push({
node: target,
runningDirection: isPortDiffrent
? runningDirection
: reverseDirection(runningDirection),
});
}
[
current.getConnectElement(DevicePort.A),
current.getConnectElement(DevicePort.B),
].forEach((item, idx) => {
if (!item) return;
const { g, port } = item;
if (g instanceof Turnout) {
if (port === DevicePort.C) return;
queue.push({
node: g,
runningDirection,
});
} else {
const isPortDiffrent =
(idx === 0 && port === DevicePort.B) ||
(idx === 1 && port === DevicePort.A);
const flip = current instanceof Section && !isPortDiffrent;
queue.push({
node: g,
runningDirection: flip
? reverseDirection(runningDirection)
: runningDirection,
});
}
});
if (current instanceof Section) {
const data = current.datas.clone();
data.normalRunningDirection = runningDirection;
data.direction = direction.value;
current.updateData(data);
} else {
[current.datas.paRef?.id, current.datas.pbRef?.id]
.filter((id): id is string => !!id)
.forEach((id) => {
const target = current.queryStore.queryById<Section | Turnout>(id);
queue.push({
node: target,
runningDirection,
});
});
}
};

View File

@ -1,8 +1,8 @@
import { Graphics } from 'pixi.js';
import { calculateMirrorPoint } from 'src/jl-graphic';
import { graphicData } from 'src/protos/stationLayoutGraphics';
import { Turnout, TurnoutPort } from './turnout/Turnout';
import { Section, SectionPort } from './section/Section';
import { Turnout } from './turnout/Turnout';
import { Section, DevicePort } from './section/Section';
import { TrainWindow } from './trainWindow/TrainWindow';
import { AxleCounting } from './axleCounting/AxleCounting';
import { Station } from './station/Station';
@ -80,7 +80,7 @@ export function drawArrow(
export function createRelatedRefProto(
type: string,
id: string,
port?: TurnoutPort | SectionPort
port?: DevicePort
) {
const typeMap = new Map([
[Section.Type, graphicData.RelatedRef.DeviceType.Section],

View File

@ -15,8 +15,8 @@ import {
AxleCounting,
AxleCountingTemplate,
} from './AxleCounting';
import { Section, SectionPort, SectionType } from '../section/Section';
import { Turnout, TurnoutPort } from '../turnout/Turnout';
import { Section, DevicePort, SectionType } from '../section/Section';
import { Turnout } from '../turnout/Turnout';
import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics';
import { Signal } from '../signal/Signal';
import { loadGenerateAxleCountingConfig } from 'src/drawApp/commonApp';
@ -74,11 +74,11 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
ps: IPoint,
direction: number,
graphic: Section | Turnout,
port: TurnoutPort | SectionPort,
port: DevicePort,
map: Map<string, number>,
reftype: string,
refGraphic: Section | Turnout,
refPort: TurnoutPort | SectionPort
refPort: DevicePort
) {
const generateAxleCountingConfig = loadGenerateAxleCountingConfig();
if (generateAxleCountingConfig?.noGenerateGroup !== undefined) {
@ -98,8 +98,8 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
if (
graphic.type == 'Turnout' &&
reftype == 'Turnout' &&
port == TurnoutPort.B &&
refPort == TurnoutPort.B
port == DevicePort.B &&
refPort == DevicePort.B
) {
//查看生成计轴bb配置
let hasBB = false;
@ -155,7 +155,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
ps: IPoint,
direction: number,
graphic: Section | Turnout,
port: TurnoutPort | SectionPort,
port: DevicePort,
map: Map<string, number>
) {
if (!map.has(`${graphic.id}-${port}`)) {
@ -244,12 +244,12 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
if (axleCountingRelations.length < 2) {
axleCountingRelations.forEach((relation) => {
const port = relation.getRelationParam(section).param;
let addPort = SectionPort.A;
let addPort = DevicePort.A;
let direction = 1;
let axleCountingPs = ps;
if (port == 'A') {
axleCountingPs = pe;
addPort = SectionPort.B;
addPort = DevicePort.B;
}
if (axleCountingPs.y > height.y) {
direction = -1;
@ -309,7 +309,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
AxleCounting.Type
);
const points = turnout.getPortPoints();
const turnoutPort = [TurnoutPort.A, TurnoutPort.B, TurnoutPort.C];
const turnoutPort = [DevicePort.A, DevicePort.B, DevicePort.C];
if (axleCountingRelations.length == 1) {
const port = axleCountingRelations[0].getRelationParam(turnout).param;
const otherPort = turnoutPort.filter((p) => {
@ -339,8 +339,8 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
} else if (axleCountingRelations.length == 0) {
const axleCountingPsA = turnout.localToCanvasPoints(points[0][0])[0];
const axleCountingPsC = turnout.localToCanvasPoints(points[2][0])[0];
this.drawAdd(axleCountingPsA, 1, turnout, TurnoutPort.A, map);
this.drawAdd(axleCountingPsC, 1, turnout, TurnoutPort.C, map);
this.drawAdd(axleCountingPsA, 1, turnout, DevicePort.A, map);
this.drawAdd(axleCountingPsC, 1, turnout, DevicePort.C, map);
}
});
}

View File

@ -8,7 +8,7 @@ import {
calculateLineMidpoint,
} from 'src/jl-graphic';
import { IRelatedRefData, protoPort2Data } from '../CommonGraphics';
import { SectionPort } from '../section/Section';
import { DevicePort } from '../section/Section';
export interface ITurnoutPosRefData {
get id(): string; //道岔的ID
@ -100,7 +100,7 @@ export class AxleCountingSection extends JlGraphic {
loadRelations() {
if (this.datas?.paRef?.id) {
this.relationManage.addRelation(
new GraphicRelationParam(this, SectionPort.A),
new GraphicRelationParam(this, DevicePort.A),
new GraphicRelationParam(
this.queryStore.queryById(this.datas.paRef.id),
protoPort2Data(this.datas.paRef.devicePort)
@ -109,7 +109,7 @@ export class AxleCountingSection extends JlGraphic {
}
if (this.datas?.pbRef?.id) {
this.relationManage.addRelation(
new GraphicRelationParam(this, SectionPort.B),
new GraphicRelationParam(this, DevicePort.B),
new GraphicRelationParam(
this.queryStore.queryById(this.datas.pbRef.id),
protoPort2Data(this.datas.pbRef.devicePort)

View File

@ -9,10 +9,10 @@ import {
import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin';
import { SectionGraphic } from '../sectionGraphic/SectionGraphic';
import { graphicData } from 'src/protos/stationLayoutGraphics';
import { Section, SectionPort, SectionType } from '../section/Section';
import { Section, DevicePort, SectionType } from '../section/Section';
import { arePolylinesIntersect } from './ConcentrationDividingLineUtils';
import { createRelatedRefProto } from '../CommonGraphics';
import { Turnout, TurnoutPort } from '../turnout/Turnout';
import { Turnout } from '../turnout/Turnout';
export interface IConcentrationDividingLineData extends GraphicData {
get code(): string; // 编号
@ -108,7 +108,7 @@ export class ConcentrationDividingLine
hasNode.segment2[1],
section.localToCanvasPoint(section.getEndPoint())
);
const relationParam = minA > minB ? SectionPort.B : SectionPort.A;
const relationParam = minA > minB ? DevicePort.B : DevicePort.A;
const portRefOtherDevice =
relationParam == 'A' ? section.datas.paRef : section.datas.pbRef;
if (
@ -131,7 +131,7 @@ export class ConcentrationDividingLine
device: refDevice,
port: devicePort[
portRefOtherDevice.devicePort
] as TurnoutPort,
] as DevicePort,
},
{ device: section, port: relationParam },
]
@ -141,7 +141,7 @@ export class ConcentrationDividingLine
device: refDevice,
port: devicePort[
portRefOtherDevice.devicePort
] as TurnoutPort,
] as DevicePort,
},
];
hasNodeSection.set(leftDevice.device.id, '1');
@ -169,12 +169,12 @@ export class ConcentrationDividingLine
leftSection: createRelatedRefProto(
Section.Type,
leftSectionId,
SectionPort.B
DevicePort.B
),
rightSection: createRelatedRefProto(
Section.Type,
rightSectionId,
SectionPort.A
DevicePort.A
),
})
);

View File

@ -33,11 +33,6 @@ export enum SectionType {
TurnoutPhysical = 2,
}
export enum SectionPort {
A = 'A',
B = 'B',
}
export interface ISectionData extends GraphicData {
get code(): string; // 编号
set code(v: string);
@ -83,6 +78,12 @@ export const SectionConsts = {
lineWidth: 5,
};
export enum DevicePort {
A = 'A',
B = 'B',
C = 'C',
}
export class Section extends JlGraphic implements ILineGraphic {
static Type = 'Section';
lineGraphic: SectionGraphic;
@ -189,6 +190,24 @@ export class Section extends JlGraphic implements ILineGraphic {
this.updateData(old);
}
getConnectElement(port: DevicePort) {
const relation = this.relationManage
.getRelationsOfGraphic(this)
.find(
(relation) =>
relation.getRelationParam(this).getParam<DevicePort>() === port &&
(relation.getOtherGraphic(this) instanceof Section ||
relation.getOtherGraphic(this) instanceof Turnout)
);
if (!relation) {
return;
}
return {
g: relation?.getOtherGraphic(this) as Section | Turnout,
port: relation?.getOtherRelationParam(this).getParam<DevicePort>(),
};
}
/** 获取拆分逻辑区段数据 */
getSplitPoints(count: number): IPointData[][] {
if (this.datas.points.length !== 2) {
@ -243,14 +262,14 @@ export class Section extends JlGraphic implements ILineGraphic {
this.queryStore.queryByType<Section>(Section.Type).forEach((section) => {
if (section.id === this.id) return;
let param: SectionPort[] = [];
let param: DevicePort[] = [];
if (
distance2(
this.localToCanvasPoint(this.getStartPoint()),
section.localToCanvasPoint(section.getStartPoint())
) <= tolerance
) {
param = [SectionPort.A, SectionPort.A];
param = [DevicePort.A, DevicePort.A];
}
if (
distance2(
@ -258,7 +277,7 @@ export class Section extends JlGraphic implements ILineGraphic {
section.localToCanvasPoint(section.getStartPoint())
) <= tolerance
) {
param = [SectionPort.B, SectionPort.A];
param = [DevicePort.B, DevicePort.A];
}
if (
distance2(
@ -266,7 +285,7 @@ export class Section extends JlGraphic implements ILineGraphic {
section.localToCanvasPoint(section.getEndPoint())
) <= tolerance
) {
param = [SectionPort.A, SectionPort.B];
param = [DevicePort.A, DevicePort.B];
}
if (
distance2(
@ -274,7 +293,7 @@ export class Section extends JlGraphic implements ILineGraphic {
section.localToCanvasPoint(section.getEndPoint())
) <= tolerance
) {
param = [SectionPort.B, SectionPort.B];
param = [DevicePort.B, DevicePort.B];
}
if (param.length) {
this.relationManage.addRelation(
@ -291,7 +310,7 @@ export class Section extends JlGraphic implements ILineGraphic {
.getRelationsOfGraphic(this)
.find(
(relation) =>
relation.getRelationParam(this).param === SectionPort.A &&
relation.getRelationParam(this).param === DevicePort.A &&
(relation.getOtherGraphic(this) instanceof Section ||
relation.getOtherGraphic(this) instanceof Turnout)
);
@ -309,7 +328,7 @@ export class Section extends JlGraphic implements ILineGraphic {
.getRelationsOfGraphic(this)
.find(
(relation) =>
relation.getRelationParam(this).param === SectionPort.B &&
relation.getRelationParam(this).param === DevicePort.B &&
(relation.getOtherGraphic(this) instanceof Section ||
relation.getOtherGraphic(this) instanceof Turnout)
);
@ -331,7 +350,7 @@ export class Section extends JlGraphic implements ILineGraphic {
loadRelations() {
if (this.datas?.paRef?.id) {
this.relationManage.addRelation(
new GraphicRelationParam(this, SectionPort.A),
new GraphicRelationParam(this, DevicePort.A),
new GraphicRelationParam(
this.queryStore.queryById(this.datas.paRef.id),
protoPort2Data(this.datas.paRef.devicePort)
@ -340,7 +359,7 @@ export class Section extends JlGraphic implements ILineGraphic {
}
if (this.datas?.pbRef?.id) {
this.relationManage.addRelation(
new GraphicRelationParam(this, SectionPort.B),
new GraphicRelationParam(this, DevicePort.B),
new GraphicRelationParam(
this.queryStore.queryById(this.datas.pbRef.id),
protoPort2Data(this.datas.pbRef.devicePort)

View File

@ -48,10 +48,11 @@ import { graphicData } from 'src/protos/stationLayoutGraphics';
import { AxleCounting } from '../axleCounting/AxleCounting';
import { LogicSection } from '../logicSection/LogicSection';
import { LogicSectionDraw } from '../logicSection/LogicSectionDrawAssistant';
import { Turnout, TurnoutPort } from '../turnout/Turnout';
import { Turnout } from '../turnout/Turnout';
import {
ISectionData,
Section,
DevicePort,
SectionConsts,
SectionTemplate,
SectionType,
@ -222,7 +223,7 @@ export class SectionDraw extends GraphicDrawAssistant<
turnouts.push(turnout);
Object.values(TurnoutPort).forEach((port) => {
Object.values(DevicePort).forEach((port) => {
const currentPortRelated = turnout.getGraphicOfPort(port);
if (
currentPortRelated.some((graphic) => graphic instanceof AxleCounting)

View File

@ -17,8 +17,8 @@ import {
createRelatedRefProto,
} from '../CommonGraphics';
import { SignalCode } from './SignalCode';
import { Section, SectionPort, SectionType } from '../section/Section';
import { Turnout, TurnoutPort } from '../turnout/Turnout';
import { Section, DevicePort, SectionType } from '../section/Section';
import { Turnout } from '../turnout/Turnout';
import { graphicData } from 'src/protos/stationLayoutGraphics';
export enum Direction {
@ -204,7 +204,7 @@ export class Signal extends JlGraphic {
let deviceId = '';
let deviceType = '';
let minD = Number.MAX_SAFE_INTEGER;
let port: SectionPort | TurnoutPort = SectionPort.A;
let port: DevicePort = DevicePort.A;
sections.forEach((sec: Section) => {
const verticesList = sec.getVerticesList();
for (let i = 0; i < verticesList.length - 1; i++) {
@ -227,7 +227,7 @@ export class Signal extends JlGraphic {
minD = d;
deviceId = sec.id;
deviceType = sec.type;
port = SectionPort.A;
port = DevicePort.A;
}
}
});
@ -245,7 +245,7 @@ export class Signal extends JlGraphic {
minD = d;
deviceId = turnout.id;
deviceType = turnout.type;
port = TurnoutPort.A;
port = DevicePort.A;
}
}
for (let i = 0; i < turnout.datas.pointB.length; i++) {
@ -260,7 +260,7 @@ export class Signal extends JlGraphic {
minD = d;
deviceId = turnout.id;
deviceType = turnout.type;
port = TurnoutPort.B;
port = DevicePort.B;
}
}
for (let i = 0; i < turnout.datas.pointC.length; i++) {
@ -275,7 +275,7 @@ export class Signal extends JlGraphic {
minD = d;
deviceId = turnout.id;
deviceType = turnout.type;
port = TurnoutPort.C;
port = DevicePort.C;
}
}
});

View File

@ -14,7 +14,7 @@ import {
createRelatedRefProto,
protoPort2Data,
} from '../CommonGraphics';
import { Section, SectionPort } from '../section/Section';
import { Section, DevicePort } from '../section/Section';
export enum CoachNum {
Four = 0,
@ -106,7 +106,7 @@ export class StopPosition extends JlGraphic {
let deviceId = '';
let deviceType = '';
let minD = Number.MAX_SAFE_INTEGER;
let port = SectionPort.A;
let port = DevicePort.A;
sections.forEach((sec: Section) => {
const verticesList = sec.getVerticesList();
for (let i = 0; i < verticesList.length - 1; i++) {
@ -129,7 +129,7 @@ export class StopPosition extends JlGraphic {
minD = d;
deviceId = sec.id;
deviceType = sec.type;
port = SectionPort.A;
port = DevicePort.A;
}
}
});

View File

@ -9,8 +9,8 @@ import {
calculateMirrorPoint,
distance,
} from 'src/jl-graphic';
import { Turnout, TurnoutPort } from '../turnout/Turnout';
import { Section } from '../section/Section';
import { Turnout } from '../turnout/Turnout';
import { DevicePort, Section } from '../section/Section';
import { AxleCounting } from '../axleCounting/AxleCounting';
import { state } from 'src/protos/device_state';
import { getKmDistance } from 'src/drawApp/lineScene';
@ -335,7 +335,7 @@ export class Train extends JlGraphic {
if (!dev) {
return;
}
const portArr = [TurnoutPort.A, TurnoutPort.B, TurnoutPort.C];
const portArr = [DevicePort.A, DevicePort.B, DevicePort.C];
const findIndex = portArr.findIndex((item) => {
return item == this.states.devicePort;
});

View File

@ -16,10 +16,10 @@ import {
import {
Section,
SectionConsts,
SectionPort,
DevicePort,
SectionType,
} from '../section/Section';
import { Turnout, TurnoutConsts, TurnoutPort } from '../turnout/Turnout';
import { Turnout, TurnoutConsts } from '../turnout/Turnout';
export interface ITransponderData extends GraphicData {
get code(): string; // 编号
@ -238,12 +238,12 @@ export class Transponder extends JlGraphic {
if (findSection) {
this.relationManage.addRelation(
new GraphicRelationParam(this),
new GraphicRelationParam(findSection, SectionPort.A)
new GraphicRelationParam(findSection, DevicePort.A)
);
return;
}
let tPort: TurnoutPort | null = null;
const portList = [TurnoutPort.A, TurnoutPort.B, TurnoutPort.C];
let tPort: DevicePort | null = null;
const portList = [DevicePort.A, DevicePort.B, DevicePort.C];
const turnouts = this.queryStore.queryByType<Turnout>(Turnout.Type);
const findTurnout = turnouts.find((turnout) => {
let s = false;

View File

@ -10,8 +10,7 @@ import {
angleOfIncludedAngle,
distance2,
} from 'src/jl-graphic';
import { Section, SectionPort, SectionType } from '../section/Section';
import { epsilon } from 'src/jl-graphic/math';
import { Section, DevicePort, SectionType } from '../section/Section';
import {
IRelatedRefData,
createRelatedRefProto,
@ -90,12 +89,6 @@ export enum TurnoutPosition {
REVERSE = 1,
}
export enum TurnoutPort {
A = 'A',
B = 'B',
C = 'C',
}
export function getForkPoint(r: number, p: IPointData): IPointData {
if (r === 0) return { x: 0, y: 0 };
const len = Math.sqrt((-p.x) ** 2 + (-p.y) ** 2);
@ -105,8 +98,8 @@ export function getForkPoint(r: number, p: IPointData): IPointData {
export class TurnoutSection extends Graphics {
turnout: Turnout;
port: TurnoutPort;
constructor(turnout: Turnout, port: TurnoutPort) {
port: DevicePort;
constructor(turnout: Turnout, port: DevicePort) {
super();
this.turnout = turnout;
this.port = port;
@ -115,23 +108,23 @@ export class TurnoutSection extends Graphics {
paint() {
let pList: IPointData[] = [];
switch (this.port) {
case TurnoutPort.A:
case DevicePort.A:
pList = this.turnout.datas.pointA;
break;
case TurnoutPort.B:
case DevicePort.B:
pList = this.turnout.datas.pointB;
break;
case TurnoutPort.C:
case DevicePort.C:
pList = this.turnout.datas.pointC;
break;
}
const gap = this.port === TurnoutPort.A ? 0 : TurnoutConsts.forkLenth;
const gap = this.port === DevicePort.A ? 0 : TurnoutConsts.forkLenth;
let color = TurnoutConsts.lineColor;
if (this.turnout.states.occupied) {
if (
this.port === TurnoutPort.A ||
(this.turnout.states.dw && this.port === TurnoutPort.B) ||
(this.turnout.states.fw && this.port === TurnoutPort.C)
this.port === DevicePort.A ||
(this.turnout.states.dw && this.port === DevicePort.B) ||
(this.turnout.states.fw && this.port === DevicePort.C)
) {
color = TurnoutConsts.occupiedColor;
}
@ -181,9 +174,9 @@ export class Turnout extends JlGraphic {
this.graphics = {
fork: new ForkGraphic(this),
sections: [
new TurnoutSection(this, TurnoutPort.A),
new TurnoutSection(this, TurnoutPort.B),
new TurnoutSection(this, TurnoutPort.C),
new TurnoutSection(this, DevicePort.A),
new TurnoutSection(this, DevicePort.B),
new TurnoutSection(this, DevicePort.C),
],
label: new VectorText(),
};
@ -259,6 +252,24 @@ export class Turnout extends JlGraphic {
}
}
getConnectElement(port: DevicePort) {
const relation = this.relationManage
.getRelationsOfGraphic(this)
.find(
(relation) =>
relation.getRelationParam(this).getParam<DevicePort>() === port &&
(relation.getOtherGraphic(this) instanceof Section ||
relation.getOtherGraphic(this) instanceof Turnout)
);
if (!relation) {
return;
}
return {
g: relation?.getOtherGraphic(this) as Section | Turnout,
port: relation?.getOtherRelationParam(this).getParam<DevicePort>(),
};
}
buildRelation(): void {
this.relationManage.deleteRelationOfGraphic(this);
@ -275,9 +286,9 @@ export class Turnout extends JlGraphic {
this.relationManage.addRelation(
new GraphicRelationParam(
this,
[TurnoutPort.A, TurnoutPort.B, TurnoutPort.C][i]
[DevicePort.A, DevicePort.B, DevicePort.C][i]
),
new GraphicRelationParam(section, SectionPort.A)
new GraphicRelationParam(section, DevicePort.A)
);
}
if (
@ -289,9 +300,9 @@ export class Turnout extends JlGraphic {
this.relationManage.addRelation(
new GraphicRelationParam(
this,
[TurnoutPort.A, TurnoutPort.B, TurnoutPort.C][i]
[DevicePort.A, DevicePort.B, DevicePort.C][i]
),
new GraphicRelationParam(section, SectionPort.B)
new GraphicRelationParam(section, DevicePort.B)
);
}
});
@ -324,11 +335,11 @@ export class Turnout extends JlGraphic {
params = [
new GraphicRelationParam(
this,
[TurnoutPort.A, TurnoutPort.B, TurnoutPort.C][i]
[DevicePort.A, DevicePort.B, DevicePort.C][i]
),
new GraphicRelationParam(
turnout,
[TurnoutPort.A, TurnoutPort.B, TurnoutPort.C][j]
[DevicePort.A, DevicePort.B, DevicePort.C][j]
),
];
}
@ -346,7 +357,7 @@ export class Turnout extends JlGraphic {
.getRelationsOfGraphic(this)
.find(
(relation) =>
relation.getRelationParam(this).param === TurnoutPort.A &&
relation.getRelationParam(this).param === DevicePort.A &&
(relation.getOtherGraphic(this) instanceof Section ||
relation.getOtherGraphic(this) instanceof Turnout)
);
@ -364,7 +375,7 @@ export class Turnout extends JlGraphic {
.getRelationsOfGraphic(this)
.find(
(relation) =>
relation.getRelationParam(this).param === TurnoutPort.B &&
relation.getRelationParam(this).param === DevicePort.B &&
(relation.getOtherGraphic(this) instanceof Section ||
relation.getOtherGraphic(this) instanceof Turnout)
);
@ -381,7 +392,7 @@ export class Turnout extends JlGraphic {
const pcRelation = this.relationManage
.getRelationsOfGraphic(this)
.find(
(relation) => relation.getRelationParam(this).param === TurnoutPort.C
(relation) => relation.getRelationParam(this).param === DevicePort.C
);
const pcDevice = pcRelation?.getOtherGraphic<Section | Turnout>(this);
if (pcDevice) {
@ -398,7 +409,7 @@ export class Turnout extends JlGraphic {
loadRelations() {
if (this.datas.paRef?.id) {
this.relationManage.addRelation(
new GraphicRelationParam(this, TurnoutPort.A),
new GraphicRelationParam(this, DevicePort.A),
new GraphicRelationParam(
this.queryStore.queryById(this.datas.paRef.id),
protoPort2Data(this.datas.paRef.devicePort)
@ -407,7 +418,7 @@ export class Turnout extends JlGraphic {
}
if (this.datas.pbRef?.id) {
this.relationManage.addRelation(
new GraphicRelationParam(this, TurnoutPort.B),
new GraphicRelationParam(this, DevicePort.B),
new GraphicRelationParam(
this.queryStore.queryById(this.datas.pbRef.id),
protoPort2Data(this.datas.pbRef.devicePort)
@ -416,7 +427,7 @@ export class Turnout extends JlGraphic {
}
if (this.datas.pcRef?.id) {
this.relationManage.addRelation(
new GraphicRelationParam(this, TurnoutPort.C),
new GraphicRelationParam(this, DevicePort.C),
new GraphicRelationParam(
this.queryStore.queryById(this.datas.pcRef.id),
protoPort2Data(this.datas.pcRef.devicePort)
@ -425,30 +436,30 @@ export class Turnout extends JlGraphic {
}
if (this.datas.paTrackSectionId) {
this.relationManage.addRelation(
new GraphicRelationParam(this, TurnoutPort.A),
new GraphicRelationParam(this, DevicePort.A),
this.queryStore.queryById<TrackSection>(this.datas.paTrackSectionId)
);
}
if (this.datas.pbTrackSectionId) {
this.relationManage.addRelation(
new GraphicRelationParam(this, TurnoutPort.B),
new GraphicRelationParam(this, DevicePort.B),
this.queryStore.queryById<TrackSection>(this.datas.pbTrackSectionId)
);
}
if (this.datas.paTrackSectionId) {
this.relationManage.addRelation(
new GraphicRelationParam(this, TurnoutPort.C),
new GraphicRelationParam(this, DevicePort.C),
this.queryStore.queryById<TrackSection>(this.datas.pcTrackSectionId)
);
}
}
getGraphicOfPort(port: TurnoutPort) {
getGraphicOfPort(port: DevicePort) {
return this.relationManage
.getRelationsOfGraphic(this)
.filter(
(relation) =>
relation.getRelationParam(this).getParam<TurnoutPort>() === port
relation.getRelationParam(this).getParam<DevicePort>() === port
)
.map((relation) => {
return relation.getOtherGraphic(this);

View File

@ -16,7 +16,6 @@ import {
ITurnoutData,
Turnout,
TurnoutConsts,
TurnoutPort,
TurnoutSection,
TurnoutTemplate,
getForkPoint,
@ -32,7 +31,7 @@ import {
GraphicEditPlugin,
getWaypointRangeIndex,
} from 'src/jl-graphic/plugins/GraphicEditPlugin';
import { Section } from '../section/Section';
import { DevicePort, Section } from '../section/Section';
import AbsorbablePoint, {
AbsorbableLine,
} from 'src/jl-graphic/graphic/AbsorbablePosition';
@ -110,15 +109,15 @@ export class TurnoutSectionHitArea implements IHitArea {
let points: IPointData[];
let start: IPointData;
switch (this.section.port) {
case TurnoutPort.A:
case DevicePort.A:
points = this.section.turnout.datas.pointA;
start = { x: 0, y: 0 };
break;
case TurnoutPort.B:
case DevicePort.B:
points = this.section.turnout.datas.pointB;
start = getForkPoint(TurnoutConsts.forkLenth, points[0]);
break;
case TurnoutPort.C:
case DevicePort.C:
points = this.section.turnout.datas.pointC;
start = getForkPoint(TurnoutConsts.forkLenth, points[0]);
break;
@ -217,7 +216,7 @@ export class TurnoutPointsInteractionPlugin extends GraphicInteractionPlugin<Tur
onSectionContextMenu(e: FederatedMouseEvent, section: TurnoutSection) {
const p = section.turnout.screenToLocalPoint(e.global);
addPointConfig.handler = () => {
if (section.port === TurnoutPort.A) {
if (section.port === DevicePort.A) {
const { start } = getWaypointRangeIndex(
[{ x: 0, y: 0 }, ...section.turnout.datas.pointA],
false,
@ -230,7 +229,7 @@ export class TurnoutPointsInteractionPlugin extends GraphicInteractionPlugin<Tur
ps.push(...points.slice(start));
section.turnout.datas.pointA = ps;
}
if (section.port === TurnoutPort.B) {
if (section.port === DevicePort.B) {
const { start } = getWaypointRangeIndex(
[{ x: 0, y: 0 }, ...section.turnout.datas.pointB],
false,
@ -243,7 +242,7 @@ export class TurnoutPointsInteractionPlugin extends GraphicInteractionPlugin<Tur
ps.push(...points.slice(start));
section.turnout.datas.pointB = ps;
}
if (section.port === TurnoutPort.C) {
if (section.port === DevicePort.C) {
const { start } = getWaypointRangeIndex(
[{ x: 0, y: 0 }, ...section.turnout.datas.pointC],
false,
@ -259,15 +258,15 @@ export class TurnoutPointsInteractionPlugin extends GraphicInteractionPlugin<Tur
this.onSelected(section.turnout);
};
clearPointConfig.handler = () => {
if (section.port === TurnoutPort.A)
if (section.port === DevicePort.A)
section.turnout.datas.pointA = [
section.turnout.datas.pointA[section.turnout.datas.pointA.length - 1],
];
if (section.port === TurnoutPort.B)
if (section.port === DevicePort.B)
section.turnout.datas.pointB = [
section.turnout.datas.pointB[section.turnout.datas.pointB.length - 1],
];
if (section.port === TurnoutPort.C)
if (section.port === DevicePort.C)
section.turnout.datas.pointC = [
section.turnout.datas.pointC[section.turnout.datas.pointC.length - 1],
];