source: imaps-frontend/src/scripts/shapes/Stairs.js@ 0c6b92a

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 2.1 KB
Line 
1import Konva from "konva";
2import MapNode from "../base/MapNode.js";
3import {_registerNode} from "konva/lib/Global.js";
4import Room from "./Room.js";
5export default class Stairs extends MapNode{
6 constructor(attrs,id) {
7
8 if(!attrs.fromLoad){
9 attrs.width *= 4;
10 }
11
12 super({
13 x: attrs.position.x,
14 y: attrs.position.y,
15 width: attrs.width * attrs.scaleX,
16 height: attrs.height * attrs.scaleY,
17 fill: "rgb(225,213,124)",
18 stroke: "rgb(16,15,15)",
19 strokeWidth: 1,
20 name: "mapObj",
21 rotation: attrs.rotation,
22 draggable: true
23 },
24 attrs.layer,
25 attrs.blockSize,
26 attrs.snap
27 );
28
29 this.floorNum = attrs.floorNum;
30
31 this.type = "Stairs"
32 this._info = {
33 name: `Stairs${id} [${this.floorNum}F]`,
34 description: "",
35 selectedPins: []
36 };
37
38 this.id = id;
39 this.eventName = "openStairsModalEvent";
40 this.initText();
41 }
42
43
44 _sceneFunc(context, shape) {
45 const { width, height} = this.attrs;
46
47 let steps = 5;
48 context.beginPath()
49 for(let i = 0; i < steps; i++){
50 context.rect((-this.blockSize) * i,(this.blockSize * 0.6) * i,width * 0.86,height/2)
51 context.fillStrokeShape(shape);
52 }
53 context.closePath()
54 }
55
56 loadInfo(attrs) {
57 this.info.name = attrs.obj_name;
58 this.info.description = attrs.description;
59 this.info.selectedPins = attrs.connected_pins;
60 this.floorNum = attrs.floor_num;
61 }
62
63 saveShapeDetails() {
64 this.setAttr("connected_pins", this.info.selectedPins);
65 this.setAttr("obj_name", this.info.name);
66 this.setAttr("description", this.info.description);
67 this.setAttr("floor_num",this.floorNum)
68 }
69 connect(node,draw = true) {
70 let canDraw = this.floorNum === node.floorNum;
71 super.connect(node,canDraw);
72 }
73
74}
75
76Stairs.prototype.className = "Stairs";
77_registerNode(Stairs);
78//TODO
Note: See TracBrowser for help on using the repository browser.