
    hJj                       S SK Jr  S SKJrJr  S SKJr  S SKrS SKJ	r	J
r
  S SKJ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  S S	KJr  S S
KJrJr  S SKJrJ r J!r!  S SK"J#r#  S SK$J%r%J&r&J'r'  SSK(J)r)J*r*  SSK+J,r,  SSK-J.r.J/r/  SSK0J1r1J2r2J3r3  SSK4J5r5J6r6J7r7J8r8  SSK9J:r:  SSKJ;r;  \(       a  S SK<J=r=  S SK>J?r?  S SK@JArA  / SQrB\" SS\R                  \R                  S9\" SS S9\" SS S S!9\" S"S S \R                  " S S#5      \S$9\" S%S \R                  S \R                  \S&9\" S'\R                  \R                  S \R                  " 1 S(k5      \S&9S).rK\L" \K5      rM\" S*S\R                  \R                  S9\MS+'   \" S,\M5      rP\" \P5      rQ\" S-\K5      rR\" \R5      rS\" S.S/\" S%SS94S0\" SS S94S1\" SS \R                  \S94S2\" SS S94S3\" S4S5S94S6\" S7\R                  \S894S9\" S:S S94S;\" SS\R                  \R                  S94/5      rU " S< S=\15      rVSJS> jrWSJS? jrX\: " S@ SA\V5      5       rY\: " SB SC\V5      5       rZ1 SDkr[SKSE jr\ " SF SG\*5      r] " SH SI5      r^g)L    )annotations)TYPE_CHECKINGOptional)SelfN)Auditor
AuditError)	validator)NULLVECVec3Z_AXISOCSMatrix44)DXFAttrDXFAttributesDefSubclassXTypeRETURN_DEFAULTgroup_code_mapping)const)EMBEDDED_OBJ_MARKEREMBEDDED_OBJ_STR)MAP_MTEXT_ALIGN_TO_FLAGS
TextHAlign
TextVAlign)set_flag_state)load_mtext_contentfast_plain_mtextplain_mtext   )SubclassProcessorDXFNamespace)
base_class)acdb_entityelevation_to_z_axis)Text	acdb_textacdb_text_group_codes)acdb_mtext_group_codesMTextexport_mtext_content
acdb_mtext)register_entity)default_copy)AbstractTagWriter)Tags)xref)AttDefAttribcopy_attrib_as_text
BaseAttrib    )defaultr	   fixerF   )r7   I   T)r7   optionalJ      )r7   r;   r	   r8   i  )r7   
dxfversionr;   r	   r8   G   >   r   r5   r=   )tagflagsfield_lengthvalignlock_positionattribute_type   promptAcDbAttributeDefinitionAcDbAttributeAcDbXrecordcloning
mtext_flagreally_lockedsecondary_attribs_countsecondary_attribs_handleiT  0align_point
   )xtyper7   current_annotation_scale(   r@   c                    ^  \ rS rSr\rSU 4S jjr\4SS jjrSS jr	SS jr
\SS j5       r\R                  SS j5       r\SS j5       r\R                  SS	 j5       r\SS
 j5       r\R                  SS j5       r\SS j5       r\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"S jjrSS jrS#U 4S jjrS$U 4S jjrS%U 4S jjrS&U 4S jjrSrU =r$ )'r4      c                >   > [         TU ]  5         S U l        S U l        g N)super__init___xrecord_embedded_mtext)self	__class__s    G/var/www/html/env/lib/python3.13/site-packages/ezdxf/entities/attrib.pyr[   BaseAttrib.__init__   s    (,8<    c                    [        U[        5      (       d   e[        R                  " U R                  5      Ul        [        R                  " U R
                  5      Ul        g)zYCopy entity data, xrecord data and embedded MTEXT are not stored
in the entity database.
N)
isinstancer4   copydeepcopyr\   r]   )r^   entitycopy_strategys      r`   	copy_dataBaseAttrib.copy_data   sB     &*------6!%t/C/C!Drb   c                    UR                   (       d  g UR                   S   nU(       a"  [        5       nUR                  U5        X0l        g g )Nr   )embedded_objectsEmbeddedMTextload_dxf_tagsr]   )r^   	processorembedded_objectmtexts       r`   load_embedded_mtextBaseAttrib.load_embedded_mtext   sA    ))#44Q7!OE	*#(  rb   c                   UR                  SU R                  R                  5        UR                  SS5        U R                  R                  S5      (       a&  UR	                  SU R                  R
                  5        U R                  (       a  UR                  U R                  5        U R                  (       a  U R                  R                  U5        g g )Nr?   H   r   rQ      )

