Ë
    £èh02  ã                  óè  — d dl mZ d dlmZmZmZmZmZmZm	Z	m
Z
 d dlZd dlZd dlmZmZmZmZmZ d dlmZmZmZmZmZmZmZ d dlmZmZ d dlmZ d dl m!Z! e	rd d	l"m#Z# g d
¢Z$dZ% ejL                  d«      Z' G d„ dejP                  «      Z) G d„ d«      Z*d"d„Z+	 	 	 	 	 	 d"d„Z,	 d#	 	 	 	 	 d$d„Z-d%d„Z.d&d„Z/d'd„Z0d(d„Z1d)d„Z2d*d„Z3d+d„Z4d+d„Z5d+d„Z6d,d„Z7d-d„Z8	 	 	 	 	 	 d.d„Z9	 	 	 	 	 	 d/d „Z:d0d!„Z;y)1é    )Úannotations)ÚIterableÚIteratorÚ
NamedTupleÚOptionalÚTupleÚListÚTYPE_CHECKINGÚSequenceN)ÚMatrix44ÚUVecÚVec3ÚNonUniformScalingErrorÚInsertTransformationError)Ú	DXFEntityÚ
DXFGraphicÚCircleÚ
LWPolylineÚPolylineÚEllipseÚis_graphic_entity)Údefault_copyÚCopyNotSupported)ÚSupportsTemporaryTransformation)ÚDrawing)ÚBlockLayout)ÚLoggerÚErrorÚinplaceÚcopiesÚ	translateÚscale_uniformÚscaleÚx_rotateÚy_rotateÚz_rotateÚaxis_rotateÚtransform_entity_by_blockrefÚtransform_entities_by_blockrefgê-�™—q=Úezdxfc                  óº   — e Zd ZdZ ej
                  «       Z ej
                  «       Z ej
                  «       Z ej
                  «       Z	 ej
                  «       Z
