|
|
|
@ -52,6 +52,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
// // 确认绘制完成按钮
|
|
|
|
|
// public enterPaintEndButton: PIXI.Sprite = PIXI.Sprite.from('assets/images/caiji.jpg');
|
|
|
|
|
public outlineFilterBlue = new OutlineFilter(2, 0x00ff00); |
|
|
|
|
// 当前要创建的数据
|
|
|
|
|
public currentData: any = null; |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.eventManager.addGlobalEventListener('window', 'keydown', (event: any) => { |
|
|
|
|
// console.log('按下了' + event.keyCode);
|
|
|
|
@ -131,10 +133,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
|
|
|
|
|
this.on('select', obj => { |
|
|
|
|
if (obj instanceof MultipointIcon) { |
|
|
|
|
console.log('选定多点图形:' + obj); |
|
|
|
|
obj.setPointVisiable(true); |
|
|
|
|
} else if (obj instanceof PolygonIcon) { |
|
|
|
|
console.log('选定多边形:' + obj); |
|
|
|
|
obj.setPointVisiable(true); |
|
|
|
|
} else { |
|
|
|
|
obj.filters = [this.outlineFilterBlue]; |
|
|
|
@ -142,28 +142,13 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
}); |
|
|
|
|
this.on('deselect', obj => { |
|
|
|
|
if (obj instanceof MultipointIcon) { |
|
|
|
|
console.log('取消选定多点图形:' + obj); |
|
|
|
|
obj.setPointVisiable(false); |
|
|
|
|
} else if (obj instanceof PolygonIcon) { |
|
|
|
|
console.log('取消选定多边形:' + obj); |
|
|
|
|
obj.setPointVisiable(false); |
|
|
|
|
} else { |
|
|
|
|
obj.filters = []; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.on('deselectAll', objects => { |
|
|
|
|
objects.forEach(element => { |
|
|
|
|
if (element instanceof MultipointIcon) { |
|
|
|
|
console.log('取消全部选定多点图形:' + element); |
|
|
|
|
element.setPointVisiable(false); |
|
|
|
|
} else if (element instanceof PolygonIcon) { |
|
|
|
|
console.log('取消全部选定多边形:' + element); |
|
|
|
|
element.setPointVisiable(false); |
|
|
|
|
} else { |
|
|
|
|
element.filters = []; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.app.ticker.add((delta) => { |
|
|
|
|
this.mousePosition = this.app.renderer.plugins.interaction.mouse.global; |
|
|
|
@ -185,7 +170,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
* @param height todo |
|
|
|
|
* @param alpha todo |
|
|
|
|
*/ |
|
|
|
|
private createSinglePointIcon(source: PIXI.Texture, x: number, y: number, width: number, height: number, alpha: number): PIXI.Sprite { |
|
|
|
|
private createSinglePointIcon(source: PIXI.Texture, x: number, y: number, width: number, height: number, |
|
|
|
|
alpha: number, name: string): PIXI.Sprite { |
|
|
|
|
const singlePointIcon = new PIXI.Sprite(source); |
|
|
|
|
singlePointIcon.x = x; |
|
|
|
|
singlePointIcon.y = y; |
|
|
|
@ -194,10 +180,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
singlePointIcon.alpha = alpha; |
|
|
|
|
singlePointIcon.anchor.set(0.5); |
|
|
|
|
singlePointIcon.interactive = true; |
|
|
|
|
singlePointIcon.name = name; |
|
|
|
|
singlePointIcon |
|
|
|
|
.on('mousedown', event => { |
|
|
|
|
event.stopPropagation(); |
|
|
|
|
console.log(event); |
|
|
|
|
|
|
|
|
|
event.currentTarget.data = event.data; |
|
|
|
|
event.currentTarget.alpha = 0.5; |
|
|
|
|
event.currentTarget.dragging = true; |
|
|
|
@ -335,14 +322,14 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
* @param points 点集合 |
|
|
|
|
*/ |
|
|
|
|
private createLineIconTest(texture: PIXI.Texture, points: PIXI.Point[]) { |
|
|
|
|
const icon = new MultipointIcon(texture, points, this); |
|
|
|
|
const icon = new MultipointIcon(texture, points, this, this.currentData.name); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 测试创建多边形 |
|
|
|
|
* @param points 点集合 |
|
|
|
|
*/ |
|
|
|
|
private createPolygonIconTest(points: PIXI.Point[]) { |
|
|
|
|
const icon = new PolygonIcon(points, this); |
|
|
|
|
const icon = new PolygonIcon(points, this, this.currentData.name); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 创建确认绘制结束按钮 |
|
|
|
@ -396,7 +383,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
break; |
|
|
|
|
case PaintMode.singlePointIcon: |
|
|
|
|
// tslint:disable-next-line: max-line-length
|
|
|
|
|
this.createSinglePointIcon(this.previewSinglePointIcon.texture, this.previewSinglePointIcon.x, this.previewSinglePointIcon.y, 32, 32, 1); |
|
|
|
|
this.createSinglePointIcon(this.previewSinglePointIcon.texture, this.previewSinglePointIcon.x, this.previewSinglePointIcon.y, 32, 32, 1, this.currentData.name); |
|
|
|
|
break; |
|
|
|
|
case PaintMode.lineIcon: |
|
|
|
|
this.previewLineSegment.visible = true; |
|
|
|
@ -410,7 +397,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
if (this.paintingIcon !== null) { |
|
|
|
|
this.backgroundImage.removeChild(this.paintingIcon); |
|
|
|
|
} |
|
|
|
|
this.paintingIcon = new MultipointIcon(this.previewSinglePointIcon.texture, this.paintPoints, this); |
|
|
|
|
this.paintingIcon = new MultipointIcon(this.previewSinglePointIcon.texture, this.paintPoints, this, this.currentData.name); |
|
|
|
|
break; |
|
|
|
|
case PaintMode.polygonIcon: |
|
|
|
|
this.previewLineSegment.visible = true; |
|
|
|
@ -540,12 +527,13 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
* 开始绘制 |
|
|
|
|
*/ |
|
|
|
|
public beginPaint(data: any) { |
|
|
|
|
switch (data.interactiveMode) { |
|
|
|
|
this.currentData = data; |
|
|
|
|
switch (this.currentData.interactiveMode) { |
|
|
|
|
case 0: |
|
|
|
|
this.beginPaintSinglePointIcon(data.imageUrl); |
|
|
|
|
this.beginPaintSinglePointIcon(); |
|
|
|
|
break; |
|
|
|
|
case 1: |
|
|
|
|
this.beginPaintLineIcon(data.imageUrl); |
|
|
|
|
this.beginPaintLineIcon(); |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
this.beginPaintPolygonIcon(); |
|
|
|
@ -554,12 +542,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 开始绘画单点图标 |
|
|
|
|
* @param imageUri 图片路径 |
|
|
|
|
*/ |
|
|
|
|
private beginPaintSinglePointIcon(imageUri: string): void { |
|
|
|
|
private beginPaintSinglePointIcon(): void { |
|
|
|
|
this.cancelPaint(); |
|
|
|
|
this.paintMode = PaintMode.singlePointIcon; |
|
|
|
|
this.changePreviewSinglePointIcon(imageUri); |
|
|
|
|
this.changePreviewSinglePointIcon(this.currentData.imageUrl); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 开始绘画多边形 |
|
|
|
@ -571,12 +558,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 开始绘制多点图标 |
|
|
|
|
* @param imageUri 图片路径 |
|
|
|
|
*/ |
|
|
|
|
private beginPaintLineIcon(imageUri: string): void { |
|
|
|
|
private beginPaintLineIcon(): void { |
|
|
|
|
this.cancelPaint(); |
|
|
|
|
this.paintMode = PaintMode.lineIcon; |
|
|
|
|
this.previewSinglePointIcon.texture = PIXI.Texture.from(imageUri); |
|
|
|
|
this.previewSinglePointIcon.texture = PIXI.Texture.from(this.currentData.imageUrl); |
|
|
|
|
this.circleShadow.visible = true; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
@ -621,7 +607,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
|
|
|
|
|
case PaintMode.polygonIcon: |
|
|
|
|
this.paintingLine.clear(); |
|
|
|
|
if (this.paintPoints.length >= 3) { |
|
|
|
|
const polygonIcon = new PolygonIcon(this.paintPoints, this); |
|
|
|
|
const polygonIcon = new PolygonIcon(this.paintPoints, this, this.currentData.name); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -650,8 +636,9 @@ export class MultipointIcon extends PIXI.Container {
|
|
|
|
|
* @param texture 图片素材 |
|
|
|
|
* @param points 点集合 |
|
|
|
|
*/ |
|
|
|
|
constructor(texture: PIXI.Texture, points: PIXI.Point[], private workingArea: WorkingAreaComponent) { |
|
|
|
|
constructor(texture: PIXI.Texture, points: PIXI.Point[], private workingArea: WorkingAreaComponent, name: string) { |
|
|
|
|
super(); |
|
|
|
|
this.name = name; |
|
|
|
|
this.pointsData = points; |
|
|
|
|
this.workingArea.backgroundImage.addChild(this); |
|
|
|
|
// 画线图标
|
|
|
|
@ -817,8 +804,9 @@ export class PolygonIcon extends PIXI.Container {
|
|
|
|
|
* |
|
|
|
|
* @param points 点集合 |
|
|
|
|
*/ |
|
|
|
|
constructor(private points: PIXI.Point[], private workingArea: WorkingAreaComponent) { |
|
|
|
|
constructor(private points: PIXI.Point[], private workingArea: WorkingAreaComponent, name: string) { |
|
|
|
|
super(); |
|
|
|
|
this.name = name; |
|
|
|
|
this.workingArea.backgroundImage.addChild(this); |
|
|
|
|
this.sortableChildren = true; |
|
|
|
|
// 画点
|
|
|
|
@ -992,7 +980,9 @@ export class Selection {
|
|
|
|
|
* 取消选定所有已选定对象 |
|
|
|
|
*/ |
|
|
|
|
public deselectAll() { |
|
|
|
|
this.workingArea.emit('deselectAll', this.objects); |
|
|
|
|
this.objects.forEach(item => { |
|
|
|
|
this.workingArea.emit('deselect', item); |
|
|
|
|
}); |
|
|
|
|
this.objects.splice(0, this.objects.length); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
@ -1012,6 +1002,8 @@ export class Selection {
|
|
|
|
|
* @param objects 对象集合 |
|
|
|
|
*/ |
|
|
|
|
public selectAll(objects: any[]) { |
|
|
|
|
|
|
|
|
|
this.objects.forEach(item => { |
|
|
|
|
this.select(item); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|