from datetime import datetime

class Config:
    def __init__(self, identificador=""):
        self.identificador = identificador
        self.fecha = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        self.FPS = 4
        self.DIR_VIDEO = ""
        self.DIR_ACT = ""
        self.IMAGES_FOLDER = ""
        self.MODEL_CAMERA = "OPENCV"
        self.DIR_OUTPUT = ""
        self.DIR_MATCHES = ""
        self.UMBRAL = 10
        self.IMAGE_GLOBAL_WIDTH = 0
        self.IMAGE_GLOBAL_HEIGHT = 0
        self.FACTOR_BRILLO = 1
        self.FACTOR_CONTRASTE = 1
        self.FACTOR_COLOR = 1
        self.REDUCCION_RUIDO = 2
        self.TIPO_RUIDO = "Gaussian"
        self.FACTOR_RUIDO = 0.1
        self.db_file = ""
        self.DIR_KEYPOINTS = ""
        self.DIR_DATABASE = ""
        self.TIPO_RECONOCIMIENTO = "sequential"
        self.ESCALA_AABB = 16
        self.FILTROS = []
        self.LAMBDA = 0.5
        self.MU = -0.53
        self.SMOOTH_STEPS = 10
        self.NUMBER_FACES = 25
        self.MAX_HOLE_SIZE = 40
        self.EDGE_LENGTH = 3
        self.MERGE_THRESHOLD = 0.1
        self.SELECTED_MESH = ""
        self.REGISTRO_FOLDER = ""
        self.CONFIG_FOLDER = ""
        self.FILE_TYPE = "jpg"

    def as_dict(self):
        return self.__dict__
    
    def get_identificador(self):
        return self.identificador
    
    def set_identificador(self, identificador):
        self.identificador = identificador

    def resetear_configuracion(self):
        self.identificador = ""
        self.fecha = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        self.FPS = 4
        self.DIR_VIDEO = ""
        self.DIR_ACT = ""
        self.IMAGES_FOLDER = ""
        self.MODEL_CAMERA = "OPENCV"
        self.DIR_OUTPUT = ""
        self.DIR_MATCHES = ""
        self.UMBRAL = 10
        self.IMAGE_GLOBAL_WIDTH = 0
        self.IMAGE_GLOBAL_HEIGHT = 0
        self.FACTOR_BRILLO = 1
        self.FACTOR_CONTRASTE = 1
        self.FACTOR_COLOR = 1
        self.REDUCCION_RUIDO = 2
        self.TIPO_RUIDO = "Gaussian"
        self.FACTOR_RUIDO = 0.1
        self.db_file = ""
        self.DIR_KEYPOINTS = ""
        self.DIR_DATABASE = ""
        self.TIPO_RECONOCIMIENTO = "sequential"
        self.ESCALA_AABB = 16
        self.FILTROS = []
        self.LAMBDA = 0.5
        self.MU = -0.53
        self.SMOOTH_STEPS = 10
        self.NUMBER_FACES = 25
        self.MAX_HOLE_SIZE = 40
        self.EDGE_LENGTH = 3
        self.MERGE_THRESHOLD = 0.1
        self.SELECTED_MESH = ""
        self.REGISTRO_FOLDER = ""
        self.CONFIG_FOLDER = ""
        self.FILE_TYPE = "jpg"
        
    def cargar_desde_json(self, config_json):
        for clave, valor in config_json.items():
            setattr(self, clave, valor)