y)r   r   N)Ú__name__Ú
__module__Ú__qualname__ÚNONEÚenumÚautoÚTRANSFORMATION_NOT_SUPPORTEDÚCOPY_NOT_SUPPORTEDÚNON_UNIFORM_SCALING_ERRORÚINSERT_TRANSFORMATION_ERRORÚVIRTUAL_ENTITY_NOT_SUPPORTED© ó    ú/lib/python3.12/site-packages/ezdxf/transform.pyr   r   ;   sM   „ Ø€DØ#, 4§9¡9£;Ð Ø"˜Ÿ™›ÐØ ) §	¡	£ÐØ"+ $§)¡)£+ÐØ#, 4§9¡9£;Ñ r8   r   c                  óZ   — e Zd Z G d„ de«      Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd	„Zy
)r   c                  ó,   — e Zd ZU ded<   ded<   ded<   y)úLogger.Entryr   ÚerrorÚstrÚmessager   ÚentityN)r,   r-   r.   Ú__annotations__r7   r8   r9   ÚEntryr<   E   s   … Ø‹Ø‹ØÔr8   rB   c                ó   — g | _         y ©N©Ú_entries©Úselfs    r9   Ú__init__zLogger.__init__J   s	   € Ø,.ˆ�r8   c                ó    — | j                   |   S )z#Returns the error entry at `index`.rE   )rH   Úindexs     r9   Ú__getitem__zLogger.__getitem__M   s   € à�}‰}˜UÑ#Ð#r8   c                ó,   — t        | j                  «      S )z Iterates over all error entries.)ÚiterrF   rG   s    r9   Ú__iter__zLogger.__iter__Q   s   € ä�D—M‘MÓ"Ð"r8   c                ó,   — t        | j                  «      S )z#Returns the count of error entries.)ÚlenrF   rG   s    r9   Ú__len__zLogger.__len__U   s   € ä�4—=‘=Ó!Ð!r8   c                ód   — | j                   j                  t        j                  |||«      «       y rD   )rF   Úappendr   rB   )rH   r=   r?   r@   s       r9   Úaddz
Logger.addY   s!   € Ø�‰×ÑœVŸ\™\¨%°¸&ÓAÕBr8   c                óT   — | j                   D �cg c]  }|j                  ‘Œ c}S c c}w )z.Returns all error messages as list of strings.)rF   r?   )rH   Úentrys     r9   ÚmessageszLogger.messages\   s"   € à+/¯=ª=Ó9©= %�—“¨=Ñ9Ð9ùÒ9s   �%c                óh   — |D ]  }	 | j                   j                  |«       Œ  y # t        $ r Y Œ-w xY wrD   )rF   ÚremoveÚ
ValueError)rH   ÚentriesrW   s      r9   ÚpurgezLogger.purge`   s7   € ÛˆEðØ—‘×$Ñ$ UÕ+ñ øô ò Ùðús   ‡%¥	1°1N)ÚreturnÚNone)rK   Úintr^   rB   )r^   zIterator[Entry])r^   r`   )r=   r   r?   r>   r@   r   )r^   z	list[str])r\   zIterable[Entry]r^   r_   )r,   r-   r.   r   rB   rI   rL   rO   rR   rU   rX   r]   r7   r8   r9   r   r   D   s2   „ ô�
ô ó
/ó$ó#ó"óCó:ôr8   r   c                óÆ  — t        «       }| D ]!  }|j                  sŒ	 |j                  |«       Œ# |S # t        t        f$ r0 |j                  t        j                  t        |«      › d�|«       Y Œdt        $ r0 |j                  t        j                  t        |«      › d�|«       Y Œ›t        $ r0 |j                  t        j                  t        |«      › d�|«       Y ŒÒw xY w)aW  Transforms the given `entities` inplace by the transformation matrix `m`,
    non-uniform scaling is not supported. The function logs errors and does not raise
    errors for unsupported entities or transformations that cannot be performed,
    see enum :class:`Error`.
    The :func:`inplace` function supports virtual entities as well.

    ú' entity does not support transformationú, entity does not support non-uniform scalingúC entity can not represent a non-orthogonal target coordinate system)r   Úis_aliveÚ	transformÚAttributeErrorÚNotImplementedErrorrU   r   r2   r>   r   r4   r   r5   )ÚentitiesÚmÚlogr@   s       r9   Ú_inplacerl   h   sÙ   € ô ‹(€CÛˆØ�ŠØð	Ø×Ñ˜QÕð	 ð0 €Jøô' Ô 3Ð4ò 	Ø�G‰GÜ×2Ñ2Ü�v“;�-ÐFÐGØöô
 &ò 	Ø�G‰GÜ×/Ñ/Ü�v“;�-ÐKÐLØöô
 )ò 	Ø�G‰GÜ×1Ñ1Ü�v“;�-ÐbÐcØöð	ús   ž3³<C Á15C Â(5C ÃC c                ó¦  — t        | |«      }g }|D �]+  }|j                  t        j                  k7  rŒ"|j                  }|j
                  r?|j                  |«       |j                  t        j                  dt        |«      › �|«       Œyt        |t        «      r5|j                  |«       |j                  d¬«      }|j                  |«       Œ¾t        |t        t        f«      sŒÕ|j                  |«       |j!                  «       D ]3  }t        |t        «      r|j                  «       }|j                  |«       Œ5 �Œ. |j#                  |«       |S )a3  Transforms the given `entities` inplace by the transformation matrix `m`,
    non-uniform scaling is supported. The function converts circular arcs into ellipses
    to perform non-uniform scaling.  The function logs errors and does not raise errors
    for unsupported entities or transformation errors, see enum :class:`Error`.

    .. important::

        The :func:`inplace` function does not support type conversion for virtual
        entities e.g. non-uniform scaling for CIRCLE, ARC or POLYLINE with bulges,
        see also function :func:`copies`.

    z8non-uniform scaling is not supported for virtual entity T)Úreplace)rl   r=   r   r4   r@   Ú
