This commit is contained in:
joylink_zhaoerwei 2023-08-08 15:22:56 +08:00
parent ddb03f379d
commit 774835ee4b

View File

@ -35,15 +35,12 @@ export class Slope extends JlGraphic {
super(Slope.Type);
this.lineGraphic = new Graphics();
this.slopeNumber = new VectorText();
this.slopeNumber.name = 'slopeNumber';
this.slopeLong = new VectorText();
this.slopeLong.name = 'slopeLong';
const vectorTexts = [this.slopeNumber, this.slopeLong];
vectorTexts.forEach((vectorText) => {
vectorText.setVectorFontSize(14);
vectorText.anchor.set(0.5);
vectorText.style.fill = '0xffffff';
vectorText.transformSave = true;
});
this.transformSave = true;
this.addChild(this.lineGraphic);
@ -80,21 +77,11 @@ export class Slope extends JlGraphic {
this.slopeNumber.text = Math.abs(
parseFloat(this.datas.slopeNumber / 1000 + '')
);
const slopeNumberPosition = this.datas.childTransforms?.find(
(t) => t.name === this.slopeNumber.name
)?.transform.position;
if (slopeNumberPosition) {
this.slopeNumber.position.set(
slopeNumberPosition.x,
slopeNumberPosition.y
);
} else {
const centerPos = calculateLineMidpoint(
this.datas.points[0],
this.datas.points[this.datas.points.length - 1]
);
this.slopeNumber.position.set(centerPos.x, centerPos.y - 15);
}
const centerPos = calculateLineMidpoint(
this.datas.points[0],
this.datas.points[this.datas.points.length - 1]
);
this.slopeNumber.position.set(centerPos.x, centerPos.y - 15);
//坡度长度
const slopeKiloMarkerL = this.queryStore.queryById(
this.datas.refDeviceId[0]
@ -105,18 +92,7 @@ export class Slope extends JlGraphic {
this.slopeLong.text =
slopeKiloMarkerR.datas.kilometerSystem[0]?.kilometer -
slopeKiloMarkerL.datas.kilometerSystem[0]?.kilometer;
const slopeLongPosition = this.datas.childTransforms?.find(
(t) => t.name === this.slopeLong.name
)?.transform.position;
if (slopeLongPosition) {
this.slopeLong.position.set(slopeLongPosition.x, slopeLongPosition.y);
} else {
const centerPos = calculateLineMidpoint(
this.datas.points[0],
this.datas.points[this.datas.points.length - 1]
);
this.slopeLong.position.set(centerPos.x, centerPos.y + 15);
}
this.slopeLong.position.set(centerPos.x, centerPos.y + 15);
}
loadRelations() {
if (this.datas.refDeviceId.length) {