# Path: pytripgui/utils/regex.py
# class Regex(Enum):
#     STRING = QRegularExpression(r"\w+[\s\w]*")
#     INT = QRegularExpression(r"-?\d*")
#     INT_POSITIVE = QRegularExpression(r"\d*[1-9]\d*")
#     FLOAT = QRegularExpression(r"-?((\d+([,\.]\d{0,3})?)|(\d*[,\.]\d{1,3}))")
#     FLOAT_POSITIVE = QRegularExpression(r"(\d*[1-9]\d*([,\.]\d{0,3})?)|(\d*[,\.](?=\d{1,3}$)(\d*[1-9]\d*))")
#     FLOAT_UNSIGNED = QRegularExpression(r"0+|((\d*[1-9]\d*([,\.]\d{0,3})?)|(\d*[,\.](?=\d{1,3}$)(\d*[1-9]\d*)))")


import math
from decimal import Decimal
from PyQt5.QtGui import QValidator, QRegularExpressionValidator
from pytrip.ctx import CtxCube
from pytrip.vdx import VdxCube
from pytripgui.utils.regex import Regex
    def _validate_general_parameters(self) -> bool:
        return self.view.name.validate() and self.view.hu_value.validate() and self.view.xoffset.validate() and\
            self.view.yoffset.validate() and self.view.slice_offset.validate()

    def _validate_tab(self, index) -> bool:
        result = True
        for field in self.view.dimensions_fields[index].values():
            if not field.validate():
                result = False
        return result

    def _validate_pixel_size(self) -> bool:
        dim = self.view.dimensions_fields[1]
        fields = [dim["width"], dim["pixel_number_x"], dim["height"], dim["pixel_number_y"]]
        # check if any of the fields are empty
        if any(not field.text for field in fields):
            return False

        width = float(dim["width"].text)
        height = float(dim["height"].text)
        pixel_number_x = int(dim["pixel_number_x"].text)
        pixel_number_y = int(dim["pixel_number_y"].text)
        if math.isclose(width / pixel_number_x, height / pixel_number_y, abs_tol=1e-3):
            for field in fields:
                field.reset_border()
            return True
        for field in fields:
            field.highlight_border()
        return False


# Path: pytripgui/utils/regex.py
# class Regex(Enum):
#     STRING = QRegularExpression(r"\w+[\s\w]*")
#     INT = QRegularExpression(r"-?\d*")
#     INT_POSITIVE = QRegularExpression(r"\d*[1-9]\d*")
#     FLOAT = QRegularExpression(r"-?((\d+([,\.]\d{0,3})?)|(\d*[,\.]\d{1,3}))")
#     FLOAT_POSITIVE = QRegularExpression(r"(\d*[1-9]\d*([,\.]\d{0,3})?)|(\d*[,\.](?=\d{1,3}$)(\d*[1-9]\d*))")
#     FLOAT_UNSIGNED = QRegularExpression(r"0+|((\d*[1-9]\d*([,\.]\d{0,3})?)|(\d*[,\.](?=\d{1,3}$)(\d*[1-9]\d*)))")


# Path: pytripgui/empty_patient_vc/empty_patient_cont.py
import math
from decimal import Decimal
from PyQt5.QtGui import QValidator, QRegularExpressionValidator
from pytrip.ctx import CtxCube
from pytrip.vdx import VdxCube
from pytripgui.utils.regex import Regex

    def _validate_general_parameters(self) -> bool:
        return self.view.name.validate() and self.view.hu_value.validate() and self.view.xoffset.validate() and\
            self.view.yoffset.validate() and self.view.slice_offset.validate()

    def _validate_tab(self, index) -> bool:
        result = True
        for field in self.view.dimensions_fields[index].values():
            if not field.validate():
                result = False
        return result

    def _validate_pixel_size(self) -> bool:
        dim = self.view.dimensions_fields[1]
        fields = [dim["width"], dim["pixel_number_x"], dim["height"], dim["pixel_number_y"]]
        # check if any of the fields are empty
        if any(not field.text for field in fields):
            return False

        width = float(dim["width"].text)
        height = float(dim["height"].text)
        pixel_number_x = int(dim["pixel_number_x"].text)
        pixel_number_y = int(dim["pixel_number_y"].text)
        if math.isclose(width / pixel_number_x, height / pixel_number_y, abs_tol=1e-3):
            for field in fields:
                field.reset_border()
            return True
        for field in fields:
            field.highlight_border()
        return False


    def _set_model_from_view(self) -> None: