3
6Ad]V- ã               @   s´   d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
 ddlmZmZmZmZ ddlmZ ddlmZ dd	lmZ ejd Zd
d„ Zdd„ ZG dd„ dƒZdS )zOThis module generates the tvtk (Traited VTK) wrapper classes for
VTK classes.

é    )Úprint_functionN)Úchainé   )Úget_tvtk_nameÚcamel2enthoughtÚis_version_58Úvtk_major_version)Ú
vtk_parser)Úindenter)Úspecial_genc       	      K   s|  dj dd„ |jƒ D ƒƒ}t| ƒ}tdtdi}tdk r<d|t< ||krV|| t| ƒ|fS |tkrz| dkrjd	} d
dj| ƒ|fS tdk r¦|t	kr¦| dkr–d	} ddj| ƒ|fS |t
tfk�rRt| ƒf}tdd„ | D ƒƒ}t|ƒdkræ|jƒ jnd}|dk�rtjjdƒ�rd}n|dk�rd}t| ƒ}|�r,|d7 }|dj||| td|ƒd�7 }dd	|fS |tk�rjdt| ƒ|fS tdj|ƒƒ‚dS )a   Return the appropriate trait type, reformatted string and
    the associated traits meta data for a given `value`

    If a sequence is given, traits.Array is returned instead of
    traits.Tuple or traits.List

    Parameters
    ----------
    value
       can be anything

    kwargs : dict
       keyword arguments for the trait definition

    Returns
    -------
    tuple : (str, str, str)
       (trait_type, value, keyword_arguments)

    Raises
    ------
    TypeError
        if this function cannot find an appropriate Trait type for `value`

    Example
    -------
    >>> get_trait_def([100., 200.], enter_set=True, auto_set=False)
    ('traits.Array', '', 'auto_set=False, enter_set=True, shape=(2,), dtype=float, value=[100.0, 200.0], cols=2')
    >>> get_trait_def(100, enter_set=True, auto_set=False)
    ('traits.Int', '100', 'auto_set=False, enter_set=True')
    >>> get_trait_def(long(100), enter_set=True, auto_set=False)  # Python 2
    ('traits.Long', '100', 'auto_set=False, enter_set=True')
    >>> get_trait_def(u'something', enter_set=True, auto_set=False)
    ('traits.Unicode', "u'something'", 'auto_set=False, enter_set=True')
    >>> get_trait_def(True, enter_set=True, auto_set=False)
    ('traits.Bool', 'True', 'auto_set=False, enter_set=True')
    z, c             s   s   | ]\}}d j ||ƒV  qdS )z{0}={1}N)Úformat)Ú.0ÚkeyÚvalue© r   úw/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.6/site-packages/mayavi-4.7.1-py3.6-linux-x86_64.egg/tvtk/wrapper_gen.pyú	<genexpr>F   s   z get_trait_def.<locals>.<genexpr>z
traits.Intztraits.Floaté   ztraits.Longú Ú ztraits.Stringz{!r}ztraits.Unicodec             s   s   | ]}t |ƒV  qd S )N)Útype)r   Úelementr   r   r   r   a   s    r   NÚintÚwinÚint64Úlongz<shape={shape}, dtype="{dtype}", value={value!r}, cols={cols})ÚshapeÚdtyper   Úcolsztraits.Arrayztraits.BoolzCould not understand type: {})ÚjoinÚitemsr   r   ÚfloatÚPY_VERr   Ústrr   ÚunicodeÚtupleÚlistÚlenÚsetÚpopÚ__name__ÚsysÚplatformÚ
startswithÚminÚboolÚ	TypeError)	r   ÚkwargsZkwargs_codeÚtype_Z
number_mapr   Údtypesr   r   r   r   r   Úget_trait_def   sF    '




r4   c       	      C   s   g }t jj| ƒ}|jt jj|ƒƒ xT|D ]L}|d dkr:q(t|d ƒdkrb|jttj|d ƒƒƒ |jt|d ƒƒ q(W ddddœ}xv|D ]j}ytt	|ƒƒdk}W n t
k
r¸   wŠY nX |rŠ|d |krŠ||d  }t|ƒdkrð|ft|ƒ S |S qŠW |S dS )a  Patch the initial default value for an attribute of
    a VTK class that does not initialise it properly.

    Parameters
    ----------
    vtk_get_meth : Method for getting the position attribute

    vtk_set_meth : Method for setting the position attribute

    default : initial default value

    Returns
    -------
    default
       If patching fails, the initial default is returned

    Examples
    --------
    >>> import vtk
    >>> vtk.vtkVersion.GetVTKVersion()
    '6.3.0'
    >>> obj = vtk.vtkXOpenGLRenderWindow()
    >>> obj.GetPosition()
    '_000000000351c458_p_void'

    >>> patch_default(vtk.vtkXOpenGLRenderWindow.GetPosition,
                      vtk.vtkXOpenGLRenderWindow.SetPosition,
                      '_000000000351c458_p_void')
    (0, 0)
    r   Nr   g        r   )r   r!   Ústring)r	   ÚVTKMethodParserÚget_method_signatureÚextendr'   Úappendr%   r   Úfrom_iterabler(   r0   )	Úvtk_get_methÚvtk_set_methÚdefaultZarg_formatsZall_sigsÚsigZdefault_mappingsZ
arg_formatZall_same_typer   r   r   Úpatch_default{   s0    $

r?   c               @   sÆ  e Zd Z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dd„ Zdd„ Zdsdd„Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zdtd)d*„Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zdud6d7„Zd8d9„ Zdvd:d;„Zdwd<d=„Z d>d?„ Z!d@dA„ Z"dxdydzd{d|d}d~dd€d�d‚dƒd„dPœZ#e$dQdR„ ƒZ%e$dSdT„ ƒZ&e$dUdV„ ƒZ'dWdX„ Z(dYdZ„ Z)d[d\„ Z*d]d^„ Z+d_d`„ Z,dadb„ Z-dcdd„ Z.dedf„ Z/dgdh„ Z0didj„ Z1dkdl„ Z2dmdn„ Z3dodp„ Z4dqdr„ Z5d5S )…ÚWrapperGeneratorz:Generates the wrapper code for all the TVTK classes.

    c             C   s0   t jƒ | _tjƒ | _tj| jƒ| _t j	ƒ | _
d S )N)r
   ZIndentÚindentr	   r6   Úparserr   ZSpecialGeneratorÚspecialZVTKDocMassagerÚdm)Úselfr   r   r   Ú__init__Ô   s    

zWrapperGenerator.__init__c             C   s
   | j jƒ S )z Returns the parser's class tree.)rB   Úget_tree)rE   r   r   r   rG   Þ   s    zWrapperGenerator.get_treec             C   sJ   | j jƒ  | j||ƒ | j||ƒ | j||ƒ | jj||ƒ |jdƒ dS )a1  Generates the code for the given node in the parse tree
        along with an opened file-like object.

        Parameters
        ----------

        - node

          A node in the ClassTree.

        - out :  file-like object.

          Must support a `write` method.  Code is written to it.

        Ú
