
    'j.i                       d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZmZmZmZmZ erddlmZ dd	lmZ d
ZdZdez  Zdez  ZdZ G d de           Z! G d d          Z" e"            Z# G d d          Z$ G d de$          Z% G d de$          Z& G d de&          Z' G d de$          Z(d%d#Z)d$S )&a  Dimension lines as composite entities build up by DXF primitives.

This add-on exist just for an easy transition from `dxfwrite` to `ezdxf`.

Classes
-------

- LinearDimension
- AngularDimension
- ArcDimension
- RadiusDimension
- DimStyle

This code was written long before I had any understanding of the DIMENSION
entity and therefore, the classes have completely different implementations and
styling features than the dimensions based on the DIMENSION entity .

.. warning::

    Try to not use these classes beside porting `dxfwrite` code to `ezdxf`
    and even for that case the usage of the regular DIMENSION entity is to
    prefer because this module will not get much maintenance and may be removed
    in the future.

    )annotations)AnyTYPE_CHECKINGIterableOptional)radiansdegreespi)abstractmethod)TextEntityAlignment)Vec3Vec2distancelerpConstructionRayUVec)Drawing)GenericLayoutType皙?.     f@g      i@      ?c                  <     e Zd ZdZg dZd fdZdd	ZddZ xZS )DimStylezBDimStyle parameter struct, a dumb object just to store values
    ))tickDIMTICK_ARCH)
tickfactorr   )tick2xF)scaleg      Y@)roundvalr   )	roundhalfF)	textcolor   )height      ?)prefix )suffixr'   )stylezOpenSansCondensed-Light)layer
DIMENSIONS)dimlinecolorr#   )
dimlineext333333?)	textabove皙?)
dimextlineT)dimextlinecolor   )dimextlinegapr.   namestrc                    t                                          t          j                   || d<   |                     |           d S )Nr5   )super__init__r   default_valuesupdate)selfr5   kwargs	__class__s      O/DATA/AppData/hermes/venv/lib/python3.11/site-packages/ezdxf/addons/dimlines.pyr9   zDimStyle.__init__\   s?    0111VF    attrreturnr   c                    | |         S N )r<   rA   s     r?   __getattr__zDimStyle.__getattr__b   s    Dzr@   valueNonec                    || |<   d S rD   rE   )r<   rA   rG   s      r?   __setattr__zDimStyle.__setattr__e   s    T


r@   )r5   r6   )rA   r6   rB   r   )rA   r6   rG   r   rB   rH   )	__name__
__module____qualname____doc__r:   r9   rF   rJ   __classcell__r>   s   @r?   r   r   /   s         ' ' 'NR               r@   r   c                  B    e Zd ZdZddZddZdd	Zedd            ZdS )	DimStylesz
    DimStyle container

    rB   rH   c           
     "   i | _         t          d          | _        |                     dt          t          d          ddddd	           |                     d
t          dddddd	           |                     dt          dddddd	           d S )NDefault	angle.deg   °r   DIMTICK_RADIUST        F)r   r(   r    r   r   r-   r1   z
angle.gradgonz	angle.radrad   )_stylesr   defaultnew	ANGLE_DEGr6   
ANGLE_GRAD	ANGLE_RADr<   s    r?   r9   zDimStyles.__init__o   s    ,.	**t99! 	 		
 		
 		
 	! 	 		
 		
 		
 	! 	 		
 		
 		
 		
 		
r@   r5   r6   r   c                B    | j                             || j                  S )z0
        Get DimStyle() object by name.
        )r\   getr]   )r<   r5   s     r?   rd   zDimStyles.get   s     |dl333r@   c                4    t          |fi |}|| j        |<   |S )z'
        Create a new dimstyle
        )r   r\   )r<   r5   r=   r)   s       r?   r^   zDimStyles.new   s*     (((("Tr@   drawing	'Drawing'c                f   t           j        j        dd}ddd}ddd}| j                            d          }|                    dd|           |                    d	d
|           | j                            d          }|                    dd|           |                    dd|           | j                            d          }|                    dd|           |                    g d|           | j                            d          }|                    g d|           dS )zy
        Insert necessary definitions into drawing:

            ticks: DIMTICK_ARCH, DIMTICK_DOT, DIMTICK_ARROW
        BYBLOCKcolorr*      r#   r   )rX   r%   )rX   g      ࿩startend
