
    Og\                        d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZmZ erd dlmZ dZd	Zd
ZdZdZdZdZdZdZddZddZddZd dZd!dZddZddZddZ d"dZ!d#dZ"d$d%dZ#	 	 	 	 	 	 	 	 d&dZ$y)'    )annotations)TYPE_CHECKING)const	validator)BoundingBox)bbox)EndCaps	JoinStyle)Drawingz$CLAYERz$CECOLORz$CELTYPEz
$CELWEIGHTz
$CELTSCALEz
$TEXTSTYLEz	$DIMSTYLEz$EXTMINz$EXTMAXc                x    || j                   vrt        j                  d| d      || j                  t        <   y)zSet current layer.zundefined layer: ""N)layersr   DXFValueErrorheaderCURRENT_LAYERdocnames     V/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/appsettings.pyset_current_layerr      s7    3::!!$6tfA">?? $CJJ}    c                    t        j                  |      st        j                  d| d      || j                  t
        <   y)zSet current :ref:`ACI`.zinvalid ACI color value: "r   N)r   is_valid_aci_colorr   r   r   CURRENT_COLOR)r   colors     r   set_current_colorr   !   s9    ''.!!$>ugQ"GHH %CJJ}r   c                x    || j                   vrt        j                  d| d      || j                  t        <   y)zSet current linetype.zundefined linetype: "r   N)	linetypesr   r   r   CURRENT_LINETYPEr   s     r   set_current_linetyper    (   8    3== !!$9$q"ABB#'CJJ r   c                    t        j                  |      st        j                  d| d      || j                  t
        <   y)zSSet current lineweight, see :ref:`lineweights` reference for valid
    values.
    zinvalid lineweight value: "r   N)r   is_valid_lineweightr   r   r   CURRENT_LINEWEIGHT)r   
lineweights     r   set_current_lineweightr&   /   s<     ((4!!$?
|1"MNN%/CJJ!"r   c                f    |dk  rt        j                  d| d      || j                  t        <   y)zSet current linetype scale.g        zinvalid linetype scale: "r   N)r   r   r   CURRENT_LINETYPE_SCALE)r   scales     r   set_current_linetype_scaler*   8   s3    |!!$=eWA"FGG).CJJ%&r   c                x    || j                   vrt        j                  d| d      || j                  t        <   y)zSet current text style.zundefined textstyle: "r   N)stylesr   r   r   CURRENT_TEXTSTYLEr   s     r   set_current_textstyler.   ?   s8    3::!!$:4&"BCC$(CJJ !r   c                x    || j                   vrt        j                  d| d      || j                  t        <   y)zSet current dimstyle.zundefined dimstyle: "r   N)	dimstylesr   r   r   CURRENT_DIMSTYLEr   s     r   set_current_dimstyler2   F   r!   r   c                t    t        | |       | j                  j                  |      }|j                  |        y)zLSet current dimstyle and copy all dimstyle attributes to the HEADER section.N)r2   r0   getcopy_to_header)r   r   dimstyles      r   set_current_dimstyle_attribsr7   M   s.    d#}}  &HC r   c                    | j                   j                          | j                  j                  d      D ]  }|j                           y)ztRestore the UCS settings in the HEADER section to the :ref:`WCS` and
    reset all active viewports to the WCS.
    z*ActiveN)r   	reset_wcs	viewports
get_config)r   vports     r   restore_wcsr=   T   s<     JJ)))4 r   c                L   | j                         }t        j                  |d      }|j                  rp|j                  |j
                  _        |j                  |j
                  _        |j                  | j                  t        <   |j                  | j                  t        <   |S )a  Calculate the extents of the model space, update the HEADER variables
    $EXTMIN and $EXTMAX and returns the result as :class:`ezdxf.math.BoundingBox`.
    Note that this function uses the :mod:`ezdxf.bbox` module to calculate the
    extent of the model space. This module is not very fast and not very
    accurate for text and ignores all :term:`ACIS` based entities.

    The function updates only the values in the HEADER section, to zoom the
    active viewport to this extents, use this recipe::

        import ezdxf
        from ezdxf import zoom, appsettings

        doc = ezdxf.readfile("your.dxf")
        extents = appsettings.update_extents(doc)
        zoom.center(doc.modelspace(), extents.center, extents.size)

    .. seealso::

        - the :mod:`ezdxf.bbox` module to understand the limitations of the
          extent calculation
        - the :mod:`ezdxf.zoom` module

    T)fast)

modelspacer   extentshas_dataextmindxfextmaxr   EXTMINEXTMAX)r   msprA   s      r   update_extentsrI   ]   sp    0 ..
Cll3T*G  $^^

6$^^

6Nr   c                4    t        |      | j                  d<   y)z}The CAD application or DXF viewer should show lines and curves with
    "thickness" (lineweight) if `state` is ``True``.
    z
$LWDISPLAYNintr   )r   states     r   show_lineweightrN      s      #5zCJJ|r   c                d    t        |      | j                  d<   t        |      | j                  d<   y)zSet the style of end caps and joints for linear entities when displaying
    line weights. These settings only affect objects created afterwards.
    z$ENDCAPSz
$JOINSTYLENrK   )r   end_caps
join_styles      r   set_lineweight_display_stylerR      s(     !]CJJz":CJJ|r   N)r   r   r   str)r   r   r   rL   )r   r   r%   rL   )r   r   r)   float)r   r   )r   r   returnr   )T)r   r   rU   None)r   r   rP   r	   rQ   r
   rU   rV   )%
__future__r   typingr   ezdxf.lldxfr   r   
ezdxf.mathr   ezdxfr   ezdxf.enumsr	   r
   ezdxf.documentr   r   r   r   r$   r(   r-   r1   rF   rG   r   r   r    r&   r*   r.   r2   r7   r=   rI   rN   rR    r   r   <module>r_      s    #   ( "  *& ! %    		%&(0/)(!D*/	/#/1:/	/r   