from ..common.base_parameter_control import BaseParameterControl
from ..lattice.lattice_filtering_settings import LatticeFilteringSettings


class LatticeControlBox(BaseParameterControl):
    def __init__(self, parent=None):
        super().__init__(title="Lattice Filtering Settings", parent=parent)

        self.latticePanel = LatticeFilteringSettings(self)
        self.settingsLayout.addWidget(self.latticePanel)

    def getReciprocalDistTol(self):
        return self.latticePanel.getReciprocalDistTol()

    def setReciprocalDistTol(self, v):
        self.latticePanel.setReciprocalDistTol(v)

    def getReciprocalDistMax(self):
        return self.latticePanel.getReciprocalDistMax()

    def setReciprocalDistMax(self, v):
        self.latticePanel.setReciprocalDistMax(v)

    def validate(self):
        if self.latticePanel.getReciprocalDistMax() == 0.0:
            raise ValueError(
                """Check Lattice Settings: 
                Reciprocal Distance Mak cannot be zero. Please provide a positive value.
            """
            )