dxfattribs)皙ɿrq   )r0   r0   DIMTICK_DOTr   r   g?)centerradiusrp   DIMTICK_ARROW)rs   r.   r   r.   g)rp   rW   )rs   rw   )g      ?rX   rx   N)	dimstylesr]   r2   blocksr^   add_line
add_circle	add_solid)rf   dimcolorcolor4color7blocks        r?   setupzDimStyles.setup   sU   & &6
 
 y11y11"">22[khOOO\{vNNN""=11Z[XNNNsvFFF""?33Z\hOOO;;;OOO""#344<<< 	 	
 	
 	
 	
 	
r@   NrB   rH   )r5   r6   rB   r   )rf   rg   )	rK   rL   rM   rN   r9   rd   r^   staticmethodr   rE   r@   r?   rR   rR   i   s{         
!
 !
 !
 !
F4 4 4 4    (
 (
 (
 \(
 (
 (
r@   rR   c                  B    e Zd ZdZddZddZddZedd            ZdS )_DimensionBasez3
    Abstract base class for dimension lines.

    dimstyler6   r*   r    intc                `    t                               |          | _        || _        || _        d S rD   )ry   rd   r   r*   r    )r<   r   r*   r    s       r?   r9   z_DimensionBase.__init__   s'    !h//
 r@   property_namerB   r   c                    |dk    r| j         | j         n| j        j         S |dk    r| j        | j        n| j        j        S | j        |         S )zw
        Get dimension line properties by `property_name` with the possibility to override several properties.
        r*   Nr    )r*   r   r    )r<   r   s     r?   propz_DimensionBase.prop   sa     G##!%!74::T]=PPj(( =, ]+ =//r@   dimvaluefloatc                (   dt          |                     d                    z   dz   }||z  }t          |v r/|                    d           |                    t                     |                     d          |z   |                     d          z   S )z,
        Format the dimension text.
        z%.r    f0r&   r(   )r6   r   DIMENSIONS_FLOATINGPOINTrstrip)r<   r   
dimtextfmtdimtexts       r?   format_dimtextz_DimensionBase.format_dimtext   s     C		* 5 5666<
x'#w..NN3NN3444yy""W,tyy/B/BBBr@   layout'GenericLayoutType'c                    d S rD   rE   r<   r   s     r?   renderz_DimensionBase.render   s    r@   N)r   r6   r*   r6   r    r   )r   r6   rB   r   )r   r   rB   r6   )r   r   )	rK   rL   rM   rN   r9   r   r   r   r   rE   r@   r?   r   r      s~         
! ! ! !
0 0 0 0C C C C    ^  r@   r   c                       e Zd ZdZ	 	 	 	 d2d3 fdZd4dZd5dZd6dZd7dZd8dZ	e
d9d            Ze
d9d            Zd:d"Zed;d%            Zd5d&Zed<d+            Zd:d,Zd:d-Zd:d.Zd=d/Zd>d0Zd:d1Z xZS )?LinearDimensionz
    Simple straight dimension line with two or more measure points, build with basic DXF entities. This is NOT a dxf
    dimension entity. And This is a 2D element, so all z-values will be ignored!

    rX   rT   Nposr   measure_pointsIterable[UVec]angler   r   r6   r*   Optional[str]r    Optional[int]c                    t                                          |||           || _        t          |          | _        dg| j        z  | _        t          |          | _        d| _	        dS )a  
        LinearDimension Constructor.

        Args:
            pos: location as (x, y) tuple of dimension line, line goes through this point
            measure_points: list of points as (x, y) tuples to dimension (two or more)
            angle: angle (in degree) of dimension line
            dimstyle: dimstyle name, 'Default' - style is the default value
            layer: dimension line layer, override the default value of dimstyle
            roundval: count of decimal places

        r'   N)
r8   r9   r   listr   section_counttext_overrider   
dimlineposr   )r<   r   r   r   r   r*   r    r>   s          r?   r9   zLinearDimension.__init__  sb    * 	5(333
">22 TD$66s))r@   sectionr   textrB   rH   c                    || j         |<   dS )zg
        Set and override the text of the dimension text for the given dimension line section.
        N)r   )r<   r   r   s      r?   set_textzLinearDimension.set_text  s     '+7###r@   c                    d  j         D              _         t           j        t           j                             fd j         D              _                              j                   _                                          dS )z`
        Calc setup values and determines the point order of the dimension line points.
        c                ,    g | ]}t          |          S rE   )r   ).0points     r?   
<listcomp>z*LinearDimension._setup.<locals>.<listcomp>(  s    LLLutE{{LLLr@   )r   c                <    g | ]}                     |          S rE   )_get_point_on_dimline)r   r   
dimlinerayr<   s     r?   r   z*LinearDimension._setup.<locals>.<listcomp>*  s9     
 
 
 &&uj99
 
 