is_virtualrT   rU   r6   r>   Ú
isinstancer   Ú
to_ellipserf   r   r   Úexploder]   )ri   rj   rk   ÚerrorsrW   r@   ÚellipseÚ
sub_entitys           r9   r   r   Œ   s  € ô  �8˜QÓ
€CØ!#€FÜˆØ�;‰;œ%×9Ñ9Ò9Øà—‘ˆØ×ÒØ�M‰M˜%Ô Ø�G‰GÜ×2Ñ2ØJÌ3ÈvË;È-ÐXØôð
 ä�fœfÔ%Ø�M‰M˜%Ô Ø×'Ñ'°Ð'Ó5ˆGØ×Ñ˜aÕ Ü˜¤¬XÐ 6Õ7Ø�M‰M˜%Ô Ø$Ÿn™nÖ.�
Ü˜j¬&Ô1Ø!+×!6Ñ!6Ó!8�JØ×$Ñ$ QÕ'ò /ð) ð2 ‡I�IˆfÔØ€Jr8   c                óp   — t        «       }t        | |«      }t        |t        «      rt	        |||«      }||fS )a   Copy entities and transform them by matrix `m`. Does not raise any exception
    and ignores all entities that cannot be copied or transformed. Just copies the input
    entities if matrix `m` is ``None``. Returns a tuple of :class:`Logger` and a list of
    transformed virtual copies. The function supports virtual entities as input and
    converts circular arcs into ellipses to perform non-uniform scaling.
    )r   Ú_copy_entitiesrp   r   Ú_transform_clones)ri   rj   rk   Úcloness       r9   r    r    »   s9   € ô ‹(€CÜ˜H cÓ*€FÜ�!”XÔÜ" 6¨1¨cÓ2ˆØ�ˆ;Ðr8   c                óú   — g }| D ]7  }|j                   sŒ	 |j                  t        ¬«      }|j                  |«       Œ9 |S # t        $ r0 |j                  t        j                  t        |«      › d�|«       Y Œtw xY w)N)Úcopy_strategyz entity does not support copy)	re   Úcopyr   rT   r   rU   r   r3   r>   )ri   rk   ry   r@   Úclones        r9   rw   rw   Ì   s}   € Ø €FÛˆØ�ŠØð		!Ø—K‘K¬l�KÓ;ˆEð �M‰M˜%Õ ð ð €Møô  ò 	Ø�G‰GÜ×(Ñ(Ü�v“;�-Ð<Ð=Øöð	ús   –AÁ6A:Á9A:c           	     ó  — g }| D ]%  }	 |j                  |«       |j                  |«       Œ' |S # t        t        f$ r0 |j	                  t
        j                  t        |«      › d�|«       Y Œht        $ r0 |j	                  t
        j                  t        |«      › d�|«       Y ŒŸt        $ r] 	 |j                  t        ||«      «       n<# t        $ r0 |j	                  t
        j                  t        |«      › d�|«       Y nw xY wY �Œw xY w)Nrb   rd   rc   )rf   rT   rg   rh   rU   r   r2   r>   r   r5   r   ÚextendÚ_scale_non_uniformÚ	TypeErrorr4   )ry   rj   rk   ri   r@   s        r9   rx   rx   Þ   s  € Ø "€HÛˆð	$Ø×Ñ˜QÔð. �O‰O˜FÕ#ð3 ð6 €Oøô1 Ô 3Ð4ò 	Ø�G‰GÜ×2Ñ2Ü�v“;�-ÐFÐGØöô
 )ò 	Ø�G‰GÜ×1Ñ1Ü�v“;�-ÐbÐcØöô
 &ò 	ðØ—‘Ô 2°6¸1Ó =Õ>øÜò Ø—‘Ü×3Ñ3Ü˜6“{�mÐ#OÐPØöðýð	ús?   ‰/¯<D	Á-5D	Â$D	Â-C	ÃD	Ã	6DÃ?D	ÄDÄD	ÄD	c              #  óX  K  — t        | t        «      r+t        j                  | «      }|j	                  |«       |–— y t        | t
        t        f«      rP| j                  «       D ]<  }t        |t        «      rt        j                  |«      }|j	                  |«       |–— Œ> y t        ‚­wrD   )	rp   r   r   Úfrom_arcrf   r   r   Úvirtual_entitiesr�   )r@   rj   ru   s      r9   r€   r€   þ   s‹   è ø€ ä�&œ&Ô!Ü×%Ñ% fÓ-ˆ
