from ..primitives.structure import gds_autoname_structure
from ..primitives.layer import layer_property
from ..geometry.coord import size2_property

__all__ = []

class gds_logo(gds_autoname_structure):
    layer = layer_property(required = True)
    size = size2_property(default = (50.0, 50.0))
    def __init__(self, layer, size= (50.0,50.0), library = None, **kwargs):
        super(gds_logo, self).__init__(
            layer = layer,
            size = size,
            library = library,
            **kwargs)

    name_prefix = "logo_"

    # @classmethod
    def __str_name__(cls, layer, size= (50.0,50.0)):
        logo_size = (1.0, 1.1)
        scale = min([size[0]/logo_size[0],size[1]/logo_size[1]])
        name = cls.name_prefix + "L" + str(layer.number) + "_S" + str(int(scale))
        return name
    __str_name__ = classmethod(__str_name__)

    def __calc_name__(self):
        return self.__str_name__(self.layer, self.size)        