r@   N)	r   r   r   r   r   dimline_points_indices_of_sorted_pointspoint_order_build_vectors)r<   r   s   `@r?   _setupzLinearDimension._setup$  s     ML8KLLL$T_GDJ<O<OPPP

 
 
 
 
,
 
 
  99$:MNNr@   indexc                2    | j         | j        |                  S )zL
        Get point on the dimension line, index runs left to right.
        )r   r   )r<   r   s     r?   _get_dimline_pointz"LinearDimension._get_dimline_point1  s     "4#3E#:;;r@   tuple[Vec3, Vec3]c                \    |                      |          |                      |dz             fS )zU
        Get start and end point on the dimension line of dimension section.
           r   )r<   r   s     r?   _get_section_pointsz#LinearDimension._get_section_points7  s8     &&w//1H1HaK2
 2
 
 	
r@   c                V    |                      d          |                      d          fS )zE
        Get the first and the last point of dimension line.
        r   r   rb   s    r?   _get_dimline_boundsz#LinearDimension._get_dimline_bounds?  s+     &&q))4+B+B2+F+FFFr@   c                0    t          | j                  dz
  S )zcount of dimline sectionsr   lenr   rb   s    r?   r   zLinearDimension.section_countE  s     4&''!++r@   c                *    t          | j                  S )zcount of dimline pointsr   rb   s    r?   point_countzLinearDimension.point_countJ  s     4&'''r@   r   r   c                    |                                   |                     |           |                     d          r|                     |           |                     |           |                     |           dS 3build dimension line object with basic dxf entitiesr1   N)r   _draw_dimliner   _draw_extension_lines
_draw_text_draw_ticksr   s     r?   r   zLinearDimension.renderO  sw    6"""99\"" 	/&&v...     r@   points	list[int]c                t    d t          |           D             }|                                 d |D             S )z7get indices of points, for points sorted by x, y valuesc                    g | ]	\  }}||f
S rE   rE   )r   idxr   s      r?   r   z=LinearDimension._indices_of_sorted_points.<locals>.<listcomp>[  s     KKK:35#,KKKr@   c                    g | ]\  }}|S rE   rE   )r   r   r   s      r?   r   z=LinearDimension._indices_of_sorted_points.<locals>.<listcomp>]  s    555
s555r@   )	enumeratesort)r   indexed_pointss     r?   r   z)LinearDimension._indices_of_sorted_pointsX  sF     LK69J9JKKK55n5555r@   c                    |                                  \  }}t          |          t          |          z
                                  | _        | j                                        | _        dS )z9build unit vectors, parallel and normal to dimension lineN)r   r   	normalizeparallel_vector
orthogonalnormal_vector)r<   point1point2s      r?   r   zLinearDimension._build_vectors_  sY    1133 $VtF|| ;FFHH!1<<>>r@   r   dimrayr   r   c                R    |                     |                    |                     S )z=get the measure target point projection on the dimension line)	intersectr   )r   r   s     r?   r   z%LinearDimension._get_point_on_dimlinee  s&      1 1% 8 8999r@   c                $   |                                  \  }}|                     d          }|dk    r|| j        |z  z
  }|| j        |z  z   }|                     d          |                     d          d}|                    |||           dS )zbuild dimension line entityr-   r   r,   r*   rj   rm   N)r   r   r   r{   )r<   r   start_point	end_pointr-   attribss         r?   r   zLinearDimension._draw_dimlinej  s    !%!9!9!;!;YYY|,,
>>%)=
)JKK!T%9J%FGI YY~..YYw''
 
 	 	 	
 	
 	
 	
 	
r@   c                   |                      d          }|                      d          |                      d          d}t          | j        | j                  D ]c\  }}t	          ||          t          |t                    k    r7||z
                                  }|||z  z
  }|                    |||           ddS )"build the extension lines entitiesr4   r,   r*   rj   rm   N)	r   zipr   r   r   maxDIMENSIONS_MIN_DISTANCEr   r{   )r<   r   r4   r   dimline_pointtarget_pointdirection_vectors          r?   r   z%LinearDimension._draw_extension_lines}  s    		/22YY~..YYw''
 

 ,/!4,
 ,
 	 	'M< |44s68 8   %1=$@#K#K#M#M +/?-/OP'$&     	 	r@   c                   |                      d          |                      d          |                      d          | j        |                      d          d}t          | j                  D ]b}|                     |          }|                     |          }|                    ||                              |t          j	                   cdS )	z%build the dimension value text entityr$   r"   r*   r)   )r$   rk   r*   rotationr)   r   rp   alignN)
r   r   ranger   _get_dimvalue_text_get_text_insert_pointadd_textset_placementr   MIDDLE_CENTER)r<   r   r   r   dimvalue_textinsert_points         r?   r   zLinearDimension._draw_text  s     ii))YY{++YYw''
YYw''
 
 T/00 	 	G 33G<<M66w??LOO""    m$7$E     	 	r@   c                    | j         |         }t          |          r|S |                     |          \  }}t          ||          |                     d          z  }|                     |          S )z?get the dimension value as text, distance from point1 to point2r   )r   r   r   r   r   r   )r<   r   overrider   r   r   s         r?   r   z"LinearDimension._get_dimvalue_text  sm    %g.x== 	O11'::FF++dii.@.@@""8,,,r@   c                    |                      |          \  }}|                     d          dz  |                     d          z   }t          ||          | j        |z  z   S )z)get the dimension value text insert pointr$          @r/   )r   r   r   r   )r<   r   r   r   dists        r?   r   z&LinearDimension._get_text_insert_point  s]    11'::yy""S(499[+A+AAFF##t'9D'@AAr@   c                                          d                                d                                d          ddd fd}                      d          rMt          d j        dz
            D ]} ||d           t          d j                  D ]} ||d           dS t           j                  D ]} ||d           dS )z@insert the dimension line ticks, (markers on the dimension line)r   r*   xscaleyscaler*   Fr   r   rotateboolrB   rH   c                    j         |rdndz   d<                                           |                               d                     dS )z*build the insert-entity for the tick blockr   rX   r   r   insertr5   rp   N)r   add_blockrefr   r   )r   r  r   r   r<   s     r?   add_tickz-LinearDimension._draw_ticks.<locals>.add_tick  sg    "&*0HS"IGJ..u55YYv&&"       r@   r   r   r   TN)F)r   r   r  r  rB   rH   )r   r   r   )r<   r   r  r   r   s   ``  @r?   r   zLinearDimension._draw_ticks  s/    ii--ii--YYw''
 
	 	 	 	 	 	 	 	 	 99X 	'q$"2Q"677 ' '&&&&q$"233 & &%%%%& & t/00 ' '&&&&' 'r@   )rX   rT   NN)r   r   r   r   r   r   r   r6   r*   r   r    r   )r   r   r   r6   rB   rH   r   )r   r   rB   r   )r   r   rB   r   )rB   r   )rB   r   r   r   rB   rH   )r   r   rB   r   )r   r   r   r   rB   r   )r   r   rB   r6   )r   r   rB   r   )rK   rL   rM   rN   r9   r   r   r   r   r   propertyr   r   r   r   r   r   r   r   r   r   r   r   r   rO   rP   s   @r?   r   r      s         !#"&      8+ + + +   < < < <
 
 
 
G G G G , , , X, ( ( ( X(! ! ! ! 6 6 6 \6? ? ? ? : : : \:
 
 
 
&   ,   &- - - -B B B B' ' ' ' ' ' ' 'r@   r   c                       e Zd ZdZeZeZeZ		 	 	 d d! f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 xZS )'AngularDimensionz
    Draw an angle dimensioning line at dimline pos from start to end, dimension text is the angle build of the three
    points start-center-end.

    rU   Nr   r   rt   rn   ro   r   r6   r*   r   r    r   c                    t                                          |||           t          |          | _        t          |          | _        t          |          | _        t          |          | _        dS )a2  
        AngularDimension constructor.

        Args:
            pos: location as (x, y) tuple of dimension line, line goes through this point
            center: center point as (x, y) tuple of angle
            start: line from center to start is the first side of the angle
            end: line from center to end is the second side of the angle
            dimstyle: dimstyle name, 'Default' - style is the default value
            layer: dimension line layer, override the default value of dimstyle
            roundval: count of decimal places

        N)r8   r9   r   r   rt   rn   ro   )	r<   r   rt   rn   ro   r   r*   r    r>   s	           r?   r9   zAngularDimension.__init__  sY    . 	5(333s))6ll%[[
99r@   rB   rH   c                ^   t          | j        | j                  | _        t          | j        | j                  | _        | j        | j        z
                                  | _        | j        | j        z
                                  | _	        | j        j
        | _        | j	        j
        | _        dS )zsetup calculation valuesN)r   rt   r   
pos_radiusrn   ru   r   start_vectorro   
end_vectorr   start_angle	end_anglerb   s    r?   r   zAngularDimension._setup  s    "4;@@t{DJ77!Z$+5@@BB8dk1<<>>,2.r@   r   r   c                    |                                   |                     |           |                     d          r|                     |           |                     |           |                     |           dS r   )r   _draw_dimension_liner   r   _draw_dimension_textr   r   s     r?   r   zAngularDimension.render  s{     	!!&)))99\"" 	/&&v...!!&)))     r@   c           
         |                     | j        | j        t          | j                  t          | j                  |                     d          |                     d          d           dS )z0draw the dimension line from start- to endangle.r*   r,   r*   rk   )ru   rt   r  r  rp   N)add_arcr  rt   r	   r  r  r   r   s     r?   r  z%AngularDimension._draw_dimension_line  st    ?; 011dn--7++>22  	 		
 		
 		
 		
 		
r@   c           	         | j         | j        fD ]i}|                    |                     |          |                     |          |                     d          |                     d          d           jdS )r   r*   r2   r  rm   N)r  r  r{   _get_extline_start_get_extline_endr   )r<   r   vectors      r?   r   z&AngularDimension._draw_extension_lines  s    ($/: 	 	FOO--f55))&11!YYw//!YY'899      	 	r@   r!  r   c                B    | j         ||                     d          z  z   S Nr4   )rt   r   r<   r!  s     r?   r  z#AngularDimension._get_extline_start%  s     {ftyy'A'AABBr@   c                &    | j         || j        z  z   S rD   rt   r  r$  s     r?   r   z!AngularDimension._get_extline_end(      {ft677r@   c                   |                      d          t          | j        | j        z   dz  t          dz  z
            |                      d          |                      d          |                      d          d}|                    |                                 |                              |                                 t          j
        	           d S )
Nr$      r   r*   r)   r"   r$   r   r*   r)   rk   r   r   )r   r	   r  r  r
   r   _get_dimtextr   r   r   r   )r<   r   r   s      r?   r  z%AngularDimension._draw_dimension_text+  s    ii))!DN2a7"s(B  YYw''YYw''YY{++
 
 	""$$ 	 	
 	
 -''))%3  
 
 
 
 
r@   c                    | j         | j        z   dz                                  }| j        |                     d          z   |                     d          dz  z   }| j        ||z  z   S )Nr   r/   r$   )r  r  r   r  r   rt   )r<   	midvectorlengths      r?   r   z'AngularDimension._get_text_insert_point=  sg    '$/9S@KKMM	Odii444tyy7J7JS7PP 	 {i&011r@   c                   |                      d          |                      d          |                      d          d}| j        df| j        |                      d          ffD ]r\  }}| j        || j        z  z   }|j        t          dz  z   }t          ||rt          ndz             |d<   |                    ||                      d	          |
           sd S )Nr   r*   r  Fr   r   rX   r   r   r	  )	r   r  r  rt   r  r   r
   r	   r  )r<   r   r   r!  mirrorr   r   s          r?   r   zAngularDimension._draw_ticksD  s    ii--ii--YYw''
 
 &_dii112
 	 	NFF  ;&4?*BCL|b3h.H")(F6Kbb*L"M"MGJ#YYv&&"      	 	r@   c                v    | j         | j        z
  |                     d          z  }|                     |          S Nr   )r  r  r   r   )r<   r   s     r?   r+  zAngularDimension._get_dimtextW  s8     $"22dii6H6HH""5)))r@   )rU   NN)r   r   rt   r   rn   r   ro   r   r   r6   r*   r   r    r   r   r  r!  r   rB   r   rB   r   rB   r6   )rK   rL   rM   rN   r_   DEGr`   GRADra   RADr9   r   r   r  r   r  r   r  r   r   r+  rO   rP   s   @r?   r  r    s4         CD
