
    h0                       S SK Jr  S SKJrJrJrJrJrJrJ	r	J
r
  S SKrS SKrS SKJrJrJrJrJr  S SKJrJrJrJrJrJrJr  S SKJrJr  S SKJr  S SK J!r!  \	(       a  S S	K"J#r#  / S
Qr$Sr%\RL                  " S5      r' " S S\RP                  5      r) " S S5      r*S"S jr+      S"S jr, S#     S$S jjr-S%S jr.S&S jr/S'S jr0S(S jr1S)S jr2S*S jr3S+S jr4S+S jr5S+S jr6S,S jr7S-S jr8      S.S jr9      S/S  jr:S0S! jr;g)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                      \ rS rSrSr\R                  " 5       r\R                  " 5       r\R                  " 5       r	\R                  " 5       r
\R                  " 5       rSrg)r   ;   r    N)__name__
__module____qualname____firstlineno__NONEenumautoTRANSFORMATION_NOT_SUPPORTEDCOPY_NOT_SUPPORTEDNON_UNIFORM_SCALING_ERRORINSERT_TRANSFORMATION_ERRORVIRTUAL_ENTITY_NOT_SUPPORTED__static_attributes__r-       A/var/www/html/env/lib/python3.13/site-packages/ezdxf/transform.pyr   r   ;   sC    D#'99;  $		"&))+#'99; r;   r   c                  p    \ rS rSr " S S\5      rSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSrg)r   D   c                  4    \ rS rSr% S\S'   S\S'   S\S'   Srg	)
Logger.EntryE   r   errorstrmessager   entityr-   N)r.   r/   r0   r1   __annotations__r:   r-   r;   r<   Entryr@   E   s    r;   rG   c                    / U l         g N_entriesselfs    r<   __init__Logger.__init__J   s	    ,.r;   c                     U R                   U   $ )z#Returns the error entry at `index`.rJ   )rM   indexs     r<   __getitem__Logger.__getitem__M   s    }}U##r;   c                ,    [        U R                  5      $ )z Iterates over all error entries.)iterrK   rL   s    r<   __iter__Logger.__iter__Q   s    DMM""r;   c                ,    [        U R                  5      $ )z#Returns the count of error entries.)lenrK   rL   s    r<   __len__Logger.__len__U   s    4==!!r;   c                b    U R                   R                  [        R                  XU5      5        g rI   )rK   appendr   rG   )rM   rB   rD   rE   s       r<   add
Logger.addY   s    V\\%&ABr;   c                X    U R                    Vs/ s H  oR                  PM     sn$ s  snf )z.Returns all error messages as list of strings.)rK   rD   )rM   entrys     r<   messagesLogger.messages\   s     +/==9=%=999s   'c                p    U H  n U R                   R                  U5        M!     g ! [         a     M1  f = frI   )rK   remove
ValueError)rM   entriesra   s      r<   purgeLogger.purge`   s7    E$$U+   s   '
55rJ   N)returnNone)rQ   intrj   rG   )rj   zIterator[Entry])rj   rl   )rB   r   rD   rC   rE   r   )rj   z	list[str])rg   zIterable[Entry]rj   rk   )r.   r/   r0   r1   r   rG   rN   rR   rV   rZ   r^   rb   rh   r:   r-   r;   r<   r   r   D   s2    
 
/$#"C:r;   r   c                   [        5       nU  H(  nUR                  (       d  M   UR                  U5        M*     U$ ! [        [        4 a1    UR                  [        R                  [        U5       S3U5         Mn  [         a1    UR                  [        R                  [        U5       S3U5         M  [         a1    UR                  [        R                  [        U5       S3U5         M  f = f)aC  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 scalingC entity can not represent a non-orthogonal target coordinate system)r   is_alive	transformAttributeErrorNotImplementedErrorr^   r   r5   rC   r   r7   r   r8   )entitiesmlogrE   s       r<   _inplacerx   h   s     (C	Q	 0 J'  34 	GG22v;-FG
 & 	GG//v;-KL
 ) 	GG11v;-bc	s   ;=C.;6C.46C.-C.c                   [        X5      n/ nU GHD  nUR                  [        R                  :w  a  M$  UR                  nUR
                  (       a@  UR                  U5        UR                  [        R                  S[        U5       3U5        M  [        U[        5      (       a3  UR                  U5        UR                  SS9nUR                  U5        M  [        U[        [        45      (       d  M  UR                  U5        UR!                  5        H9  n[        U[        5      (       a  UR                  5       nUR                  U5        M;     GMG     UR#                  U5        U$ )a  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)rx   rB   r   r7   rE   
is_virtualr]   r^   r9   rC   
isinstancer   
to_ellipserr   r   r   exploderh   )ru   rv   rw   errorsra   rE   ellipse
sub_entitys           r<   r   r      s      8
C!#F;;%999MM% GG22J3v;-X
 ff%%MM% '''5Ga X 677MM% $nn.
j&11!+!6!6!8J$$Q' /) 2 IIfJr;   c                t    [        5       n[        X5      n[        U[        5      (       a  [	        X1U5      nX#4$ )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_entitiesr|   r   _transform_clones)ru   rv   rw   cloness       r<   r    r       s6     (CH*F!X"6c2;r;   c                   / nU  H;  nUR                   (       d  M   UR                  [        S9nUR                  U5        M=     U$ ! [         a1    UR                  [        R                  [        U5       S3U5         M{  f = f)N)copy_strategyz entity does not support copy)	rq   copyr   r]   r   r^   r   r6   rC   )ru   rw   r   rE   clones        r<   r   r      s}     F		!KKlK;E MM%   M   	GG((v;-<=	s   A7B Bc           	     *   / nU  H&  n UR                  U5        UR                  U5        M(     U$ ! [        [        4 a1    UR	                  [
        R                  [        U5       S3U5         Ml  [         a1    UR	                  [
        R                  [        U5       S3U5         M  [         a_     UR                  [        XA5      5         M  ! [         a3    UR	                  [
        R                  [        U5       S3U5          GM  f = ff = f)Nrn   rp   ro   )rr   r]   rs   rt   r^   r   r5   rC   r   r8   r   extend_scale_non_uniform	TypeErrorr7   )r   rv   rw   ru   rE   s        r<   r   r      s    "H	$Q. OOF#3 6 O1  34 	GG22v;-FG
 ) 	GG11v;-bc
 & 	 26 => 336{m#OP 	s3   1=D16D*	D4C7DDDDc              #  ~  #    [        U [        5      (       a,  [        R                  " U 5      nUR	                  U5        Uv   g [        U [
        [        45      (       aX  U R                  5        HC  n[        U[        5      (       a  [        R                  " U5      nUR	                  U5        Uv   ME     g [        e7frI   )	r|   r   r   from_arcrr   r   r   virtual_entitiesr   )rE   rv   r   s      r<   r   r      s     &&!!%%f-
Q	FZ2	3	3 113J*f--$--j9
  #	 4 s   B;B=c                    [        U5      nU(       a>  [        U [        R                  " UR                  UR
                  UR                  5      S9$ [        5       $ )z=Translates (moves) `entities` inplace by the `offset` vector.rv   )r   rx   r   r!   xyzr   )ru   offsetvs      r<   r!   r!     s=    VAH$6$6qssACC$EFF8Or;   c                    [        U5      n[        U5      [        :  a  [        U [        R
                  " X"U5      S9$ [        5       $ )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_FACTORrx   r   r#   r   )ru   factorfs      r<   r"   r"     s9    
 	fA
1v""HNN1$;<<8Or;   c           
     t    SS jn[        U [        R                  " U" U5      U" U5      U" U5      5      5      $ )zScales `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                F    [        U 5      n [        U 5      [        :  a  U $ S$ )Ng      ?)r   r   r   )r   s    r<   safescale.<locals>.safe+  s"    !HF//q8S8r;   )r   r   rj   r   )r   r   r#   )ru   sxsyszr   s        r<   r#   r#   !  s/    9 8X^^DHd2hRIJJr;   c                v    [        U5      nU(       a  [        U [        R                  " U5      S9$ [	        5       $ zBRotates `entities` inplace by `angle` in radians about the x-axis.r   )r   rx   r   r$   r   ru   angleas      r<   r$   r$   2  -    eAH$5$5a$8998Or;   c                v    [        U5      nU(       a  [        U [        R                  " U5      S9$ [	        5       $ )zBRotates `entities` inplace by `angle` in radians about the y-axis.r   )r   rx   r   r%   r   r   s      r<   r%   r%   :  r   r;   c                v    [        U5      nU(       a  [        U [        R                  " U5      S9$ [	        5       $ r   )r   rx   r   r&   r   r   s      r<   r&   r&   B  r   r;   c                    [        U5      nU(       d
  [        5       $ [        U5      nUR                  (       d  [	        U [
        R                  " XC5      S9$ [        5       $ )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_nullrx   r   r'   )ru   axisr   r   r   s        r<   r'   r'   J  sF     	eAxT
A99H$8$8$>??8Or;   c                     [        U /U5      SL$ )zApply 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)rE   rv   s     r<   r(   r(   X  s     "6(A.d::r;   c                ,    [        [        U 5      U5      $ )zApply a transformation by moving entities into a block and replacing the entities
by a block reference with the applied transformation.
)r   list)ru   rv   s     r<   r)   r)   _  s     "$x.!44r;   c                6   [        U 5      S:X  a  g U S   n[        U5      (       d  g UR                  nUc  g UR                  5       nUc  g UR                  R                  5       nUR                  UR                  S5      n UR                  U5        U  H&  n[        U5      (       d  M  UR                  Xu5        M(     U$ ! [         aM    [        R                  S5        UR                  U5        UR                  R                  UR                  SS9   g f = f)Nr   )r   r   r   z#cannot apply invalid transformationF)r   )rY   r   doc
get_layoutblocksnew_anonymous_blockadd_blockrefnamerr   r   loggerwarningdelete_entitydelete_blockmove_to_layout)ru   rv   first_entityr   layoutblockinsertes           r<   r   r   h  s    8}A;L\**


C
{$$&F~JJ**,E  Y7F Q!!!+  L % <>V$



7	s   C ADDc                    U  H;  n[        U[        5      (       d  M  UR                  5       nUR                  U5        M=     g rI   )r|   r   temporary_transformationapply_transformation)ru   rE   tts      r<   apply_temporary_transformationsr     s6    f=>>002B##F+ r;   )ru   Iterable[DXFEntity]rv   r   rj   r   rI   )ru   r   rv   zOptional[Matrix44]rj   zTuple[Logger, List[DXFEntity]])ru   r   rw   r   rj   zlist[DXFEntity])r   r   rv   r   rw   r   )rE   r   rv   r   )ru   r   r   r   rj   r   )ru   r   r   r   rj   r   )
ru   r   r   r   r   r   r   r   rj   r   )ru   r   r   r   rj   r   )ru   r   r   r   r   r   rj   r   )rE   r   rv   r   rj   bool)ru   r   rv   r   rj   BlockLayout | None)ru   zSequence[DXFEntity]rv   r   rj   r   )ru   r   rj   rk   )<
__future__r   typingr   r   r   r   r   r	   r
   r   r3   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   rx   r   r    r   r   r   r!   r"   r#   r$   r%   r&   r'   r(   r)   r   r   r-   r;   r<   <module>r      sG   #	 	 	      ? ; ")  			7	#/DII /! !H!H,!,, ,` <@!&8#"$@ K";5!5&.55!&.D,r;   