
    OgJj                       d dl mZ d dlmZmZ d dlmZ d dlZd dlm	Z	m
Z
 d dlmZ d dlmZmZmZmZmZ d dlmZmZmZmZmZmZ d d	lmZ d d
lmZmZ d dlmZm Z m!Z! d dl"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.m/Z/ ddl0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z: ddlm;Z; erd dl<m=Z= d dl>m?Z? d dl@mAZA g dZB eddej                  ej                         edd        edd d !       ed"d d  ej                  d d#      e$       ed%d ej                  d ej                  e&       ed'ej                  ej                  d  ej                  h d(      e&      d)ZK eLeK      ZM ed*dej                  ej                        eMd+<    ed,eM      ZP eeP      ZQ ed-eK      ZR eeR      ZS ed.d/ ed%d      fd0 edd       fd1 edd ej                  e      fd2 edd       fd3 ed4d5      fd6 ed7ej                  e8      fd9 ed:d       fd; eddej                  ej                        fg      ZU G d< d=e1      ZVdJd>ZWdJd?ZXe: G d@ dAeV             ZYe: G dB dCeV             ZZh dDZ[dKdEZ\ G dF dGe*      Z] G dH dI      Z^y)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                      e Zd ZeZd fdZefddZddZddZ	e
dd       Zej                  dd       Ze
dd       Zej                  dd       Ze
dd	       Zej                  dd
       Ze
dd       Zej                  dd       Ze
dd       ZddZdddZdd dZdd dZddZd! fdZd" fdZd# fdZd$ fdZ xZS )%r4   c                >    t         |           d | _        d | _        y N)super__init___xrecord_embedded_mtext)self	__class__s    Z/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/entities/attrib.pyrZ   zBaseAttrib.__init__   s    (,8<    c                    t        |t              sJ t        j                  | j                        |_        t        j                  | j
                        |_        y)ziCopy 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_datazBaseAttrib.copy_data   s?     &*-----6!%t/C/C!Dr`   c                    |j                   sy |j                   d   }|r#t               }|j                  |       || _        y y )Nr   )embedded_objectsEmbeddedMTextload_dxf_tagsr\   )r]   	processorembedded_objectmtexts       r_   load_embedded_mtextzBaseAttrib.load_embedded_mtext   sC    ))#44Q7!OE	*#(D  r`   c                   |j                  d| j                  j                         |j                  dd       | j                  j                  d      r&|j	                  d| j                  j
                         | j                  r|j                  | j                         | j                  r| j                  j                  |       y y )Nr?   H   r   rQ      )

