Changeset 0c6b92a for imaps-frontend/src/scripts/shapes
- Timestamp:
- 12/12/24 17:06:06 (5 weeks ago)
- Branches:
- main
- Parents:
- d565449
- Location:
- imaps-frontend/src/scripts/shapes
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/src/scripts/shapes/Entrance.js
rd565449 r0c6b92a 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"; 1 import {_registerNode} from "konva/lib/Global"; 2 import MapNode from "../base/MapNode.js"; 3 import {node} from "prop-types"; 27 4 28 this.id = id; 5 export default class Entrance extends MapNode { 29 6 30 this._info = { 31 name: `Entrance ${id}`, 32 connectedRoom: "", 33 description: "", 34 isMainEntrance: false, 35 selectedPin: "", 36 selectedPins: [], 37 }; 7 constructor(attrs, id) { 38 8 39 this.initText(); 40 } 9 if (!attrs.fromLoad) { 10 attrs.height *= 2; 11 } 12 super( 13 { 14 x: attrs.position.x, 15 y: attrs.position.y, 16 width: attrs.width, 17 height: attrs.height, 18 fill: "rgb(126,238,167)", 19 stroke: "#252627", 20 strokeWidth: 1, 21 opacity: 0.9, 22 name: "mapObj", 23 draggable: true, 24 rotation: attrs.rotation, 25 zIndex: 1, 26 }, 27 attrs.layer, 28 attrs.blockSize, 29 attrs.snap 30 ); 31 this.type = "Entrance"; 32 this.eventName = "openEntranceModalEvent"; 33 this.floorNum = attrs.floorNum 41 34 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 } 35 this.id = id; 49 36 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 } 37 this._info = { 38 name: `Entrance${id} [${this.floorNum}F]`, 39 connectedRoom: "", 40 description: "", 41 isMainEntrance: false, 42 selectedPin: "", 43 selectedPins: [], 44 }; 45 46 this.initText(); 47 this.moveToTop(); 48 } 49 50 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 } 58 59 saveShapeDetails() { 60 console.info("fnum entrance",this.attrs.floorNum) 61 62 this.setAttr("connected_pins", this.info.selectedPins); 63 this.setAttr("obj_name", this.info.name); 64 this.setAttr("description", this.info.description); 65 this.setAttr("is_main_entrance", this.info.isMainEntrance); 66 this.setAttr("connected_room", this.info.connectedRoom); 67 this.setAttr("floor_num",this.floorNum); 68 } 69 70 connect(node, draw = true) { 71 if(this.floorNum !== node.floorNum) return; 72 73 super.connect(node) 74 } 75 76 setInfo(infoObj) { 77 console.log("SA VIKNA SETINFO") 78 this.info = infoObj; 79 if(this.info.connectedRoom == null || this.info.connectedRoom === "" ){ 80 this.strokeWidth(2); 81 this.stroke("#a10114") 82 }else{ 83 this.strokeWidth(1) 84 this.stroke("black") 85 } 86 } 57 87 } 58 88 -
imaps-frontend/src/scripts/shapes/InfoPin.js
rd565449 r0c6b92a 1 import Konva from "konva"; 2 import MapShape from "./MapShape"; 3 import Factory from "../util/Factory"; 1 4 2 import { _registerNode } from "konva/lib/Global"; 5 export default class InfoPin extends MapShape { 6 constructor(mousePos, blockSize, layer, snappable,id) { 3 import MapNode from "../base/MapNode.js"; 4 import {node} from "prop-types"; 5 import draw from "../../pages/Draw/Draw.jsx"; 6 export default class InfoPin extends MapNode { 7 constructor(attrs,id) { 8 attrs.snap = false; 7 9 super( 8 10 { 9 x: mousePos.x,10 y: mousePos.y,11 radiusX: blockSize * 0.5,12 radiusY: blockSize * 0.7,13 tailHeight: blockSize * 1.2,14 fill: "# d70113",11 x: attrs.position.x, 12 y: attrs.position.y, 13 radiusX: attrs.blockSize * 0.5, 14 radiusY: attrs.blockSize * 0.7, 15 tailHeight: attrs.blockSize * 1.2, 16 fill: "#f60000", 15 17 stroke: "#1b1b1b", 16 strokeWidth: 0.2,18 strokeWidth: 1, 17 19 draggable: true, 18 20 name: "mapObj", 19 21 }, 20 layer,21 blockSize,22 snappable22 attrs.layer, 23 attrs.blockSize, 24 attrs.snap 23 25 ); 24 26 25 27 this.id = id; 28 this.eventName = "openPinModalEvent"; 29 this.floorNum = attrs.floorNum; 26 30 27 this.modalEventName = "openPinModalEvent";28 31 this.type = "InfoPin"; 29 32 this._info = { 30 name: `Pin ${id}`,33 name: `Pin${id} [${this.floorNum}F]`, 31 34 selectedPins: [], 32 35 description: "", … … 34 37 35 38 this.on("mouseover", () => { 36 this.fill(" yellow");39 this.fill("#FFD700"); 37 40 }); 38 41 this.on("mouseout", () => { 39 this.fill(" red");42 this.fill("#f60000"); 40 43 }); 44 41 45 42 46 this.initText(); 43 47 } 44 48 _sceneFunc(context, shape) { 45 const { radiusX, radiusY, tailHeight } = this.attrs; 49 const { radiusX, radiusY, tailHeight } = this.attrs; // attrs od konva 46 50 47 51 context.beginPath(); … … 59 63 } 60 64 65 61 66 loadInfo(attrs) { 62 67 this.info.name = attrs.obj_name; 63 68 this.info.selectedPins = attrs.connected_pins; 64 69 this.info.description = attrs.description; 70 this.floorNum = attrs.floor_num 65 71 } 66 72 … … 69 75 this.setAttr("connected_pins", this.info.selectedPins); 70 76 this.setAttr("description", this.info.description); 77 this.setAttr("floor_num",this.floorNum) 71 78 console.log(this.info, "vnatre vo info"); 79 } 80 81 connect(node, draw = true) { 82 if(this.floorNum !== node.floorNum) return; 83 super.connect(node) 72 84 } 73 85 } -
imaps-frontend/src/scripts/shapes/Room.js
rd565449 r0c6b92a 1 1 import Konva from "konva"; 2 import MapShape from ". /MapShape";2 import MapShape from "../base/MapShape.js"; 3 3 import { _registerNode } from "konva/lib/Global"; 4 4 export default class Room extends MapShape { 5 constructor(mousePos, blockSize, layer, rotation, snap, id, scaleX = 1, scaleY = 1){ 5 constructor(attrs,id){ 6 7 if(!attrs.fromLoad){ 8 attrs.width *= 12; 9 attrs.height *= 8; 10 } 11 12 console.log(attrs.position,"hehe") 6 13 super( 7 14 { 8 x: mousePos.x,9 y: mousePos.y,10 width: blockSize * 8 *scaleX,11 height: blockSize * 4 *scaleY,12 fill: " #DDE0F8",15 x: attrs.position.x, 16 y: attrs.position.y, 17 width: attrs.width * attrs.scaleX, 18 height: attrs.height * attrs.scaleY, 19 fill: "rgb(86,168,253)", 13 20 stroke: "grey", 14 21 strokeWidth: 1, 15 22 name: "mapObj", 16 rotation: rotation,23 rotation: attrs.rotation, 17 24 draggable: true, 18 25 }, 19 layer,20 blockSize,21 snap26 attrs.layer, 27 attrs.blockSize, 28 attrs.snap 22 29 ); 23 30 31 this.floorNum = attrs.floorNum; 32 24 33 this._info = { 25 name: `Room ${id}`,34 name: `Room${id} [${this.floorNum}F]`, 26 35 type: "", 27 36 description: "", … … 29 38 30 39 this.type = "Room"; 31 this. modalEventName = "openRoomModalEvent";40 this.eventName = "openRoomModalEvent"; 32 41 this.id = id; 33 42 … … 39 48 this.info.type = attrs.room_type; 40 49 this.info.description = attrs.description; 50 this.floorNum = attrs.floor_num; 41 51 } 42 52 … … 45 55 this.setAttr("room_type", this.info.type); 46 56 this.setAttr("description", this.info.description); 57 this.setAttr("floor_num",this.floorNum); 47 58 } 48 59 } -
imaps-frontend/src/scripts/shapes/Stairs.js
rd565449 r0c6b92a 1 1 import Konva from "konva"; 2 import { MapShape } from "./MapShape"; 2 import MapNode from "../base/MapNode.js"; 3 import {_registerNode} from "konva/lib/Global.js"; 4 import Room from "./Room.js"; 5 export default class Stairs extends MapNode{ 6 constructor(attrs,id) { 3 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 76 Stairs.prototype.className = "Stairs"; 77 _registerNode(Stairs); 4 78 //TODO -
imaps-frontend/src/scripts/shapes/Wall.js
rd565449 r0c6b92a 1 1 import Konva from "konva"; 2 import MapShape from ". /MapShape";2 import MapShape from "../base/MapShape.js"; 3 3 import { _registerNode } from 'konva/lib/Global'; 4 4 export default class Wall extends MapShape { 5 constructor(mousePos, blockSize, layer, rotation,snap, draggable = true,scaleX = 1, scaleY = 1){ 5 constructor(attrs){ 6 if(!attrs.fromLoad){ 7 attrs.height *= 8; 8 } 9 10 6 11 super( 7 12 { 8 x: mousePos.x,9 y: mousePos.y,10 width: blockSize *scaleX,11 height: blockSize * 8 *scaleY,12 fill: "# DDE0F8",13 x: attrs.position.x, 14 y: attrs.position.y, 15 width: attrs.width * attrs.scaleX, 16 height: attrs.height * attrs.scaleY, 17 fill: "#d3d3d3", 13 18 stroke: "grey", 14 19 strokeWidth: 1, 15 20 name: "mapObj", 16 draggable: draggable,17 rotation: rotation,21 draggable: true, 22 rotation: attrs.rotation, 18 23 zIndex: 0, 19 24 }, 20 layer,21 blockSize,22 snap,25 attrs.layer, 26 attrs.blockSize, 27 attrs.snap, 23 28 ); 24 25 29 this.type = "Wall"; 30 31 this.floorNum = attrs.floorNum; 26 32 } 27 } 33 34 loadInfo(attrs) { 35 this.floorNum = attrs.floor_num; 36 } 37 38 saveShapeDetails() { 39 this.setAttr("floor_num",this.floorNum) 40 } 41 } 28 42 29 43 Wall.prototype.className = 'Wall'
Note:
See TracChangeset
for help on using the changeset viewer.