diff --git a/src/drawApp/graphics/TurnoutInteraction.ts b/src/drawApp/graphics/TurnoutInteraction.ts index 4b2c78c..6b5309e 100644 --- a/src/drawApp/graphics/TurnoutInteraction.ts +++ b/src/drawApp/graphics/TurnoutInteraction.ts @@ -233,7 +233,6 @@ export class TurnoutOperationPlugin extends GraphicInteractionPlugin { val = turnout.states[propName] > 0 ? 0 : 20; successNotify(`限速设为${val}`); } - console.log(val); setSwitchStatus(lineId, { ...state, id: turnout.datas.code, diff --git a/src/graphics/section/Section.ts b/src/graphics/section/Section.ts index 53295f4..c38c507 100644 --- a/src/graphics/section/Section.ts +++ b/src/graphics/section/Section.ts @@ -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() { diff --git a/src/graphics/section/SectionDrawAssistant.ts b/src/graphics/section/SectionDrawAssistant.ts index 8a52cea..f88db7b 100644 --- a/src/graphics/section/SectionDrawAssistant.ts +++ b/src/graphics/section/SectionDrawAssistant.ts @@ -420,6 +420,10 @@ export class SectionPointEditPlugin extends GraphicInteractionPlugin
{ 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);