write_tag2dxfrE   hasattrwrite_vertexrQ   r[   
write_tagsr\   export_dxf_tagsr]   	tagwriters     r_   export_dxf_r2018_featuresz$BaseAttrib.export_dxf_r2018_features   s    R!8!89R#88M*""2txx';';<==  /  00;  r`   c                b    t        | j                  j                  t        j                  z        S )z)This is a constant attribute if ``True``.)boolrt   rA   r   ATTRIB_CONSTr]   s    r_   is_constzBaseAttrib.is_const   s"     DHHNNU%7%7788r`   c                    t        | j                  j                  t        j                  |      | j                  _        y rX   )r   rt   rA   r   r~   r]   states     r_   r   zBaseAttrib.is_const  s$    '8J8JERr`   c                b    t        | j                  j                  t        j                  z        S )z#Attribute is invisible if ``True``.)r}   rt   rA   r   ATTRIB_INVISIBLEr   s    r_   is_invisiblezBaseAttrib.is_invisible  "     DHHNNU%;%;;<<r`   c                    t        | j                  j                  t        j                  |      | j                  _        y rX   )r   rt   rA   r   r   r   s     r_   r   zBaseAttrib.is_invisible
  %    '8N8NPUVr`   c                b    t        | j                  j                  t        j                  z        S )zkVerification is required on input of this attribute. (interactive CAD
        application feature)
        )r}   rt   rA   r   ATTRIB_VERIFYr   s    r_   	is_verifyzBaseAttrib.is_verify  s"    
 DHHNNU%8%8899r`   c                    t        | j                  j                  t        j                  |      | j                  _        y rX   )r   rt   rA   r   r   r   s     r_   r   zBaseAttrib.is_verify  s$    '8K8KUSr`   c                b    t        | j                  j                  t        j                  z        S )zANo prompt during insertion. (interactive CAD application feature))r}   rt   rA   r   ATTRIB_IS_PRESETr   s    r_   	is_presetzBaseAttrib.is_preset  r   r`   c                    t        | j                  j                  t        j                  |      | j                  _        y rX   )r   rt   rA   r   r   r   s     r_   r   zBaseAttrib.is_preset  r   r`   c                ,    t        | j                        S )zdReturns ``True`` if the entity has an embedded MTEXT entity for multi-line
        support.
        )r}   r\   r   s    r_   has_embedded_mtext_entityz$BaseAttrib.has_embedded_mtext_entity"  s    
 D(())r`   c                    | j                   st        d      | j                   j                         }|j                  | j	                                |S )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]   rn   s     r_   r   zBaseAttrib.virtual_mtext_entity)  sI    
 ##<==$$99;  !8!8!:;r`   c                    | j                   r2| j                   j                  }|rt        |d      S t        |d      S y)a  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   zBaseAttrib.plain_mtext4  s>    " '',,D'E::"4u55r`   c                   | j                   t               | _         | j                   j                  |       t        | |       t	        | |       t        | t              rt        j                  }nt        j                  }|| j                  _        |j                  j                  | j                  _        |j                  j                  | j                  _        | j                  j                  d       | j                  j                  d       | j                  j                  d       |r | j!                  |j#                                yy)a  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\   rj   	set_mtext_update_content_from_mtext_update_location_from_mtextrb   r2   r   ATTRIB_TYPE_MULTI_LINEATTDEF_TYPE_MULTI_LINErt   rE   stylechar_heightheightdiscardr   r   )r]   rn   r   rE   s       r_   r   zBaseAttrib.set_mtextM  s     '#0?D &&u-"4/#D%0 dF#"99N"99N"0 ))//!#/0##E$<$<$>? r`   c                H    | j                  ||       |j                          y)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]   rn   r   s      r_   embed_mtextzBaseAttrib.embed_mtexto  s     	u01r`   c                P    d| _         t        j                  | j                  _        y)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_LINErt   rE   r   s    r_   discard_mtextzBaseAttrib.discard_mtext  s      $"'"?"?r`   c                t    t         |   |       | j                  r| j                  j                  |       yy)5Register required resources to the resource registry.N)rY   register_resourcesr\   )r]   registryr^   s     r_   r   zBaseAttrib.register_resources  s2    "8,  33H=  r`   c                    t        |t              sJ t        |   ||       | j                  r4|j                  r'| j                  j                  |j                  |       yyy)3Translate resources from self to the copied entity.N)rb   r4   rY   map_resourcesr\   )r]   clonemappingr^   s      r_   r   zBaseAttrib.map_resources  sW    %,,,eW-E$9$9  ..u/D/DgN %:r`   c                    | j                   t        | 	  |       | S | j                   j                         }|j                  |       | j	                  |d       | j                  |       | S )NF)r   )r\   rY   	transformr   r   post_transform)r]   mrn   r^   s      r_   r   zBaseAttrib.transform  sh    'Ga  	 ((==?EOOANN5UN;"r`   c                    t         |   |       | j                  j                  d      s@|j	                  t
        j                  dt        |        d       |j                  |        yy)zValidity check.r@   z*Missing mandatory "tag" attribute, entity z	 deleted.)codemessageN)	rY   auditrt   ru   fixed_errorr   TAG_ATTRIBUTE_MISSINGstrtrash)r]   auditorr^   s     r_   r   zBaseAttrib.audit  s`    gxx&55DSYKyY    MM$ 'r`   returnNone)re   r   r   r   rl   r    r   r   rz   r.   r   r   )r   r}   )r   r}   r   r   r   r)   )Tr   r   rn   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__acdb_attdef_xrecordXRECORD_DEFrZ   r-   rg   ro   r{   propertyr   setterr   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r^   s   @r_   r4   r4      s+   %K= 5A E)
< 9 9 __S S = = W W : : T T = = W W * *	2 @D @>O   r`   r4   c                X    |j                  dd      }|r|d   | j                  _        y y )NT)r   r   r   )
plain_textrt   r   )r   rn   contents      r_   r   r     s0    T5G  
	 r`   c                n   | j                   }t        |j                   j                        }t        |j                   j                        }|j	                         }|j                  t              r|j                  |_        nQt        |      }|j                  |      }|j                         |_        |j                  |      j                  |_        ||_        ||_        t        j                  |j                   j                  t         j"                  t$        j&                  f      \  |_        |_        y rX   )rt   r   insert	extrusionget_text_directioniscloser   	angle_degrotationr   from_wcs	normalizerQ   r   getattachment_pointr   LEFTr   TOPhalignrC   )r   rn   rt   r   r   text_directionocss          r_   r   r     s    
