From 2116fc6735972f0400846aabeb80c3446867678e Mon Sep 17 00:00:00 2001 From: "DESKTOP-474NEJQ\\xzsjob" <359059686@qq.com> Date: Tue, 8 Sep 2020 17:08:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=20=E6=A0=B9=E6=8D=AEid?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E5=9B=BE=E6=A0=87=E5=B1=9E=E6=80=A7=20[?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3]=20=E8=B0=83=E7=94=A8=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=87=BD=E6=95=B0=E6=97=B6=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=9B=BE=E6=A0=87=E5=A4=A7=E5=B0=8F=E6=9C=AA?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=88=B0=E6=AD=A3=E7=A1=AE=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../working-area/working-area.component.ts | 69 ++++++++++++++----- 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 5bf565a..7002dba 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -238,6 +238,16 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV } }); } + public refreshIcon(id: string): void { + const icon = this.backgroundImage.children.find(item => item.name === id); + if (icon instanceof SinglePointIcon) { + icon.refresh(); + } else if (icon instanceof MultipointIcon) { + icon.refresh(); + } else if (icon instanceof PolygonIcon) { + icon.refresh(); + } + } /** * * @param value 缩放倍数 @@ -276,9 +286,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV const floorData = this.canvasData.originaleveryStoreyData.data; const buildingData = this.canvasData.originalcompanyBuildingData.data; const floor = this.canvasData.selectStorey; - console.log(this.canvasData.originaleveryStoreyData); - console.log(this.canvasData.originalcompanyBuildingData); - // // key=>属性名 data[key]=>属性值 Object.keys(floorData).forEach((key) => { switch (floorData[key].InteractiveMode) { @@ -575,6 +582,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV */ public setBackgroundScale(scale: number): void { this.backgroundImage.scale.set(scale); + this.emit('mouseWheel', this.backgroundImage.scale.x); } /** * 设置背景图角度 @@ -842,7 +850,7 @@ export class SinglePointIcon extends PIXI.Container { private text = new PIXI.Text(this.assetData.Name + '\r\n' + this.assetData.PropertyInfos.find(item => item.PropertyName === '名称/编号')?.PropertyValue, this.style); - + private image = PIXI.Sprite.from(this.assetData.ImageUrl); constructor(public assetData: any, private workingArea: WorkingAreaComponent) { super(); this.workingArea.backgroundImage.addChild(this); @@ -850,16 +858,16 @@ export class SinglePointIcon extends PIXI.Container { this.y = this.assetData.Point.y; this.name = this.assetData.Id; this.angle = this.assetData.Angle; - const singlePointIcon = PIXI.Sprite.from(this.assetData.ImageUrl); - singlePointIcon.x = 0; - singlePointIcon.y = 0; - singlePointIcon.width = this.assetData.Width; - singlePointIcon.height = this.assetData.Height; - - singlePointIcon.alpha = 1; - singlePointIcon.anchor.set(0.5); - singlePointIcon.interactive = true; - singlePointIcon + + this.image.x = 0; + this.image.y = 0; + this.image.width = this.assetData.Width; + this.image.height = this.assetData.Height; + + this.image.alpha = 1; + this.image.anchor.set(0.5); + this.image.interactive = true; + this.image .on('mousedown', event => { event.stopPropagation(); console.log(this.assetData); @@ -906,12 +914,12 @@ export class SinglePointIcon extends PIXI.Container { } }); - this.text.x = singlePointIcon.x; - this.text.y = singlePointIcon.y - singlePointIcon.height / 2; + this.text.x = this.image.x; + this.text.y = this.image.y - this.image.height / 2; this.text.anchor.set(0.5, 1); this.addChild(this.text); - this.addChild(singlePointIcon); + this.addChild(this.image); } // 设置名称 public setNameVisible(value: boolean, mode: GameMode) { @@ -919,6 +927,15 @@ export class SinglePointIcon extends PIXI.Container { this.text.visible = value; } } + // 刷新 + public refresh() { + this.image.width = this.assetData.Width; + this.image.height = this.assetData.Height; + this.angle = this.assetData.Angle; + this.text.text = this.assetData.Name + + '\r\n' + + this.assetData.PropertyInfos.find(item => item.PropertyName === '名称/编号')?.PropertyValue; + } } /** * 多点连线 @@ -1135,6 +1152,12 @@ export class MultipointIcon extends PIXI.Container { this.text.visible = value; } } + // + public refresh() { + this.text.text = this.assetData.Name + + '\r\n' + + this.assetData.PropertyInfos.find(item => item.PropertyName === '名称/编号')?.PropertyValue; + } } /** * 多边形 @@ -1349,6 +1372,18 @@ export class PolygonIcon extends PIXI.Container { this.text.visible = value; } } + public refresh() { + this.text.text = this.assetData.Name + + '\r\n' + + this.assetData.PropertyInfos.find(item => item.PropertyName === '名称/编号')?.PropertyValue; + // 填充多边形 + const color: number = this.assetData.Color.substring(0, 7).replace('#', '0x'); + const angle: number = parseInt(this.assetData.Color.substring(7), 16) / 255; + this.polygonGraphics.clear(); + this.polygonGraphics.beginFill(color, angle); + this.polygonGraphics.drawPolygon(this.getPoints()); + this.polygonGraphics.endFill(); + } } export class Line extends PIXI.Container { From cff456ca1642a0a73aaa2e5ffd93ee310ce307f0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-474NEJQ\\xzsjob" <359059686@qq.com> Date: Tue, 8 Sep 2020 17:12:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/working-area/working-area.component.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 7002dba..09efe03 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -238,6 +238,10 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV } }); } + /** + * 根据id刷新图标 + * @param id 图标数据id + */ public refreshIcon(id: string): void { const icon = this.backgroundImage.children.find(item => item.name === id); if (icon instanceof SinglePointIcon) {