write_tag2dxfrE   hasattrwrite_vertexrQ   r\   
write_tagsr]   export_dxf_tagsr^   	tagwriters     r`   export_dxf_r2018_features$BaseAttrib.export_dxf_r2018_features   s    R!8!89R#88M**""2txx';';<==  /  00;  rb   c                b    [        U R                  R                  [        R                  -  5      $ )z)This is a constant attribute if ``True``.)boolrx   rA   r   ATTRIB_CONSTr^   s    r`   is_constBaseAttrib.is_const   s"     DHHNNU%7%7788rb   c                    [        U R                  R                  [        R                  U5      U R                  l        g rY   )r   rx   rA   r   r   r^   states     r`   r   r     s$    '8J8JERrb   c                b    [        U R                  R                  [        R                  -  5      $ )z#Attribute is invisible if ``True``.)r   rx   rA   r   ATTRIB_INVISIBLEr   s    r`   is_invisibleBaseAttrib.is_invisible  "     DHHNNU%;%;;<<rb   c                    [        U R                  R                  [        R                  U5      U R                  l        g rY   )r   rx   rA   r   r   r   s     r`   r   r   
  %    '8N8NPUVrb   c                b    [        U R                  R                  [        R                  -  5      $ )z[Verification is required on input of this attribute. (interactive CAD
application feature)
)r   rx   rA   r   ATTRIB_VERIFYr   s    r`   	is_verifyBaseAttrib.is_verify  s"    
 DHHNNU%8%8899rb   c                    [        U R                  R                  [        R                  U5      U R                  l        g rY   )r   rx   rA   r   r   r   s     r`   r   r     s$    '8K8KUSrb   c                b    [        U R                  R                  [        R                  -  5      $ )zANo prompt during insertion. (interactive CAD application feature))r   rx   rA   r   ATTRIB_IS_PRESETr   s    r`   	is_presetBaseAttrib.is_preset  r   rb   c                    [        U R                  R                  [        R                  U5      U R                  l        g rY   )r   rx   rA   r   r   r   s     r`   r   r     r   rb   c                ,    [        U R                  5      $ )zTReturns ``True`` if the entity has an embedded MTEXT entity for multi-line
support.
)r   r]   r   s    r`   has_embedded_mtext_entity$BaseAttrib.has_embedded_mtext_entity"  s    
 D(())rb   c                    U R                   (       d  [        S5      eU R                   R                  5       nUR                  U R	                  5       5        U$ )zReturns the embedded MTEXT entity as a regular but virtual
:class:`MText` entity with the same graphical properties as the
host entity.
zno embedded MTEXT entity exist)r]   	TypeErrorvirtual_mtext_entityupdate_dxf_attribsgraphic_propertiesr^   rq   s     r`   r   BaseAttrib.virtual_mtext_entity)  sI    
 ##<==$$99;  !8!8!:;rb   c                    U R                   (       a1  U R                   R                  nU(       a
  [        USS9$ [        USS9$ g)aS  Returns the embedded MTEXT content without formatting codes.
Returns an empty string if no embedded MTEXT entity exist.

The `fast` mode is accurate if the DXF content was created by
reliable (and newer) CAD applications like AutoCAD or BricsCAD.
The `accurate` mode is for some rare cases where the content was
created by older CAD applications or unreliable DXF libraries and CAD
applications.

The `accurate` mode is **much** slower than the `fast` mode.

Args:
    fast: uses the `fast` mode to extract the plain MTEXT content if
        ``True`` or the `accurate` mode if set to ``False``

F)splitr6   )r]   textr   r   )r^   fastr   s      r`   r   BaseAttrib.plain_mtext4  s>    " '',,D'E::"4u55rb   c                   U R                   c  [        5       U l         U R                   R                  U5        [        X5        [	        X5        [        U [        5      (       a  [        R                  nO[        R                  nX0R                  l        UR                  R                  U R                  l        UR                  R                  U R                  l        U R                  R                  S5        U R                  R                  S5        U R                  R                  S5        U(       a   U R!                  UR#                  5       5        gg)aT  Set multi-line properties from a :class:`MText` entity.

The multi-line ATTRIB/ATTDEF entity requires DXF R2018, otherwise an
ordinary single line ATTRIB/ATTDEF entity will be exported.

Args:
    mtext: source :class:`MText` entity
    graphic_properties: copy graphic properties (color, layer, ...) from
        source MTEXT if ``True``

Nwidthobliquetext_generation_flag)r]   rm   	set_mtext_update_content_from_mtext_update_location_from_mtextrd   r2   r   ATTRIB_TYPE_MULTI_LINEATTDEF_TYPE_MULTI_LINErx   rE   stylechar_heightheightdiscardr   r   )r^   rq   r   rE   s       r`   r   BaseAttrib.set_mtextM  s     '#0?D &&u-"4/#D0 dF##"99N"99N"0 ))//!#/0##E$<$<$>? rb   c                F    U R                  X5        UR                  5         g)a|  Set multi-line properties from a :class:`MText` entity and destroy the
source entity afterward.

The multi-line ATTRIB/ATTDEF entity requires DXF R2018, otherwise an
ordinary single line ATTRIB/ATTDEF entity will be exported.

Args:
    mtext: source :class:`MText` entity
    graphic_properties: copy graphic properties (color, layer, ...) from
        source MTEXT if ``True``

N)r   destroy)r^   rq   r   s      r`   embed_mtextBaseAttrib.embed_mtexto  s     	u1rb   c                P    SU l         [        R                  U R                  l        g)zDiscard multi-line feature.

The embedded MTEXT will be removed and the ATTRIB/ATTDEF will be converted to a
single-line attribute.
N)r]   r   ATTRIB_TYPE_SINGLE_LINErx   rE   r   s    r`   discard_mtextBaseAttrib.discard_mtext  s      $"'"?"?rb   c                ~   > [         TU ]  U5        U R                  (       a  U R                  R                  U5        gg)5Register required resources to the resource registry.N)rZ   register_resourcesr]   )r^   registryr_   s     r`   r   BaseAttrib.register_resources  s2    "8,  33H=  rb   c                   > [        U[        5      (       d   e[        TU ]  X5        U R                  (       a9  UR                  (       a'  U R                  R                  UR                  U5        ggg)3Translate resources from self to the copied entity.N)rd   r4   rZ   map_resourcesr]   )r^   clonemappingr_   s      r`   r   BaseAttrib.map_resources  sX    %,,,,e-E$9$9  ..u/D/DgN %:rb   c                   > U R                   c  [        TU ]	  U5        U $ U R                   R                  5       nUR                  U5        U R	                  USS9  U R                  U5        U $ )NF)r   )r]   rZ   	transformr   r   post_transform)r^   mrq   r_   s      r`   r   BaseAttrib.transform  sh    'Ga  	 ((==?EOOANN5UN;"rb   c                   > [         TU ]  U5        U R                  R                  S5      (       d=  UR	                  [
        R                  S[        U 5       S3S9  UR                  U 5        gg)zValidity check.r@   z*Missing mandatory "tag" attribute, entity z	 deleted.)codemessageN)	rZ   auditrx   ry   fixed_errorr   TAG_ATTRIBUTE_MISSINGstrtrash)r^   auditorr_   s     r`   r   BaseAttrib.audit  sc    gxx&&55DSYKyY    MM$ 'rb   )r]   r\   returnNone)rg   r   r   r   ro   r    r   r   r~   r.   r   r   )r   r   )r   r   r   r   r   r)   )Tr   r   rq   r)   r   r   r   zxref.Registryr   r   )r   r   r   xref.ResourceMapperr   r   )r   r   r   r   )r   r   r   r   )__name__
__module____qualname____firstlineno__acdb_attdef_xrecordXRECORD_DEFr[   r-   ri   rr   r   propertyr   setterr   r   r   r   r   r   r   r   r   r   r   r   r   __static_attributes____classcell__r_   s   @r`   r4   r4      s+   %K= 5A E)
< 9 9 __S S = = W W : : T T = = W W * *	2 @D @>O   rb   r4   c                \    UR                  SSS9nU(       a  US   U R                  l        g g )NT)r   r   r   )
plain_textrx   r   )r   rq   contents      r`   r   r     s0    T5G  
	 rb   c                v   U R                   n[        UR                   R                  5      n[        UR                   R                  5      nUR	                  5       nUR                  [        5      (       a  UR                  Ul        OQ[        U5      nUR                  U5      nUR                  5       Ul        UR                  U5      R                  Ul        X2l        X2l        [        R                  " UR                   R                  [         R"                  [$        R&                  45      u  Ul        Ul        g rY   )rx   r   insert	extrusionget_text_directioniscloser   	angle_degrotationr   from_wcs	normalizerQ   r   getattachment_pointr   LEFTr   TOPhalignrC   )r   rq   rx   r   r   text_directionocss          r`   r   r     s    
((C%))""#FUYY(()I--/N  %//)nf%!++-||N3==JO599		""Z__jnn$ECJ
rb   c                  j   ^  \ rS rSrSrSr\" \\\	\
5      r S   S	U 4S jjjrS
S jrS
S jrSrU =r$ )r1   i  zDXF ATTDEF entityATTDEFc                D  > [         [        U ]  U5      nU(       a  UR                  U[        SSS9  UR                  U[
        SSS9  UR                  U R                  R                  5      U l	        U R                  U5        UR                  (       a  [        US5        U$ Nr5   T)recoverrF   )r   rQ   )rZ   r%   load_dxf_attribsfast_load_dxfattribsr'   acdb_attdef_group_codesfind_subclassr   namer\   rr   r12r$   r^   ro   rx   r_   s      r`   r  AttDef.load_dxf_attribs  s     D$0;**30EqRV*W**,a +  &33D4D4D4I4IJDM$$Y/}}#C)BC
rb   c                    U R                  U5        U R                  U5        U R                  U5        UR                  [        R
                  :  a  U R                  U5        g g rY   )export_acdb_entityexport_acdb_textexport_acdb_attdefr>   r   DXF2018r   r}   s     r`   export_entityAttDef.export_entity  sQ    	*i(	*5==0**95 1rb   c                    UR                   [        R                  :  a.  UR                  [        R                  [
        R                  5        U R                  R                  U/ SQ5        g )N)rG   r@   rA   rB   rC   rD   )	r>   r   DXF12rw   SUBCLASS_MARKERacdb_attdefr  rx   export_dxf_attribsr}   s     r`   r  AttDef.export_acdb_attdef  sJ    %++-  !6!68H8HI##	
rb   r\   rY   ro   zOptional[SubclassProcessor]r   r!   r   )r   r   r   r   __doc__DXFTYPEr   r"   r#   r&   r  
DXFATTRIBSr  r  r  r   r   r   s   @r`   r1   r1     sI    Gz;	;OJ 8<4	 $6
 
rb   r1   c                  t   ^  \ rS rSrSrSr\" \\\	\
5      r S	   S
U 4S jjjrSS jrSS jrSS jrSrU =r$ )r2   i  zDXF ATTRIB entityATTRIBc                D  > [         [        U ]  U5      nU(       a  UR                  U[        SSS9  UR                  U[
        SSS9  UR                  U R                  R                  5      U l	        U R                  U5        UR                  (       a  [        US5        U$ r  )rZ   r%   r  r  r'   acdb_attrib_group_codesr
  r   r  r\   rr   r  r$   r  s      r`   r  Attrib.load_dxf_attribs  s     D$0;**30EqRV*W**,a +  &33D4D4D4I4IJDM$$Y/}}#C)BC
