#!D:/IDE/anaconda3/envs/Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
@FileName：ColorAdjustmentSelector.py
@Description：
@Author：XSH
@Time：2026/1/20 20:13
@Department：研发部
@Copyright：©2026 乐辰生物
"""
from PyQt5 import Qt
from datetime import datetime, date
import copy
from AppCore.AppDBModels.CoreModel import (CoreModel, DBManager, dbController)
from sqlalchemy.orm import declarative_base, mapper, sessionmaker, Session
from sqlalchemy.orm import (declarative_base, Mapped, mapped_column, relationship, mapper, sessionmaker)
from sqlalchemy import Table, Engine, create_engine, Column, ForeignKey, and_, or_, insert, delete, update, select, func, ColumnElement,distinct
from sqlalchemy.types import (Text, VARCHAR, REAL, Float, Integer, String, SmallInteger, DateTime, Date, ARRAY,Boolean, JSON)
from sqlalchemy.orm.decl_api import DeclarativeBase, MetaData
from AppUtils.utils import *
from AppCore.Levels import *

class ColorAdjustmentSelector(CoreModel):
    __tablename__ = 't_ColorAdjustmentSelector'
    ID                      : Mapped[int   ] = mapped_column(primary_key=True                      , nullable=False, doc='颜色通道选择器序号', comment='颜色通道选择器序号')
    AdjustmentSelector      : Mapped[str   ] = mapped_column(Text      , default=''                , nullable=True , doc='颜色通道选择器　　', comment='颜色通道选择器　　')
    AdjustmentHue           : Mapped[float ] = mapped_column(            default= 1.56494          , nullable=True , doc='颜色通道色相　　　', comment='颜色通道色相　　　')
    AdjustmentSaturation    : Mapped[float ] = mapped_column(            default= 1.56494          , nullable=True , doc='颜色通道饱和度　　', comment='颜色通道饱和度　　')
    def __init__(self, **args):
        super(ColorAdjustmentSelector, self).__init__()
        self.initialize()
        self.initParameter(**args)

    def initValue(self):
        super(ColorAdjustmentSelector, self).initValue()
        self.ID                       = None
        self.AdjustmentSelector       = None
        self.AdjustmentHue            = None
        self.AdjustmentSaturation     = None

    @property
    def isAvailable(self) -> bool:
        return self.hasAdjustmentSelector and self.hasAdjustmentHue and self.hasAdjustmentSaturation


    __field__ = (
        'ID'                    ,
        'AdjustmentSelector'    ,
        'AdjustmentHue'         ,
        'AdjustmentSaturation'  ,
    )
    __types__ = (
        int   ,
        str   ,
        float ,
        float ,
    )
    @classmethod
    def initModels(cls) -> list:
        return [
            cls.instance(ID                       = 1,AdjustmentSelector       = "Red"      ,AdjustmentHue            = 0.15625 ,AdjustmentSaturation     = 1.04688,),
            cls.instance(ID                       = 2,AdjustmentSelector       = "Yellow"   ,AdjustmentHue            = 0.0625  ,AdjustmentSaturation     = 1.07031,),
            cls.instance(ID                       = 3,AdjustmentSelector       = "Green"    ,AdjustmentHue            = 0.21875 ,AdjustmentSaturation     = 1.32031,),
            cls.instance(ID                       = 4,AdjustmentSelector       = "Cyan"     ,AdjustmentHue            = 0.3125  ,AdjustmentSaturation     = 1.05469,),
            cls.instance(ID                       = 5,AdjustmentSelector       = "Blue"     ,AdjustmentHue            = 0.03125 ,AdjustmentSaturation     = 0.98438,),
            cls.instance(ID                       = 6,AdjustmentSelector       = "Magenta"  ,AdjustmentHue            = 1.40625 ,AdjustmentSaturation     = 0.95313,),

        ]
    @property
    def hasID                      (self) -> bool:
        return hasattr(self, 'ID'                  ) and isinstance(self.ID                      , (int, float))

    @property
    def hasAdjustmentSelector      (self) -> bool:
        return hasattr(self, 'AdjustmentSelector'  ) and isinstance(self.AdjustmentSelector      , str         )

    @property
    def hasAdjustmentHue           (self) -> bool:
        return hasattr(self, 'AdjustmentHue'       ) and isinstance(self.AdjustmentHue           , (int, float))

    @property
    def hasAdjustmentSaturation    (self) -> bool:
        return hasattr(self, 'AdjustmentSaturation') and isinstance(self.AdjustmentSaturation    , (int, float))
