desc: 调整绘图右键包围框起点

This commit is contained in:
zyy 2019-12-13 15:11:01 +08:00
parent 2f639cce5e
commit c287f8d13b
2 changed files with 11 additions and 20 deletions

View File

@ -304,10 +304,14 @@ class MouseController extends Eventful {
// 右键拖动区域大小
handleMouseMoveRight(point2) {
const point1 = this.rightClickPoint;
const x = Math.min(point1.x, point2.x) + this.$jmap.$options.offsetX;
const y = Math.min(point1.y, point2.y) + this.$jmap.$options.offsetY;
const width = Math.abs(point1.x - point2.x);
const height = Math.abs(point1.y - point2.y);
const originX = Math.min(point1.x, point2.x);
const originY = Math.min(point1.y, point2.y);
const dx = originX + this.$jmap.$options.offsetX;
const dy = originY + this.$jmap.$options.offsetY;
const x = dx / this.$jmap.$options.scaleRate;
const y = dy / this.$jmap.$options.scaleRate;
const width = Math.abs(point1.x - point2.x) / this.$jmap.$options.scaleRate + 10;
const height = Math.abs(point1.y - point2.y) / this.$jmap.$options.scaleRate + 10;
this.$jmap.renderCheckBox({code: 'check_box', _type: 'CheckBox', point: {x: x, y: y}, width: width, height: height });
}
}

View File

@ -14,17 +14,13 @@ export default class checkBox extends Group {
create() {
const model = this.model;
this.grouper = new Group({
id: model.code,
position: [model.point.x, model.point.y]
});
this.box = new Rect({
zlevel: model.zlevel,
z: model.z,
draggable: false,
shape: {
x: 0,
y: 0,
x: model.point.x,
y: model.point.y,
width: this.model.width,
height: this.model.height
},
@ -32,15 +28,6 @@ export default class checkBox extends Group {
fill: 'rgb(135,206,250,0.2)'
}
});
this.grouper.add(this.box);
this.add(this.grouper);
}
setModel(dx, dy) {
this.model.point.x += dx;
this.model.point.y += dy;
}
setSize(width, height) {
this.model.width = width;
this.model.height = height;
this.add(this.box);
}
}