|
@@ -83,31 +83,19 @@ export class LineSegment {
|
|
|
_this.clearState();
|
|
|
return;
|
|
|
}
|
|
|
- let objects = Selector.getPoints();
|
|
|
+ const objects = Selector.getPoints();
|
|
|
if (
|
|
|
_this._state == undefined &&
|
|
|
objects != undefined &&
|
|
|
objects.length > 0
|
|
|
) {
|
|
|
- let layer = App.currentLayer();
|
|
|
- let p = [];
|
|
|
- let ln = _this.createLine(p);
|
|
|
- objects.forEach(object => {
|
|
|
- object.attrs.connections.push(ln);
|
|
|
- p.push(object.x());
|
|
|
- p.push(object.y());
|
|
|
- object.parent.on("dragmove", () => {
|
|
|
- let p = [];
|
|
|
- p.push(object.x());
|
|
|
- p.push(object.y());
|
|
|
- //object.attrs.connections[0].points(p.slice());
|
|
|
- layer.batchDraw();
|
|
|
- });
|
|
|
- ln.points(p.slice());
|
|
|
- layer.batchDraw();
|
|
|
- });
|
|
|
-
|
|
|
- _this.drawPoint(p);
|
|
|
+ const layer = App.currentLayer();
|
|
|
+ const point_groups = new Set(objects.map(object => object.parent));
|
|
|
+ const points_xy = objects.reduce((prev, next) => prev.concat([next.x(), next.y()]), []);
|
|
|
+ let ln = _this.createLine(points_xy);
|
|
|
+ _this.attachPoints(ln, point_groups);
|
|
|
+ layer.add(ln);
|
|
|
+ App.stage.draw();
|
|
|
App.clearSelectedTool();
|
|
|
_this.clearState();
|
|
|
return;
|