分隔符调整

This commit is contained in:
dong 2023-07-24 15:44:56 +08:00
parent a69a0ff463
commit 3548f75666

View File

@ -18,6 +18,7 @@ import {
} from './Separator'; } from './Separator';
import { SeparatorData } from 'src/drawApp/graphics/SeparatorInteraction'; import { SeparatorData } from 'src/drawApp/graphics/SeparatorInteraction';
import { Turnout } from '../turnout/Turnout'; import { Turnout } from '../turnout/Turnout';
import { LogicSection } from '../logicSection/LogicSection';
export class SeparatorDraw extends GraphicDrawAssistant< export class SeparatorDraw extends GraphicDrawAssistant<
SeparatorTemplate, SeparatorTemplate,
@ -65,6 +66,7 @@ export class SeparatorDraw extends GraphicDrawAssistant<
} }
const arrType = [Section.Type, Turnout.Type]; // 只统计关联关系是道岔和区段的 const arrType = [Section.Type, Turnout.Type]; // 只统计关联关系是道岔和区段的
sections.forEach((section) => { sections.forEach((section) => {
if (section.datas.sectionType == SectionType.TurnoutPhysical) return; // 排除道岔区段
const allR = section.relationManage const allR = section.relationManage
.getRelationsOfGraphic(section) .getRelationsOfGraphic(section)
.filter((ref) => { .filter((ref) => {
@ -74,20 +76,24 @@ export class SeparatorDraw extends GraphicDrawAssistant<
allR.forEach((relation, index) => { allR.forEach((relation, index) => {
const r = relation.getRelationParam(section); const r = relation.getRelationParam(section);
const other = relation.getOtherRelationParam(section); const other = relation.getOtherRelationParam(section);
if (!section.datas.children.includes(other.g.id)) { if (!section.datas.children.includes(other.g.id + '')) {
// 排除物理区段和自身逻辑区段的关联关系 // 排除物理区段和自身逻辑区段的关联关系
port.push(r.param); port.push(r.param);
} }
section.datas.children.forEach((id, ind) => {
if (ind != 0) {
const logicSection = this.app.queryStore.queryById(id);
if (!rMap.has(id)) {
rMap.set(id, { g: logicSection });
}
}
});
if (!rMap.has(setKey(r))) { if (!rMap.has(setKey(r))) {
rMap.set(setKey(r), { ...r }); rMap.set(setKey(r), { ...r });
} }
if (!rMap.has(setKey(other))) { if (!rMap.has(setKey(other))) {
rMap.set(setKey(other), { ...other, repetition: true }); rMap.set(setKey(other), { ...other, repetition: true });
} }
if (section.datas.sectionType === SectionType.Logic) {
// 逻辑区段没有断路分隔符
return;
}
if (index == allR.length - 1) { if (index == allR.length - 1) {
if (!port.includes('A')) { if (!port.includes('A')) {
rMap.set(`${section.id}_A`, { rMap.set(`${section.id}_A`, {
@ -110,7 +116,13 @@ export class SeparatorDraw extends GraphicDrawAssistant<
const allR = turnout.relationManage const allR = turnout.relationManage
.getRelationsOfGraphic(turnout) .getRelationsOfGraphic(turnout)
.filter((ref) => { .filter((ref) => {
return arrType.includes(ref.getOtherGraphic(turnout).type); const otherG = ref.getOtherGraphic(turnout);
return (
otherG.type == Turnout.Type ||
(otherG.type == Section.Type &&
(otherG as Section).datas.sectionType !=
SectionType.TurnoutPhysical) // 排除道岔区段
);
}); });
const port: string[] = []; const port: string[] = [];
allR.forEach((relation, index) => { allR.forEach((relation, index) => {
@ -169,7 +181,10 @@ export class SeparatorDraw extends GraphicDrawAssistant<
rMap.forEach((item) => { rMap.forEach((item) => {
if (!item.repetition) { if (!item.repetition) {
let p; let p;
if (item.g.type == Section.Type) { if (item.g.type == LogicSection.Type) {
const ps = item.g.linePoints;
p = ps[0];
} else if (item.g.type == Section.Type) {
p = item.g.getStartPoint(); p = item.g.getStartPoint();
if (item.param == 'B') { if (item.param == 'B') {
p = item.g.getEndPoint(); p = item.g.getEndPoint();