rb   c                    U R                  U5        U R                  U5        U R                  U5        UR                  [        R
                  :  a  U R                  U5        g g rY   )r  export_acdb_attrib_textexport_acdb_attribr>   r   r  r   r}   s     r`   r  Attrib.export_entity  sQ    	*$$Y/	*5==0**95 1rb   c                    UR                   [        R                  :  a.  UR                  [        R                  [
        R                  5        U R                  R                  U/ SQ5        g )N)r   r   r   	thicknessr   r   r   r   r   rQ   r   r   )	r>   r   r  rw   r  r&   r  rx   r  r}   s     r`   r'  Attrib.export_acdb_attrib_text  sJ     %++-  !6!6	G##	
rb   c                    UR                   [        R                  :  a.  UR                  [        R                  [
        R                  5        U R                  R                  U/ SQ5        g )N)r@   rA   rB   rC   rD   )	r>   r   r  rw   r  acdb_attribr  rx   r  r}   s     r`   r(  Attrib.export_acdb_attrib4  sJ    %++-  !6!68H8HI##
	
rb   r  rY   r  r   )r   r   r   r   r  r  r   r"   r#   r&   r.  r   r  r  r'  r(  r   r   r   s   @r`   r2   r2     sN    Gz;	;OJ 8<4	 "6
.
 
