#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：ConfigInterface.py
@Description：
@Author：XSH
@Time：2025/11/11 12:05
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from PyQt5 import Qt
from abc import abstractmethod
from AppInterfaces.ModelInterface           import ContextModelInterface
from AppUtils.ConvertUtils import ConvertUtils
from AppUtils.AppConvert import AppConvert
class ConfigInterface(ContextModelInterface):
    @abstractmethod
    def UpdateMaxLocation(self):
        pass

    @classmethod
    def isAberration(cls, classifier: str) -> bool:
        return isinstance(classifier, str) and classifier == 'Aberration'

    @classmethod
    def isMicronucleus(cls, classifier: str) -> bool:
        return isinstance(classifier, str) and classifier == 'Micronucleus'

    @classmethod
    def isKaryotyping(cls, classifier: str) -> bool:
        return isinstance(classifier, str) and classifier == 'Karyotyping'

    def toYaml(self) -> str:
        buffer: dict[str, object]  = self.to_field()
        return ConvertUtils.toYaml(buffer)

    def asYaml(self, buffer: str):
        dict_buffer: dict[str, object] = ConvertUtils.asYaml(buffer)
        self.as_field(dict_buffer)

    def as_field(self, buffer: dict[str, object], is_primary: bool = True):
        primary: str
        index  : int
        keys: list[str] = buffer.keys()
        for index, _property in enumerate(self.__slots__):
            if _property in keys:
                setattr(self, _property, AppConvert.ObjectConvert(buffer.get(_property, None), self.__types__[index]))

    def to_field(self, is_primary: bool = True) -> dict[str, object]:
        buffer: dict[str, object] = {}
        primary: str = ''
        for index, _property in enumerate(self.__slots__):
            buffer[_property] = getattr(self, _property, None)
        return buffer