Browse Source

[修正]多选状态下未选择对象时会发送选择发生变化消息

zhuzhou
徐振升 4 years ago
parent
commit
3381a71581
  1. 17
      src/app/working-area/model/axShape.ts
  2. 2
      src/app/working-area/model/events.ts
  3. 68
      src/app/working-area/working-area.component.ts

17
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;

2
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';

68
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'
}

Loading…
Cancel
Save