From fb68623073b97908b7724dba9edd83e0be4dba46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=8C=AF=E5=8D=87?= <359059686@qq.com> Date: Tue, 2 Feb 2021 16:09:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B01.0.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/working-area/model/axShape.ts | 17 ++--- src/app/working-area/model/events.ts | 2 + .../working-area/working-area.component.ts | 68 +++++++------------ 3 files changed, 37 insertions(+), 50 deletions(-) diff --git a/src/app/working-area/model/axShape.ts b/src/app/working-area/model/axShape.ts index 9409a21..5c6ce51 100644 --- a/src/app/working-area/model/axShape.ts +++ b/src/app/working-area/model/axShape.ts @@ -35,14 +35,15 @@ export class AxShape extends Graphics { this.buttonMode = true; this .on('pointerdown', event => { - event.stopPropagation(); - if (this.allowSelect) { - this.workingArea.select(this); - } - if (this.allowEdit) { - this.mouseDragging = true; - this.mousePosition = new PIXI.Point(event.data.global.x, event.data.global.y); - } + event.stopPropagation(); + if (this.allowSelect + && event.data.button === 0) { + this.workingArea.select(this); + } + if (this.allowEdit) { + this.mouseDragging = true; + this.mousePosition = new PIXI.Point(event.data.global.x, event.data.global.y); + } }) .on('pointerup', event => { this.mouseDragging = false; diff --git a/src/app/working-area/model/events.ts b/src/app/working-area/model/events.ts index 2cd6cf5..d7da978 100644 --- a/src/app/working-area/model/events.ts +++ b/src/app/working-area/model/events.ts @@ -65,3 +65,5 @@ export const EVENT_UPDATE_TEXTURES = 'UPDATE_TEXTURES_EVENT'; export const EVENT_MODIFY_TEXTURE_ATTRIBUTE = 'MODIFY_TEXTURE_ATTRIBUTE_EVENT'; export const EVENT_PARAMETRIC_GEOMETRY_UPATED = 'PARAMETRIC_GEOMETRY_UPATED_EVENT'; + +export const EVENT_SELECTION_CHANGED = 'selectionChanged'; diff --git a/src/app/working-area/working-area.component.ts b/src/app/working-area/working-area.component.ts index 127abb7..da4a16a 100644 --- a/src/app/working-area/working-area.component.ts +++ b/src/app/working-area/working-area.component.ts @@ -21,6 +21,7 @@ import { AxSelection } from './model/axSelection'; import { AxMessageSystem } from './model/axMessageSystem'; import { Grid2D } from './model/grid2D'; import { Viewport } from 'pixi-viewport'; +import { EVENT_SELECTION_CHANGED } from './model/events'; @Component({ @@ -156,7 +157,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV * RC版: 该版本已经相当成熟了,基本上不存在导致错误的BUG,与即将发行的正式版相差无几。 * Release版: 该版本意味“最终版本”,在前面版本的一系列测试版之后,终归会有一个正式版本,是最终交付用户使用的一个版本。该版本有时也称为标准版。一般情况下,Release不会以单词形式出现在软件封面上,取而代之的是符号®。 */ - public VERSION = '1.0.14.20210202_beta'; + public VERSION = '1.0.15.20210202_beta'; /** * 数据初始化 */ @@ -232,7 +233,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.selection.clear(); this.emit('canvasDataChanged'); this.canvasData.isChange = true; - AxMessageSystem.send(CanvasAction.selectionChanged); + AxMessageSystem.send(EVENT_SELECTION_CHANGED); } } /** @@ -371,7 +372,8 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV }); this.camera2D.on('pointerdown', event => { - if (this.isCtrlKeyClicked === true) { + if (this.isCtrlKeyClicked === true + && event.data.button === 0) { this.rectToolGraphics.visible = true; this.initialScreenMousePos = this.backgroundImage.toLocal(this.mousePosition); this.finalScreenMousePos = this.backgroundImage.toLocal(this.mousePosition); @@ -424,7 +426,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV const final = this.finalScreenMousePos; this.rectToolGraphics.clear(); - this.rectToolGraphics.lineStyle(2, 0x00ff00, 1); + this.rectToolGraphics.lineStyle(1 / this.camera2D.scale.x, 0x00ff00, 1); this.rectToolGraphics.beginFill(0xccccf2, 0.25); if (final.x > init.x && final.y > init.y) { this.rectToolGraphics.drawRect(init.x, init.y, final.x - init.x, final.y - init.y); @@ -438,6 +440,12 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.rectToolGraphics.endFill(); } }); + // 右键事件 + this.camera2D.on('rightclick', event => { + event.stopPropagation(); + this.deselectAll(); + this.setPaintMode(PaintMode.endPaint); + }); } /** @@ -489,28 +497,6 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.refreshPreviewLineSegment(this.currentClickPoint.position, this.circleShadow.position); this.refreshPreviewPoint(); } - // /** - // * 显示框选 - // */ - // if (this.rectToolGraphics.visible === true) { - - // const init = this.initialScreenMousePos; - // const final = this.finalScreenMousePos; - - // this.rectToolGraphics.clear(); - // this.rectToolGraphics.lineStyle(2, 0x00ff00, 1); - // this.rectToolGraphics.beginFill(0xccccf2, 0.25); - // if (final.x > init.x && final.y > init.y) { - // this.rectToolGraphics.drawRect(init.x, init.y, final.x - init.x, final.y - init.y); - // } else if (final.x > init.x && final.y < init.y) { - // this.rectToolGraphics.drawRect(init.x, final.y, final.x - init.x, init.y - final.y); - // } else if (final.x < init.x && final.y > init.y) { - // this.rectToolGraphics.drawRect(final.x, init.y, init.x - final.x, final.y - init.y); - // } else if (final.x < init.x && final.y < init.y) { - // this.rectToolGraphics.drawRect(final.x, final.y, init.x - final.x, init.y - final.y); - // } - // this.rectToolGraphics.endFill(); - // } }); /** * 创建图标事件(数据处理) @@ -976,11 +962,11 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV // } // } }) - .on('rightclick', event => { - event.stopPropagation(); - this.deselectAll(); - this.setPaintMode(PaintMode.endPaint); - }) + // .on('rightclick', event => { + // event.stopPropagation(); + // this.deselectAll(); + // this.setPaintMode(PaintMode.endPaint); + // }) .on('pointerover', (event) => { if (this.previewImage !== null && this.paintMode === PaintMode.singlePointIcon) { @@ -1571,7 +1557,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV } this.selection.add(shape); this.setSelectEffect(shape); - AxMessageSystem.send(CanvasAction.selectionChanged); + AxMessageSystem.send(EVENT_SELECTION_CHANGED); } /** * 选择 @@ -1588,18 +1574,20 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV } this.selection.add(shape); this.setSelectEffect(shape); - AxMessageSystem.send(CanvasAction.selectionChanged); + AxMessageSystem.send(EVENT_SELECTION_CHANGED); } /** * 选择集合中的形状 * @param shape 形状集合 */ public selectAll(shape: AxShape[]) { - this.selection.addArray(shape); - this.selection.all().forEach(item => { + if (shape.length > 0) { + this.selection.addArray(shape); + this.selection.all().forEach(item => { this.setSelectEffect(item); }); - AxMessageSystem.send(CanvasAction.selectionChanged); + AxMessageSystem.send(EVENT_SELECTION_CHANGED); + } } /** * 先清空再选择全部 @@ -1616,7 +1604,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.selection.all().forEach(item => { this.setSelectEffect(item); }); - AxMessageSystem.send(CanvasAction.selectionChanged); + AxMessageSystem.send(EVENT_SELECTION_CHANGED); } /** * 选择集合中所有id的形状 @@ -1640,7 +1628,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV this.clearSelectEffect(item); }); this.selection.clear(); - AxMessageSystem.send(CanvasAction.selectionChanged); + AxMessageSystem.send(EVENT_SELECTION_CHANGED); } } /** @@ -1672,7 +1660,3 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV legend.visible = b; } } -enum CanvasAction { - selectionChanged = 'selectionChanged', - copyDataChanged = 'copyDataChanged' -}