
    Og6.                        d dl mZ d dlmZmZmZmZ d dlmZ d dl	m
Z
mZ erd dlmZ d dlmZ ddgZd	Zej$                  Zd
Zej*                  ZdZdZ G d d      Zy)    )annotations)AnyOptionalIteratorTYPE_CHECKING)colors)	validatorconst)Drawing)	DXFEntity
GfxAttribsTRANSPARENCY_BYBLOCK0ByLayer      ?g      c                     e Zd ZU dZeZded<   eZded<   dZ	ded<   e
Zded	<   eZded
<   dZded<   eZded<   eede
eded	 	 	 	 	 	 	 	 	 	 	 	 	 d(dZd)dZd)dZd*dZd+d,dZd+d-dZed)d       Zej2                  d.d       Zed/d       Zej2                  d0d       Zed1d       Zej2                  d2d       Zed)d       Zej2                  d.d       Zed/d       Zej2                  d0d       Zed3d        Zej2                  d4d!       Zed5d"       Zej2                  d6d#       Ze d7d$       Z!d8d%Z"e d9d&       Z#e d:d'       Z$y);r   a<  
    Represents often used DXF attributes of graphical entities.

    Args:
        layer (str): layer name as string
        color (int): :ref:`ACI` color value as integer
        rgb: RGB true color (red, green, blue) tuple, each channel value in the
            range from 0 to 255, ``None`` for not set
        linetype (str): linetype name, does not check if the linetype exist!
        lineweight (int):  see :ref:`lineweights` documentation for valid values
        transparency (float): transparency value in the range from 0.0 to 1.0,
            where 0.0 is opaque and 1.0 if fully transparent, -1.0 for
            transparency by block, ``None`` for transparency by layer
        ltscale (float): linetype scaling factor > 0.0, default factor is 1.0

    Raises:
        DXFValueError: invalid attribute value

    str_layerint
