
    'j
                         d dl mZmZ d dlmZmZmZ d dlmZm	Z	 d dl
mZ d dlmZ g dZdeded	efd
Zd Zdedee         fdZddedee         defdZddedefdZdededefdZdS )    )Iterablecast)UVecVec2BoundingBox2d)Layout
Paperspace)	DXFEntity)bbox)centerobjectsextentswindowlayoutpointsizec                 b   | j         }|r| j        rAt          t          |                    }|                    |t          |                     dS | j        rGt          t          |           }|                    t          |          t          |                     dS t          d          dS )zResets the active viewport center of `layout` to the given `point`,
    argument `size` defines the width and height of the viewport.
    Replaces the current viewport configuration by a single window
    configuration.

    zunsupported layout typeN)
docis_modelspaceguess_heightr   set_modelspace_vportis_any_paperspacer   r	   reset_main_viewport	TypeError)r   r   r   r   heightpsps         D/DATA/AppData/hermes/venv/lib/python3.11/site-packages/ezdxf/zoom.pyr   r      s     *C
 7 	7!$t**--F$$VT%[[99999% 	7z6**C##DKKd<<<<<56667 7    c                 D    | j         }| j        }t          |dz  |          S )Ng       @)xymax)r   widthr   s      r   r   r       s$    FEVFus{F###r   entitiesc                     t          | t                    r$|                                 fd|D             }t          j        |d          }|j        r t          | |j        |j        |z             d S d S )Nc              3   $   K   | ]
}|u|V  d S N ).0emain_viewports     r   	<genexpr>z#zoom_to_entities.<locals>.<genexpr>+   s-      FFaq/E/E/E/E/E/EFFr   T)fast)
isinstancer	   r+   r   r   has_datar   r   )r   r$   factorr   r+   s       @r   zoom_to_entitiesr1   '   s    &*%% G,,..$FFFF8FFFHl8$///G >vw~w|f'<=====> >r      r0   c                 T    | j         fd|D             }t          | ||           dS )a'  Resets the active viewport limits of `layout` to the extents of the
    given `entities`. Only entities in the given `layout` are taken into
    account. The argument `factor` scales the viewport limits.
    Replaces the current viewport configuration by a single window
    configuration.

    c              3   <   K   | ]}|j         j        k    |V  d S r'   )dxfowner)r)   r*   r6   s     r   r,   zobjects.<locals>.<genexpr>:   s1      ;;QaekU&:&:q&:&:&:&:;;r   N)
layout_keyr1   )r   r$   r0   contentr6   s       @r   r   r   1   s>     E;;;;(;;;GVWf-----r   c                 (    t          | | |           dS )zResets the active viewport limits of `layout` to the extents of all
    entities in this `layout`. The argument `factor` scales the viewport limits.
    Replaces the current viewport configuration by a single window
    configuration.

    N)r1   )r   r0   s     r   r   r   >   s     VVV,,,,,r   p1p2c                 ^    t          ||g          }t          | |j        |j                   dS )zResets the active viewport limits of `layout` to the lower left corner
    `p1` and the upper right corner `p2`.
    Replaces the current viewport configuration by a single window
    configuration.

    N)r   r   r   )r   r:   r;   r   s       r   r   r   H   s1     RH%%G
67>7<00000r   N)r2   )typingr   r   
ezdxf.mathr   r   r   ezdxf.layoutsr   r	   ezdxf.entitiesr
   ezdxfr   __all__r   r   r1   floatr   r   r   r(   r   r   <module>rD      sp   " ! ! ! ! ! ! ! 0 0 0 0 0 0 0 0 0 0 , , , , , , , , $ $ $ $ $ $      
4
4
476 7$ 7d 7 7 7 7&$ $ $>V >x	/B > > > >
. 
.F 
.hy&9 
.5 
. 
. 
. 
.- -F -E - - - -16 1t 1 1 1 1 1 1 1r   