C $#"&      :/ / / /! ! ! !
 
 
 

 
 
 
C C C C8 8 8 8
 
 
 
$2 2 2 2   &* * * * * * * *r@   r  c                  R     e Zd ZdZ	 	 	 	 dd fdZd fdZddZddZddZ xZ	S ) ArcDimensionz
    Arc is defined by start- and endpoint on arc and the center point, or by three points lying on the arc if acr3points
    is True. Measured length goes from start- to endpoint. The dimension line goes through the dimlinepos.

    FrT   Nr   r   rt   rn   ro   
arc3pointsr  r   r6   r*   r   r    r   c	           	     d    t                                          |||||||           || _        dS )a  
        Args:
            pos: location as (x, y) tuple of dimension line, line goes through this point
            center: center point of arc
            start: start point of arc
            end: end point of arc
            arc3points: if **True** arc is defined by three points on the arc (center, start, end)
            dimstyle: dimstyle name, 'Default' - style is the default value
            layer: dimension line layer, override the default value of dimstyle
            roundval: count of decimal places

        N)r8   r9   r;  )
r<   r   rt   rn   ro   r;  r   r*   r    r>   s
            r?   r9   zArcDimension.__init__f  s4    . 	feS(E8LLL$r@   rB   rH   c                    t                                                       | j        r't          | j        | j        | j                  | _        d S d S rD   )r8   r   r;  center_of_3points_arcrt   rn   ro   )r<   r>   s    r?   r   zArcDimension._setup  sM    ? 	/TZ DKKK	 	r@   r!  r   c                R    | j         || j        |                     d          z   z  z   S r#  )rt   ru   r   r$  s     r?   r  zArcDimension._get_extline_start  s,    {dkDIIo$>$>>?
 	
r@   c                &    | j         || j        z  z   S rD   r&  r$  s     r?   r   zArcDimension._get_extline_end  r'  r@   c                    | j         | j        z
  | j        z  |                     d          z  }|                     |          S r2  )r  r  ru   r   r   )r<   
