物理区段目的地码显示

This commit is contained in:
Yuan 2023-08-03 09:26:45 +08:00
parent d14f0a0e8b
commit 4656f3147d
3 changed files with 37 additions and 2 deletions

View File

@ -233,7 +233,6 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin<Turnout> {
val = turnout.states[propName] > 0 ? 0 : 20;
successNotify(`限速设为${val}`);
}
console.log(val);
setSwitchStatus(lineId, {
...state,
id: turnout.datas.code,

View File

@ -68,12 +68,18 @@ export class Section extends JlGraphic implements ILineGraphic {
static Type = 'Section';
lineGraphic: Graphics;
labelGraphic: VectorText;
childSections: Section[] = [];
destinationCodeGraphic: VectorText;
constructor() {
super(Section.Type);
this.lineGraphic = new Graphics();
this.labelGraphic = new VectorText();
this.destinationCodeGraphic = new VectorText();
this.destinationCodeGraphic.setVectorFontSize(14);
this.destinationCodeGraphic.anchor.set(0.5);
this.destinationCodeGraphic.style.fill = '#ff0';
this.destinationCodeGraphic.transformSave = true;
this.destinationCodeGraphic.name = 'destinationCode';
this.labelGraphic.setVectorFontSize(14);
this.labelGraphic.anchor.set(0.5);
this.labelGraphic.style.fill = '#0f0';
@ -82,6 +88,7 @@ export class Section extends JlGraphic implements ILineGraphic {
this.transformSave = true;
this.addChild(this.lineGraphic);
this.addChild(this.labelGraphic);
// this.addChild(this.destinationCodeGraphic);
}
doRepaint() {
@ -123,6 +130,31 @@ export class Section extends JlGraphic implements ILineGraphic {
this.datas.points[0].y + 20
);
}
// if (this.datas.code === 'G1004') {
// debugger;
// }
if (this.datas.destinationCode.trim().length > 0) {
if (
!this.children.some((child) => child === this.destinationCodeGraphic)
) {
this.addChild(this.destinationCodeGraphic);
}
this.destinationCodeGraphic.text = this.datas.destinationCode;
const destinationCodePosition = this.datas.childTransforms?.find(
(t) => t.name === this.destinationCodeGraphic.name
)?.transform.position;
// if (destinationCodePosition) {
// this.destinationCodeGraphic.position.set(
// destinationCodePosition.x,
// destinationCodePosition.y
// );
// } else {
this.destinationCodeGraphic.position.set(
this.datas.points[0].x,
this.datas.points[0].y - 20
);
// }
}
}
getStartPoint() {

View File

@ -420,6 +420,10 @@ export class SectionPointEditPlugin extends GraphicInteractionPlugin<Section> {
g.labelGraphic.cursor = 'pointer';
g.labelGraphic.selectable = true;
g.labelGraphic.draggable = true;
g.destinationCodeGraphic.eventMode = 'static';
g.destinationCodeGraphic.cursor = 'pointer';
g.destinationCodeGraphic.selectable = true;
g.destinationCodeGraphic.draggable = true;
g.on('selected', this.onSelected, this);
g.on('unselected', this.onUnselected, this);
g.on('_rightclick', this.onContextMenu, this);