Browse Source

[优化] 图标的旋转/缩放不再影响图标名称

develop
徐振升 4 years ago
parent
commit
603531d3f5
  1. 27
      src/app/working-area/working-area.component.ts

27
src/app/working-area/working-area.component.ts

@ -522,6 +522,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.paintingIcon = new MultipointIcon(assetData1, this);
// this.paintingIcon = new MultipointIcon(this.previewSinglePointIcon.texture, new PIXI.Point(0, 0), this.paintPoints, this,
// this.canvasData.selectTemplateData.name);
this.emit('backgroundScale', this.backgroundImage.scale.x);
break;
case PaintMode.polygonIcon:
this.previewLineSegment.visible = true;
@ -821,6 +822,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
break;
}
this.paintPoints.splice(0, this.paintPoints.length);
this.emit('backgroundScale', this.backgroundImage.scale.x);
}
/**
*
@ -906,7 +909,8 @@ export class SinglePointIcon extends PIXI.Container {
this.x = this.assetData.Point.x;
this.y = this.assetData.Point.y;
this.name = this.assetData.Id;
this.angle = this.assetData.Angle;
this.image.angle = this.assetData.Angle;
this.image.x = 0;
this.image.y = 0;
@ -982,7 +986,7 @@ export class SinglePointIcon extends PIXI.Container {
public refresh() {
this.image.width = this.assetData.Width;
this.image.height = this.assetData.Height;
this.angle = this.assetData.Angle;
this.image.angle = this.assetData.Angle;
this.text.text = this.assetData.Name
+ '\r\n'
+ this.assetData.PropertyInfos.find(item => item.PropertyName === '名称/编号')?.PropertyValue;
@ -1047,13 +1051,10 @@ export class MultipointIcon extends PIXI.Container {
this.iconsTilingSprite.push(icon);
this.addChild(icon);
if (i === 0) {
// 名称
// this.text = new PIXI.Text(this.assetData.Name, {
// fontFamily: 'Arial', fontSize: 18, fill: 0xffffff, align: 'center'
// });
this.text.anchor.set(0.5);
this.text.position = icon.position;
this.text.y -= this.assetData.Height;
icon.addChild(this.text);
this.addChild(this.text);
}
}
// 画点
@ -1112,6 +1113,8 @@ export class MultipointIcon extends PIXI.Container {
this.iconsTilingSprite[index].angle = angle;
this.iconsTilingSprite[index].width = distance;
this.text.position = this.iconsTilingSprite[index].position;
this.text.y -= this.assetData.Height;
} else if (index < array.length - 1) {// 不是第一个点,也不是最后一个点
this.iconsTilingSprite[index].x = newPosition.x;
this.iconsTilingSprite[index].y = newPosition.y;
@ -1152,6 +1155,11 @@ export class MultipointIcon extends PIXI.Container {
});
});
// 缩放
this.workingArea.on('backgroundScale', data => {
const scale = 1 / data;
this.text.scale.set(scale);
});
// 添加选中事件
this.iconsTilingSprite.forEach((item, index, array) => {
item.interactive = true;
@ -1372,6 +1380,11 @@ export class PolygonIcon extends PIXI.Container {
.on('rightclick', event => {
// this.workingArea.selection.deselectAll();
});
// 缩放
this.workingArea.on('backgroundScale', data => {
const scale = 1 / data;
this.text.scale.set(scale);
});
}
/**
*

Loading…
Cancel
Save