arc_lengths     r?   r+  zArcDimension._get_dimtext  sH    ^d..kii  ! 	
 "":...r@   )FrT   NN)r   r   rt   r   rn   r   ro   r   r;  r  r   r6   r*   r   r    r   r   r3  r5  )
rK   rL   rM   rN   r9   r   r  r   r+  rO   rP   s   @r?   r:  r:  _  s          !!#"&% % % % % % %4     
 
 
 

8 8 8 8/ / / / / / / /r@   r:  c                  f     e Zd ZdZ	 	 	 	 dd fdZddZd dZd dZd dZd!dZ	d"dZ
d dZ xZS )#RadialDimensionz
    Draw a radius dimension line from `target` in direction of `center` with length drawing units. RadiusDimension has
    a special tick!!
    r   rT   Nrt   r   targetr.  r   r   r6   r*   r   r    r   c                    t                                          |||           t          |          | _        t          |          | _        t          |          | _        dS )at  
        Args:
            center: center point of radius
            target: target point of radius
            length: length of radius arrow (drawing length)
            dimstyle: dimstyle name, 'Default' - style is the default value
            layer: dimension line layer, override the default value of dimstyle
            roundval: count of decimal places

        N)r8   r9   r   rt   rE  r   r.  )r<   rt   rE  r.  r   r*   r    r>   s          r?   r9   zRadialDimension.__init__  sL    & 	5(3336ll6llFmmr@   rB   rH   c                    | j         | j        z
                                  | _        t	          | j        | j                   | _        d S rD   )rE  rt   r   target_vectorr   ru   rb   s    r?   r   zRadialDimension._setup  s:    K$+%
)++ 	 t{DK88r@   r   r   c                    |                                   |                     |           |                     |           |                     |           dS )r   N)r   r  r  r   r   s     r?   r   zRadialDimension.render  sQ    !!&)))!!&)))     r@   c                    | j         | j        | j        | j        z
  z  z   }|                    || j        |                     d          |                     d          d           d S )Nr,   r*   rj   rm   )rt   rH  ru   r.  r{   rE  r   )r<   r   r   s      r?   r  z$RadialDimension._draw_dimension_line  sy    k$+";<
 	>227++  	 	
 	
 	
 	
 	
