
    BPc                         d dl Z d dlZd dlmZmZ d dlmZ  G d dej                  Ze	dk    r e            
                                 dS dS )    N)TextElementCircle)inkex_gettextc                   :    e Zd ZdZd Zd Zdej        fdZd Z	dS )NumberNodeszIReplace the selection's nodes with numbered dots according to the optionsc                    |                     ddd           |                     ddd           |                     dt          d	d
           |                     dt          d	d           |                     dd           d S )Nz	--dotsize10pxz"Size of the dots on the path nodes)defaulthelpz
--fontsize20pxzSize of node labelsz--start   zFirst number in the sequence)typer
   r   z--stepz Numbering step between two nodesz--tabz'The selected UI-tab when OK was pressed)r   )add_argumentint)selfparss     3/usr/share/inkscape/extensions/path_number_nodes.pyadd_argumentszNumberNodes.add_arguments   s    .R 	 	
 	
 	
 	,=RSSSC1O 	 	
 	
 	
 	30R 	 	
 	
 	
 	'(QRRRRR    c                     | j         j                            t          j                  }|s!t          j        t          d                    |D ]}|                     |           d S )Nz'Please select at least one path object.)svg	selectionfilterinkexPathElementAbortExtension_add_dot)r   filterednodes      r   effectzNumberNodes.effect+   sn    8%,,U->?? 	U&q)R'S'STTT 	 	DLL	 	r   r    c                 j   |                                                     t          j                              }|                    t          j                              }|                    t          j                              }|j                            |                                          }|                                                                  |_        t          j        ddd          }t          |j	                  D ]\  }\  }}	|                    t          t          |          t          |	          t          | j                            | j        j                  dz                                }
||
_        |                    |                     || j                            | j        j                  dz  z   |	| j                            | j        j                  dz  z
  | j        j        | j        j        |z  z                        |                                 dS )z%Add a dot label for this path elementnonez#000)strokefill   )cxcyrN)	getparentaddr   Grouppath	transformcomposed_transformStyle	enumerate
end_pointsr   strr   unittouuoptionsdotsizestyleappendadd_textstartstepdelete)r   r    group	dot_group	num_grouppath_trans_appliedr7   r;   xycircles              r   r   zNumberNodes.add_dot2   s   !^^--11%+--@@IIekmm,,	IIekmm,,	!Y001H1H1J1JKK>>++>>@@@vv>>??%&8&CDD 	 	LD&1a]]1vv1vv$(++DL,@AAAEFF   F !FL**4<+?@@1DE**4<+?@@1DEL&$,*;d*BC     	r   c                     t          t          |          t          |                    }t          |          |_        | j                            | j        j                  dddddd|_        |S )z&Add a text label at the given location)rA   rB   z1.0r#   normalz#999)z	font-sizezfill-opacityr$   zfont-weightz
font-styler%   )r   r3   textr   r4   r5   fontsizer7   )r   rA   rB   rF   elems        r   r9   zNumberNodes.add_textO   si    SVVs1vv...II	**4<+@AA!#"
 

 r   N)
__name__
__module____qualname____doc__r   r!   r   r   r   r9    r   r   r   r      sh        SSS S S  E-    :    r   r   __main__)mathr   r   r   inkex.localizationr   r   EffectExtensionr   rI   runrM   r   r   <module>rS      s   (   % % % % % % % % 1 1 1 1 1 1@ @ @ @ @%' @ @ @F zKMM r   