Browse Source

[修正] 删除箭头错误

develop
徐振升 4 years ago
parent
commit
d3691fd43d
  1. 54
      src/app/working-area/working-area.component.ts

54
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;
}
}
/**

Loading…
Cancel
Save