Ø×Ñ˜QÔØÓÜ	�FœZ¬Ð2Ô	3Ø ×1Ñ1Ö3ˆJÜ˜*¤fÔ-Ü$×-Ñ-¨jÓ9�
Ø× Ñ  Ô#ØÓñ	 4ô ˆùs   ‚B(B*c                ó°   — t        |«      }|r@t        | t        j                  |j                  |j
                  |j                  «      ¬«      S t        «       S )z=Translates (moves) `entities` inplace by the `offset` vector.©rj   )r   rl   r   r!   ÚxÚyÚzr   )ri   ÚoffsetÚvs      r9   r!   r!     s=   € äˆV‹€AÙÜ˜¤H×$6Ñ$6°q·s±s¸A¿C¹CÀÇÁÓ$EÔFÐFÜ‹8€Or8   c                ó”   — t        |«      }t        |«      t        kD  r"t        | t	        j
                  |||«      ¬«      S t        «       S )zƒScales `entities` inplace by a `factor` in all axis. Scaling factors smaller than
    :attr:`MIN_SCALING_FACTOR` are ignored.

    r†   )ÚfloatÚabsÚMIN_SCALING_FACTORrl   r   r#   r   )ri   ÚfactorÚfs      r9   r"   r"     s;   € ô
 	ˆf‹€AÜ
ˆ1ƒvÔ"Ò"Ü˜¤H§N¡N°1°a¸Ó$;Ô<Ð<Ü‹8€Or8   c           
     óp   — dd„}t        | t        j                   ||«       ||«       ||«      «      «      S )a  Scales `entities` inplace by the factors `sx` in x-axis, `sy` in y-axis and `sz`
    in z-axis. Scaling factors smaller than :attr:`MIN_SCALING_FACTOR` are ignored.

    .. important::

        same limitations for virtual entities as the :func:`inplace` function

    c                óD   — t        | «      } t        | «      t        kD  r| S dS )Ng      ð?)r�   rŽ   r�   )r‘   s    r9   Úsafezscale.<locals>.safe+  s"   € Ü�!‹HˆÜ˜“FÔ/Ò/ˆqÐ8°SÐ8r8   )r‘   r�   r^   r�   )r   r   r#   )ri   ÚsxÚsyÚszr”   s        r9   r#   r#   !  s/   € ó9ô �8œXŸ^™^©D°«H±d¸2³hÁÀRÃÓIÓJÐJr8   c                óp   — t        |«      }|r t        | t        j                  |«      ¬«      S t	        «       S ©zBRotates `entities` inplace by `angle` in radians about the x-axis.r†   )r�   rl   r   r$   r   ©ri   ÚangleÚas      r9   r$   r$   2  ó-   € äˆe‹€AÙÜ˜¤H×$5Ñ$5°aÓ$8Ô9Ð9Ü‹8€Or8   c                óp   — t        |«      }|r t        | t        j                  |«      ¬«      S t	        «       S )zBRotates `entities` inplace by `angle` in radians about the y-axis.r†   )r�   rl   r   r%   r   rš   s      r9   r%   r%   :  r�   r8   c                óp   — t        |«      }|r t        | t        j                  |«      ¬«      S t	        «       S r™   )r�   rl   r   r&   r   rš   s      r9   r&   r&   B  r�   r8   c                ó´   — t        |«      }|s
t        «       S t        |«      }|j                  s!t	        | t        j                  ||«      ¬«      S t        «       S )z†Rotates `entities` inplace by `angle` in radians about the rotation axis starting
    at the origin pointing in `axis` direction.
    r†   )r�   r   r   Úis_nullrl   r   r'   )ri   Úaxisr›   rœ   r‹   s        r9   r'   r'   J  sH   € ô 	ˆe‹€AÙÜ‹xˆäˆT‹
