Ë
    £èh}/  ã                  ó¼   — 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           ú0lib/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-  € ØˆØ�;‰;œ-Ò'Ø�H‰H�w˜tŸ{™{˜m¨1Ð-Ô.Ø�?‰?Ô/Ò/Ø�H‰H�v˜dŸo™oÐ.Ð/Ô0Ø×ÑÐ'Ø�H‰H�t˜D×,Ñ,Ð-Ð.Ô/Ø�>‰>Ô-Ò-Ø�H‰H�z $§.¡.Ð!1°Ð3Ô4Ø×ÑÔ1Ò1Ø�H‰H�{ 4×#3Ñ#3Ð"4Ð5Ô6Ø×ÑÐ)Ø�H‰H�}¤U¨4×+=Ñ+=¸qÓ%AÐ$BÐCÔDØ�=‰=œOÒ+Ø�H‰H�x¤ d§m¡m°QÓ 7Ð8Ð9Ô:à�y‰y˜‹|Ðr+   c                óV   — | j                   j                  › d| j                  «       › d�S )NÚ(Ú))Ú	__class__Ú__name__r8   ©r(   s    r)   Ú__repr__zGfxAttribs.__repr__[   s'   € Ø—.‘.×)Ñ)Ð*¨!¨D¯L©L«NÐ+;¸1Ð=Ð=r+   c                ó4   — t        | j                  «       «      S )zReturns iter(self).)ÚiterÚitemsr>   s    r)   Ú__iter__zGfxAttribs.__iter__^   s   € ä�D—J‘J“LÓ!Ð!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Ø�K‰K˜ $§+¡+Ð.Ô/Ù˜TŸ_™_Ô0AÒAØ�K‰K˜ $§/¡/Ð2Ô3Ø×ÑÐ'à�K‰K˜¤v§~¡~°d×6FÑ6FÓ'GÐHÔIÙ˜TŸ^™^Ô/?Ò?Ø�K‰K˜ T§^¡^Ð4Ô5Ù˜T×-Ñ-Ô1CÒCØ�K‰K˜ t§¡Ð7Ô8Ø×ÑÐ)à×!Ñ!Ô%9Ò9Ø—‘˜^¬V×-HÑ-HÐIÕJà—‘à&Ü×1Ñ1°$×2DÑ2DÓEðôñ ˜TŸ]™]¬oÒ=Ø�K‰K˜ D§M¡MÐ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   € ô �D—J‘J˜~Ó.Ó/Ð/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   € ä×(Ñ(¨Ô.ØˆD�Kä×%Ñ%Ð(<¸T¸FÀ!Ð&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   € ä×'Ñ'¨Ô.Ø#ˆD�Oä×%Ñ%Ð(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Õä×%Ñ%Ð(BÀ5À'ÈÐ&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   € ä×(Ñ(¨Ô.Ø!ˆD�Nä×%Ñ%Ð(?À¸vÀQÐ&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Õä×%Ñ%Ð(BÀ5À'ÈÐ&KÓLÐLr+   c                ó   — | j                   S )z¨transparency 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ÕØÔ*Ò*Ü!5ˆDÕÜ˜œuÔ%¨3°%Ô+>¸3Ò+>Ø!&ˆDÕð ,?ô ×%Ñ%Ð(DÀUÀGÈ1Ð&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<   € ä�eœe¤S˜\Ô*°¸²Ü! %›LˆD�Mä×%Ñ%Ð(FÀuÀgÈQÐ&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Ô):Ó;Ø—Z‘Z 
Ô,<Ó=Ø—z‘z ,Ô0BÓCØ—J‘J˜|¬_Ó=ô
ð 	
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   € ð —‘ˆØ�:‰:×Ñ §
¡
Ô+Ø $§
¡
ˆF�9ÑØ!ŸZ™Zˆˆ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ÓÐøô ò 	Ù“5ŠLð	ú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ÑÜ Ÿ.™.¨¨<©Ó9ˆGŒKØ˜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  … ñð(  €FˆCÓØ'€J�Ó'Ø(,€KÐ%Ó,Ø%€IˆsÓ%Ø)€K�Ó)Ø%)€M�?Ó)Ø%€HˆeÓ%ð
 #Ø&Ø$(Ø(Ø,Ø(,Ø(ñð ðð ð	ð
 "ðð ðð ðð &ðð óó&ó&>ó"ôôB0ð òó ðð ‡\�\òFó ðFð òó ðð ‡\�\òLó ðLð ò ó ð ð 	‡Z�Zò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€ð €Ø—N‘NÐ ØÐ Ø×-Ñ-Ð Ø€ØÐ ÷oò or+   