N)rA   ÚresetÚ_write_prelimsÚ_gen_class_initÚ_gen_methodsrC   Úgenerate_codeÚwrite)rE   ÚnodeÚoutr   r   r   rM   â   s    
zWrapperGenerator.generate_codec             C   s   d}|j | jj|ƒƒ dS )z}Write preliminary information given the node in the class
        tree, `node`, and output file-like object, `out`.

        a�  
        # Automatically generated code: EDIT AT YOUR OWN RISK
        from traits import api as traits
        from traitsui.item import Item, spring
        from traitsui.group import HGroup
        from traitsui.view import View

        from tvtk import vtk_module as vtk
        from tvtk import tvtk_base
        from tvtk.tvtk_base_handler import TVTKBaseHandler
        from tvtk import messenger
        from tvtk.tvtk_base import deref_vtk
        from tvtk import array_handler
        from tvtk.array_handler import deref_array
        from tvtk.tvtk_classes.tvtk_helper import wrap_vtk


        def InstanceEditor(*args, **kw):
            from traitsui.editors.api import InstanceEditor as Editor
            return Editor(view_name="handler.view")

        try:
            long
        except NameError:
            # Silly workaround for Python3.
            long = int

        inf = float('inf')

        N)rN   rA   r   )rE   rO   rP   Zprelimr   r   r   rJ     s    "zWrapperGenerator._write_prelimsc             C   s  | j }| jƒ j|jƒ}|j}| j|ƒ}|jdks:|jdkr@d}nD| j|jƒd }|dkr„t|ƒ}dt	ƒ  }	|j
|j|	ƒƒ |j
dƒ dt	ƒ  }
|j
|j|
ƒƒ | jj|j||ƒ |jƒ  dt	ƒ  }|j
|j|ƒƒ d	d
d„ |jƒ D ƒk�rdt	ƒ  }|j
|j|ƒƒ d S )Nr   ÚvtkObjectBaseztvtk_base.TVTKBaseÚobjectz:from tvtk.tvtk_classes.%(base_fname)s import %(base_name)sz

z6
        class %(class_name)s(%(base_name)s):
        z¤
        def __init__(self, obj=None, update=True, **traits):
            tvtk_base.TVTKBase.__init__(self, vtk.%(vtk_class_name)s, obj, update, **traits)

        Úvtk3DWidgetc             S   s   g | ]
}|j ‘qS r   )Úname)r   Úxr   r   r   ú
<listcomp>L  s    z4WrapperGenerator._gen_class_init.<locals>.<listcomp>az  
            def setup_observers(self):
                """Setup the observers for the object."""
                super(%(class_name)s, self).setup_observers()
                tvtk_base._object_cache.setup_observers(self._vtk_obj,
                                              'EndInteractionEvent',
                                              self.update_traits)
            )rA   rG   Ú	get_classrT   r*   Ú_get_class_nameÚlevelÚ	__bases__r   ÚlocalsrN   r   rD   Zwrite_class_docÚ__doc__ÚincrÚget_ancestors)rE   rO   rP   rA   ÚklassZvtk_class_nameÚ
class_nameÚ	base_nameZ
base_fnameÚ_impZcdefÚdeclr   r   r   rK   *  s*    






z WrapperGenerator._gen_class_initc             C   s  | j ƒ j|jƒ}| jj|ƒ |jdkrH| j}|jjdƒ |jj	ddgƒ | j
||ƒ\}}| j||ƒ}| j||ƒ\}}	|	j|ƒ | j||ƒ | j||ƒ ||||	dœ}
|jdkrî|jd jdkrî|jd j}x"|
jƒ D ]}|
| j|| ƒ qÔW |
|_i }x*|
d |
d	 |
d
 fD ]}|j|ƒ �qW tjtt|jƒ ƒƒƒ}dd|  }|j| jj|ƒƒ tjtt|
d ƒƒƒ}dd|  }|j| jj|ƒƒ tj|
ƒ}|d |d	 |d
   }}}dd„ }||ddgƒ t|jƒ}d| }t|jƒ ƒ}t|jƒ ƒ}t|jƒ ƒ}tjd|| |  ƒ}dd|  }|j| jj|ƒƒ d}|j| jj|ƒƒ | jj ƒ  d}|j| jj|ƒƒ | jj ƒ  d| }|j| jj|ƒƒ | jj!ƒ  d}|j| jj|ƒƒ | jj ƒ  d}d| }dd||f  }|j| jj|ƒƒ | jj!ƒ  d}|j| jj|ƒƒ | jj ƒ  ||dgƒ ||d d!d"d#d$d%gƒ t|jƒ ƒ}t|jƒ ƒ}t|jƒ ƒ}tjd&|||f ƒ}d'd(||f  }|j| jj|ƒƒ | jj!ƒ  d)}|j| jj|ƒƒ | jj ƒ  d2}d4}d/||f }d0d1||f  }|j| jj|ƒƒ | jj!ƒ  | jj!ƒ  d S )5NÚ	vtkCameraÚRollÚGetRollÚSetRoll)ÚtoggleÚstateÚget_setÚallow_update_failurer   rR   rh   ri   rj   z
_updateable_traits_ = \z
%s

rk   z
_allow_update_failure_ = \c             S   s2   x,|D ]$}y
| |= W q t k
r(   Y qX qW d S )N)ÚKeyError)ÚdÚkeysr   r   r   r   Ú_safe_remove¦  s
    

z3WrapperGenerator._gen_methods.<locals>._safe_removeZreference_countÚprogresszEdit %s propertiesz(%s)z
_full_traitnames_list_ = \z4
def trait_view(self, name=None, view_element=None):zb
if view_element is not None or name not in (None, '', 'traits_view', 'full_traits_view', 'view'):z6
return super(%s, self).trait_view(name, view_element)z
if name == 'full_traits_view':z2Item("handler._full_traits_list",show_label=False)z
View((%s),z
full_traits_view = \z{
%s
title='%s', scrollable=True, resizable=True,
handler=TVTKBaseHandler,
buttons=['OK', 'Cancel'])
return full_traits_viewz
elif name == 'view':Zprogress_textZabort_executeZrelease_data_flagZdragableZpickableÚdebugZglobal_warning_displayzView((%s, %s, %s),z	
view = \zo
%s
title='%s', scrollable=True, resizable=True,
handler=TVTKBaseHandler,
buttons=['OK', 'Cancel'])
return viewz$
elif name in (None, 'traits_view'):z$HGroup(spring, "handler.view_type", zshow_border=True)z
Item("handler.info.object", z3editor = InstanceEditor(view_name="handler.view"), z#style = "custom", show_label=False)zView((%s, %s),z
traits_view = \zx
%s
title='%s', scrollable=True, resizable=True,
handler=TVTKBaseHandler,
buttons=['OK', 'Cancel'])
return traits_view

z5HGroup(spring, "handler.view_type", show_border=True)zP
Item("handler.info.object", editor = InstanceEditor(view_name="handler.view"), zs
Item("handler.info.object", editor = InstanceEditor(view_name="handler.view"), style = "custom", show_label=False))"rG   rW   rT   rB   Úparser*   Úget_set_methsr)   Úother_methsr8   Ú_gen_toggle_methodsÚ_gen_state_methodsÚ_gen_get_set_methodsÚupdateÚ_gen_get_methodsÚ_gen_other_methodsrY   ÚparentsÚdatarn   ÚtextwrapÚfillÚreprr%   r    rN   rA   r   ÚcopyÚdeepcopyr   Úsortedr]   Údecr)rE   rO   rP   r_   Úprh   Ztoggle_allow_failureri   rj   rk   r|   ÚpdÚiÚutÚjunkÚcoderm   ro   r`   ÚtitleZt_gZs_gZgs_gZitem_contentsZviewtype_contentsZview_contentsr   r   r   rL   Y  s²    













  
zWrapperGenerator._gen_methodsc             C   s�   ddddœ}|j |krŒ| jƒ j||j  ƒ}|j}d}x<|D ]4}|| }	|| j|	ƒ x|	D ]}
|d|
 7 }qZW q:W |d7 }|j| jj|ƒƒ dS )	zaThis method generates delegates for specific classes.  It
        modifies the n_data dictionary.ÚvtkPropertyÚvtkProperty2DÚvtkVolumeProperty)ÚvtkActorÚ
