计轴区段名称显示

This commit is contained in:
joylink_zhaoerwei 2023-07-12 15:51:33 +08:00
parent b53e27640a
commit 8e15d22360

View File

@ -5,6 +5,7 @@ import {
JlGraphic,
JlGraphicTemplate,
VectorText,
calculateLineMidpoint,
} from 'src/jl-graphic';
import { IRelatedRefData, protoPort2Data } from '../CommonGraphics';
import { SectionPort } from '../section/Section';
@ -49,7 +50,7 @@ export class AxleCountingSection extends JlGraphic {
this.labelGraphic = new VectorText();
this.labelGraphic.setVectorFontSize(14);
this.labelGraphic.anchor.set(0.5);
this.labelGraphic.style.fill = '#0f0';
this.labelGraphic.style.fill = '0xff0000';
this.labelGraphic.transformSave = true;
this.labelGraphic.name = 'label';
this.transformSave = true;
@ -83,10 +84,11 @@ export class AxleCountingSection extends JlGraphic {
if (labelPosition) {
this.labelGraphic.position.set(labelPosition.x, labelPosition.y);
} else {
this.labelGraphic.position.set(
this.datas.points[0].x,
this.datas.points[0].y + 20
const centerPos = calculateLineMidpoint(
this.datas.points[0],
this.datas.points[this.datas.points.length - 1]
);
this.labelGraphic.position.set(centerPos.x, centerPos.y + 20);
}
}
get linePoints(): IPointData[] {