€AØ�9Š9Ü˜¤H×$8Ñ$8¸¸AÓ$>Ô?Ð?Ü‹8€Or8   c                ó    — t        | g|«      duS )z�Apply a transformation by moving an entity into a block and replacing the entity
    by a block reference with the applied transformation.
    N)Ú_transform_by_blockref)r@   rj   s     r9   r(   r(   X  s   € ô " 6 (¨AÓ.°dÐ:Ð:r8   c                ó,   — t        t        | «      |«      S )z�Apply a transformation by moving entities into a block and replacing the entities
    by a block reference with the applied transformation.
    )r¤   Úlist)ri   rj   s     r9   r)   r)   _  s   € ô "¤$ x£.°!Ó4Ð4r8   c                ó  — t        | «      dk(  ry | d   }t        |«      sy |j                  }|€y |j                  «       }|€y |j                  j                  «       }|j                  |j                  d«      }	 |j                  |«       | D ]   }t        |«      sŒ|j                  ||«       Œ" |S # t        $ rP t        j                  d«       |j                  |«       |j                  j                  |j                  d¬«       Y y w xY w)Nr   )r   r   r   z#cannot apply invalid transformationF)r”   )rQ   r   ÚdocÚ
get_layoutÚblocksÚnew_anonymous_blockÚadd_blockrefÚnamerf   r   ÚloggerÚwarningÚdelete_entityÚdelete_blockÚmove_to_layout)ri   rj   Úfirst_entityr¨   ÚlayoutÚblockÚinsertÚes           r9   r¤   r¤   h  s   € ô ˆ8ƒ}˜ÒØà˜A‘;€LÜ˜\Ô*Øà
×
Ñ
€CØ
€{Øà×$Ñ$Ó&€FØ€~Øà�J‰J×*Ñ*Ó,€EØ× Ñ  §¡¨YÓ7€FðØ×Ñ˜Ôó ˆÜ˜QÕØ×!Ñ! ! UÕ+ð ð €Løô %ò Ü�‰Ð<Ô>Ø×Ñ˜VÔ$Ø�
‰
×Ñ §
¡
°ÐÔ7Ùð	ús   Á:B2 Â2ADÄ
Dc                óv   — | D ]4  }t        |t        «      sŒ|j                  «       }|j                  |«       Œ6 y rD   )rp   r   Útemporary_transformationÚapply_transformation)ri   r@   Útts      r9   Úapply_temporary_transformationsr¼   Š  s3   € ÛˆÜ�fÔ=Õ>Ø×0Ñ0Ó2ˆBØ×#Ñ# FÕ+ñ r8   )ri   úIterable[DXFEntity]rj   r   r^   r   rD   )ri   r½   rj   zOptional[Matrix44]r^   zTuple[Logger, List[DXFEntity]])ri   r½   rk   r   r^   zlist[DXFEntity])ry   r½   rj   r   rk   r   )r@   r   rj   r   )ri   r½   rŠ   r   r^   r   )ri   r½   r�   r�   r^   r   )
ri   r½   r•   r�   r–   r�   r—   r�   r^   r   )ri   r½   r›   r�   r^   r   )ri   r½   r¢   r   r›   r�   r^   r   )r@   r   rj   r   r^   Úbool)ri   r½   rj   r   r^   úBlockLayout | None)ri   zSequence[DXFEntity]rj   r   r^   r¿   )ri   r½   r^   r_   )<Ú
__future__r   Útypingr   r   r   r   r   r	   r
   r   r0   ÚloggingÚ
ezdxf.mathr   r   r   r   r   Úezdxf.entitiesr   r   r   r   r   r   r   Úezdxf.entities.copyr   r   Úezdxf.protocolsr   Úezdxf.documentr   Úezdxf.layoutsr   Ú__all__r�   Ú	getLoggerr®   ÚEnumr   r   rl   r   r    rw   rx   r€   r!   r"   r#   r$   r%   r&   r'   r(   r)   r¤   r¼   r7   r8   r9   Ú<module>rÌ      sI  ðõ #÷	÷ 	ó 	ó Û ÷õ ÷÷ ñ ÷ ?Ý ;Ý "áÝ)ò€ð Ð Ø	ˆ×	Ñ	˜7Ó	#€ô/ˆD�I‰Iô /÷!ñ !óH!ðH,Ø!ð,àð,ð ó,ð` <@ðØ!ðØ&8ðà#óó"ó$ó@ó óóKó"óóóó;ð5Ø!ð5Ø&.ð5àó5ðØ!ðØ&.ðàóôD,r8   