Browse Source

Merge branch '0.1.0'

develop
徐振升 4 years ago
parent
commit
f714871ea6
  1. 334
      src/app/ui/plan-assistance/plan-assistance.component.ts
  2. 250
      src/app/working-area/working-area.component.ts
  3. BIN
      src/assets/images/举高喷射消防车.png

334
src/app/ui/plan-assistance/plan-assistance.component.ts

File diff suppressed because it is too large Load Diff

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

@ -2,7 +2,7 @@ import { Component, OnInit, ElementRef, ViewChild, AfterViewInit, Input } from '
import * as PIXI from 'pixi.js';
import { EventEmitter } from 'events';
import { EventManager } from '@angular/platform-browser';
import { OutlineFilter } from 'pixi-filters';
import { OutlineFilter, OldFilmFilter } from 'pixi-filters';
import { CanvasShareDataService, GameMode } from '../canvas-share-data.service';
import {CacheTokenService} from '../http-interceptors/cache-token.service'; // 引入自动登录 获取token服务
import * as ObjectID from 'bson-objectid';
@ -60,7 +60,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
/**
*
*/
public paintMode: PaintMode;
private paintMode: PaintMode;
/**
*
*/
@ -122,6 +122,12 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
public animation;
public animationIcon;
public animationTime;
// 车辆作业面
public carAreas: PolygonIcon[];
// 车辆数据
public carData: Map<string, any> = new Map<string, any>();
// 当前选择的车辆id
public selectCar: any = null;
// 根据ID 找到数据
// 是否登录
@ -237,7 +243,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
* @param icon
*/
public moveIconToScreenCenter(icon) {
if (icon.parent === this.backgroundImage && icon.assetData.Type === 1) {
if (icon.parent === this.backgroundImage && icon.assetData.Type !== 0) {
console.log(this.backgroundImage.position);
this.backgroundImage.pivot.set(icon.x, icon.y);
this.backgroundImage.position.set(771, 404);
@ -304,6 +310,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
}
});
this.on('backgroundScale', scale => {
this.previewSinglePointIcon.scale.set(1 / this.backgroundImage.scale.x);
this.backgroundImage.children.forEach(item => {
if (item instanceof SinglePointIcon) {
if (item.assetData.FixedSize) {
@ -463,11 +470,12 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
const single = new SinglePointIcon(element, this);
});
const tempData = [
const putCarAreaData = [
{
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -521,6 +529,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -574,6 +583,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -627,6 +637,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -680,6 +691,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -733,6 +745,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -786,6 +799,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -839,6 +853,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -892,6 +907,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -945,6 +961,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -998,6 +1015,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -1051,6 +1069,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -1104,6 +1123,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -1157,6 +1177,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -1210,6 +1231,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -1263,6 +1285,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
Id: '5f6719a4e03abe3856d87d7b',
Name: '作业面',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#00ff0080',
Point: {
x: 0,
@ -1320,10 +1343,13 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
IsFromBuilding: true,
InteractiveMode: 0
},
];
const tempCarAreaData = [
{
Id: '5f6719a4e03abe3856d87d7b',
Name: '禁停区',
Angle: 0,
Type: [1, 2, 3, 4],
Color: '#ff000080',
Point: {
x: 0,
@ -1372,13 +1398,75 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
PropertyInfos: [],
IsFromBuilding: true,
InteractiveMode: 0
}, {
Id: '5f6719a4e03abe3856d87d7b',
Name: '禁停区',
Angle: 0,
Type: [1],
Color: '#ff000080',
Point: {
x: 0,
y: 0
},
Width: 32,
Border: {
w: 0,
x: 0,
y: 0,
z: 0
},
Height: 32,
Enabled: true,
FloorId: '5f670bb79e91f4410005f564',
DrawMode: 0,
FillMode: 1,
GameMode: 0,
ImageUrl: '/api/Objects/PlanPlatform/5e7b384e8121c2286c0cb290.png',
CompanyId: '5f67042b9e91f4410005f55c',
FixedSize: false,
CanConnection: true,
ConnectionObjs: [],
Thickness: 0,
BuildingId: '5f6704859e91f4410005f55f',
MultiPoint: [
{
x: 5149 - 4000,
y: 4097 - 2830
},
{
x: 6094 - 4000,
y: 4097 - 2830
},
{
x: 6094 - 4000,
y: 4152 - 2830
},
{
x: 5149 - 4000,
y: 4152 - 2830
},
],
TemplateId: '5e7b38610137e12020bd7f7b',
FireElementId: '5e7967f30814180f1c1ecaab',
PropertyInfos: [],
IsFromBuilding: true,
InteractiveMode: 0
}
];
tempData.forEach(element => {
const poly = new PolygonIcon(element, this);
putCarAreaData.forEach(element => {
const poly = new PutCarArea(element, this);
poly.visible = false;
});
tempCarAreaData.forEach(element => {
const poly = new PutCarArea(element, this);
poly.visible = false;
poly.polygonGraphics.interactive = false;
});
this.setNameVisible(false, GameMode.BasicInformation);
}
@ -1387,10 +1475,51 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
* @param data
*/
public ShowCarIcon(data: any) {
this.carData.set(data.Id, data);
const carButton = PIXI.Sprite.from(data.ImageUrl);
carButton.name = data.Id;
carButton.buttonMode = true;
carButton.interactive = true;
carButton
.on('pointerdown', (event) => {
if (this.paintMode !== PaintMode.Car) {
this.setPaintMode(PaintMode.Car);
this.selectCar = this.carData.get(event.currentTarget.name);
event.currentTarget.name = '';
event.currentTarget.visible = false;
this.previewSinglePointIcon.texture = PIXI.Texture.from(data.ImageUrl);
this.previewSinglePointIcon.visible = true;
this.previewSinglePointIcon.scale.set(1 / this.backgroundImage.scale.x);
this.backgroundImage.children.forEach(item => {
if (item instanceof PutCarArea) {
if (item.assetData.Type.indexOf(this.selectCar.Type) !== -1) {
item.visible = true;
} else {
item.visible = false;
}
}
});
}
})
.on('pointerup', (event) => {
})
.on('pointerupoutside', (event) => {
})
.on('pointerover', (event) => {
})
.on('pointerout', (event) => {
});
carButton.setParent(this.app.stage);
carButton.position.set(25, this.count * 65);
this.count++;
const tempCar2 = new Car(data, this);
tempCar2.setParent(this.app.stage);
tempCar2.position.set(25, this.count * 25);
}
/**
*
@ -1625,6 +1754,9 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.paintMode = PaintMode.endPaint;
}
break;
case PaintMode.Car:
// console.log('创建车辆');
break;
}
} else if (!event.currentTarget.dragging && this.selection.isMultiselection === true) {
this.rectToolGraphics.visible = true;
@ -1672,6 +1804,12 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
event.stopPropagation();
this.cancelPaint();
this.selection.deselectAll();
})
.on('pointerover', (event) => {
this.previewSinglePointIcon.filters = [new OldFilmFilter()];
})
.on('pointerout', (event) => {
this.previewSinglePointIcon.filters = null;
});
this.app.stage.addChild(this.backgroundImage);
@ -1723,7 +1861,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.previewSinglePointIcon = PIXI.Sprite.from('assets/images/noImg.png');
this.previewSinglePointIcon.width = 32;
this.previewSinglePointIcon.height = 32;
this.previewSinglePointIcon.alpha = 0.5;
this.previewSinglePointIcon.alpha = 1;
this.previewSinglePointIcon.anchor.set(0.5);
this.previewSinglePointIcon.visible = false;
this.backgroundImage.addChild(this.previewSinglePointIcon);
@ -1856,6 +1994,32 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
break;
}
}
/**
*
* @param mode
*/
public setPaintMode(mode: PaintMode) {
this.reset();
this.paintMode = mode;
switch (mode) {
case PaintMode.Car:
break;
}
}
/**
*
*/
public getPaintMode(): PaintMode {
return this.paintMode;
}
/**
*
*/
public reset() {
this.previewSinglePointIcon.filters = null;
this.previewSinglePointIcon.visible = false;
}
/**
*
*/
@ -1972,7 +2136,8 @@ enum PaintMode {
polygonIcon,
endPaint,
Pipeline,
Arrows
Arrows,
Car
}
/**
*
@ -2023,7 +2188,7 @@ export class SinglePointIcon extends PIXI.Container {
event.stopPropagation();
this.workingArea.selection.selectOne(this);
if (this.assetData.CanConnection && this.parent === this.workingArea.backgroundImage) {
if (this.workingArea.paintMode === PaintMode.Pipeline) {
if (this.workingArea.getPaintMode() === PaintMode.Pipeline) {
if (this.workingArea.paintingPipeline === null) {
this.workingArea.previewLineSegment.visible = true;
this.workingArea.currentClickPoint.position =
@ -2612,8 +2777,54 @@ export class PolygonIcon extends PIXI.Container {
this.polygonGraphics.endFill();
}
}
export class Car extends SinglePointIcon {
/**
*
*/
export class PutCarArea extends PIXI.Container {
public polygonGraphics: 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.sortableChildren = true;
// 填充多边形
const color: number = this.assetData.Color.substring(0, 7).replace('#', '0x');
const angle: number = parseInt(this.assetData.Color.substring(7), 16) / 255;
this.polygonGraphics.beginFill(color, angle);
this.polygonGraphics.drawPolygon(this.assetData.MultiPoint);
this.polygonGraphics.endFill();
this.addChild(this.polygonGraphics);
// 添加选中事件
this.polygonGraphics.interactive = true;
this.polygonGraphics
.on('pointerdown', (event) => {
if (this.workingArea.getPaintMode() === PaintMode.Car) {
this.workingArea.selectCar.Point =
new PIXI.Point(this.workingArea.previewSinglePointIcon.x, this.workingArea.previewSinglePointIcon.y);
const car = new SinglePointIcon(this.workingArea.selectCar, this.workingArea);
this.workingArea.setPaintMode(PaintMode.endPaint);
}
})
.on('pointerup', (event) => {
})
.on('pointerupoutside', (event) => {
})
.on('pointerover', (event) => {
this.workingArea.previewSinglePointIcon.filters = null;
this.workingArea.previewSinglePointIcon.zIndex = this.zIndex + 1;
})
.on('pointerout', (event) => {
this.workingArea.previewSinglePointIcon.filters = [
new OldFilmFilter()
];
});
}
}
/**
* 线
@ -2707,6 +2918,9 @@ export class Arrows extends PIXI.Container {
this.line.endFill();
}
}
/**
*
*/
@ -2847,3 +3061,13 @@ export class PropertyInfo {
*/
public PropertyValue: string;
}
/**
*
*/
export enum Type {
= 0,
= 1,
= 2,
= 3,
= 4
}

BIN
src/assets/images/举高喷射消防车.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Loading…
Cancel
Save