_aci_colorNOptional[colors.RGB]_true_color	_linetype_lineweightOptional[float]_transparencyfloat_ltscalelayercolorrgblinetype
lineweighttransparencyltscalec               f    || _         || _        || _        || _        || _        || _        || _        y )Nr   )selfr    r!   r"   r#   r$   r%   r&   s           U/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/gfxattribs.py__init__zGfxAttribs.__init__5   s6     

 $(    c                   g }| j                   t        k7  r|j                  d| j                    d       | j                  t        k7  r|j                  d| j                          | j
                  |j                  d| j
                          | j                  t        k7  r|j                  d| j                   d       | j                  t        k7  r|j                  d| j                          | j                  (|j                  dt        | j                  d              | j                  t        k7  r(|j                  d	t        | j                  d              d
j                  |      S )Nzlayer=''zcolor=zrgb=z
linetype='zlineweight=ztransparency=   zltscale=z, )r   DEFAULT_LAYERappendr   DEFAULT_ACI_COLORr   r   DEFAULT_LINETYPEr   DEFAULT_LINEWEIGHTr   roundr   DEFAULT_LTSCALEjoin)r(   ss     r)   __str__zGfxAttribs.__str__H   s-   ;;-'HHwt{{m1-.??//HHvdoo./0'HHtD,,-./>>--HHz$..!13411HH{4#3#3"456)HH}U4+=+=q%A$BCD==O+HHxdmmQ 789:yy|r+   c                V    | j                   j                   d| j                          dS )N())	__class____name__r8   r(   s    r)   __repr__zGfxAttribs.__repr__[   s'    ..))*!DLLN+;1==r+   c                4    t        | j                               S )zReturns iter(self).)iteritemsr>   s    r)   __iter__zGfxAttribs.__iter__^   s    DJJL!!r+   c                X   g }|s| j                   t        k7  r|j                  d| j                   f       |s| j                  t        k7  r|j                  d| j                  f       | j
                  0|j                  dt        j                  | j
                        f       |s| j                  t        k7  r|j                  d| j                  f       |s| j                  t        k7  r|j                  d| j                  f       | j                  e| j                  t        k(  r"|j                  dt        j                  f       n0|j                  dt        j                  | j                        f       |s| j                   t"        k7  r|j                  d| j                   f       |S )a   Returns the DXF attributes as list of name, value pairs, returns
        also the default values if argument `default_values` is ``True``.
        The true_color and transparency attributes do not have default values,
        the absence of these attributes is the default value.
        r    r!   
true_colorr#   r$   r%   r&   )r   r/   r0   r   r1   r   r   rgb2intr   r2   r   r3   r$   r   r   float2transparencyr   r5   )r(   default_valuesdatas      r)   rB   zGfxAttribs.itemsb   sJ    ')T[[M9KK$++./T__0AAKK$//23'KKv~~d6F6F'GHIT^^/??KKT^^45T--1CCKKt78)!!%99^V-H-HIJ&11$2D2DE T]]o=KKDMM23r+   c                6    t        | j                  |            S )a  Returns the DXF attributes as :class:`dict`, returns also the
        default values if argument `default_values` is ``True``.
        The true_color and transparency attributes do not have default values,
        the absence of these attributes is the default value.
        )dictrB   )r(   rH   s     r)   asdictzGfxAttribs.asdict   s     DJJ~.//r+   c                    | j                   S )z
layer name)r   r>   s    r)   r    zGfxAttribs.layer   s     {{r+   c                n    t        j                  |      r|| _        y t        j                  d| d      )Nzinvalid layer name 'r-   )r	   is_valid_layer_namer   r
   DXFValueErrorr(   names     r)   r    zGfxAttribs.layer   s2    ((.DK%%(<TF!&DEEr+   c                    | j                   S )z:ref:`ACI` color value)r   r>   s    r)   r!   zGfxAttribs.color   s     r+   c                n    t        j                  |      r|| _        y t        j                  d| d      )Nzinvalid ACI color value 'r-   )r	   is_valid_aci_colorr   r
   rP   r(   values     r)   r!   zGfxAttribs.color   s2    ''.#DO%%(A%&JKKr+   c                    | j                   S )zBtrue color value as (red, green, blue) tuple, ``None`` for not set)r   r>   s    r)   r"   zGfxAttribs.rgb        r+   c                    |d | _         y t        j                  |      r|| _         y t        j                  d| d      )Nzinvalid true color value 'r-   )r   r	   is_valid_rgbr
   rP   rV   s     r)   r"   zGfxAttribs.rgb   s@    =#D##E*$D%%(B5'&KLLr+   c                    | j                   S )zlinetype name)r   r>   s    r)   r#   zGfxAttribs.linetype   s     ~~r+   c                n    t        j                  |      r|| _        y t        j                  d| d      )Nzinvalid linetype name 'r-   )r	   is_valid_table_namer   r
   rP   rQ   s     r)   r#   zGfxAttribs.linetype   s2    ((.!DN%%(?vQ&GHHr+   c                    | j                   S )r$   )r   r>   s    r)   r$   zGfxAttribs.lineweight   rY   r+   c                n    t        j                  |      r|| _        y t        j                  d| d      )Nzinvalid lineweight value 'r-   )r	   is_valid_lineweightr   r
   rP   rV   s     r)   r$   zGfxAttribs.lineweight   s3    ((/$D%%(B5'&KLLr+   c                    | j                   S )ztransparency value from 0.0 for opaque to 1.0 is fully transparent,
        -1.0 is for transparency by block and ``None`` if for transparency
        by layer
        )r   r>   s    r)   r%   zGfxAttribs.transparency   s     !!!r+   c                    |d | _         y |t        k(  rt        | _         y t        |t              rd|cxk  rdk  r	|| _         y  t	        j
                  d| d      )Ng        r   zinvalid transparency value 'r-   )r   r   
isinstancer   r
   rP   rV   s     r)   r%   zGfxAttribs.transparency   s`    =!%D**!5Du%3%+>3+>!&D ,? %%(DUG1&MNNr+   c                    | j                   S )zlinetype scaling factor)r   r>   s    r)   r&   zGfxAttribs.ltscale   s     }}r+   c                    t        |t        t        f      r|dkD  rt        |      | _        y t	        j
                  d| d      )Ngư>zinvalid linetype scale value 'r-   )rd   r   r   r   r
   rP   rV   s     r)   r&   zGfxAttribs.ltscale   s<    eeS\*!%LDM%%(FugQ&OPPr+   c           
         |j                   } | |j                  dt              |j                  dt              |j                  dt              |j                  dt
              |j                  dt                    S )a  Load default DXF attributes from the HEADER section.

        There is no default true color value and the default transparency is not
        stored in the HEADER section.

        Loads following header variables:

            - ``$CLAYER`` - current layer name
            - ``$CECOLOR`` - current ACI color
            - ``$CELTYPE`` - current linetype name
            - ``$CELWEIGHT`` - current lineweight
            - ``$CELTSCALE`` - current linetype scaling factor

        $CLAYER$CECOLOR$CELTYPE
$CELWEIGHT
$CELTSCALE)r    r!   r#   r$   r&   )headergetr/   r1   r2   r3   r5   )clsdocrm   s      r)   load_from_headerzGfxAttribs.load_from_header   sc      **Y6**Z):;ZZ
,<=zz,0BCJJ|_=
 	
r+   c                F   |j                   }|j                  j                  | j                        r| j                  |d<   | j                  |d<   |j
                  j                  | j                        r| j                  |d<   | j                  |d<   | j                  |d<   y)a  Write DXF attributes as default values to the HEADER section.

        Writes following header variables:

            - ``$CLAYER`` - current layer name, if a layer table entry exist in `doc`
            - ``$CECOLOR`` - current ACI color
            - ``$CELTYPE`` - current linetype name, if a linetype table entry exist in `doc`
            - ``$CELWEIGHT`` - current lineweight
            - ``$CELTSCALE`` - current linetype scaling factor

        rh   ri   rj   rk   rl   N)	rm   layers	has_entryr    r!   	linetypesr#   r$   r&   )r(   rp   rm   s      r)   write_to_headerzGfxAttribs.write_to_header  s     ::

+ $

F9!ZZz==""4==1!%F:#|#|||r+   c                r    	 |j                         }| j                  |      S # t        $ r
  |        cY S w xY w)z[Get the graphical attributes of an `entity` as :class:`GfxAttribs`
        object.
        )graphic_propertiesAttributeError	from_dict)ro   entityds      r)   from_entityzGfxAttribs.from_entity  s>    
	))+A }}Q  	5L	s   # 66c                F    |        }dD ]  }||v st        ||||           d|v rt        j                  |d         |_        d|v rX|d   }t	        |t
              r	||_        |S |t        j                  k(  rt        |_        |S t        j                  |      |_        |S )ak  Construct :class:`GfxAttribs` from a dictionary of raw DXF values.

        Supported attributes are:

            - layer: layer name as string
            - color: :ref:`ACI` value as int
            - true_color: raw DXF integer value for RGB colors
            - rgb: RGB tuple of int or ``None``
            - linetype: linetype name as string
            - lineweight: lineweight as int, see basic concept of :ref:`lineweights`
            - transparency: raw DXF integer value of transparency or a float in the
              range from 0.0 to 1.0
            - ltscale: linetype scaling factor as float

        )r    r!   r#   r$   r&   r"   rE   r%   )	setattrr   int2rgbr"   rd   r   r%   r   transparency2float)ro   r|   attribsattrib_namer%   s        r)   rz   zGfxAttribs.from_dict!  s    " %
 		>K aan=		> 1 ..<9GKQ^,L,.'3$
 	 !<!<<';$  (.'@'@'N$r+   )r    r   r!   r   r"   r   r#   r   r$   r   r%   r   r&   r   )returnr   )r   zIterator[tuple[str, Any]])F)r   zlist[tuple[str, Any]])r   dict[str, Any])rR   r   )r   r   )rW   r   )r   r   )rW   r   )r   r   )rW   r   )r   r   )rW   r   )rp   r   r   r   )rp   z	'Drawing'r   None)r{   r   r   r   )r|   r   r   r   )%r=   
__module____qualname____doc__r/   r   __annotations__r1   r   r   r2   r   r3   r   r   r5   r   r*   r8   r?   rC   rB   rL   propertyr    setterr!   r"   r#   r$   r%   r&   classmethodrq   rv   r}   rz    r+   r)   r   r      sS   (  FC'J'(,K%,%Is%)K)%)M?)%He%
 #&$((,(,(  	
 "   & &&>"B0   \\F F   \\L L     	ZZM M   __I I     M M " " O O   ^^Q Q 
 
0,*     % %r+   N)
__future__r   typingr   r   r   r   ezdxfr   ezdxf.lldxfr	   r
   ezdxf.documentr   ezdxf.entitiesr   __all__r/   BYLAYERr1   r2   LINEWEIGHT_BYLAYERr3   r5   r   r   r   r+   r)   <module>r      sd    # 9 9  (&(/
0 NN  --  o or+   