
    BPc,                         d Z ddlZddlmZ ddlmZmZmZ ddl	m
Z
  G d dej                  Zedk    r e                                             dS dS )	zF
Interpolation of attributes in selected objects or group's children.
    N)inkex_gettext)ColorInterpolatorValueInterpolatorAttributeInterpolator)	is_numberc                   J     e Zd ZdZ fdZd Zd Zed             Zd Z	 xZ
S )
InterpAttGz
    This effect applies a value for any interpolatable attribute for all
    elements inside the selected group or for all elements in a multiple selection.
    c                 $   t          t          |                                            | j                            ddt
          ddd           | j                            ddt
          d	d
           | j                            dd|                     t          t          g          dd           | j                            ddt
          ddd           | j                            ddt
          ddd           | j                            ddt
          ddd           | j                            dd t
          d!d"d#           | j                            d$t          j
        d%d&d'           | j                            d(t
          d)d*           d S )+Nz-az--attattwidthzAttribute to be interpolated.)typedestdefaulthelpz-oz--att-other	att_otherz#Other attribute (for a limited UI).)r   r   r   z-tz--att-other-typeatt_other_typezThe other attribute type.z-wz--att-other-whereatt_other_wheretagz-That is a tag attribute or a style attribute?z-sz--start-val	start_valz#F00zInitial interpolation value.z-ez	--end-valend_valz#00FzEnd interpolation value.z-uz--unitunitnonezValues unit.z--zsortzsortFz&use z-order instead of selection orderz--tabtabz'The selected UI-tab when OK was pressed)superr	   __init__
arg_parseradd_argumentstr	arg_classr   r   inkexBoolean)self	__class__s    ./usr/share/inkscape/extensions/interp_att_g.pyr   zInterpAttG.__init__$   s   j$((***$$0 	% 	
 	
 	
 	$$6 	% 	
 	
 	
 	$$!24E FGG!, 	% 	
 	
 	
 	$$"@ 	% 	
 	
 	
 	$$/ 	% 	
 	
 	
 	$$+ 	% 	
 	
 	
 	$$(66 	% 	
 	
 	
 	$$9 	% 	
 	
 	
 	$$:	 	% 	
 	
 	
 	
 	
    c                    | j         j        sg S t          | j         j                  dk    rt| j        j        r=t          | j         j                                                                                  S t          | j         j                                                  S | j         j                            t          j
                                                  }t          |          pg S )z%Returns a list of elements to work on   )svg	selectionlenoptionsr   listrendering_ordervaluesfilterr!   Groupfirst)r#   nodes     r%   get_elementszInterpAttG.get_elementse   s    x! 	Itx!""Q&&|! KDH.>>@@GGIIJJJ*1133444 x!((55;;==DzzRr&   c                    t          j                    }t          j                    }| j        j                            dd          }| j        j                            dd          }| j        j        dk    r|| j        j        z  }|| j        j        z  }|                     |||           |                     |||           ||fS )zJCreate dummy nodes to use the interpolation classes defined in inkex.tween,.r   )r!   PathElementr,   r   replacer   r   apply_value)r#   pathpat1pat2start_value	end_values         r%   create_dummy_nodeszInterpAttG.create_dummy_nodest   s     "" ""l,44S#>>L(00c::	<&&4<,,K**It[111tY///Tzr&   c                 >   |                     d          r|dd         }|| j        |<   dS |                     d          rt          |          s5t          j        t          d                              ||                    |dk    r| j                            |d           dS |dk    r| j                            d|           dS |d	k    r| j        	                    |           dS dS |d
k    r| xj        |z  c_        dS | 
                    ||           dS )zApplies a value to a given node. If path starts with "transform/" or "style/", the
        value is applied to either transform or style.zstyle/   Nz
transform/z Unable to set attribute {} to {}ztransform/trans-xr   ztransform/trans-yztransform/scale	transform)
startswithstyler   r!   AbortExtension_formatrC   add_translate	add_scaleset)r3   r;   valueatt_names       r%   r:   zInterpAttG.apply_value   sK    ??8$$ 	"ABBxH#(DJx   __\** 	"U## *899@@uMM   ***,,UA66666,,,,,Q66666***((///// +*[  NNe#NNNNHHT5!!!!!r&   c                   
 d }| j         j        dk    rs| j         j        !t          j        t          d                    | j         j        dk    r| j         j        }n| j         j        dz   | j         j        z   }| j         j        }n=| j         j        }| j         j        dk    s| j         j        dk    rt          j        j	        }| 
                    |          \  }}|                    d          rd}	 t          j        |||d           }n#  t          j        ||||          }Y nxY w|                                 

s!t          j        t          d                    
fd	t          t!          
                    D             }t#          |
          D ]6\  }}|                    |          }	t&                              |||	           7d
S )Notherz?You selected 'Other'. Please enter an attribute to interpolate.r   /heightr   rC   z$There is no selection to interpolatec                 @    g | ]}d t                    dz
  z  |z  S )g      ?r(   )r+   ).0i
collections     r%   
<listcomp>z%InterpAttG.effect.<locals>.<listcomp>   s.    QQQQJ!+,q0QQQr&   T)r,   r   r   r!   rF   rG   r   r   tweenUnitValueInterpolatorr@   rD   r   create_from_attributer4   ranger+   zipinterpolater	   r:   )r#   methodr;   path1path2interpolatorstepstimer3   	new_valuerU   s             @r%   effectzInterpAttG.effect   s   <w&&|%-*WXX   |+u44|-|3c9DL<RR\0FF<#D|8++t|/?7/J/J:..t44u??;'' 	D		0FudD LL	0FudF LLL &&((
 	R&q)O'P'PQQQQQQQ%J:P:PQQQeZ00 	: 	:JD$$0066I""4y9999ts   4D D')__name__
__module____qualname____doc__r   r4   r@   staticmethodr:   rd   __classcell__)r$   s   @r%   r	   r	      s         
?
 ?
 ?
 ?
 ?
B        " " \",( ( ( ( ( ( (r&   r	   __main__)rh   r!   inkex.localizationr   rG   inkex.tweenr   r   r   inkex.utilsr   EffectExtensionr	   re   run r&   r%   <module>rr      s   (   1 1 1 1 1 1 S S S S S S S S S S ! ! ! ! ! !c c c c c& c c cL zJLL r&   