From d3691fd43d5caef3f60734d47998379fa4f5dded Mon Sep 17 00:00:00 2001 From: "DESKTOP-474NEJQ\\xzsjob" <359059686@qq.com> Date: Tue, 22 Sep 2020 11:51:37 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E6=AD=A3]=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=AE=AD=E5=A4=B4=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../working-area/working-area.component.ts | 54 ++++++++----------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 016f93f..32b7d4e 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -157,7 +157,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV if (event.keyCode === 46) { this.selection.objects.forEach(item => { // 删除 选中的数据 - if (item.assetData.IsFromBuilding) { + if (item.assetData?.IsFromBuilding) { // console.log(this.canvasData.originaleveryStoreyData.data[item.assetData.Id]); delete this.canvasData.originalcompanyBuildingData?.data[item.assetData.Id]; // console.log(this.canvasData.originalcompanyBuildingData.data[item.assetData.Id]); @@ -318,7 +318,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.rectToolGraphics.closePath(); } if (this.paintingArrows !== null) { - this.paintingArrows.data.pointB = new PIXI.Point(this.circleShadow.position.x, this.circleShadow.position.y); + this.paintingArrows.assetData.pointB = new PIXI.Point(this.circleShadow.position.x, this.circleShadow.position.y); this.paintingArrows.refresh(); } }); @@ -776,10 +776,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV case PaintMode.Arrows: if (this.paintingArrows === null) { const data = { + Id: ObjectID.default.generate(), name: 'string', point: new PIXI.Point(this.circleShadow.x, this.circleShadow.y), pointA: new PIXI.Point(this.circleShadow.x, this.circleShadow.y), - pointB: new PIXI.Point(this.circleShadow.x, this.circleShadow.y), + pointB: new PIXI.Point(this.circleShadow.x, this.circleShadow.y), source: 'assets/images/进攻方向.png', }; this.paintingArrows = new Arrows(data, this); @@ -1784,13 +1785,15 @@ export class Car extends SinglePointIcon { /** * 管线 */ -export class Pipeline extends PIXI.Graphics { +export class Pipeline extends PIXI.Container { + public line: PIXI.Graphics = new PIXI.Graphics(); constructor(public assetData: any, private workingArea: WorkingAreaComponent) { super(); this.name = this.assetData.Id; this.x = this.assetData.Point.x; this.y = this.assetData.Point.y; this.workingArea.backgroundImage.addChild(this); + this.addChild(this.line); // 画线图标 this.refresh(); this.interactive = true; @@ -1804,25 +1807,25 @@ export class Pipeline extends PIXI.Graphics { * 刷新 */ public refresh() { - this.clear(); - this.lineStyle(5, 0x0000ff, 1); + this.line.clear(); + this.line.lineStyle(5, 0x0000ff, 1); for (let i = 0, count = this.assetData.MultiPoint.length; i < count; i++) { const pointA = this.assetData.MultiPoint[i]; if (i === 0) { - this.moveTo(pointA.x, pointA.y); + this.line.moveTo(pointA.x, pointA.y); } else { - this.lineTo(pointA.x, pointA.y); + this.line.lineTo(pointA.x, pointA.y); if (i === count - 1) { const pointB = this.assetData.MultiPoint[i - 1]; const angle = Math.atan2((pointA.y - pointB.y), (pointA.x - pointB.x)) * (180 / Math.PI) + 90; - this.beginFill(0x0000ff); - this.drawStar(pointA.x, pointA.y, 3, 5, 0, (Math.PI / 180 * angle)); + this.line.beginFill(0x0000ff); + this.line.drawStar(pointA.x, pointA.y, 3, 5, 0, (Math.PI / 180 * angle)); } else { - this.drawCircle(pointA.x, pointA.y, 5); + this.line.drawCircle(pointA.x, pointA.y, 5); } } } - this.endFill(); + this.line.endFill(); // if (this.assetData.MultiPoint.length >= 2) { // const pointA = this.assetData.MultiPoint[this.assetData.MultiPoint.length - 2]; // const pointB = this.assetData.MultiPoint[this.assetData.MultiPoint.length - 1]; @@ -1838,20 +1841,13 @@ export class Pipeline extends PIXI.Graphics { * 创建一个只有2个点组成的箭头 */ export class Arrows extends PIXI.Container { - public data: any; - // public icon: PIXI.Sprite; public line: PIXI.Graphics = new PIXI.Graphics(); - public san: PIXI.Graphics = new PIXI.Graphics(); public ready = false; - constructor(assetData: any, private workingArea: WorkingAreaComponent) { + constructor(public assetData: any, private workingArea: WorkingAreaComponent) { super(); this.workingArea.backgroundImage.addChild(this); - this.data = assetData; - // 画线图标 - // this.icon = new PIXI.Sprite(PIXI.Texture.from(this.data.source)); + this.name = this.assetData.Id; this.addChild(this.line); - this.addChild(this.san); - // this.addChild(this.icon); this.refresh(); this.interactive = true; this.on('mousedown', event => { @@ -1866,22 +1862,16 @@ export class Arrows extends PIXI.Container { public refresh() { this.line.clear(); this.line.lineStyle(5, 0xff0000, 1); - this.line.moveTo(this.data.pointA.x, this.data.pointA.y); - this.line.lineTo(this.data.pointB.x, this.data.pointB.y); + this.line.moveTo(this.assetData.pointA.x, this.assetData.pointA.y); + this.line.lineTo(this.assetData.pointB.x, this.assetData.pointB.y); - const angle = Math.atan2((this.data.pointB.y - this.data.pointA.y), (this.data.pointB.x - this.data.pointA.x)) * (180 / Math.PI) + 90; + const angle = Math.atan2((this.assetData.pointB.y - this.assetData.pointA.y), (this.assetData.pointB.x - this.assetData.pointA.x)) + * (180 / Math.PI) + 90; - // this.san.clear(); - // this.san.lineStyle(5, 0xff0000, 1); this.line.beginFill(0xff0000); console.log(Math.PI / 180 / 1.6); - this.line.drawStar(this.data.pointB.x, this.data.pointB.y, 3, 10, 0, (Math.PI / 180 * angle)); - // this.san.angle = angle; + this.line.drawStar(this.assetData.pointB.x, this.assetData.pointB.y, 3, 10, 0, (Math.PI / 180 * angle)); this.line.endFill(); - // this.icon.anchor.set(0, 0.5); - // this.icon.x = this.data.pointB.x; - // this.icon.y = this.data.pointB.y; - // this.icon.angle = angle; } } /**