rb   r2   >   r@   rA   ownerhandlerG   versionrB   rD   c                    U R                   (       a  U R                  5       $ U R                  [        S9n[        R
                  " XR                  S9$ )zXReturns the content of the ATTRIB/ATTDEF entity as a new virtual TEXT or
MTEXT entity.

)drop)
dxfattribsdoc)r   r   r5  IGNORE_FROM_ATTRIBr%   newr6  )attribr5  s     r`   r3   r3   P  sC    
 ''**,,""(:";J88zzz::rb   c                  L    \ rS rSr\" \5      r\SS j5       r\SS j5       r	Sr
g)EmbeddedMTextNSi[  c                    U R                   $ rY   )_DXFATTRIBSr   s    r`   r5  EmbeddedMTextNS.dxfattribs^  s    rb   c                    g)NzEmbedded MText r   s    r`   dxftypeEmbeddedMTextNS.dxftypeb  s    rb   r@  N)r   r   r   )r   r   r   r   r   r+   r=  r   r5  rA  r   r@  rb   r`   r;  r;  [  s2    
+K       rb   r;  c                  r    \ rS rSrSrSS jrSS jr\rSS jrSS jr	SS jr
S rSS	 jrSS
 jrSS jrSrg)rm   ig  a+  Representation of the embedded MTEXT object in ATTRIB and ATTDEF.

