import { floorplanService } from '../Service/FloorplanService'
import { mathUtil } from '../MathUtil.js'
import { coordinate } from '../Coordinate'
import Constant from '../Constant'

export default class MoveRectangle {
    constructor() {}

    moveFullRectangle(dx,dy, rectangleId) {
        let rectangle = floorplanService.getRectangle(rectangleId)

        rectangle.points[0] = {
            x:rectangle.points[0].x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:rectangle.points[0].y - dy/coordinate.res * Constant.defaultZoom/coordinate.zoom,
        }

        rectangle.points[1] = {
            x:rectangle.points[1].x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:rectangle.points[1].y - dy/coordinate.res * Constant.defaultZoom/coordinate.zoom,
        }

        rectangle.points[2] = {
            x:rectangle.points[2].x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:rectangle.points[2].y - dy/coordinate.res * Constant.defaultZoom/coordinate.zoom,
        }

        rectangle.points[3] = {
            x:rectangle.points[3].x + dx/coordinate.res * Constant.defaultZoom/coordinate.zoom,
            y:rectangle.points[3].y - dy/coordinate.res * Constant.defaultZoom/coordinate.zoom,
        }
    }

    moveRectangleVertex(newPosition,rectangleId,index) {
        let rectangle = floorplanService.getRectangle(rectangleId)
        rectangle.updatePoints(newPosition,index)
    }

    moveRectangleSide(newPosition,rectangleId,index) {
        let rectangle = floorplanService.getRectangle(rectangleId)
        rectangle.updateSides(newPosition,index)
    }
}

const moveRectangle = new MoveRectangle()
export { moveRectangle }
