# 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/view/qt_view_adapter.py
# class LineEdit:
#     def __init__(self, line_edit):
#         self._ui = line_edit
# 
#     @property
#     def text(self):
#         return self._ui.text()
# 
#     @text.setter
#     def text(self, text):
#         self._ui.setText(str(text))
# 
#     def clear(self):
#         self._ui.clear()
# 
#     def set_enabled(self, enabled):
#         self._ui.setEnabled(enabled)
# 
#     def emit_on_text_change(self, callback):
#         """
#         When user have changed text in UI, callback will be called with new text:
#         callback(new_text)
#         """
#         self._ui.textChanged.connect(callback)
# 
#     def set_validator(self, validator):
#         self._ui.setValidator(validator)
# 
#     def enable_validation(self, validator, custom_validation=None):
#         self._ui.setValidator(validator)
#         if custom_validation:
#             self._ui.textChanged.connect(custom_validation)
#         else:
#             self._ui.textChanged.connect(self.validate)
# 
#     def disable_validation(self):
#         self._ui.textChanged.disconnect()
# 
#     def validate(self):
#         if self._ui.validator():
#             state = self._ui.validator().validate(self._ui.text(), 0)[0]
#             if state == QValidator.Acceptable:
#                 self.reset_border()
#                 return True
#             self.highlight_border()
#         return False
# 
#     def highlight_border(self):
#         self._ui.setStyleSheet("border: 1px solid red")
# 
#     def reset_border(self):
#         self._ui.setStyleSheet("")


from PyQt5 import QtWidgets, uic
from PyQt5.QtGui import QRegularExpressionValidator
from pathlib import Path
from pytripgui.utils.regex import Regex
from pytripgui.view.qt_view_adapter import LineEdit

        validator = QRegularExpressionValidator(Regex.STRING.value)
        self._name.enable_validation(validator)

        validator = QRegularExpressionValidator(Regex.FLOAT.value)
        enable_validation_list(validator, self._center)

    @property
    def name(self):
        return self._name.text

    @property
    def center(self):
        return [float(field.text) for field in self._center]

    def validate(self) -> bool:
        return self._name.validate() and validate_list(self._center)

    def disable_fields(self) -> None:
        self._name.set_enabled(False)
        for field in self._center:
            field.set_enabled(False)


class SphericalVOIWidget(VOIWidget):
    def __init__(self):
        super().__init__("spherical_voi.ui")

        self._radius = LineEdit(self.radius_lineEdit)


# 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/view/qt_view_adapter.py
# class LineEdit:
#     def __init__(self, line_edit):
#         self._ui = line_edit
# 
#     @property
#     def text(self):
#         return self._ui.text()
# 
#     @text.setter
#     def text(self, text):
#         self._ui.setText(str(text))
# 
#     def clear(self):
#         self._ui.clear()
# 
#     def set_enabled(self, enabled):
#         self._ui.setEnabled(enabled)
# 
#     def emit_on_text_change(self, callback):
#         """
#         When user have changed text in UI, callback will be called with new text:
#         callback(new_text)
#         """
#         self._ui.textChanged.connect(callback)
# 
#     def set_validator(self, validator):
#         self._ui.setValidator(validator)
# 
#     def enable_validation(self, validator, custom_validation=None):
#         self._ui.setValidator(validator)
#         if custom_validation:
#             self._ui.textChanged.connect(custom_validation)
#         else:
#             self._ui.textChanged.connect(self.validate)
# 
#     def disable_validation(self):
#         self._ui.textChanged.disconnect()
# 
#     def validate(self):
#         if self._ui.validator():
#             state = self._ui.validator().validate(self._ui.text(), 0)[0]
#             if state == QValidator.Acceptable:
#                 self.reset_border()
#                 return True
#             self.highlight_border()
#         return False
# 
#     def highlight_border(self):
#         self._ui.setStyleSheet("border: 1px solid red")
# 
#     def reset_border(self):
#         self._ui.setStyleSheet("")


# Path: pytripgui/add_vois_vc/voi_widget.py
from PyQt5 import QtWidgets, uic
from PyQt5.QtGui import QRegularExpressionValidator
from pathlib import Path
from pytripgui.utils.regex import Regex
from pytripgui.view.qt_view_adapter import LineEdit


        validator = QRegularExpressionValidator(Regex.STRING.value)
        self._name.enable_validation(validator)

        validator = QRegularExpressionValidator(Regex.FLOAT.value)
        enable_validation_list(validator, self._center)

    @property
    def name(self):
        return self._name.text

    @property
    def center(self):
        return [float(field.text) for field in self._center]

    def validate(self) -> bool:
        return self._name.validate() and validate_list(self._center)

    def disable_fields(self) -> None:
        self._name.set_enabled(False)
        for field in self._center:
            field.set_enabled(False)


class SphericalVOIWidget(VOIWidget):
    def __init__(self):
        super().__init__("spherical_voi.ui")

        self._radius = LineEdit(self.radius_lineEdit)


        validator = QRegularExpressionValidator(Regex.FLOAT_UNSIGNED.value)