r@   c           
     r   |                     |                                 |                     d          | j        j        |                     d          |                     d          |                     d          d                              |                                 t          j                   d S )Nr$   r*   r)   r"   r*  r   r   )	r   r+  r   rH  	angle_degr   _get_insert_pointr   MIDDLE_RIGHTr   s     r?   r  z$RadialDimension._draw_dimension_text  s    ""$$))H-- .87++7++;//  	 		
 		
 -""$$,?,L  
 
 
 
 
r@   r   c                \    | j         | j        | j        |                     d          z   z  z
  S )Nr/   )rE  rH  r.  r   rb   s    r?   rM  z!RadialDimension._get_insert_point  s/    {$+		+0F0F"FG
 	
r@   c                b    |                      | j        |                     d          z            S r2  )r   ru   r   rb   s    r?   r+  zRadialDimension._get_dimtext  s)    ""4;71C1C#CDDDr@   c           
         |                     | j        d| j        j        dz   |                     d          |                     d          |                     d          d           d S )NrW      r   r*   )r   r  r  r*   r	  )r  rE  rH  rL  r   r   s     r?   r   zRadialDimension._draw_ticks  sv    ;! .83>))L11))L117++	  	 		
 		
 		
 		
 		
r@   )r   rT   NN)rt   r   rE  r   r.  r   r   r6   r*   r   r    r   r   r  r4  r5  )rK   rL   rM   rN   r9   r   r   r  r  rM  r+  r   rO   rP   s   @r?   rD  rD    s          !#"&$ $ $ $ $ $ $09 9 9 9! ! ! !
 
 
 

 
 
 

 
 
 