((C%))""#FUYY(()I--/N %//)nf%!++-||N3==CJCO599		""Z__jnn$ECJ
r`   c                  X     e Zd ZdZdZ eeeee	      Z
	 d	 	 	 d fdZddZddZ xZS )	r1   zDXF ATTDEF entityATTDEFc                <   t         t        |   |      }|r|j                  |t        dd       |j                  |t
        dd       |j                  | j                  j                        | _	        | j                  |       |j                  rt        |d       |S Nr5   T)recoverrF   )r   rQ   )rY   r%   load_dxf_attribsfast_load_dxfattribsr'   acdb_attdef_group_codesfind_subclassr   namer[   ro   r12r$   r]   rl   rt   r^   s      r_   r   zAttDef.load_dxf_attribs  s     D$0;**30EqRV*W**,a +  &33D4D4D4I4IJDM$$Y/}}#C)BC
r`   c                    | j                  |       | j                  |       | j                  |       |j                  t        j
                  k\  r| j                  |       y y rX   )export_acdb_entityexport_acdb_textexport_acdb_attdefr>   r   DXF2018r{   ry   s     r_   export_entityzAttDef.export_entity  sQ    	*i(	*5==0**95 1r`   c                    |j                   t        j                  kD  r.|j                  t        j                  t
        j                         | j                  j                  |g d       y )N)rG   r@   rA   rB   rC   rD   )	r>   r   DXF12rs   SUBCLASS_MARKERacdb_attdefr   rt   export_dxf_attribsry   s     r_   r   zAttDef.export_acdb_attdef  sJ    %++-  !6!68H8HI##	
r`   rX   rl   zOptional[SubclassProcessor]r   r!   r   )r   r   r   __doc__DXFTYPEr   r"   r#   r&   r  
DXFATTRIBSr   r   r   r   r   s   @r_   r1   r1     s?    Gz;	;OJ 8<4	$6
r`   r1   c                  `     e Zd ZdZdZ eeeee	      Z
	 d	 	 	 d fdZd	dZd	dZd	dZ xZS )
r2   zDXF ATTRIB entityATTRIBc                <   t         t        |   |      }|r|j                  |t        dd       |j                  |t
        dd       |j                  | j                  j                        | _	        | j                  |       |j                  rt        |d       |S r   )rY   r%   r   r   r'   acdb_attrib_group_codesr   r   r   r[   ro   r   r$   r   s      r_   r   zAttrib.load_dxf_attribs  s     D$0;**30EqRV*W**,a +  &33D4D4D4I4IJDM$$Y/}}#C)BC
r`   c                    | j                  |       | j                  |       | j                  |       |j                  t        j
                  k\  r| j                  |       y y rX   )r   export_acdb_attrib_textexport_acdb_attribr>   r   r   r{   ry   s     r_   r   zAttrib.export_entity  sQ    	*$$Y/	*5==0**95 1r`   c                    |j                   t        j                  kD  r.|j                  t        j                  t
        j                         | j                  j                  |g d       y )N)r   r   r   	thicknessr   r   r   r   r   rQ   r   r   )	r>   r   r   rs   r  r&   r   rt   r  ry   s     r_   r  zAttrib.export_acdb_attrib_text  sJ     %++-  !6!6	G##	
r`   c                    |j                   t        j                  kD  r.|j                  t        j                  t
        j                         | j                  j                  |g d       y )N)r@   rA   rB   rC   rD   )	r>   r   r   rs   r  acdb_attribr   rt   r  ry   s     r_   r  zAttrib.export_acdb_attrib4  sJ    %++-  !6!68H8HI##
	
r`   rX   r  r   )r   r   r   r  r  r   r"   r#   r&   r  r  r   r   r  r  r   r   s   @r_   r2   r2     sD    Gz;	;OJ 8<4	"6
.
r`   r2   >   r@   rA   ownerhandlerG   versionrB   rD   c                    | j                   r| j                         S | j                  t              }t	        j
                  || j                        S )z`Returns the content of the ATTRIB/ATTDEF entity as a new virtual TEXT or
    MTEXT entity.

    )drop)
