import VectorType from '../enum/VectorType.js'
import CustomImage from '../Geometry/CustomImage.js'
import { mathUtil } from '../MathUtil.js'
import { floorplanService } from './FloorplanService'
import Constant from '../Constant'

export default class CustomImageService {
    constructor() {
        this.url = null;
    }

    setCustomImageUrl(url){
        this.url = url;
    }

    async createCustomImage(center,vectorId) {
        const customImage = new CustomImage(this.url, center,vectorId)
        if(this.url){
            const imageData = await floorplanService.loadImageData(this.url)
            customImage.setImageData(imageData)
            customImage.width = imageData.width;
            customImage.height = imageData.height;
        }

        floorplanService.addCustomImage(customImage)
        this.url = null;
        return customImage
    }

    deleteCustomImage(customImageId, floorNum) {
        floorplanService.deleteCustomImage(customImageId, floorNum)
    }

    setCustomImageInfo(customImageInfo) {
        let customImage = floorplanService.getCustomImage(customImageInfo.vectorId)
        customImage.vectorId = customImageInfo.vectorId
        customImage.angle = customImageInfo.angle
        customImage.url = customImageInfo.url
        customImage.scale = customImageInfo.scale
    }
}

const customImageService = new CustomImageService()
export { customImageService }