分隔符调整

This commit is contained in:
dong 2023-06-30 11:15:12 +08:00
parent 9807065c19
commit 46ce8c3be9

View File

@ -133,18 +133,27 @@ export class SeparatorDraw extends GraphicDrawAssistant<
}); });
} }
if (index == allR.length - 1) { if (index == allR.length - 1) {
const ps = turnout.getPortPoints();
let isALeft = true; // 判断A端在左还是右
if (ps[0][ps[0].length - 1].x > ps[1][ps[1].length - 1].x) {
isALeft = false;
}
if (!port.includes('A')) { if (!port.includes('A')) {
rMap.set(`${turnout.id}_A`, { rMap.set(`${turnout.id}_A`, {
g: turnout, g: turnout,
param: 'A', param: 'A',
separatorType: separatorTypeEnum.endB, separatorType: isALeft
? separatorTypeEnum.endA
: separatorTypeEnum.endB,
}); });
} }
if (!port.includes('B')) { if (!port.includes('B')) {
rMap.set(`${turnout.id}_B`, { rMap.set(`${turnout.id}_B`, {
g: turnout, g: turnout,
param: 'B', param: 'B',
separatorType: separatorTypeEnum.endA, separatorType: isALeft
? separatorTypeEnum.endB
: separatorTypeEnum.endA,
}); });
} }
} }
@ -152,11 +161,6 @@ export class SeparatorDraw extends GraphicDrawAssistant<
}); });
rMap.forEach((item) => { rMap.forEach((item) => {
if (!item.repetition) { if (!item.repetition) {
const sType = item.separatorType || separatorTypeEnum.section;
const separator = new Separator();
const data = new SeparatorData();
data.separatorType = sType;
separator.loadData(data);
let p; let p;
if (item.g.type == Section.Type) { if (item.g.type == Section.Type) {
p = item.g.getStartPoint(); p = item.g.getStartPoint();
@ -175,12 +179,20 @@ export class SeparatorDraw extends GraphicDrawAssistant<
p = lps[lps.length - 1]; p = lps[lps.length - 1];
} }
const tps = item.g.localToCanvasPoint(p); const tps = item.g.localToCanvasPoint(p);
separator.position.set(tps.x, tps.y); const sType = item.separatorType || separatorTypeEnum.section;
separator.id = GraphicIdGenerator.next(); this.createSeparator(sType, tps);
this.storeGraphic(separator);
} }
}); });
} }
createSeparator(separatorType: separatorTypeEnum, tps: Point) {
const separator = new Separator();
const data = new SeparatorData();
data.separatorType = separatorType;
separator.loadData(data);
separator.position.set(tps.x, tps.y);
separator.id = GraphicIdGenerator.next();
this.storeGraphic(separator);
}
} }
//碰撞检测 //碰撞检测