vtkActor2DÚ	vtkVolumer   z%%s = tvtk_base.vtk_property_delegate
rH   N)rT   rG   Zget_noder|   rx   rN   rA   r   )rE   rO   Zn_datarP   Z	prop_nameZ	prop_nodeZ	prop_datar‰   r   Úpropsr„   r   r   r   Ú_generate_delegates  s    


z$WrapperGenerator._generate_delegatesc             C   sö   | j jƒ }i }tƒ }xØ|D ]Ð}| j|ƒ}| j||ƒrn| j||ƒ\}}	|sP||= n|	r^|j|ƒ | j|||ƒ qd| ||< d}
|| rŠd}
yt|d| ƒ}W n8 t	k
rÔ   t|d| ƒ}| j
|||
|ddd� Y qX | j
|||
|dd� qW ||fS )NÚGetztvtk_base.false_bool_traitztvtk_base.true_bool_traitÚSetT)ÚmappedÚbroken_bool)r•   )rB   Úget_toggle_methodsr(   Ú_reform_nameÚ_is_specialÚ _get_special_updateable_failableÚaddÚ_write_special_traitÚgetattrÚAttributeErrorÚ_write_trait)rE   r_   rP   ÚmethsÚupdateable_traitsrk   ÚmrT   Ú
updateableÚcan_failÚt_defr<   r;   r   r   r   ru     s6    



z$WrapperGenerator._gen_toggle_methodsc             C   s`  | j }| j}|jƒ }i }�x@|D �]6}| j|ƒ}d| ||< i }	d}
x2|| D ]&\}}||	| j|ƒ< t|tjƒrNd}
qNW |jdkrŽ|dkrŽd}
|jdkr¤|dkr¤d}
|jdkrº|d	krºd}
|jd
krÐ|dkrÐd}
|jdkræ|dkræd}
t|d| ƒsød}
|
dk�r|d)k�rd}
d }|
dk�r8|jdk�r8|dk�r8d}|
dk�rf|jdk�rf|dk�rft	t
ddƒƒ}|
dk�rŠ|jdk�rŠ|dk�rŠd}|
dk�r®|jdk�r®|dk�r®d*}tjdk�rÞ|
dk�rÞ|jdk�rÞ|d k�rÞd}|
�s,| j|| d d ƒ}|d k�rd!tƒ  }nt|d"ƒ�r,t|ƒdd+… }t|d| ƒ�s@d}
|
dk�rX|d,k�rXd}
d }|
dk�r€|jdk�r€|dk�r€d}|
dk�r®|jdk�r®|dk�r®t	t
ddƒƒ}|
dk�rÒ|jdk�rÒ|dk�rÒd}|
dk�rö|jdk�rö|dk�röd-}tjdk�r&|
dk�r&|jdk�r&|d k�r&d}|
�s®| j|| d d ƒ}|d k�rXd!tƒ  }n2t|d"ƒ�r€t|ƒdd.… }d#tƒ  }n
d#tƒ  }t|d| ƒ}| j||||d$d%� q ||= t|d| ƒ}| j|||ƒ |
dk�röt|d| ƒ}| j|||ƒ x`|| dd … D ]L\}}| j|ƒ}t|d&||f ƒ}d'||f }d(tƒ  }| j||||ƒ �qW q W |S )/Nr“   r   r   ÚvtkCellQualityZQualityMeasureÚvtkRenderViewZInteractionModeÚvtkMatrixMathFilterZ	OperationÚvtkResliceImageViewerZResliceModeZaxis_alignedÚvtkThresholdZPointsDataTypeé
   r”   ÚDataScalarTypeÚOutputScalarTypeÚUpdateExtenté   ÚvtkGenericEnSightReaderZ	ByteOrderÚvtkImageDataÚ
