#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：AlgorithmManagerInterface.py
@Description：
@Author：XSH
@Time：2025/11/15 12:11
@Department：研发部
@Copyright：©2025 乐辰生物
"""
from abc import abstractmethod, abstractstaticmethod
from AppInterfaces.ManagerInterface                                 import ManagerInterface            #
from AppInterfaces.AppAlgorithmInterfaces.AlgorithmModelInterface   import AlgorithmModelInterface     #
from AppInterfaces.AppAlgorithmInterfaces.SurfaceFittingInterface   import SurfaceFittingInterface     #

class AlgorithmManagerInterface(ManagerInterface):
    ScanSurface             : SurfaceFittingInterface       #
    PreviewClassifier       : AlgorithmModelInterface       #
    PreferredClassifier     : AlgorithmModelInterface       #
    CollectClassifier       : AlgorithmModelInterface       #
    AsyncCollectClassifier  : AlgorithmModelInterface       #

    def initDetector(self):
        self.initPreviewClassifier      ()

    def deleDetector(self):
        self.delePreviewClassifier      ()


    def initClassifier(self):
        self.initCollectClassifier()


    def deleClassifier(self):
        self.deleCollectClassifier()

    def initAsyncClassifier(self):
        self.initCollectClassifier()

    def deleAsyncClassifier(self):
        self.deleCollectClassifier()

    @property
    def Detector(self) -> AlgorithmModelInterface:
        return self.preview_classifier

    @property
    def Classifier(self) -> AlgorithmModelInterface:
        return self.collect_classifier

    @property
    def Fitting(self) -> SurfaceFittingInterface:
        return self.scansurface

    @property
    def AsyncClassifier(self) -> AlgorithmModelInterface:
        return self.aslnc_classifier

    @abstractmethod
    def initPreviewClassifier   (self):
        pass

    @abstractmethod
    def initCollectClassifier   (self):
        pass


    @abstractmethod
    def delePreviewClassifier   (self):
        pass

    @abstractmethod
    def deleCollectClassifier   (self):
        pass

    @abstractmethod
    def initScanSurface(self):
        pass

    @property
    def preview_classifier(self) -> AlgorithmModelInterface:
        return None if not self.hasPreviewClassifier else self.PreviewClassifier

    @property
    def collect_classifier(self) -> AlgorithmModelInterface:
        return None if not self.hasCollectClassifier else self.CollectClassifier

    @property
    def preview(self) -> AlgorithmModelInterface:
        return None if not self.hasPreviewClassifier else self.PreviewClassifier

    @property
    def collect(self) -> AlgorithmModelInterface:
        return None if not self.hasCollectClassifier else self.CollectClassifier

    @property
    def scansurface(self) -> SurfaceFittingInterface:
        return None if not self.hasScanSurface else self.ScanSurface

    @property
    def preferred(self) -> AlgorithmModelInterface:
        return None if not self.hasPreferredClassifier else self.PreferredClassifier

    @property
    def hasScanSurface             (self) -> bool:
        return hasattr(self, 'ScanSurface'           ) and isinstance(self.ScanSurface             , SurfaceFittingInterface)

    @property
    def hasPreviewClassifier       (self) -> bool:
        return hasattr(self, 'PreviewClassifier'     ) and isinstance(self.PreviewClassifier       , AlgorithmModelInterface)

    @property
    def hasPreferredClassifier     (self) -> bool:
        return hasattr(self, 'PreferredClassifier'   ) and isinstance(self.PreferredClassifier     , AlgorithmModelInterface)

    @property
    def hasCollectClassifier       (self) -> bool:
        return hasattr(self, 'CollectClassifier'     ) and isinstance(self.CollectClassifier       , AlgorithmModelInterface)

    @property
    def hasAsyncCollectClassifier  (self) -> bool:
        return hasattr(self, 'AsyncCollectClassifier') and isinstance(self.AsyncCollectClassifier  , AlgorithmModelInterface)




    def initLowClassifier(self):
        self.initPreviewClassifier()

    def initHigClassifier(self):
        self.initCollectClassifier()

    def deleLowClassifier(self):
        self.delePreviewClassifier  ()

    def deleHigClassifier(self):
        self.deleCollectClassifier  ()


    @abstractstaticmethod
    def SlideFocusingArray(left: int, top: int, width: int, height: int, max_row: int, max_col: int, focus_rows: int, focus_cols: int, re_row_col: bool = False) -> list[list[int]]:
        pass

    @abstractstaticmethod
    def SlideOilDropingArray(left: int, top: int, width: int, height: int, max_row: int, max_col: int, drop_rows: int, drop_cols: int) -> list[list[int]]:
        pass

    @abstractstaticmethod
    def SlideAnointingArray(left: int, top: int, width: int, height: int, max_row: int, max_col: int, drop_rows: int, drop_cols: int) -> (list, list):
        pass
    @abstractstaticmethod
    def SlideScanningArray(begin_row: int, begin_col: int, row_number: int, col_number: int, max_row: int, max_col: int, is_row_s_line: bool = True) -> list[list[int]]:
        pass

    @abstractstaticmethod
    def MicronucleusScanningArray(begin_row: int, begin_col: int, row_number: int, col_number: int, max_row: int, max_col: int, focus_rows: int, focus_cols: int) -> list[list[int]]:
        pass

    @abstractstaticmethod
    def getOilPointCount(width: int, height: int) -> int:
        pass

    @abstractstaticmethod
    def getAnointingPointCount(width: int, height: int) -> (int, int):
        pass