
import { circleService } from '../Service/CircleService'
import { coordinate } from '../Coordinate'
import { floorplanService } from '../Service/FloorplanService'
import { mathUtil } from '../MathUtil';

//独立的，不会和线条以及其他构件融合
export default class AddCircle {
    constructor() {
        this.start = null
        this.end = null;
        this.currentVectorId = null
    }

    execute(position){
        if(this.start == null){
            this.start = coordinate.getXYFromScreen(position)
        }
        else if(this.currentVectorId == null){
            this.end = {
                x:position.x,
                y:position.y
            };
            const circle = circleService.createCircle(this.start,position)
            this.currentVectorId = circle.vectorId
        }
        else {
            this.end = {
                x:position.x,
                y:position.y
            };
            const circle = floorplanService.getCircle(this.currentVectorId)
            circle.updatePoints(position,2)
        }
    }

    clear(){
        this.start = null
        this.end = null;
        this.currentVectorId = null
    }
}

const addCircle = new AddCircle()
export { addCircle }