
    hZ                       S SK Jr  S SKJrJrJr  S SKJr  S SKrS SK	J
r
  S SKJr  S SKJrJrJr  S SKJrJrJr  S S	KJr  \(       a  S S
KJr  S SKJrJr  S SKJr  S SKJr  \R@                  " S5      r! " S S\5      r" " S S5      r#g)    )annotations)AnyTYPE_CHECKINGOptional)ProtocolN)MTextLineAlignment)const)DXFAttributeErrorDIMJUSTDIMTAD)Vec3UVecUCS)ARROWS)Drawing)DimStyle	Dimension)BaseDimensionRenderer)xrefezdxfc                      \ rS rSrSS jrSrg)SupportsOverride   c                    g N selfs    Q/var/www/html/env/lib/python3.13/site-packages/ezdxf/entities/dimstyleoverride.pyoverrideSupportsOverride.override   s        r   N)returnDimStyleOverride)__name__
__module____qualname____firstlineno__r    __static_attributes__r   r"   r   r   r      s    r"   r   c                     \ rS rSrS#S$S jjr\S%S j5       r\S&S j5       rS'S jrS#S(S jjr	S#S(S j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/S jr     S0           S1S jjrS2S jrS&S jrS3S4S jjr   S5       S6S jjr      S7               S8S jjr    S9             S:S jjr       S;               S<S jjr      S7           S=S jjr     S0         S>S jjrS?S@S jjrS?S@S jjrSASBS jjrSCS jrSDSES jjr SES jr!S#SFS  jjr"S?SGS! jjr#S"r$g)Hr$      Nc                    Xl         UR                  SS5      nU R                  R                  R	                  U5      U l        U R                  5       U l        U R                  U=(       d    0 5        g )NdimstyleSTANDARD)		dimensionget_dxf_attribdoc	dimstylesgetr-   get_dstyle_dictdimstyle_attribsupdate)r   r/   r    dim_style_names       r   __init__DimStyleOverride.__init__   sX    "'66z:N"&(("4"4"8"8"H&*&:&:&< 	HN#r"   c                .    U R                   R                  $ )zDrawing object (internal API))r/   r1   r   s    r   r1   DimStyleOverride.doc/   s     ~~!!!r"   c                .    U R                   R                  $ )zDXF version (internal API))r1   
dxfversionr   s    r   r=   DimStyleOverride.dxfversion4   s     xx"""r"   c                L    U R                   R                  U R                  5      $ )zGet XDATA section ACAD:DSTYLE, to override DIMSTYLE attributes for
this DIMENSION entity.

Returns a ``dict`` with DIMSTYLE attribute names as keys.

(internal API)
)r/   get_acad_dstyler-   r   s    r   r4    DimStyleOverride.get_dstyle_dict9   s     ~~--dmm<<r"   c                    XR                   ;   a  U R                   U   nU$  U R                  R                  X5      nU$ ! [         a    Un U$ f = f)a  Returns DIMSTYLE `attribute` from override dict
:attr:`dimstyle_attribs` or base :class:`DimStyle`.

Returns `default` value for attributes not supported by DXF R12. This
is a hack to use the same algorithm to render DXF R2000 and DXF R12
DIMENSION entities. But the DXF R2000 attributes are not stored in the
DXF R12 file! This method does not catch invalid attribute names!
Check debug log for ignored DIMSTYLE attributes.

)r5   r-   r0   r
   )r   	attributedefaultresults       r   r3   DimStyleOverride.getC   sb     ---**95F 	!55iI  % ! !s   ? AAc                ,    U R                  X5      nX	 U$ )zzReturns DIMSTYLE `attribute` from override dict :attr:`dimstyle_attribs` and
removes this `attribute` from override dict.
r3   )r   rC   rD   values       r   popDimStyleOverride.popW   s     ,Or"   c                :    U R                   R                  U5        g)zdUpdate override dict :attr:`dimstyle_attribs`.

Args:
    attribs: ``dict`` of DIMSTYLE attributes

N)r5   r6   )r   attribss     r   r6   DimStyleOverride.update`   s     	$$W-r"   c                $    U R                  U5      $ )z7Returns DIMSTYLE attribute `key`, see also :meth:`get`.rH   r   keys     r   __getitem__DimStyleOverride.__getitem__i   s    xx}r"   c                     X R                   U'   g)z9Set DIMSTYLE attribute `key` in :attr:`dimstyle_attribs`.Nr5   )r   rQ   rI   s      r   __setitem__DimStyleOverride.__setitem__m   s    %*c"r"   c                @     U R                   U	 g! [         a     gf = f)zeDeletes DIMSTYLE attribute `key` from :attr:`dimstyle_attribs`,
ignores :class:`KeyErrors` silently.
N)r5   KeyErrorrP   s     r   __delitem__DimStyleOverride.__delitem__q   s'    	%%c* 		s    
c                    U R                   R                  [        R                  :X  d   eS HC  nU R	                  US5      nU(       d  M  UR                  [        R                  " U5      5        ME     g N)dimblkdimblk1dimblk2	dimldrblk )r1   r=   r	   DXF12r3   add_block_namer   
block_name)r   registryattrib_name
arrow_names       r   register_resources_r12'DimStyleOverride.register_resources_r12z   s[     xx""ekk111HK+r2Jz ''(9(9*(EF Ir"   c                Z   U R                   R                  [        R                  :X  d   eUR	                  5       nS H[  nU R                  US5      nU(       d  M  UR                  [        R                  " U5      5      n[        R                  " U5      X4'   M]     UR                  5         g r]   )r1   r=   r	   rc   r    r3   get_block_namer   re   rh   commit)r   copymappingcopy_overriderg   rh   re   s          r   map_resources_r12"DimStyleOverride.map_resources_r12   s    
 xx""ekk111HK+r2Jz$33F4E4Ej4QR
-3->->z-J*	 I
 	r"   c                N    U R                   R                  U R                  5        g)zbWrites overridden DIMSTYLE attributes into ACAD:DSTYLE section of
XDATA of the DIMENSION entity.

N)r/   set_acad_dstyler5   r   s    r   rm   DimStyleOverride.commit   s    
 	&&t'<'<=r"   c                b  ^  SU 4S jjnUb  [        U5      T R                  S'   Ub'  U" SU5        ST R                  S'   ST R                  S'   Ub'  U" S	U5        S
T R                  S'   ST R                  S'   Ub'  U" SU5        S
T R                  S'   ST R                  S'   Ub
  U" SU5        gg)a  Set arrows or user defined blocks and disable oblique stroke as tick.

Args:
    blk: defines both arrows at once as name str or user defined block
    blk1: defines left arrow as name str or as user defined block
    blk2: defines right arrow as name str or as user defined block
    ldrblk: defines leader arrow as name str or as user defined block
    size: arrow size in drawing units

c                $   > UTR                   U '   g r   rU   )dimvarnamer   s     r   	set_arrow.DimStyleOverride.set_arrows.<locals>.set_arrow   s    ,0D!!&)r"   Ndimaszr^   r   dimsah        dimtszr_      r`   ra   )rx   strry   r   r#   Nonefloatr5   )r   blkblk1blk2ldrblksizerz   s   `      r   
set_arrowsDimStyleOverride.set_arrows   s    &	1 .3DkD!!(+?h$./D!!(+.1D!!(+i&./D!!(+.1D!!(+i&./D!!(+.1D!!(+k6* r"   c                    U R                  SS5      nSu  p#US:X  a\  [        U R                  S5      5      (       a'  U R                  SS5      nU R                  SS5      nX#4$ U R                  S	S5      nUnUnX#4$ )
zGGet arrow names as strings like 'ARCHTICK' as tuple (dimblk1, dimblk2).r   r   )rb   rb   r~   r}   r_   rb   r`   r^   )r3   bool)r   r   r   r   r   s        r   get_arrow_names DimStyleOverride.get_arrow_names   s    (A&
S=DHHX&''xx	2.xx	2.
 z hhx,zr"   c                L    U R                  SS5      nUS:X  a  S$ [        U5      $ )Ndimdsepr   ,)r3   chr)r   r   s     r   get_decimal_separator&DimStyleOverride.get_decimal_separator   s'    xx	1-ls4G4r"   c                4    [        U5      U R                  S'   g)zZUse oblique stroke as tick, disables arrows.

Args:
    size: arrow size in daring units

r   Nr   )r   r   s     r   set_tickDimStyleOverride.set_tick   s     +0+h'r"   c                    U(       a$  [         UR                  5          U R                  S'   U(       aJ  UR                  5       n[        U   U R                  S'   US:X  a  Ub  [	        U5      U R                  S'   gggg)a  Set measurement text alignment, `halign` defines the horizontal
alignment, `valign` defines the vertical alignment, `above1` and
`above2` means above extension line 1 or 2 and aligned with extension
line.

Args:
    halign: `left`, `right`, `center`, `above1`, `above2`,
        requires DXF R2000+
    valign: `above`, `center`, `below`
    vshift: vertical text shift, if `valign` is `center`;
        >0 shift upward, <0 shift downwards

dimjustdimtadcenterNdimtvp)r   lowerr5   r   r   )r   halignvalignvshifts       r   set_text_alignDimStyleOverride.set_text_align   sr    & /6v||~/FD!!),\\^F.4VnD!!(+!f&827-%%h/ '9! r"   c                   SU R                   S'   SU R                   S'   [        U5      U R                   S'   Ub  [        U5      U R                   S'   O[        U5      U R                   S'   Ub  [        U5      U R                   S'   Ub  [        U5      U R                   S	'   Ub  XPR                   S
'   Uc  Ub>  SnUSL a  [        R                  nUSL a  U[        R
                  -  nXR                   S'   gg)ai  Set tolerance text format, upper and lower value, text height
factor, number of decimal places or leading and trailing zero
suppression.

Args:
    upper: upper tolerance value
    lower: lower tolerance value, if None same as upper
    hfactor: tolerance text height factor in relation to the dimension
        text height
    align: tolerance text alignment enum :class:`ezdxf.enums.MTextLineAlignment`
    dec: Sets the number of decimal places displayed
    leading_zeros: suppress leading zeros for decimal dimensions if ``False``
    trailing_zeros: suppress trailing zeros for decimal dimensions if ``False``

r   dimtolr   dimlimdimtpNdimtmdimtfacdimtoljdimtdecFdimtzin)r5   r   intr	   DIMZIN_SUPPRESSES_LEADING_ZEROS DIMZIN_SUPPRESSES_TRAILING_ZEROS)	r   upperr   hfactoraligndecleading_zerostrailing_zerosr   s	            r   set_toleranceDimStyleOverride.set_tolerance  s    2 +,h'*+h').ug&-25\D!!'*-25\D!!'*/4W~D!!),/25zD!!),?/2!!), $(BG%??&5AAA/6!!), )Cr"   c                   SU R                   S'   SU R                   S'   [        U5      U R                   S'   [        U5      U R                   S'   Ub  [        U5      U R                   S'   Uc  Ub=  SnUS	L a  [        R                  nUS	L a  U[        R                  -  nXpR                   S
'   Ub  [        U5      U R                   S'   gg)a  Set limits text format, upper and lower limit values, text
height factor, number of decimal places or leading and trailing zero
suppression.

Args:
    upper: upper limit value added to measurement value
    lower: lower limit value subtracted from measurement value
    hfactor: limit text height factor in relation to the dimension
        text height
    dec: Sets the number of decimal places displayed,
        requires DXF R2000+
    leading_zeros: suppress leading zeros for decimal dimensions if
        ``False``, requires DXF R2000+
    trailing_zeros: suppress trailing zeros for decimal dimensions if
        ``False``, requires DXF R2000+

r   r   r   r   r   r   Nr   Fr   r   )r5   r   r	   r   r   r   )r   r   r   r   r   r   r   r   s           r   
set_limitsDimStyleOverride.set_limits7  s    6 +,h'*+h').ug&).ug&/4W~D!!), $(BG%??&5AAA/6!!),?/23xD!!), r"   c                L   U(       d  U(       a  US-   U-   U R                   S'   Ub  X0R                   S'   Ub  X@R                   S'   Ub  [        U5      U R                   S'   Uc  Ub>  SnUSL a  [        R                  nUSL a  U[        R                  -  nXR                   S	'   gg)
a  Set dimension text format, like prefix and postfix string, rounding
rule and number of decimal places.

Args:
    prefix: dimension text prefix text as string
    postfix: dimension text postfix text as string
    rnd: Rounds all dimensioning distances to the specified value, for
        instance, if DIMRND is set to 0.25, all distances round to the
        nearest 0.25 unit. If you set DIMRND to 1.0, all distances round
        to the nearest integer.
    dec: Sets the number of decimal places displayed for the primary
        units of a dimension. requires DXF R2000+
    sep: "." or "," as decimal separator
    leading_zeros: suppress leading zeros for decimal dimensions if ``False``
    trailing_zeros: suppress trailing zeros for decimal dimensions if ``False``

<>dimpostNdimrnddimdecr   r   Fdimzin)r5   ordr	   r   r   )	r   prefixpostfixrndr   sepr   r   r   s	            r   set_text_format DimStyleOverride.set_text_formatf  s    6 W/5}w/FD!!),?.1!!(+?.1!!(+?/23xD!!), $(BF%>>&%@@@.4!!(+ )Cr"   c                    Ub  XR                   S'   Ub  X R                   S'   Ub  X0R                   S'   Ub  X@R                   S'   Ub  XPR                   S'   Ub  X`R                   S'   gg)a6  Set dimension line properties.

Args:
    color: color index
    linetype: linetype as string
    lineweight: line weight as int, 13 = 0.13mm, 200 = 2.00mm
    extension: extension length
    disable1: True to suppress first part of dimension line
    disable2: True to suppress second part of dimension line

Ndimclrddimltypedimlwddimdledimsd1dimsd2rU   )r   colorlinetype
lineweight	extensiondisable1disable2s          r   set_dimline_format#DimStyleOverride.set_dimline_format  s    ( /4!!),08!!*-!.8!!(+ .7!!(+.6!!(+.6!!(+  r"   c                    Ub  XR                   S'   Ub  X R                   S'   Ub  X0R                   S'   Ub  X@R                   S'   Ub  SU R                   S'   XPR                   S'   gg)	a<  Set common extension line attributes.

Args:
    color: color index
    lineweight: line weight as int, 13 = 0.13mm, 200 = 2.00mm
    extension: extension length above dimension line
    offset: offset from measurement point
    fixed_length: set fixed length extension line, length below the
        dimension line
Ndimclredimlwedimexedimexor   dimfxlondimfxlrU   )r   r   r   r   offsetfixed_lengths         r   set_extline_format#DimStyleOverride.set_extline_format  s}    $ /4!!),!.8!!(+ .7!!(+.4!!(+#01D!!*-.:!!(+ $r"   c                T    Ub  XR                   S'   U(       a  SU R                   S'   gg)zSet attributes of the first extension line.

Args:
    linetype: linetype for the first extension line
    disable: disable first extension line if ``True``

Ndimltex1r   dimse1rU   r   r   disables      r   set_extline1DimStyleOverride.set_extline1  0     08!!*-./D!!(+ r"   c                T    Ub  XR                   S'   U(       a  SU R                   S'   gg)zSet attributes of the second extension line.

Args:
    linetype: linetype for the second extension line
    disable: disable the second extension line if ``True``

Ndimltex2r   dimse2rU   r   s      r   set_extline2DimStyleOverride.set_extline2  r   r"   c                8    XR                   R                  l        g)zSet dimension text.

- `text` = " " to suppress dimension text
- `text` = "" or "<>" to use measured distance as dimension text
- otherwise display `text` literally

N)r/   dxftext)r   r   s     r   set_textDimStyleOverride.set_text  s     #'r"   c                <    XR                   S'   X R                   S'   g)zSet relative text movement, implemented as user location override
without leader.

Args:
    dh: shift text in text direction
    dv: shift text perpendicular to text direction

text_shift_htext_shift_vNrU   )r   dhdvs      r   
shift_textDimStyleOverride.shift_text  s      13n-02n-r"   c                    U R                  U5        U R                  R                  S:  nU R                  R                  S;   nU(       d  U(       a'  U(       a  SOSU R                  S'   X0R                  S'   gg)a*  Set text location by user, special version for linear dimensions,
behaves for other dimension types like :meth:`user_location_override`.

Args:
    location: user defined text location
    leader: create leader from text to dimension line
    relative: `location` is relative to default location.

   )r         r   dimtmoverelative_user_locationN)user_location_overrider/   dimtyper5   )r   locationleaderrelativelinearcurveds         r   set_locationDimStyleOverride.set_location  sg     	##H-''!+''94V5;D!!*->F!!":; r"   c                    U R                   R                  U R                   R                  SSS9  [        U5      U R                  S'   g)zSet text location by user, `location` is relative to the origin of
the UCS defined in the :meth:`render` method or WCS if the `ucs`
argument is ``None``.

Tr  )statery   user_locationN)r/   set_flag_stateUSER_LOCATION_OVERRIDEr   r5   )r   r  s     r   r  'DimStyleOverride.user_location_override  sB     	%%NN11I 	& 	
 26ho.r"   c                L    U R                   R                  R                  X5      $ )z1Get designated DIMENSION renderer. (internal API))r1   dimension_rendererdispatch)r   ucss     r   get_rendererDimStyleOverride.get_renderer  s    xx**33D>>r"   c                   U R                  U5      nU(       a  U R                  R                  S5        OYU R                  R                  R	                  SS9nUR
                  U R                  R                  l        UR                  U5        UR                  5         [        U R                  5      (       a  U R                  5         U$ )a  Starts the dimension line rendering process and also writes overridden
dimension style attributes into the DSTYLE XDATA section. The rendering process
"draws" the graphical representation of the DIMENSION entity as DXF primitives
(TEXT, LINE, ARC, ...) into an anonymous content BLOCK.

You can discard the content BLOCK for a friendly CAD applications like BricsCAD,
because the rendering of the dimension entity is done automatically by BricsCAD
if the content BLOCK is missing, and the result is in most cases better than the
rendering done by `ezdxf`.

AutoCAD does not render DIMENSION entities automatically, therefore I see
AutoCAD as an unfriendly CAD application.

Args:
    ucs: user coordinate system
    discard: discard the content BLOCK created by `ezdxf`, this works for
        BricsCAD, AutoCAD refuses to open DXF files containing DIMENSION
        entities without a content BLOCK

Returns:
    The rendering object of the DIMENSION entity for analytics

z6DIMENSION entity without geometry BLOCK (discard=True)D)	type_char)r  r1    add_acad_incompatibility_messageblocksnew_anonymous_blockry   r/   r   geometryrenderfinalizelenr5   rm   )r   r  discardrendererblocks        r   r  DimStyleOverride.render"  s    2 $$S)HH55H HHOO77#7FE*/**DNN'OOE"t$$%%KKMr"   )r/   r-   r5   r   )r/   r   r    zOptional[dict])r#   r   )r#   r   )r#   dict)rC   r   rD   r   r#   r   )rM   r$  r#   r   )rQ   r   r#   r   )rQ   r   rI   r   r#   r   )rQ   r   r#   r   )rf   zxref.Registryr#   r   )rn   r   ro   zxref.ResourceMapperr#   r   )r#   r   )NNNNN)r   Optional[str]r   r%  r   r%  r   r%  r   Optional[float]r#   r   )r#   ztuple[str, str])r   )r   r   r#   r   )NNN)r   r%  r   r%  r   r&  r#   r   )NNNNNN)r   r   r   r&  r   r&  r   zOptional[MTextLineAlignment]r   Optional[int]r   Optional[bool]r   r(  r#   r   )NNNN)r   r   r   r   r   r&  r   r'  r   r(  r   r(  r#   r   )rb   rb   NNNNN)r   r   r   r   r   r&  r   r'  r   r%  r   r(  r   r(  r#   r   )r   r'  r   r%  r   r'  r   r&  r   r(  r   r(  )
r   r'  r   r'  r   r&  r   r&  r   r&  )NF)r   r%  )r   )r   r   r#   r   )r   r   r   r   r#   r   )FF)r  r   r#   r   )r  Optional[UCS])r  r)  r#   r   )%r%   r&   r'   r(   r8   propertyr1   r=   r4   r3   rJ   r6   rR   rV   rZ   ri   rq   rm   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r)   r   r"   r   r$   r$      s	   $$ " " # #=(.+
G$/B	4> """ $ $%+%+ %+ 	%+
 %+ %+ 
%+N56 !% $"&	@@ @  	@
 
@> "&#'.2!(,)-/7/7 /7 !	/7
 ,/7 /7 &/7 '/7 
/7j $(!(,)--8-8 -8 !	-8
 -8 &-8 '-8 
-8b #!!(,)-+5+5 +5 	+5
 +5 +5 &+5 '+5 
+5^  $"&$(%)#'#'77  7 "	7
 #7 !7 !7F  $$(%)"&(,;; "; #	;
  ; &;<00'
3G"	@?% %r"   r$   )$
__future__r   typingr   r   r   typing_extensionsr   loggingezdxf.enumsr   ezdxf.lldxfr	   ezdxf.lldxf.constr
   r   r   
ezdxf.mathr   r   r   ezdxf.render.arrowsr   ezdxf.documentr   ezdxf.entitiesr   r   ezdxf.render.dim_baser   r   r   	getLoggerloggerr   r$   r   r"   r   <module>r9     sb    # / / &  *  @ @ & & &&2;			7	#x 
k kr"   