dxfattribsdoc)r   r   r  IGNORE_FROM_ATTRIBr%   newr  )attribr  s     r_   r3   r3   P  sE    
 ''**,,""(:";J88zvzz::r`   c                  @    e Zd Z ee      Zedd       Zedd       Zy)EmbeddedMTextNSc                    | j                   S rX   )_DXFATTRIBSr   s    r_   r  zEmbeddedMTextNS.dxfattribs^  s    r`   c                     y)NzEmbedded MText r   s    r_   dxftypezEmbeddedMTextNS.dxftypeb  s    r`   N)r   r   r   )	r   r   r   r   r+   r   r   r  r#  r"  r`   r_   r  r  [  s2    
+K       r`   r  c                  Z    e Zd ZdZddZddZeZddZddZddZ	d Z
ddZdd	Zdd
Zy)rj   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    t               | _        d| _        y )Nr6   )r  rt   r   r   s    r_   rZ   zEmbeddedMText.__init__|  s     #$	r`   c                b    t               }t        j                  | j                        |_        |S rX   )rj   rc   rd   rt   )r]   copy_s     r_   rc   zEmbeddedMText.copy  s"    MM$((+	r`   c                    |j                  | j                  t        |j                  d   d      }t	        |      | _        y )Nr   F)r   subclassr   )r   rt   r(   ri   r   r   )r]   rl   tagss      r_   rk   zEmbeddedMText.load_dxf_tags  s@    --HH5//2	 . 
 't,	r`   c                    t        j                  | j                  j                               }| j                  |_        |S )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).

        )r  )r)   r  rt   all_existing_dxf_attribsr   r   s     r_   r   z"EmbeddedMText.virtual_mtext_entity  s/     		TXX%F%F%HIYY
r`   c                    |j                   | _         | j                  }|j                  j                         j                         D ])  \  }}|j	                  |      s|j                  ||       + y)z8Set embedded MTEXT attributes from given `mtext` entity.N)r   rt   r,  itemsis_supportedset)r]   rn   rt   kvs        r_   r   zEmbeddedMText.set_mtext  sZ    JJ	hhII668>>@ 	DAq"1	r`   c           	         | j                   }dt        fdddddddd	f	D ])  \  }}|j                  |      r|j                  ||       + y )
Nr   )r   g      @)r           )defined_heightr4  )r   r   )flow_direction   )r   Standard)line_spacing_styler   )line_spacing_factorg      ?)rt   r
   ru   r0  )r]   rt   keyr7   s       r_   set_required_dxf_attributesz)EmbeddedMText.set_required_dxf_attributes  s\    hhw ##!!%(

 	&LC ;;s#W%	&r`   c                    |j                  t        t               | j                          | j                  j                  |g d       t        | j                  |       | j                  j                  |g d       y)z+Export embedded MTEXT as "Embedded Object".)r   r   r   r5  r   r6  )r   r   r   
rect_widthrect_heightr   r9  r:  box_fill_scalebg_fillbg_fill_colorbg_fill_true_colorbg_fill_color_namebg_fill_transparencyN)rs   r   r   r<  rt   r  r*   r   ry   s     r_   rx   zEmbeddedMText.export_dxf_tags  sd    02BC((*##
	
 	TYY	2##	
r`   c                    | j                   j                  d      r&|j                  | j                   j                         yy)r   r   N)rt   ru   add_text_styler   )r]   r   s     r_   r   z EmbeddedMText.register_resources  s/    88G$##DHHNN3 %r`   c                    |j                   j                  d      r5|j                  |j                   j                        |j                   _        yy)r   r   N)rt   ru   get_text_styler   )r]   r   r   s      r_   r   zEmbeddedMText.map_resources  s7    99W%%44UYY__EEIIO &r`   Nr   )r   rj   r   r   r   r   r   )r   rj   r   r   r   r   )r   r   r   r  rZ   rc   __copy__rk   r   r   r<  rx   r   r   r"  r`   r_   rj   rj   g  s=    (
 H-&""
H4
Fr`   rj   )r   r%   rn   r)   r   r   )r  r4   )_
__future__r   typingr   r   typing_extensionsr   rc   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'   rn   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   r  r3   r  rj   r"  r`   r_   <module>rj     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r`   