Introduced in DXF R2018? The DXF reference of the `MTEXT`_ entity
documents only the attached MTEXT entity. The ODA DWG specs includes all
MTEXT attributes of MTEXT starting at group code 10

Stores the required parameters to be shown as as MTEXT.
The AcDbText subclass contains  the first line of the embedded MTEXT as
plain text content as group code 1, but this tag seems not to be maintained
if the ATTRIB entity is copied.

Some DXF attributes are duplicated and maintained by the CAD application:

    - textstyle: same group code 7 (AcDbText, EmbeddedObject)
    - text (char) height: same group code 40 (AcDbText, EmbeddedObject)

.. _MTEXT: https://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-7DD8B495-C3F8-48CD-A766-14F9D7D0DD9B

c                0    [        5       U l        SU l        g )Nr6   )r;  rx   r   r   s    r`   r[   EmbeddedMText.__init__|  s     #$	rb   c                d    [        5       n[        R                  " U R                  5      Ul        U$ rY   )rm   re   rf   rx   )r^   copy_s     r`   re   EmbeddedMText.copy  s"    MM$((+	rb   c                ~    UR                  U R                  [        UR                  S   SS9n[	        U5      U l        g )Nr   F)r   subclassr  )r  rx   r(   rl   r   r   )r^   ro   tagss      r`   rn   EmbeddedMText.load_dxf_tags  s@    --HH5//2	 . 
 't,	rb   c                    [         R                  " U R                  R                  5       S9nU R                  Ul        U$ )zReturns the embedded MTEXT entity as regular but virtual MTEXT