E E E E

 

 

 

 

 

 

 

r@   rD  r   r   r   point3rB   r   c                    t          | |          }t          | |          }t          | |          }t          | |          }|                    |          }|                    |          }|                    |          S )z
    Calc center point of 3 point arc. ConstructionCircle is defined by 3 points
    on the circle: point1, point2 and point3.
    )r   r   r   r   )	r   r   rS  ray1ray2	midpoint1	midpoint2center_ray1center_ray2s	            r?   r>  r>    sv    
 66**D66**DVV$$IVV$$I//),,K//),,K  ---r@   N)r   r   r   r   rS  r   rB   r   )*rN   
__future__r   typingr   r   r   r   mathr   r	   r
   abcr   ezdxf.enumsr   
ezdxf.mathr   r   r   r   r   r   ezdxf.documentr   ezdxf.eztypesr   r   r   r_   r`   ra   dictr   rR   ry   r   r   r  r:  rD  r>  rE   r@   r?   <module>rd     s}   2 # " " " " " 9 9 9 9 9 9 9 9 9 9 9 9 % % % % % % % % % %       + + + + + + H H H H H H H H H H H H H H H H 0&&&&&&//////  BJ	RZ
	7 7 7 7 7t 7 7 7t`
 `
 `
 `
 `
 `
 `
 `
F IKK	) ) ) ) ) ) ) )XS' S' S' S' S'n S' S' S'lK* K* K* K* K*~ K* K* K*\6/ 6/ 6/ 6/ 6/# 6/ 6/ 6/rX
 X
 X
 X
 X
n X
 X
 X
v. . . . . .r@   