ScalarTypeé   ÚvtkImagePlaneWidgetZPlaneOrientationr   ZAttributeModeÚdarwinÚvtkRenderWindowZ
StereoTypezftraits.Trait('%(default)s',
                                       tvtk_base.TraitRevPrefixMap(%(d)s))Ú__iter__zutraits.Trait('%(default)s', %(extra_val)s,
                                       tvtk_base.TraitRevPrefixMap(%(d)s))T)r•   z	Set%sTo%szdef set_%s_to_%s(self):z"self._vtk_obj.Set%(m)sTo%(key)s()
)r¬   r­   r®   éÿÿÿÿr¸   )r¬   r­   r®   r¸   r¸   )rB   rA   Zget_state_methodsr˜   Ú
isinstanceÚvtkrQ   r*   Úhasattrr&   Úranger+   r,   r[   r#   r�   rŸ   Ú_write_tvtk_methodÚ_write_generic_method)rE   r_   rP   rB   rA   r    r¡   r¢   rT   rm   Zvtk_valr   ÚvalZ	extra_valr=   r¥   r<   Úvtk_methrU   rc   Úbodyr   r   r   rv   G  sÔ    
























z#WrapperGenerator._gen_state_methodsc             C   sø  | j }|jƒ }i }tƒ }�xÔ|D �]Ê}| j|ƒ}d| ||< t|d| ƒ}	t|d| ƒ}
|j|
ƒ}|j|	ƒ}| j||ƒr²| j||ƒ\}}|s”||= n|r¢|j|ƒ | j	|||ƒ q ||  rè|d d rè| j
|||
|ƒ | j
|||	ƒ q || �r || \}}nt|
|	d ƒd  }}|�r(| j|||ƒ q t|tƒ�r’|jdƒ�r’y| j|||ƒ W n6 tk
�rˆ } ztdt|ƒƒ d }W Y d d }~X n
X ||= q |d k�sªt|tjƒ�rÔt|ƒdk�rÄd gd fg}t|ƒdk�rîd gd gfg}d gd fg}nB|d d d k�s|d d dk�r0t|d ƒ|d< d g|d d< |d d d dk�rr|d d d k�rrd	}| j||||	d
d� n`|d d d k�r¬t|d d ƒdk�r¬| j|||
|	ƒ n | j
|||
|ƒ | j
|||	|ƒ ||= q t|tƒ�rVt|ƒdk�rV|jdƒd k�s|jdƒd!k�s|jdƒd"k�rVd}|jd#k�r2d}dj|d�}| j||||	d
|d� q yt|dd
d�\}}}W nF tk
�r´   td|j dd� td| ƒ td| ƒ ||= Y q X |�rÌdj|||ƒ}ndj||ƒ}| j||||	d
d� q W ||fS )$Nr“   r”   r   r   Z_p_voidzWarning:r   r5   zGtraits.Trait(None, None, traits.String(enter_set=True, auto_set=False))F)r•   r   ÚcolorZ
bond_colorZ
backgroundÚFalser‹   ÚvtkLightÚTruez$tvtk_base.vtk_color_trait({default}))r=   )r•   Úforce_updateT)Z	enter_setZauto_setz%s:ú )ÚendzIgnoring method: Get/Set%szdefault: %s, range: Nonez{0}({1}, {2})z{0}({1})r¸   r¸   r¸   )r‹   rÄ   )rB   Úget_get_set_methodsr(   r˜   r�   r7   r™   rš   r›   rœ   r½   r?   Ú_write_trait_with_ranger¹   r#   ÚendswithÚ#_write_trait_with_default_undefinedr0   Úprintrº   rQ   r'   r&   rŸ   Ú_write_propertyr%   Úfindr*   r   r4   )rE   r_   rP   rB   r    r¡   rk   Úvtk_attr_namerT   r<   r;   Úget_sigÚset_sigr£   r¤   r=   ÚrngÚ	exceptionr¥   ÚforceÚ
trait_typer1   r   r   r   rw   Ò  s¨    






$(
(
 z%WrapperGenerator._gen_get_set_methodsc             C   s  | j }|jƒ }xú|D ]ò}t||ƒ}|dkr<| j||dd� q|dkrR| j||ƒ q|dkrh| j||ƒ q| j|dd … ƒ}|j|ƒ}d}	d}
t|ƒdkr²|d	 d d kr²d}	d}
n,t|ƒdkrÞx|D ]}|d d krÄd}	P qÄW |	rò| j	|||d ƒ |
r| j
||||ƒ qW d S )
NÚ	GetOutputF)r(   ÚGetInputÚGetOutputPortr   Tr   r   )rB   Úget_get_methodsr�   Ú_write_get_output_methodÚ_write_pure_get_input_methodÚ"_write_pure_get_output_port_methodr˜   r7   r'   rÎ   r½   )rE   r_   rP   rB   r    r¢   r;   rT   r>   Z
write_propZwrite_getterr†   r   r   r   ry   …  s4    



z!WrapperGenerator._gen_get_methodsc             C   s8   | j }|jƒ }x$|D ]}t||ƒ}| j|||ƒ qW d S )N)rB   Úget_other_methodsr�   r½   )rE   r_   rP   rB   r    r¢   rÀ   r   r   r   rz   §  s
    

z#WrapperGenerator._gen_other_methodsFc             C   s>   |dkrdS |j ƒ r|r|S t|ƒ}tj|ƒr6|d S |S dS )z|Converts a VTK name to an Enthought style one.  If `method`
        is True it does not touch names that are all upper case.ZTeXZtexÚ_N)Úisupperr   ÚkeywordÚ	iskeyword)rE   rT   ÚmethodÚresr   r   r   r˜   ³  s    
zWrapperGenerator._reform_namec             C   s0   g }t |ƒttfkr"dd„ |D ƒS t|jƒS dS )z5Returns renamed VTK classes as per TVTK naming style.c             S   s   g | ]}t |jƒ‘qS r   )r   r*   )r   rU   r   r   r   rV   É  s   z4WrapperGenerator._get_class_name.<locals>.<listcomp>N)r   r&   r%   r   r*   )rE   ZklassesÚretr   r   r   rX   Å  s
    z WrapperGenerator._get_class_namec             C   sL   dddg}t |ƒ}|jdƒd	krDx|D ]}|j|ƒd
kr&dS q&W dS dS dS )aE  Given `val` which is extracted from the method call
        signature, this returns the type of the value.  Right now this
        is in ['vtk', 'array', 'basic'].  'vtk' refers to a VTK type,
        'array' to a vtkDataArray/vtkCellArray/vtkPoints/vtkIdList,
        'basic' refers to a non-VTK, basic Python type.
        ÚArrayÚ	vtkPointsÚ	vtkIdListrº   r   ÚarrayÚbasicNr¸   r¸   )r   rÏ   )rE   r¿   Z
_arr_typesÚsr†   r   r   r   Ú
_find_typeÎ  s    

zWrapperGenerator._find_typec             C   s8   t |ƒdkr |d d dkr dS dd„ |D ƒ}| j|ƒS )zçGiven a method signature `sig`, this finds the argument
        types.  It uses the `_find_type` method to obtain its result.
        If no arguments are present in *all* of the signatures, then
        it returns `None`.

        r   r   Nc             S   s   g | ]}|d  ‘qS )r   r   )r   rë   r   r   r   rV   é  s    z3WrapperGenerator._find_arg_type.<locals>.<listcomp>)r'   rì   )rE   r>   Úargsr   r   r   Ú_find_arg_typeß  s
    zWrapperGenerator._find_arg_typec             C   s   dd„ |D ƒ}| j |ƒS )zMGiven a method signature `sig`, this finds the return
        types.
        c             S   s   g | ]}|d  ‘qS )r   r   )r   rë   r   r   r   rV   ð  s    z6WrapperGenerator._find_return_type.<locals>.<listcomp>)rì   )rE   r>   Zretsr   r   r   Ú_find_return_typeì  s    z"WrapperGenerator._find_return_typec             C   s   | j |ƒ| j|ƒfS )z¹Given a method signature `sig`, this finds the return and
        argument types using.  This is a convenience type and returns
        a tuple containing (ret_type, arg_type).
        )rï   rî   )rE   r>   r   r   r   Ú_find_sig_typeó  s    zWrapperGenerator._find_sig_typec             C   s   dd„ |D ƒS )zcReturns a list of argument signatures from the signature
        information for a method.
        c             S   s   g | ]}|d  ‘qS )r   r   )r   rë   r   r   r   rV   þ  s    z8WrapperGenerator._find_array_arg_sig.<locals>.<listcomp>r   )rE   r>   r   r   r   Ú_find_array_arg_sigú  s    z$WrapperGenerator._find_array_arg_sigc             C   s®   t |dƒ}| jj|ƒ}d}|r*dtƒ  }n
dtƒ  }|j| jj|ƒƒ t|ƒdkr\d}d}	nd}d	}	| j||||	ƒ |rªd
}d}	|	d7 }	|	d7 }	t |dƒ}
| j|||
|	ƒ dS )a  Write the get_output method.  This method is special and
        needs special care.  `klass` is the class for which the method
        is being wrapped, `out` is the output file.  If `set` is True,
        a set_output method is also wrapped.  This defaults to False.
        r×   z9Output of this source, i.e. the result of `get_output()`.aÃ  
            def _get_output(self):
                return wrap_vtk(self._vtk_obj.GetOutput())

            def _set_output(self, obj):
                old_val = self._get_output()
                self._wrap_call(self._vtk_obj.SetOutput, deref_vtk(obj))
                self.trait_property_changed('output', old_val, obj)
            output = traits.Property(_get_output, _set_output,
                                     desc="%(doc)s")

            zÓ
            def _get_output(self):
                return wrap_vtk(self._vtk_obj.GetOutput())
            output = traits.Property(_get_output,
                                     desc="%(doc)s")

            r   zdef get_output(self):z*return wrap_vtk(self._vtk_obj.GetOutput())zdef get_output(self, idx=None):z´
            if idx is None:
                return wrap_vtk(self._vtk_obj.GetOutput())
            else:
                return wrap_vtk(self._vtk_obj.GetOutput(idx))
            zdef set_output(self, obj):zold_val = self._get_output()
z9self._wrap_call(self._vtk_obj.SetOutput, deref_vtk(obj))
z4self.trait_property_changed('output', old_val, obj)
Ú	SetOutputN)	r�   rB   r7   r[   rN   rA   r   r'   r¾   )rE   r_   rP   r(   r;   r>   ÚdocÚ	trait_defrc   rÁ   r<   r   r   r   rÛ     s*    


z)WrapperGenerator._write_get_output_methodc             C   s€   t |dƒ}t |dƒ}| jj|ƒ}t|ƒdkrld}dtƒ  }|j| jj|ƒƒ | j|||ƒ | j||||ƒ n| j	|d||ƒ dS )z±Write the set/get_source method.  This method needs special
        care.  `klass` is the class for which the method is being
        wrapped, `out` is the output file.
        Ú	GetSourceÚ	SetSourcer   zDThe first source of this object, i.e. the result of `get_source(0)`.aÄ  
            def _get_source(self):
                return wrap_vtk(self._vtk_obj.GetSource(0))

            def _set_source(self, obj):
                old_val = self._get_source()
                self._wrap_call(self._vtk_obj.SetSource, deref_vtk(obj))
                self.trait_property_changed('source', old_val, obj)
            source = traits.Property(_get_source, _set_source,
                                     desc="%(doc)s")

            ÚsourceN)
r�   rB   r7   r'   r[   rN   rA   r   r½   rÎ   )rE   r_   rP   r;   r<   rÒ   ró   rô   r   r   r   Ú_write_get_source_method=  s    


z)WrapperGenerator._write_get_source_methodc             C   sr   t |dƒ}dtƒ  }| j}|j|j|ƒƒ d}|j|j|ƒƒ |j}| jj|||ƒ |j|jdƒƒ |jdƒ dS )zÇHandle the GetOutputPort method so that it does not print
        unnecessary warning messages.  `klass` is the class for which
        the method is being wrapped, `out` is the output file.
        rÙ   zÑ
        def _get_output_port(self):
            if self._vtk_obj.GetNumberOfOutputPorts():
                return wrap_vtk(self._vtk_obj.GetOutputPort())
            else:
                return None
        z6output_port = traits.Property(_get_output_port, desc=\ú)rH   N)r�   r[   rA   rN   r   r\   rD   Úwrite_trait_doc)rE   r_   rP   r;   r¥   rA   ró   r   r   r   rÝ   [  s    

z3WrapperGenerator._write_pure_get_output_port_methodc             C   sf   t |dƒ}| jj|ƒ}t|ƒdkrRd}dtƒ  }|j| jj|ƒƒ | j|||ƒ n| j	|d|dƒ dS )z¼Write the get_input method when the class only has the
        getter and no setter.  `klass` is the class for which the
        method is being wrapped, `out` is the output file.
        rØ   r   zBThe first input of this object, i.e. the result of `get_input(0)`.aH  
            def _get_input(self):
                try:
                    return wrap_vtk(self._vtk_obj.GetInput(0))
                except TypeError:
                    return wrap_vtk(self._vtk_obj.GetInput())
            input = traits.Property(_get_input,
                                    desc="%(doc)s")

            ÚinputN)
r�   rB   r7   r'   r[   rN   rA   r   r½   rÎ   )rE   r_   rP   r;   rÑ   ró   rô   r   r   r   rÜ   r  s    


z-WrapperGenerator._write_pure_get_input_methodc             C   s€   t |dƒ}t |dƒ}| jj|ƒ}t|ƒdkrld}dtƒ  }|j| jj|ƒƒ | j|||ƒ | j||||ƒ n| j	|d||ƒ dS )z°Write the set/get_input method.  This method needs special
        care.  `klass` is the class for which the method is being
        wrapped, `out` is the output file.
        rØ   ÚSetInputr   zBThe first input of this object, i.e. the result of `get_input(0)`.a3  
            def _get_input(self):
                try:
                    return wrap_vtk(self._vtk_obj.GetInput(0))
                except TypeError:
                    return wrap_vtk(self._vtk_obj.GetInput())

            def _set_input(self, obj):
                old_val = self._get_input()
                self._wrap_call(self._vtk_obj.SetInput, deref_vtk(obj))
                self.trait_property_changed('input', old_val, obj)
            input = traits.Property(_get_input, _set_input,
                                    desc="%(doc)s")

            rû   N)
r�   rB   r7   r'   r[   rN   rA   r   r½   rÎ   )rE   r_   rP   r;   r<   rÒ   ró   rô   r   r   r   Ú_write_get_input_methodŒ  s    


z(WrapperGenerator._write_get_input_methodc             C   sT   t |dƒ}t |dƒ}d}dtƒ  }|j| jj|ƒƒ | j|||ƒ | j|||ƒ dS )zõWrite the set/get_input_connection method.  This method
        needs needs to be wrapped as a property and a method for
        convenience.  `klass` is the class for which the method is
        being wrapped, `out` is the output file.
        ÚGetInputConnectionÚSetInputConnectionz\The first input connection for this object, i.e. the result of `get_input_connection(0, 0)`.a£  
        def _get_input_connection(self):
            if self._vtk_obj.GetTotalNumberOfInputConnections():
                return wrap_vtk(self._vtk_obj.GetInputConnection(0, 0))
            else:
                return None

        def _set_input_connection(self, obj):
            old_val = self._get_input_connection()
            self._wrap_call(self._vtk_obj.SetInputConnection, deref_vtk(obj))
            self.trait_property_changed('input_connection', old_val, obj)
        input_connection = traits.Property(_get_input_connection,
                                           _set_input_connection,
                                           desc="%(doc)s")

        N)r�   r[   rN   rA   r   r½   )rE   r_   rP   r;   r<   ró   rô   r   r   r   Ú"_write_get_input_connection_method­  s    


z3WrapperGenerator._write_get_input_connection_methodNc             C   sl  |dkr| j j|ƒ}|dkr dS | j|ƒ\}}|j}| j|dd�}tj|ƒrT|d }|dk}	|dkol|jdk}
|dkrÆd| }d}|	rŽ|d7 }|dkr¤|d| 7 }n|d| 7 }|	r¼|d7 }|d7 }n’d| }|dk�rd}|	rè|d7 }|d| 7 }|	�r<|d7 }n8|dk�r4| j|ƒ}d||f }|
�r<|d7 }nd| }|dk�rP|d7 }n|d7 }| j||||ƒ dS ) a†  Write a generic tvtk_method to `out`.

        Parameters
        ----------

        - out : file like object

        - vtk_meth : VTK method

          The VTK method to wrap.  A docstring is extracted from
          this.

        - sig : Signature of vtk_method (default: None)

          If None, this is computed.  If not, the passed signature
          information is used.
        NT)rã   rß   ÚAddInputÚRemoveInputÚRemoveAllInputsÚSetInputByNumberÚInsertNextCellÚvtkCellArrayzdef %s(self):r   zold_val = self._get_input()
rº   ré   z#ret = wrap_vtk(self._vtk_obj.%s())
zret = self._vtk_obj.%s()
zAself.trait_property_changed('input', old_val, self._get_input())
zreturn ret

zdef %s(self, *args):zYmy_args = [deref_vtk(x) for x in args]
ret = self._wrap_call(self._vtk_obj.%s, *my_args)
zRmy_args = deref_array(args, %s)
ret = self._wrap_call(self._vtk_obj.%s, *my_args)
zself.update_traits()
z/ret = self._wrap_call(self._vtk_obj.%s, *args)
zreturn wrap_vtk(ret)
zreturn ret
)r  r  r  r  )r  )r  )rº   ré   )rº   ré   )	rB   r7   rð   r*   r˜   rá   râ   rñ   r¾   )rE   r_   rP   rÀ   r>   Úret_typeÚarg_typeÚ
vtk_m_namerT   Zmethod_affects_inputZmethod_needs_updaterc   rÁ   Úarr_sigr   r   r   r½   Ë  s`    
 