entity. This entity does not have the graphical attributes of the host
entity (ATTRIB/ATTDEF).

)r5  )r)   r8  rx   all_existing_dxf_attribsr   r   s     r`   r   "EmbeddedMText.virtual_mtext_entity  s/     		TXX%F%F%HIYY
rb   c                    UR                   U l         U R                  nUR                  R                  5       R                  5        H.  u  p4UR	                  U5      (       d  M  UR                  X45        M0     g)z8Set embedded MTEXT attributes from given `mtext` entity.N)r   rx   rN  itemsis_supportedset)r^   rq   rx   kvs        r`   r   EmbeddedMText.set_mtext  sU    JJ	hhII668>>@DA"" Arb   c           	         U R                   nS[        4SSSSSSSS	4	 H.  u  p#UR                  U5      (       a  M  UR                  X#5        M0     g )
Nr   )r   g      @)r           )defined_heightrX  )r   r   )flow_direction   )r   Standard)line_spacing_styler   )line_spacing_factorg      ?)rx   r
   ry   rS  )r^   rx   keyr7   s       r`   set_required_dxf_attributes)EmbeddedMText.set_required_dxf_attributes  sV    hhw ##!!%(

LC ;;s##%

rb   c                    UR                  [        [        5        U R                  5         U R                  R                  U/ SQ5        [        U R                  U5        U R                  R                  U/ SQ5        g)z+Export embedded MTEXT as "Embedded Object".)r   r   r   rY  r   rZ  )r   r   r   
rect_widthrect_heightr   r]  r^  box_fill_scalebg_fillbg_fill_colorbg_fill_true_colorbg_fill_color_namebg_fill_transparencyN)rw   r   r   r`  rx   r  r*   r   r}   s     r`   r|   EmbeddedMText.export_dxf_tags  sd    02BC((*##
	
 	TYY	2##	
rb   c                    U R                   R                  S5      (       a&  UR                  U R                   R                  5        gg)r   r   N)rx   ry   add_text_styler   )r^   r   s     r`   r    EmbeddedMText.register_resources  s2    88G$$##DHHNN3 %rb   c                    UR                   R                  S5      (       a5  UR                  UR                   R                  5      UR                   l        gg)r   r   N)rx   ry   get_text_styler   )r^   r   r   s      r`   r   EmbeddedMText.map_resources  s:    99W%%%44UYY__EEIIO &rb   )rx   r   Nr   )r   rm   r   r   r   r   r   )r   rm   r   r   r   r   )r   r   r   r   r  r[   re   __copy__rn   r   r   r`  r|   r   r   r   r@  rb   r`   rm   rm   g  s=    (
 H-&""
H4
Frb   rm   )r   r%   rq   r)   r   r   )r9  r4   )_
__future__r   typingr   r   typing_extensionsr   re   ezdxf.auditr   r   ezdxf.lldxfr	   
ezdxf.mathr
   r   r   r   r   ezdxf.lldxf.attributesr   r   r   r   r   r   r   ezdxf.lldxf.typesr   r   ezdxf.enumsr   r   r   ezdxf.toolsr   ezdxf.tools.textr   r   r   dxfnsr    r!   	dxfentityr"   dxfgfxr#   r$   r   r%   r&   r'   rq   r(   r)   r*   r+   factoryr,   r-   ezdxf.lldxf.tagwriterr.   ezdxf.lldxf.tagsr/   ezdxfr0   __all__is_valid_attrib_tagfix_attrib_tagis_in_integer_rangeDXF2007is_integer_boolr   r  	is_one_ofattrib_fieldsdictattdef_fieldsis_valid_one_line_textfix_one_line_textr  r	  r.  r$  point3dr   r4   r   r   r1   r2   r7  r3   r;  rm   r@  rb   r`   <module>r     s   # * "  + ! ; ;   C H H &  3 ! 4 8 8  % 7% DL 	//&&	 R#BD9
//15 ==++ 
--==%%i0[5r ]#!..

%
%	h  3]C,[9 /=9,[9  " 
GC+, 
wr1-.
 #33$		
 
#GB$:;	#WS#%>?	%--IJ	#WR%;< #77..		
9%( zR  R j#* /
Z /
 /
d D
Z D
 D
N	 ;	 l 	 zF zFrb   