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

F4 Finalna Verzija

Location:
imaps-frontend/src/scripts/main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/src/scripts/main/MapBuilder.js

    r0c6b92a r79a0317  
    2121
    2222        // TODO AKO DRAGNIT NEKOJ OD POCETOK NA STAGE POZICIIVE KE SA ZEZNAT
    23         // TODO jwt vo cookie
    2423        // TODO placed shape i mouseMoveHandler da ne callback ( da ne vrakjat funkcija)
    2524        // TODO text na top layer sekogas
     
    3534        this.textLayer = new Konva.Layer();
    3635        this.gridLayer.listening(false);
     36
     37        this.isDrawEventBound = false;
    3738
    3839
     
    9697    setupEventListeners() {
    9798        document.getElementById("shapeOptions").addEventListener("click", this.selectShape.bind(this));
    98         window.addEventListener("keydown", this.handleExitSelection.bind(this));
    99         window.addEventListener("keydown", this.handleDelete.bind(this));
    100         window.addEventListener("keydown", this.rotateShapesBy90Deg.bind(this));
    101         window.addEventListener("keydown", this.toggleEfficientDrawingMode.bind(this));
     99        // window.addEventListener("keydown", this.handleExitSelection.bind(this));
     100        // window.addEventListener("keydown", this.handleDelete.bind(this));
     101        // window.addEventListener("keydown", this.rotateShapesBy90Deg.bind(this));
     102        // window.addEventListener("keydown", this.toggleEfficientDrawingMode.bind(this));
    102103        window.addEventListener("resize", this.handleResize.bind(this));
    103104
     
    107108        this.boundEfficientDrawingModeEventListener = this.toggleEfficientDrawingMode.bind(this);
    108109
    109         //this.attachKeyPressEventListeners();
     110        this.attachKeyPressEventListeners();
    110111
    111112        this.stage.on("mousedown touchstart", this.handleMouseDown.bind(this));
     
    119120
    120121    detachKeyPressEventListeners() {
     122        console.log("DETACH")
    121123        window.removeEventListener("keydown", this.boundEscapeEventListener);
    122124        window.removeEventListener("keydown", this.boundDeleteEventListener);
     
    126128
    127129    attachKeyPressEventListeners() {
     130        console.log("ATTACH")
    128131        window.addEventListener("keydown", this.boundEscapeEventListener);
    129132        window.addEventListener("keydown", this.boundDeleteEventListener);
     
    269272        let infoPin = Factory.createShape("InfoPin", attrs);
    270273        addEventHandling(infoPin, this, "dblclick");
    271         //this.shapes.push(infoPin);
    272274        ShapeRegistry.add(infoPin)
    273275        this.mainLayer.add(infoPin);
     
    307309
    308310        const placedObj = Factory.createShape(this.hoverObj.type, attrs);
     311
    309312        if (!placedObj) return;
    310313
     
    312315
    313316        this.mainLayer.add(placedObj);
    314         //this.shapes.push(placedObj);
    315         console.log("VO PLACED SHAEPS WALL ZITI SE: " + placedObj.className);
    316317        ShapeRegistry.add(placedObj);
    317318        addEventHandling(placedObj, this, "dblclick");
    318319        this.mainLayer.draw();
    319 
    320320        // site ovie func da se vo edna funkcija vo shape.
    321321
    322322        placedObj.displayName(this.textLayer);
    323323        placedObj.snapToGrid();
     324        placedObj.onPlace();
    324325
    325326        triggerMapSave();
     
    328329            this.stopDrawing();
    329330        }
     331        this.mainTransformer.nodes([])
    330332    }
    331333
    332334    stopDrawing() {
    333         this.mainTransformer.nodes([]);
    334         if (this.hoverObj != null) this.hoverObj.remove();
    335         this.dragLayer.removeChildren();
    336         this.stage.off("mousemove", this.boundMouseMoveHandler);
    337         this.stage.off("click", this.boundPlaceShapeHandler);
     335        if(this.isDrawEventBound){
     336            this.mainTransformer.nodes([]);
     337            if (this.hoverObj != null) this.hoverObj.remove();
     338            this.dragLayer.removeChildren();
     339            this.stage.off("mousemove", this.boundMouseMoveHandler);
     340            this.stage.off("click", this.boundPlaceShapeHandler);
     341            this.isDrawEventBound = false;
     342        }
     343
    338344    }
    339345
     
    365371        this.dragLayer.add(this.hoverObj);
    366372        this.dragLayer.moveToTop();
     373
     374
    367375        this.boundMouseMoveHandler = this.mouseMoveHandler.bind(this);
    368376        this.boundPlaceShapeHandler = this.placeShape.bind(this);
     377        this.isDrawEventBound = true;
    369378
    370379        this.stage.on("mousemove", this.boundMouseMoveHandler);
     
    374383    selectShape(e) {
    375384        if (e.target.tagName === "LI") {
     385          this.stopDrawing()
    376386            const shapeType = e.target.getAttribute("data-info");
    377387            this.startDrawing(shapeType);
    378             this.mainTransformer.nodes([]);
     388            this.mainTransformer.nodes([])
    379389        }
    380390    }
     
    464474
    465475    saveShapeDetails() {
    466         // this.shapes.forEach(shape => {
    467         //     shape.saveShapeDetails();
    468         //     console.log(shape.info);
    469         // });
    470476        ShapeRegistry.saveDetails();
    471477        console.log("thisflornum",this.floorNum)
     
    478484    }
    479485
    480     getPayload(){
    481         this.saveShapeDetails();
    482         return {
    483             shapes: ShapeRegistry.getShapes(this.floorNum),
    484             roomTypes: JSON.stringify(this.roomTypes),
    485             mapName: this.mapName,
    486             floorNum: this.floorNum
    487         }
    488     }
    489486
    490487
    491488    handleStageClick(e) {
    492489        if (this.selectionRectangle.visible()) {
     490            console.log("STAGECLICK1")
    493491            return;
    494492        }
    495493
    496494        if (e.target === this.stage) {
     495            console.log("STAGECLICK2")
    497496            this.mainTransformer.nodes([]);
    498497            return;
     
    500499
    501500        if (!e.target.hasName("mapObj")) {
     501            console.log("STAGECLICK3")
    502502            return;
    503503        }
     
    505505        const metaPressed = e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey;
    506506        const isSelected = this.mainTransformer.nodes().indexOf(e.target) >= 0;
     507
    507508
    508509        if (!metaPressed && !isSelected) {
     
    527528    }
    528529
    529     getRoomTypes() {
    530         return this.roomTypes;
    531     }
    532 
    533     getRooms() {
    534         return this.getShapeInfoByType("Room");
    535     }
    536 
    537     getPins() {
    538         return this.getShapeInfoByType("InfoPin");
    539     }
    540 
    541     getEntrances() {
    542         return this.getShapeInfoByType("Entrance");
    543     }
    544 
    545 
    546 
    547     getShapeInfoByType(type) {
    548         return ShapeRegistry.getShapes(this.floorNum).filter((shape) => shape.className === type).map((shape) => shape.info);
    549     }
    550 
    551530
    552531    drawConnection(node1Name, node2Name) {
    553532
    554533        ShapeRegistry.drawConnection(node1Name,node2Name);
    555     }
    556 
    557     getNodeByName(name) {
    558         return ShapeRegistry.getShapes(this.floorNum).filter(shape => shape instanceof MapNode && shape.info.name === name)[0];
    559534    }
    560535
     
    571546    }
    572547
    573     isMainEntranceSelected() {
    574         console.log(this.getEntrances().forEach((en) => console.log(en.isMainEntrance, "asdsad")));
    575 
    576         let hasMainEntrance = false;
    577 
    578         this.getEntrances().forEach((entrance) => {
    579             if (entrance.isMainEntrance === true) hasMainEntrance = true;
    580         });
    581 
    582         return hasMainEntrance;
    583 
    584     }
    585548
    586549    clearMap() {
     
    653616        this.mainLayer.add(this.selectionRectangle);
    654617
    655         ShapeRegistry.getShapes(this.floorNum).forEach((shape) => shape.displayName(this.textLayer));
     618        ShapeRegistry.getShapes(this.floorNum).forEach((shape) => {
     619            shape.displayName(this.textLayer);
     620            if(shape.className === "Entrance"){
     621                shape.setHighlight();
     622            }
     623        });
    656624    }
    657625
  • imaps-frontend/src/scripts/main/MapDisplay.js

    r0c6b92a r79a0317  
    44import {zoomStage} from "../util/zoomStage.js";
    55import {addEventHandling} from "../util/addEventHandling.js";
     6import ShapeRegistry from "../util/ShapeRegistry.js";
    67import triggerNavigate from "../util/triggerNavigate.js";
    78import config from "../net/netconfig.js";
     9import {dispatchCustomEvent} from "../util/dispatchCustomEvent.js";
     10import { jsPDF } from "jspdf";
     11
    812
    913export class MapDisplay {
     
    1822        });
    1923
     24        this.selectedRoom = {
     25            id: 1,
     26            name: "223",
     27            type: "Laboratory",
     28            image:
     29                "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMSEhUTExIVFhUXGBsYGBcWFxgXFhcYFRgXFxUVFRYYHiggGBolGxUXITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGxAQGysmHSUtLS0rLS0tLS0tLS0tLS0rKy0tKy0rLi0tLS0tKy4tLSstLS0vLS0tLS0rLS0tKy0tLf/AABEIAMIBAwMBIgACEQEDEQH/xAAcAAACAgMBAQAAAAAAAAAAAAAFBgMEAAECBwj/xABOEAACAQIDBAcE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jYFBtt/t7Pn8RWVlNHkDL20dMsdp+FGr1hCsFVIjgQCPSsrKMQvhCRtu0qXIVQo7gB8K9n3JtgYKzAAlZMDiSTJPaaysqr4Jhp6xOVZWUrCdL/PuqUfz6VqsrAOlrf8APwrKysY8T+lf/p5/qrfwNJT1lZVVwLLkPbr+zd8vnXW3/YT8XyrKyo/jZX8CCGDUdEug9kfCoMQKysrk/Edq4KF0VwtarKqKTCqWK/aJ51lZTY+SeX5Rq3C/bt+H9T8QPSi+8o+xwv4f/LFZWUHwI/nETYn7S5/PM0xpWVlLm5HxfKafhULVlZUihlctWVlEBo1lZWURT//Z",
     30            description: "223 is a laboratory with a capacity of 40 people",
     31        };
     32        this.toggleSearch = false;
     33
    2034        this.shapes = [];
    2135        this.roomTypes = [];
     
    2842        this.stage.add(this.textLayer);
    2943
     44
     45        this.cachedCanvases = [];
     46
    3047        this.floorNum = floorNum;
    3148
     
    6481        dsrData.forEach((shape) => {
    6582            if (shape.className !== "InfoPin") {
     83                console.log("SHAPE ATTRS CREATE: " + JSON.stringify(shape.attrs));
    6684                const renderedShape = Factory.createRenderedShape(shape.className, shape.attrs);
    6785                addEventHandling(renderedShape, this, "click");
    6886                this.shapes.push(renderedShape);
     87                console.log(renderedShape)
    6988            }
    7089        });
     
    7897    }
    7998
    80 
    81 
    8299    loadMapN(floorData) {
    83100        if (floorData == null || floorData === "") return;
     
    97114
    98115
     116
    99117    drawRouteNEW(nodes, offset = 0) {
    100118
     
    106124        let buff = [nodes[idx].coordinates.x, nodes[idx].coordinates.y];
    107125
    108 
    109126        ++idx;
    110127
     
    115132
    116133            if (idx >= nodes.length){
     134                console.log("FLOOR NUM DISPLAY: " + this.floorNum)
     135                let stageInfo = {stage:this.stage.clone(),floor:this.floorNum};
     136                this.cachedCanvases.push(stageInfo);
     137                dispatchCustomEvent("navend",this.downloadURI)
    117138                return;
    118139            }
     
    122143
    123144            if (nextNode.floorNumber !== currentNode.floorNumber) {
     145                let stageInfo = {stage:this.stage.clone(),floor:this.floorNum};
     146                this.cachedCanvases.push(stageInfo);
    124147                triggerNavigate(nodes, idx, nextNode.floorNumber, nextNode);
    125148                return;
     
    131154            const endY = nextNode.coordinates.y;
    132155
    133             const numSegments = 12;
     156            const numSegments = 10;
    134157
    135158            const deltaX = (endX - startX) / numSegments;
     
    157180                    clearInterval(interval);
    158181                    idx++;
    159                     setTimeout(drawNextSegment, 150);
     182                    setTimeout(drawNextSegment, 60);
    160183                }
    161             }, 50);
     184            }, 30);
    162185        };
    163186
    164187        drawNextSegment();
    165188    }
    166 
    167 
    168189
    169190    initializeRoomTypes() {
     
    173194    }
    174195
    175     getRoomTypes() {
    176         return this.roomTypes;
    177     }
    178 
    179 
    180     getShapeByName(name){
    181         return this.shapes.find(shape => shape.info.name === name)
    182     }
    183 
    184196    getShapeByType(type) {
    185197        return this.shapes.filter((shape) => shape.class === type)
    186     }
    187 
    188     toggleSearchRoom() {
    189         this.toggleSearch = !this.toggleSearch;
    190198    }
    191199
     
    196204    }
    197205
    198     getMainEntrance() {
    199         return this.shapes.filter(shape => shape.class === "Entrance").filter(el => el.info.isMainEntrance === true)[0];
    200     }
    201 
    202     setFilter(filter) {
     206     downloadURI(uri, name) {
     207        let link = document.createElement('a');
     208        link.download = name;
     209        link.href = uri;
     210        document.body.appendChild(link);
     211        link.click();
     212        document.body.removeChild(link);
     213    }
     214
     215
     216    getRouteImages(mapDetails = { mapName: "mapName", from: "from", to: "to" }) {
     217
     218        const pdf = new jsPDF("p", "mm", "a4");
     219        const pageWidth = pdf.internal.pageSize.getWidth();
     220        const pageHeight = pdf.internal.pageSize.getHeight();
     221        const margin = 10;
     222        let yOffset = margin;
     223
     224        const imagesData = [];
     225
     226        let minWidth = 800;
     227
     228        this.cachedCanvases.forEach((canvas, index) => {
     229            console.log("CANVASL " + JSON.stringify(canvas.stage))
     230            let dsrStage = Konva.Node.create(canvas.stage, document.createElement("div"));
     231
     232            let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
     233
     234            dsrStage.getLayers().forEach(layer => {
     235                layer.getChildren().forEach(shape => {
     236                    const shapeX = shape.x();
     237                    const shapeY = shape.y();
     238                    const width = shape.width() * shape.scaleX();
     239                    const height = shape.height() * shape.scaleY();
     240
     241                    minX = Math.min(minX, shapeX - shape.offsetX() * shape.scaleX());
     242                    minY = Math.min(minY, shapeY - shape.offsetY() * shape.scaleY());
     243                    maxX = Math.max(maxX, shapeX + width - shape.offsetX() * shape.scaleX());
     244                    maxY = Math.max(maxY, shapeY + height - shape.offsetY() * shape.scaleY());
     245                });
     246            });
     247
     248            let padding = 50;
     249
     250            const virtualWidth = maxX - minX + padding;
     251            const virtualHeight = maxY - minY + padding;
     252
     253            const scaleDownFactor = Math.min(pageWidth / virtualWidth, pageHeight / virtualHeight);
     254
     255            dsrStage.size({ width: virtualWidth, height: virtualHeight });
     256            dsrStage.position({ x: -minX, y: -minY });
     257            dsrStage.batchDraw();
     258
     259            let canvasImageURI = dsrStage.toDataURL({
     260                pixelRatio: 1
     261            });
     262
     263            imagesData.push(canvasImageURI);
     264            console.log(`Generated Image ${index + 1}`);
     265        });
     266
     267
     268
     269        imagesData.forEach((imageURI, index) => {
     270            const text = `Floor: ${this.cachedCanvases[index].floor}`;
     271            pdf.text(text, margin, yOffset + 5);
     272
     273            const img = new Image();
     274            img.src = imageURI;
     275
     276            const maxWidth = pageWidth - 2 * margin;
     277            const maxHeight = pageHeight - 2 * margin;
     278            let imgWidth = maxWidth;
     279            let imgHeight = maxHeight / 2
     280
     281            if (imgHeight > maxHeight) {
     282                imgHeight = maxHeight;
     283                imgWidth = (pageWidth * maxHeight) / pageHeight;
     284            }
     285
     286            if (yOffset + imgHeight > pageHeight - margin) {
     287                pdf.addPage();
     288                yOffset = margin;
     289            }
     290
     291            pdf.addImage(imageURI, "PNG", margin, yOffset, imgWidth, imgHeight);
     292            yOffset += imgHeight + 10;
     293        });
     294
     295        pdf.save(`${mapDetails.mapName}-${mapDetails.from}-->${mapDetails.to}.route.pdf`);
     296    }
     297
     298
     299
     300setFilter(filter) {
    203301        let rooms = this.getShapeByType("Room")
    204302        if (filter === "All") {
Note: See TracChangeset for help on using the changeset viewer.