import VectorType from '../enum/VectorType.js'
import Rectangle from '../Geometry/Rectangle.js'
import { floorplanService } from './FloorplanService'


export default class RectangleService {
    constructor() {
    }
  
    createRectangle(leftTopPosition,rightDownPosition,vectorId,floor) {
        const rectangle = new Rectangle(leftTopPosition,rightDownPosition,vectorId,floor)
        floorplanService.addRectangle(rectangle)
        return rectangle
    }

    updateRectangleVertex(vectorId,newPosition,index){
        const rectangle = floorplanService.getRectangle(vectorId)
        rectangle.updatePoints(newPosition,index)
    }

    setRectangleInfo(rectangleInfo) {
        let rectangle = floorplanService.getRectangle(rectangleInfo.vectorId)
        rectangle.vectorId = rectangleInfo.vectorId
        rectangle.angle = rectangleInfo.angle
        rectangle.points = JSON.parse(JSON.stringify(rectangleInfo.points))
    }

    deleteRectangle(rectangleId, floorNum) {
        floorplanService.deleteRectangle(rectangleId, floorNum)
    }
}

const rectangleService = new RectangleService()
export { rectangleService }