计轴删除后的计轴区段
This commit is contained in:
parent
bcb235ccaf
commit
7aacacaa99
@ -16,10 +16,8 @@ import {
|
||||
ITurnoutPosRefData,
|
||||
} from './AxleCountingSection';
|
||||
import { AxleCounting } from '../axleCounting/AxleCounting';
|
||||
import { Turnout } from '../turnout/Turnout';
|
||||
import { Turnout, TurnoutPort } from '../turnout/Turnout';
|
||||
import { createRelatedRefProto } from '../CommonGraphics';
|
||||
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
|
||||
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
|
||||
|
||||
function hasCommonElements(arr1: string[], arr2: string[]) {
|
||||
for (let i = 0; i < arr1.length; i++) {
|
||||
@ -99,12 +97,25 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant<
|
||||
const pbRef = createRelatedRefProto(graphics[1].type, graphics[1].id);
|
||||
const turnoutPosData: ITurnoutPosRefData[] = [];
|
||||
if (commonElement[0].type == 'Turnout') {
|
||||
commonElement.forEach((Turnout) => {
|
||||
if (commonElement.length > 1) {
|
||||
turnoutPosData.push({
|
||||
id: Turnout.id,
|
||||
position: 0,
|
||||
});
|
||||
commonElement.forEach((Turnout, i) => {
|
||||
if (commonElement.length == 2) {
|
||||
if (turoutPos == -1) {
|
||||
if (i == 1) {
|
||||
turnoutPosData.push({
|
||||
id: Turnout.id,
|
||||
position: 1,
|
||||
});
|
||||
} else {
|
||||
turnoutPosData.push({
|
||||
id: Turnout.id,
|
||||
position: 0,
|
||||
});
|
||||
}
|
||||
} else
|
||||
turnoutPosData.push({
|
||||
id: Turnout.id,
|
||||
position: 0,
|
||||
});
|
||||
} else {
|
||||
if (turoutPos == 0) {
|
||||
turnoutPosData.push({
|
||||
@ -272,6 +283,59 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant<
|
||||
}
|
||||
}
|
||||
}
|
||||
//补删除计轴后的区段
|
||||
const axleCountingAll = this.app.queryStore.queryByType<AxleCounting>(
|
||||
AxleCounting.Type
|
||||
);
|
||||
const deleteRefTurout: string[] = [];
|
||||
const redawAxleCounting: AxleCounting[] = [];
|
||||
axleCountingAll.forEach((axleCounting) => {
|
||||
const axleCountingRelations =
|
||||
axleCounting.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
axleCounting,
|
||||
AxleCountingSection.Type
|
||||
);
|
||||
if (
|
||||
axleCounting.datas.axleCountingRef.length == 2 &&
|
||||
axleCountingRelations.length < 2
|
||||
) {
|
||||
axleCounting.datas.axleCountingRef.forEach((ref) => {
|
||||
if (ref.deviceType == 1) {
|
||||
redawAxleCounting.push(axleCounting);
|
||||
}
|
||||
if (ref.deviceType == 1 && !deleteRefTurout.includes(ref.id)) {
|
||||
deleteRefTurout.push(ref.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
deleteRefTurout.forEach((id) => {
|
||||
const turout = this.app.queryStore.queryById(id);
|
||||
const turoutRelations =
|
||||
turout.relationManage.getRelationsOfGraphicAndOtherType(
|
||||
turout,
|
||||
Turnout.Type
|
||||
);
|
||||
const refTurout = turoutRelations[0].getOtherGraphic(turout);
|
||||
const refs = refTurout.relationManage
|
||||
.getRelationsOfGraphicAndOtherType(refTurout, AxleCounting.Type)
|
||||
.find(
|
||||
(relation) =>
|
||||
relation.getRelationParam(refTurout).param !== TurnoutPort.C
|
||||
);
|
||||
const refAxleCountin = refs?.getOtherGraphic(refTurout) as AxleCounting;
|
||||
this.draw(
|
||||
[refAxleCountin, redawAxleCounting[0]],
|
||||
[refTurout, turout],
|
||||
map
|
||||
);
|
||||
this.draw(
|
||||
[refAxleCountin, redawAxleCounting[1]],
|
||||
[refTurout, turout],
|
||||
map,
|
||||
-1
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
class AxleCountingSectionGraphicHitArea implements IHitArea {
|
||||
@ -291,23 +355,10 @@ class AxleCountingSectionGraphicHitArea implements IHitArea {
|
||||
}
|
||||
}
|
||||
|
||||
export const splitSectionConfig: MenuItemOptions = {
|
||||
name: '拆分计轴区段',
|
||||
};
|
||||
const SectionEditMenu: ContextMenu = ContextMenu.init({
|
||||
name: '区段编辑菜单',
|
||||
groups: [
|
||||
{
|
||||
items: [splitSectionConfig],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export class AxleCountingSectionInteraction extends GraphicInteractionPlugin<AxleCountingSection> {
|
||||
static Name = 'AxleCountingSection_transform';
|
||||
constructor(app: JlDrawApp) {
|
||||
super(AxleCountingSectionInteraction.Name, app);
|
||||
app.registerMenu(SectionEditMenu);
|
||||
}
|
||||
static init(app: JlDrawApp) {
|
||||
return new AxleCountingSectionInteraction(app);
|
||||
|
Loading…
Reference in New Issue
Block a user