z#WrapperGenerator._write_tvtk_methodc             C   s€   t |ƒtkr|}n| jj|jƒ}| j}|j|j|ƒƒ |jƒ  |rZ|j|jd| d ƒƒ |j|j|ƒƒ |jdƒ |j	ƒ  dS )a‰  Write out a method given the declaration, `decl`, the VTK
        method, `vtk_doc_meth`, from which the docstring is to be
        extracted and the code body, `body`.  Each of these is set as
        per the current indentation level.  output is written to the
        `out` object.

        `vtk_doc_meth` could also be a string, in which case the
        string is used directly.

        z"""
rH   N)
r   r#   rD   Úget_method_docr\   rA   rN   r   r]   rƒ   )rE   rP   rc   Zvtk_doc_methrÁ   ró   rA   r   r   r   r¾   #  s    
z&WrapperGenerator._write_generic_methodc             C   s  d| }|j }	d}
|rd}
d}|dk	r.d| }|jdƒrJ|dd… d }n|d	7 }d
tƒ  }|r¨d}|	dd… dks|t|ƒ‚|	dd… d }|	dd… d }dtƒ  }n
dtƒ  }| j}|j|j|ƒƒ |j}| jj	|||ƒ |j|jdƒƒ |jdƒ |j|j|ƒƒ |jdƒ dS )a‡  Write out a complete trait definition to `out`.

        Parameters
        ----------
        - out : File like object.

        - t_name : `string`: Name of the trait.

        - t_def : `string` : Trait definition.

        - vtk_set_meth : VTK setter method.

        - mapped : `bool` : Specifies if the trait is mapped.

        - force_update : `string` or `None` : force_update argument.

        - broken_bool : `bool` (default: `False`)

          If `True` the bool method does not have a 'Set' method and
          must be handled specially.  In this case make sure that the
          vtk_set_meth points to the 'Get' method.

        z_%s_changedr   rß   Nz, %srù   r   z, desc=\z(desc=\z%(t_name)s = %(t_def)szCIf broken_bool is true, make sure vtk_set_meth is of form 'GetProp'r   r“   ÚOnÚOffaf  
            def %(changed)s(self, old_val, new_val):
                def _bool_change(val, obj=self._vtk_obj):
                    if val:
                        obj.%(vtk_on_name)s()
                    else:
                        obj.%(vtk_off_name)s()
                self._do_change(_bool_change, self.%(t_name)s%(map_str)s%(force_str)s)
            zÉ
            def %(changed)s(self, old_val, new_val):
                self._do_change(self._vtk_obj.%(vtk_m_name)s,
                                self.%(t_name)s%(map_str)s%(force_str)s)
            rH   r¸   )
r*   rË   r[   ÚAssertionErrorrA   rN   r   r\   rD   rú   )rE   rP   Út_namer¥   r<   r•   rÆ   r–   Úchangedr	  Zmap_strZ	force_strrô   ÚmsgZvtk_on_nameZvtk_off_nameZchanged_defrA   ró   r   r   r   rŸ   ;  s6    

	

zWrapperGenerator._write_traitc             C   st  | j }d| }|j}| jj|ƒ}	| j|	ƒ}
|
dkr>dtƒ  }n
dtƒ  }|j|j|ƒƒ |�rd| }|j}| jj|ƒ}	| j|	ƒ}|rÄ|dkršdtƒ  }n(|dkr¸| j	|	ƒ}dtƒ  }n
d	tƒ  }n<|dkrØd
tƒ  }n(|dkrö| j	|	ƒ}dtƒ  }n
dtƒ  }|j|j|ƒƒ dtƒ  }n
dtƒ  }dtƒ  }|j|j|ƒƒ |j
}| jj|||ƒ |j|jdƒƒ |jdƒ dS )a�  Writes out a traited property to `out` given the trait
        name, `t_name`, the VTK get method, `vtk_get_meth` an optional
        VTK set method for read-write traits as, `vtk_set_meth` plus a
        boolean value for `multi_arg`.  If `multi_arg` is True, the
        setter is treated as if it accepts a list of parameters.  If
        not the setter is treated as if it accepts a single parameter.
        z_get_%srº   ré   zq
            def %(getter)s(self):
                return wrap_vtk(self._vtk_obj.%(vtk_get_name)s())
            zg
            def %(getter)s(self):
                return self._vtk_obj.%(vtk_get_name)s()
            z_set_%sa„  
                    def %(setter)s(self, *args):
                        old_val = self.%(getter)s()
                        my_args = [deref_vtk(x) for x in args]
                        self._wrap_call(self._vtk_obj.%(vtk_set_name)s,
                                        *my_args)
                        self.trait_property_changed('%(t_name)s', old_val, args)
                    a†  
                    def %(setter)s(self, *args):
                        old_val = self.%(getter)s()
                        my_args = deref_array(args, %(arr_sig)s)
                        self._wrap_call(self._vtk_obj.%(vtk_set_name)s,
                                        *my_args)
                        self.trait_property_changed('%(t_name)s', old_val, args)
                    aB  
                    def %(setter)s(self, *args):
                        old_val = self.%(getter)s()
                        self._wrap_call(self._vtk_obj.%(vtk_set_name)s,
                                        *args)
                        self.trait_property_changed('%(t_name)s', old_val, args)
                    aH  
                    def %(setter)s(self, arg):
                        old_val = self.%(getter)s()
                        self._wrap_call(self._vtk_obj.%(vtk_set_name)s,
                                        deref_vtk(arg))
                        self.trait_property_changed('%(t_name)s', old_val, arg)
                    a„  
                    def %(setter)s(self, arg):
                        old_val = self.%(getter)s()
                        my_arg = deref_array([arg], %(arr_sig)s)
                        self._wrap_call(self._vtk_obj.%(vtk_set_name)s,
                                        my_arg[0])
                        self.trait_property_changed('%(t_name)s', old_val, arg)
                    a=  
                    def %(setter)s(self, arg):
                        old_val = self.%(getter)s()
                        self._wrap_call(self._vtk_obj.%(vtk_set_name)s,
                                        arg)
                        self.trait_property_changed('%(t_name)s', old_val, arg)
                    z.traits.Property(%(getter)s, %(setter)s, desc=\z"traits.Property(%(getter)s, desc=\z%(t_name)s = %(t_def)srù   rH   N)rº   ré   )rA   r*   rB   r7   rï   r[   rN   r   rî   rñ   r\   rD   rú   )rE   rP   r  r;   r<   Z	multi_argrA   ÚgetterZvtk_get_namer>   r  rô   ÚsetterZvtk_set_namer  r
  r¥   ró   r   r   r   rÎ   ‡  sH    	



	
	


z WrapperGenerator._write_propertyc             C   s²   | j |ƒ}t|d| ƒ}t|d| ƒ}t||d ƒ}|r˜t|ƒttfkr`djdjdt|ƒ ƒƒ}nd}t	|ƒ\}	}
}dj||	|d�}| j
||||dd	� nd
}t|j|j|ƒƒ‚d S )Nr“   r”   z({})z, útraits.UndefinedzOtraits.Trait({default}, {trait_type}({kwargs}), enter_set=True, auto_set=False))r=   rÖ   r1   F)r•   z+We cannot determine the trait type of {}.{})r  )r˜   r�   r?   r   r%   r&   r   r   r'   r4   rŸ   r0   r*   )rE   r_   rP   rÐ   rT   r;   r<   Zvalue_for_typer=   rÖ   rß   r1   r¥   Úmessager   r   r   rÌ   í  s"    
z4WrapperGenerator._write_trait_with_default_undefinedc       	      C   sà   | j jƒ | \}}||d k r:|d | dk r:||d f}||d krb||d  dk rb|d |f}||d k sz||d kr–dtƒ  }|d d
… d }ndtƒ  }|d d… d }| j|ƒ}t|d| ƒ}| j||||dd	� d S )Nr   r¯   r   z:traits.Trait(%(default)s, %(default)s, traits.Range%(rng)sz", enter_set=True, auto_set=False))z-traits.Trait(%(default)s, traits.Range%(rng)sr”   F)r•   r¸   r¸   )rB   rÉ   r[   r˜   r�   rŸ   )	rE   r_   rP   rÐ   r=   rÓ   r¥   rT   r<   r   r   r   rÊ     s     
z(WrapperGenerator._write_trait_with_rangeÚ_write_any_outputÚ_write_any_sourceÚ_write_any_scalar_typeÚ_write_any_inputÚ_write_any_input_connectionTÚ_write_any_something_file_nameÚ _write_any_something_file_prefixÚ _write_image_reader2_header_sizeÚ)_write_hardware_selector_prop_color_valueÚ._write_axes_transform_representation_toleranceÚ_write_span_space_resolutionÚ+_write_smart_volume_mapper_vector_componentÚ0_write_hyper_tree_grid_cell_centers_vertex_cells)z[a-zA-Z0-9]+\.Output$z[a-zA-Z0-9]+\.Source$z[a-zA-Z0-9]+\.ScalarType$z[a-zA-Z0-9]+\.Input$z[a-zA-Z0-9]+\.InputConnection$z[a-zA-Z0-9\.]+FileName$z[a-zA-Z0-9\.]+FilePrefix$zvtkImageReader2.HeaderSize$z#vtkHardwareSelector.PropColorValue$z)vtkAxesTransformRepresentation.Tolerance$zvtkSpanSpace.Resolution$z%vtkSmartVolumeMapper.VectorComponent$z(vtkHyperTreeGridCellCenters.VertexCells$c             C   s<   dj |j|fƒ}x&| jjƒ D ]}tj||ƒr|S qW dS dS )aX   Return the key in `special_traits` that matches klass.vtk_attr_name
        using regular expression

        Parameters
        ----------
        klass : class
           VTK class

        vtk_attr_name : str
           VTK class attribute name

        Returns
        -------
        key
           key is None if nothing matches
        Ú.N)r   r*   Úspecial_traitsrn   ÚreÚmatch)Úclsr_   rÐ   Ú	full_nameZre_exprr   r   r   Ú_get_special_matched_keyq  s
    z)WrapperGenerator._get_special_matched_keyc             C   s<   | j ||ƒ}|dkr*d}t|j|j|ƒƒ‚| j| dd… S )aa   Return (updateable, failable) for the klass.vtk_attr_name

        Parameters
        ----------
        klass : class
           VTK class

        vtk_attr_name : str
           VTK class attribute name

        Raises
        ------
        ValueError
           if klass.vtk_attr_name does not match anything in
           `special_traits`
        Nz7{0}.{1} does not have a special method for get/set coder¯   )r)  Ú
ValueErrorr   r*   r$  )r'  r_   rÐ   r   r  r   r   r   rš   Š  s
    z1WrapperGenerator._get_special_updateable_failablec             C   s,   dj |j|fƒ}tjdj | jjƒ ƒ|ƒdk	S )a   Returns True if klass.vtk_attr_name matches anything
        in `special_traits`

        Parameters
        ----------
        klass : class
           VTK class

        vtk_attr_name : str
           VTK class attribute name

        Returns
        -------
        boolean
        r#  ú|N)r   r*   r%  r&  r$  rn   )r'  r_   rÐ   r(  r   r   r   r™   ¤  s    zWrapperGenerator._is_specialc             C   s2   | j ||ƒ}| j| \}}}t| |ƒ|||ƒ d S )N)r)  r$  r�   )rE   r_   rP   rÐ   r   rß   Úmethod_namer   r   r   rœ   ¹  s    z%WrapperGenerator._write_special_traitc             C   s   | j ||dd� d S )NT)r(   )rÛ   )rE   r_   rP   rÐ   r   r   r   r  ¾  s    z"WrapperGenerator._write_any_outputc             C   s   | j ||ƒ d S )N)rø   )rE   r_   rP   rÐ   r   r   r   r  Á  s    z"WrapperGenerator._write_any_sourcec             C   s   dS )z This method does nothing Nr   )rE   r_   rP   rÐ   r   r   r   r  Ä  s    z'WrapperGenerator._write_any_scalar_typec             C   s   | j ||ƒ d S )N)rý   )rE   r_   rP   rÐ   r   r   r   r  È  s    z!WrapperGenerator._write_any_inputc             C   s   | j ||ƒ d S )N)r   )rE   r_   rP   rÐ   r   r   r   r  Ë  s    z,WrapperGenerator._write_any_input_connectionc             C   s4   | j |ƒ}t|d| ƒ}d}| j||||dd� d S )Nr”   ztvtk_base.vtk_file_name("")F)r•   )r˜   r�   rŸ   )rE   r_   rP   rÐ   rT   r<   r¥   r   r   r   r  Î  s    
z/WrapperGenerator._write_any_something_file_namec             C   s4   | j |ƒ}t|d| ƒ}d}| j||||dd� d S )Nr”   ztvtk_base.vtk_file_prefix("")F)r•   )r˜   r�   rŸ   )rE   r_   rP   rÐ   rT   r<   r¥   r   r   r   r  Õ  s    
z1WrapperGenerator._write_any_something_file_prefixc       	      C   s|   |dkrt dƒ‚| jjƒ | \}}tdk r@t|ƒ}dj|d�}ndj|d�}| j|ƒ}t|d| ƒ}| j||||dd	� d S )
NZ
HeaderSizezDNot sure why you ask for me! I only deal with HeaderSize. Panicking.r   z6traits.Long({default}, enter_set=True, auto_set=False))r=   z5traits.Int({default}, enter_set=True, auto_set=False)r”   F)r•   )	ÚRuntimeErrorrB   rÉ   r"   r   r   r˜   r�   rŸ   )	rE   r_   rP   rÐ   r=   rß   r¥   rT   r<   r   r   r   r  Û  s    

z1WrapperGenerator._write_image_reader2_header_sizec             C   sF   |dkrt dƒ‚d}| j|ƒ}t|d| ƒ}| j||||ddd� d S )NZPropColorValuezHNot sure why you ask for me! I only deal with PropColorValue. Panicking.z*tvtk_base.vtk_color_trait((1.0, 1.0, 1.0))r”   FrÃ   )r•   rÆ   )r-  r˜   r�   rŸ   )rE   r_   rP   rÐ   r¥   rT   r<   r   r   r   r  ö  s    
z:WrapperGenerator._write_hardware_selector_prop_color_valuec       
      C   sz   |dkrt dƒ‚| jjƒ | \}}tƒ r<d}t|ƒ |d }dj||d�}| j|ƒ}t|d| ƒ}	| j||||	dd	� d S )
NZ	TolerancezCNot sure why you ask for me! I only deal with Tolerance. Panicking.zfvtkAxesTransformRepresentation: tolerance not updatable (VTK 5.8 bug - value not properly initialized)r   zJtraits.Trait({default}, traits.Range{rng}, enter_set=True, auto_set=False))r=   rÓ   r”   F)r•   )	r-  rB   rÉ   r   rÍ   r   r˜   r�   rŸ   )
rE   r_   rP   rÐ   r=   rÓ   r  r¥   rT   r<   r   r   r   r    s    
z?WrapperGenerator._write_axes_transform_representation_tolerancec       
      C   s|   |dkrt dƒ‚| jjƒ | \}}tdkr>d}t|ƒ |d }dj||d�}| j|ƒ}t|d| ƒ}	| j||||	d	d
� d S )NZVectorComponentzINot sure why you ask for me! I only deal with VectorComponent. Panicking.é   zbvtkSmartVolumeMapper: VectorComponent not updatable (VTK 8.x bug - value not properly initialized)r   zJtraits.Trait({default}, traits.Range{rng}, enter_set=True, auto_set=False))r=   rÓ   r”   F)r•   )	r-  rB   rÉ   r   rÍ   r   r˜   r�   rŸ   )
rE   r_   rP   rÐ   r=   rÓ   r  r¥   rT   r<   r   r   r   r!  !  s    
z<WrapperGenerator._write_smart_volume_mapper_vector_componentc       
      C   s|   |dkrt dƒ‚| jjƒ | \}}tdkr>d}t|ƒ |d }dj||d�}| j|ƒ}t|d| ƒ}	| j||||	d	d
� d S )NZ
ResolutionzDNot sure why you ask for me! I only deal with Resolution. Panicking.é   zUvtkSpanSpace: Resolution not updatable (VTK 7.x bug - value not properly initialized)r   zJtraits.Trait({default}, traits.Range{rng}, enter_set=True, auto_set=False))r=   rÓ   r”   F)r•   )	r-  rB   rÉ   r   rÍ   r   r˜   r�   rŸ   )
rE   r_   rP   rÐ   r=   rÓ   r  r¥   rT   r<   r   r   r   r   6  s    
z-WrapperGenerator._write_span_space_resolutionc             C   sX   |dkrt dƒ‚tdkr$d}t|ƒ d}| j|ƒ}t|d| ƒ}| j||||dd� d S )	NZVertexCellszENot sure why you ask for me! I only deal with VertexCells. Panicking.r.  zevtkHyperTreeGridCellCenters: VertexCells not updatable (VTK 8.x bug - value not properly initialized)ztvtk_base.true_bool_traitr”   F)r•   )r-  r   rÍ   r˜   r�   rŸ   )rE   r_   rP   rÐ   r  r¥   rT   r<   r   r   r   r"  K  s    
zAWrapperGenerator._write_hyper_tree_grid_cell_centers_vertex_cells)F)F)N)NF)F)FFr  )FFr  )FFr  )FFr  )FFr  )TFr  )TFr  )TFr  )TTr  )TTr  )TTr   )TTr!  )TTr"  )6r*   Ú
__module__Ú__qualname__r\   rF   rG   rM   rJ   rK   rL   r’   ru   rv   rw   ry   rz   r˜   rX   rì   rî   rï   rð   rñ   rÛ   rø   rÝ   rÜ   rý   r   r½   r¾   rŸ   rÎ   rÌ   rÊ   r$  Úclassmethodr)  rš   r™   rœ   r  r  r  r  r  r  r  r  r  r  r!  r   r"  r   r   r   r   r@   Ð   s‚   
#%/ /+  4"
	

9!
X
L
e 2r@   )r\   Ú
__future__r   r%  r+   rº   r}   rá   r€   Ú	itertoolsr   Úcommonr   r   r   r   r   r	   r
   r   Úversion_infor"   r4   r?   r@   r   r   r   r   Ú<module>   s    
\U