[d565449] | 1 | import Konva from "konva";
|
---|
| 2 | import MapShape from "./MapShape";
|
---|
| 3 | import { _registerNode } from "konva/lib/Global";
|
---|
| 4 | export default class Entrance extends MapShape {
|
---|
| 5 | constructor(mousePos, blockSize, layer, rotation, snap,id,scaleX = 1, scaleY = 1) {
|
---|
| 6 | super(
|
---|
| 7 | {
|
---|
| 8 | x: mousePos.x,
|
---|
| 9 | y: mousePos.y,
|
---|
| 10 | width: blockSize * scaleX,
|
---|
| 11 | height: blockSize * 2 * scaleY,
|
---|
| 12 | fill: "#0051ff",
|
---|
| 13 | stroke: "grey",
|
---|
| 14 | strokeWidth: 1,
|
---|
| 15 | opacity: 0.7,
|
---|
| 16 | name: "mapObj",
|
---|
| 17 | draggable: true,
|
---|
| 18 | rotation: rotation,
|
---|
| 19 | zIndex: 1,
|
---|
| 20 | },
|
---|
| 21 | layer,
|
---|
| 22 | blockSize,
|
---|
| 23 | snap
|
---|
| 24 | );
|
---|
| 25 | this.type = "Entrance";
|
---|
| 26 | this.modalEventName = "openEntranceModalEvent";
|
---|
| 27 |
|
---|
| 28 | this.id = id;
|
---|
| 29 |
|
---|
| 30 | this._info = {
|
---|
| 31 | name: `Entrance ${id}`,
|
---|
| 32 | connectedRoom: "",
|
---|
| 33 | description: "",
|
---|
| 34 | isMainEntrance: false,
|
---|
| 35 | selectedPin: "",
|
---|
| 36 | selectedPins: [],
|
---|
| 37 | };
|
---|
| 38 |
|
---|
| 39 | this.initText();
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | loadInfo(attrs) {
|
---|
| 43 | this.info.name = attrs.obj_name;
|
---|
| 44 | this.info.connectedRoom = attrs.connected_room;
|
---|
| 45 | this.info.description = attrs.description;
|
---|
| 46 | this.info.isMainEntrance = attrs.is_main_entrance;
|
---|
| 47 | this.info.selectedPins = attrs.connected_pins;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | saveShapeDetails() {
|
---|
| 51 | this.setAttr("connected_pins", this.info.selectedPins);
|
---|
| 52 | this.setAttr("obj_name", this.info.name);
|
---|
| 53 | this.setAttr("description", this.info.description);
|
---|
| 54 | this.setAttr("is_main_entrance", this.info.isMainEntrance);
|
---|
| 55 | this.setAttr("connected_room", this.info.connectedRoom);
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | Entrance.prototype.className = "Entrance";
|
---|
| 60 | _registerNode(Entrance);
|
---|