Ignore:
Timestamp:
01/21/25 03:08:24 (3 days ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
0c6b92a
Message:

F4 Finalna Verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/src/scripts/shapes/Entrance.js

    r0c6b92a r79a0317  
    22import MapNode from "../base/MapNode.js";
    33import {node} from "prop-types";
     4import ShapeRegistry from "../util/ShapeRegistry.js";
     5import ShapeQuery from "../util/ShapeQuery.js";
     6import Konva from "konva";
    47
    58export default class Entrance extends MapNode {
     
    1417                x: attrs.position.x,
    1518                y: attrs.position.y,
    16                 width: attrs.width,
    17                 height: attrs.height,
     19                width: attrs.width * attrs.scaleX,
     20                height: attrs.height * attrs.scaleY,
    1821                fill: "rgb(126,238,167)",
    1922                stroke: "#252627",
     
    4649        this.initText();
    4750        this.moveToTop();
     51
     52        console.log("room CONNECT: " + attrs.connected_room,this.info.connectedRoom + "CON")
     53        console.log("entrance: " + this.info.name)
    4854    }
    4955
    5056    loadInfo(attrs) {
    51         this.info.name = attrs.obj_name;
    52         this.info.connectedRoom = attrs.connected_room;
    53         this.info.description = attrs.description;
    54         this.info.isMainEntrance = attrs.is_main_entrance;
    55         this.info.selectedPins = attrs.connected_pins;
    56         this.floorNum = attrs.floor_num;
     57        this.info.name = attrs.obj_name ?? `Entrance${this.id} [${this.floorNum}F]`;
     58        this.info.connectedRoom = attrs.connected_room ?? ``;
     59        this.info.description = attrs.description ?? ``;
     60        this.info.isMainEntrance = attrs.is_main_entrance ?? false;
     61        this.info.selectedPins = attrs.connected_pins ?? [];
    5762    }
     63
    5864
    5965    saveShapeDetails() {
    6066        console.info("fnum entrance",this.attrs.floorNum)
    61 
    6267        this.setAttr("connected_pins", this.info.selectedPins);
    6368        this.setAttr("obj_name", this.info.name);
     
    7580
    7681    setInfo(infoObj) {
    77         console.log("SA VIKNA SETINFO")
    7882        this.info = infoObj;
     83        this.setHighlight();
     84    }
     85
     86    setHighlight(){
     87        console.log("info room: " + this.info.connectedRoom)
    7988        if(this.info.connectedRoom == null || this.info.connectedRoom === "" ){
     89            console.log("vleze if")
    8090            this.strokeWidth(2);
    81             this.stroke("#a10114")
     91            this.stroke("#8a000d")
    8292        }else{
    8393            this.strokeWidth(1)
     
    8595        }
    8696    }
     97
     98    onPlace() {
     99        ShapeQuery
     100            .findAllByTypeAndFloor(this.floorNum,"Room")
     101            .forEach(room => {
     102                if(Konva.Util.haveIntersection(room.getClientRect(),this.getClientRect())){
     103                    this.info.connectedRoom = room.info.name;
     104                }
     105            })
     106        this.setHighlight()
     107    }
    87108}
    88109
Note: See TracChangeset for help on using the changeset viewer.