
    Og
                    ^    d dl mZ d dlmZ d dlmZ d dlmZ dgZdZ	dZ
 G d d      Zdd	Zy
)    )annotations)XRecord)Tags)DXFTagRoundtripXRecordf   c                  :    e Zd ZdZdd	dZd
dZddZddZddZy)r   a  Helper class for ACAD Roundtrip Data.

    The data is stored in an XRECORD, in sections separated by tags
    (102, "ACAD_SECTION_NAME").

    Example for inverted clipping path of SPATIAL_FILTER objects:

    ...
    100
    AcDbXrecord
    280
    1
    102
    ACAD_INVERTEDCLIP_ROUNDTRIP
    10
    399.725563048036
    20
    233.417786599994
    30
    0.0
    ...
    102
    ACAD_INVERTEDCLIP_ROUNDTRIP_COMPARE
    10
    399.725563048036
    20
    233.417786599994
    ...

    Nc                *    |
t               }|| _        y N)r   xrecord)selfr   s     g/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/entities/acad_xrec_roundtrip.py__init__zRoundtripXRecord.__init__.   s    ?iG    c                b    | j                   j                  D ]  \  }}|t        k(  s||k(  s y y)z4Returns True if an entry section for key is present.TF)r   tagsSECTION_MARKER_CODE)r   keycodevalues       r   has_sectionzRoundtripXRecord.has_section3   s6    <<,, 	KD%**u|	 r   c                    | j                   j                  }t        ||      \  }}|t        k(  r1|j	                  t        t        |             |j                  |       y|||dz   | y)zTSet content of section `key` to `tags`. Replaces the content of an existing section.   N)r   r   find_section	NOT_FOUNDappendr   r   extend)r   r   r   xrecord_tagsstartends         r   set_sectionzRoundtripXRecord.set_section:   s]    ||((!,4
sI':C @A%,0LS)r   c                    | j                   j                  }t        ||      \  }}|t        k7  r||dz   | S t	               S )z%Returns the content of section `key`.r   )r   r   r   r   r   r   r   r   r    r!   s        r   get_sectionzRoundtripXRecord.get_sectionD   sA    ||((!,4
sI	C00vr   c                l    | j                   j                  }t        ||      \  }}|t        k7  r|||= yy)z;Removes section `key`, section `key` doesn't have to exist.N)r   r   r   r   r$   s        r   discardzRoundtripXRecord.discardL   s:    ||((!,4
sIU3Y' r   r   )r   zXRecord | NonereturnNone)r   strr(   bool)r   r*   r   r   r(   r)   )r   r*   r(   r   )r   r*   r(   r)   )	__name__
__module____qualname____doc__r   r   r"   r%   r'    r   r   r   r      s     >
1(r   c                    t         }t        |       D ]6  \  }}|j                  dk7  r|j                  |k(  r|}(|t         k7  s2||fc S  |t         k7  r|t	        |       fS t         t         fS )zlReturns the start- and end index of section `key`.

    Returns (-1, -1) if the section does not exist.
    r   )r   	enumerater   r   len)r   r   r    indextags        r   r   r   T   su    
 Eo  
s88s?99Ei%<  	c$iir   N)r   r   r   r*   r(   ztuple[int, int])
__future__r   ezdxf.entitiesr   ezdxf.lldxf.tagsr   ezdxf.lldxf.typesr   __all__r   r   r   r   r0   r   r   <module>r;      s8    # " ! $
 	C( C(L r   