/*
 * Copyright (C) 2022 - Florindo Smilari (spherIC)
 */
package ch.spherIC.recurvebowsight.ui.calcsight;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import ch.spherIC.recurvebowsight.model.IArcherySetup;
import ch.spherIC.recurvebowsight.model.IRiser;
import ch.spherIC.recurvebowsight.model.ISight;

public class CalculateSightSightSettingViewModel extends ViewModel {

    private final MutableLiveData<IRiser> mRiser;
    private final MutableLiveData<Double> mVvisH;
    private final MutableLiveData<Double> mVvisV;
    private final MutableLiveData<ISight> mSight;
    private final MutableLiveData<Double> mHeVis;
    private final MutableLiveData<Double> mAV;
    private final MutableLiveData<Double> mAH;
    private final MutableLiveData<Double> mVertScaleRngMin;
    private final MutableLiveData<Double> mVertScaleRngMax;
    private final MutableLiveData<Double> mScalePointerOffset;
    private final MutableLiveData<Double> mVertSkalaMiddle;
    private final MutableLiveData<Double> mEvS;
    private IArcherySetup selectedArcherySetup;
    private Double startAngle;
    private Double shootingDistance;

    public CalculateSightSightSettingViewModel() {
        this.mRiser = new MutableLiveData<>();
        this.mSight = new MutableLiveData<>();
        this.mVvisH = new MutableLiveData<>();
        this.mVvisV = new MutableLiveData<>();
        this.mHeVis = new MutableLiveData<>();
        this.mAV = new MutableLiveData<>();
        this.mAH = new MutableLiveData<>();
        this.mVertScaleRngMin = new MutableLiveData<>();
        this.mVertScaleRngMax = new MutableLiveData<>();
        this.mScalePointerOffset = new MutableLiveData<>();
        this.mVertSkalaMiddle = new MutableLiveData<>();
        this.mEvS = new MutableLiveData<>();

        this.mRiser.setValue(null);
        this.mSight.setValue(null);
        this.mVvisH.setValue(null);
        this.mVvisV.setValue(null);
        this.mHeVis.setValue(null);
        this.mAV.setValue(null);
        this.mAH.setValue(null);
        this.mVertScaleRngMin.setValue(null);
        this.mVertScaleRngMax.setValue(null);
        this.mScalePointerOffset.setValue(null);
        this.mVertSkalaMiddle.setValue(null);
        this.mEvS.setValue(null);
    }

    public void setSelectedRiser(IRiser aSelectedRiser) {
        this.mRiser.setValue(aSelectedRiser);
        this.mVvisH.setValue(aSelectedRiser != null ? aSelectedRiser.getVVisH() : null);
        this.mVvisV.setValue(aSelectedRiser != null ? aSelectedRiser.getVVisV() : null);
    }

    public void setSelectedSight(ISight aSight) {
        this.mSight.setValue(aSight);
        this.mAV.setValue(aSight != null ? aSight.getAV() : null);
        this.mAH.setValue(aSight != null ? aSight.getAH() : null);
        this.mVertScaleRngMin.setValue(aSight != null ? aSight.getVertSkalaRangeMin() : null);
        this.mVertScaleRngMax.setValue(aSight != null ? aSight.getVertSkalaRangeMax() : null);
        this.mScalePointerOffset.setValue(aSight != null ? aSight.getPointerOffset() : null);
    }

    public void setVertSkalaMiddle(Double vertSkalaMiddle) {
        this.mVertSkalaMiddle.setValue(vertSkalaMiddle);
    }

    public void setStartAngle(Double startAngle) {
        this.startAngle = startAngle;
    }

    public void setSelectedArcherySetup(IArcherySetup selectedArcherySetup) {
        this.selectedArcherySetup = selectedArcherySetup;
    }

    public void setHeVis(Double aHeVis) {
        this.mHeVis.setValue(aHeVis);
    }

    public LiveData<IRiser> getSelectedRiser() {
        return mRiser;
    }

    public LiveData<ISight> getSelectedSight() {
        return mSight;
    }

    public LiveData<Double> getVVisH() {
        return this.mVvisH;
    }

    public LiveData<Double> getVVisV() {
        return this.mVvisV;
    }

    public LiveData<Double> getHeVis() {
        return mHeVis;
    }

    public LiveData<Double> getAV() {
        return mAV;
    }

    public LiveData<Double> getAH() {
        return mAH;
    }

    public LiveData<Double> getVertScaleRngMin() {
        return mVertScaleRngMin;
    }

    public LiveData<Double> getVertScaleRngMax() {
        return mVertScaleRngMax;
    }

    public LiveData<Double> getScalePointerOffset() {return mScalePointerOffset;}

    public LiveData<Double> getVertSkalaMiddle() {
        return mVertSkalaMiddle;
    }

    public LiveData<Double> getEvS() {
        return mEvS;
    }

    public Double getStartAngle() {return startAngle;}

    public IArcherySetup getSelectedArcherySetup() {return selectedArcherySetup;}

    public Double getShootingDistance() {return shootingDistance;}

    public void setShootingDistance(Double shootingDistance) {this.shootingDistance = shootingDistance;}
}