|
@@ -1,5 +1,5 @@
|
|
import { APP_STATE } from "../enums/app-state-enum";
|
|
import { APP_STATE } from "../enums/app-state-enum";
|
|
-import { stages as Stages } from "../application/stages";
|
|
+import { stageManager as Stages } from "./stage-manager";
|
|
import { state as State } from "../application/state";
|
|
import { state as State } from "../application/state";
|
|
import { objects as Objects } from "../application/objects";
|
|
import { objects as Objects } from "../application/objects";
|
|
import { ELEMENTS_CLASS } from "../enums/elements-class-enum";
|
|
import { ELEMENTS_CLASS } from "../enums/elements-class-enum";
|
|
@@ -11,7 +11,7 @@ export class Selector {
|
|
this._selectorPosNow;
|
|
this._selectorPosNow;
|
|
this._mode = "";
|
|
this._mode = "";
|
|
this._stage = Stages.getCurrentKonvaStage();
|
|
this._stage = Stages.getCurrentKonvaStage();
|
|
- this._layer = Stages.getCurrentLayer();
|
|
+ this._layer = Stages.getCurrentKonvaLayer();
|
|
this._selectorRect = new Konva.Rect({
|
|
this._selectorRect = new Konva.Rect({
|
|
x: 0,
|
|
x: 0,
|
|
y: 0,
|
|
y: 0,
|
|
@@ -29,7 +29,7 @@ export class Selector {
|
|
|
|
|
|
addToLayer() {
|
|
addToLayer() {
|
|
this._selectorRect.listening(false);
|
|
this._selectorRect.listening(false);
|
|
- this._layer.add(this._selectorRect);
|
|
+ Stages.getCurrentKonvaLayer().add(this._selectorRect);
|
|
}
|
|
}
|
|
|
|
|
|
getSelectedObjects() {
|
|
getSelectedObjects() {
|
|
@@ -42,6 +42,12 @@ export class Selector {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ getKonvaPoints() {
|
|
|
|
+ return this._objects.filter(
|
|
|
|
+ x => x.attrs.class != undefined && x.attrs.class == ELEMENTS_CLASS.POINT
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
startDragSelector(posIn) {
|
|
startDragSelector(posIn) {
|
|
this._selectorPosStart = { x: posIn.x, y: posIn.y };
|
|
this._selectorPosStart = { x: posIn.x, y: posIn.y };
|
|
this._selectorPosNow = { x: posIn.x, y: posIn.y };
|
|
this._selectorPosNow = { x: posIn.x, y: posIn.y };
|
|
@@ -50,6 +56,7 @@ export class Selector {
|
|
configureSelectorEvents() {
|
|
configureSelectorEvents() {
|
|
var _this = this;
|
|
var _this = this;
|
|
this._stage.on("mousedown", function(e) {
|
|
this._stage.on("mousedown", function(e) {
|
|
|
|
+ Stages.getCurrentKonvaLayer().add(_this._selectorRect);
|
|
_this._mode = "drawing";
|
|
_this._mode = "drawing";
|
|
_this.startDragSelector({ x: e.evt.layerX, y: e.evt.layerY });
|
|
_this.startDragSelector({ x: e.evt.layerX, y: e.evt.layerY });
|
|
});
|
|
});
|
|
@@ -60,6 +67,7 @@ export class Selector {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
this._stage.on("mouseup", function(e) {
|
|
this._stage.on("mouseup", function(e) {
|
|
|
|
+ _this._selectorRect.remove();
|
|
_this._mode = "";
|
|
_this._mode = "";
|
|
_this._selectorRect.visible(false);
|
|
_this._selectorRect.visible(false);
|
|
_this._stage.draw();
|
|
_this._stage.draw();
|
|
@@ -78,7 +86,7 @@ export class Selector {
|
|
this._selectorRect.height(posRect.y2 - posRect.y1);
|
|
this._selectorRect.height(posRect.y2 - posRect.y1);
|
|
this._selectorRect.visible(true);
|
|
this._selectorRect.visible(true);
|
|
for (let i = 0; i < currentObjects.length; i = i + 1) {
|
|
for (let i = 0; i < currentObjects.length; i = i + 1) {
|
|
- let object = currentObjects[i];
|
|
+ let object = currentObjects[i].konvaObject;
|
|
if (object.children != undefined && object.children.length > 0) {
|
|
if (object.children != undefined && object.children.length > 0) {
|
|
for (let j = 0; j < object.children.length; j++) {
|
|
for (let j = 0; j < object.children.length; j++) {
|
|
this.style(object.children[j], this._selectorRect);
|
|
this.style(object.children[j], this._selectorRect);
|