3
îÈ‘[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   úS/home/yuhw/wc/wire-cell-python/venv/lib/python3.6/site-packages/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   ÚkwargsÚkwargs_codeÚtype_Ú
number_mapr   Údtypesr   r   r   r   r   Úget_trait_def   sF    '




r6   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ÚdefaultÚarg_formatsÚall_sigsÚsigÚdefault_mappingsÚ
arg_formatÚall_same_typer   r   r   Úpatch_default{   s0    $

rF   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
   ÚIndentÚindentr	   r8   Úparserr   ÚSpecialGeneratorÚspecialÚVTKDocMassagerÚdm)Úselfr   r   r   Ú__init__Ô   s    

zWrapperGenerator.__init__c             C   s
   | j jƒ S )z Returns the parser's class tree.)rJ   Úget_tree)rO   r   r   r   rQ   Þ   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)rI   ÚresetÚ_write_prelimsÚ_gen_class_initÚ_gen_methodsrL   Úgenerate_codeÚwrite)rO   ÚnodeÚoutr   r   r   rW   â   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)rX   rI   r   )rO   rY   rZ   Úprelimr   r   r   rT     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)
            )rI   rQ   Ú	get_classr_   r*   Ú_get_class_nameÚlevelÚ	__bases__r   ÚlocalsrX   r   rN   Úwrite_class_docÚ__doc__ÚincrÚget_ancestors)rO   rY   rZ   rI   ÚklassÚvtk_class_nameÚ
class_nameÚ	base_nameÚ
base_fnameÚ_impÚcdefÚdeclr   r   r   rU   *  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   r]   rw   rx   ry   z
_updateable_traits_ = \z
%s

rz   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_removeÚ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':Úprogress_textÚabort_executeÚrelease_data_flagÚdragableÚpickableÚdebugÚ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))"rQ   rb   r_   rJ   Úparser*   Úget_set_methsr)   Úother_methsr:   Ú_gen_toggle_methodsÚ_gen_state_methodsÚ_gen_get_set_methodsÚupdateÚ_gen_get_methodsÚ_gen_other_methodsrd   ÚparentsÚdatar}   ÚtextwrapÚfillÚreprr%   r    rX   rI   r   ÚcopyÚdeepcopyr   Úsortedri   Údecr)rO   rY   rZ   rk   Úprw   Útoggle_allow_failurerx   ry   rz   r’   ÚpdÚiÚutÚjunkÚcoder|   r~   rm   ÚtitleÚt_gÚs_gÚgs_gÚitem_contentsÚviewtype_contentsÚview_contentsr   r   r   rV   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
rR   N)r_   rQ   Úget_noder’   rŽ   rX   rI   r   )rO   rY   Ún_datarZ   Ú	prop_nameÚ	prop_nodeÚ	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·   )rJ   Úget_toggle_methodsr(   Ú_reform_nameÚ_is_specialÚ _get_special_updateable_failableÚaddÚ_write_special_traitÚgetattrÚAttributeErrorÚ_write_trait)rO   rk   rZ   ÚmethsÚupdateable_traitsrz   Úmr_   Ú
updateableÚcan_failÚt_defr>   r=   r   r   r   r‹     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   ÚvtkCellQualityÚQualityMeasureÚvtkRenderViewÚInteractionModeÚvtkMatrixMathFilterÚ	OperationÚvtkResliceImageViewerÚResliceModeÚaxis_alignedÚvtkThresholdÚPointsDataTypeé
   r¶   ÚDataScalarTypeÚOutputScalarTypeÚUpdateExtenté   ÚvtkGenericEnSightReaderÚ	ByteOrderÚvtkImageDataÚ
ScalarTypeé   ÚvtkImagePlaneWidgetÚPlaneOrientationr   ÚAttributeModeÚdarwinÚvtkRenderWindowÚ
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ä   )rJ   rI   Úget_state_methodsrº   Ú
isinstanceÚvtkr\   r*   Úhasattrr&   Úranger+   r,   rf   r#   r¿   rÁ   Ú_write_tvtk_methodÚ_write_generic_method)rO   rk   rZ   rJ   rI   rÂ   rÃ   rÄ   r_   r|   Úvtk_valr   ÚvalÚ	extra_valr?   rÇ   r>   Úvtk_methr`   rr   Úbodyr   r   r   rŒ   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   Ú_p_voidzWarning:r   r7   zGtraits.Trait(None, None, traits.String(enter_set=True, auto_set=False))F)r·   r   ÚcolorÚ
bond_colorÚ
backgroundÚFalser¨   ÚvtkLightÚTruez$tvtk_base.vtk_color_trait({default}))r?   )r·   Úforce_updateT)Ú	enter_setÚauto_setz%s:ú )ÚendzIgnoring method: Get/Set%szdefault: %s, range: Nonez{0}({1}, {2})z{0}({1})rä   rä   rä   )r¨   rö   )rJ   Úget_get_set_methodsr(   rº   r¿   r9   r»   r¼   r½   r¾   rê   rF   Ú_write_trait_with_rangeræ   r#   ÚendswithÚ#_write_trait_with_default_undefinedr0   Úprintrç   r\   r'   r&   rÁ   Ú_write_propertyr%   Úfindr*   r   r6   )rO   rk   rZ   rJ   rÂ   rÃ   rz   Úvtk_attr_namer_   r>   r=   Úget_sigÚset_sigrÅ   rÆ   r?   ÚrngÚ	exceptionrÇ   ÚforceÚ
trait_typer1   r   r   r   r�   Ò  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   )rJ   Úget_get_methodsr¿   Ú_write_get_output_methodÚ_write_pure_get_input_methodÚ"_write_pure_get_output_port_methodrº   r9   r'   r  rê   )rO   rk   rZ   rJ   rÂ   rÄ   r=   r_   rB   Ú
write_propÚwrite_getterr�   r   r   r   r�   …  s4    



z!WrapperGenerator._gen_get_methodsc             C   s8   | j }|jƒ }x$|D ]}t||ƒ}| j|||ƒ qW d S )N)rJ   Úget_other_methodsr¿   rê   )rO   rk   rZ   rJ   rÂ   rÄ   rï   r   r   r   r�   §  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.ÚTeXÚtexÚ_N)Úisupperr   ÚkeywordÚ	iskeyword)rO   r_   Ú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   r`   r   r   r   ra   É  s   z4WrapperGenerator._get_class_name.<locals>.<listcomp>N)r   r&   r%   r   r*   )rO   ÚklassesÚretr   r   r   rc   Å  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  )rO   rí   Ú
_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   ra   é  s    z3WrapperGenerator._find_arg_type.<locals>.<listcomp>)r'   r&  )rO   rB   Ú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   ra   ð  s    z6WrapperGenerator._find_return_type.<locals>.<listcomp>)r&  )rO   rB   Ú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(  )rO   rB   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   ra   þ  s    z8WrapperGenerator._find_array_arg_sig.<locals>.<listcomp>r   )rO   rB   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¿   rJ   r9   rf   rX   rI   r   r'   rë   )rO   rk   rZ   r(   r=   rB   ÚdocÚ	trait_defrr   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¿   rJ   r9   r'   rf   rX   rI   r   rê   r  )rO   rk   rZ   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=\ú)rR   N)r¿   rf   rI   rX   r   rh   rN   Úwrite_trait_doc)rO   rk   rZ   r=   rÇ   rI   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¿   rJ   r9   r'   rf   rX   rI   r   rê   r  )rO   rk   rZ   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")

            r6  N)
r¿   rJ   r9   r'   rf   rX   rI   r   rê   r  )rO   rk   rZ   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¿   rf   rX   rI   r   rê   )rO   rk   rZ   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@  )rA  )rç   r"  )rç   r"  )	rJ   r9   r+  r*   rº   r  r  r,  rë   )rO   rk   rZ   rï   rB   Úret_typeÚarg_typeÚ
vtk_m_namer_   Úmethod_affects_inputÚmethod_needs_updaterr   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"""
rR   N)
r   r#   rN   Úget_method_docrh   rI   rX   r   ri   r™   )rO   rZ   rr   Úvtk_doc_methrð   r.  rI   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, %sr4  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)
            rR   rä   )
r*   rÿ   rf   ÚAssertionErrorrI   rX   r   rh   rN   r5  )rO   rZ   Út_namerÇ   r>   r·   rø   r¸   ÚchangedrD  Úmap_strÚ	force_strr/  ÚmsgÚvtk_on_nameÚvtk_off_nameÚchanged_defrI   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)sr4  rR   N)rç   r"  )rI   r*   rJ   r9   r*  rf   rX   r   r(  r,  rh   rN   r5  )rO   rZ   rM  r=   r>   Ú	multi_argrI   ÚgetterÚvtk_get_namerB   rB  r/  ÚsetterÚvtk_set_namerC  rG  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 {}.{})rZ  )rº   r¿   rF   r   r%   r&   r   r   r'   r6   rÁ   r0   r*   )rO   rk   rZ   r  r_   r=   r>   Ú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ä   )rJ   rý   rf   rº   r¿   rÁ   )	rO   rk   rZ   r  r?   r  rÇ   r_   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_traitsr}   ÚreÚmatch)Úclsrk   r  Ú	full_nameÚ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×   )rq  Ú
ValueErrorr   r*   rk  )rn  rk   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
        rj  ú|N)r   r*   rl  rm  rk  r}   )rn  rk   r  ro  r   r   r   r»   ¤  s    zWrapperGenerator._is_specialc             C   s2   | j ||ƒ}| j| \}}}t| |ƒ|||ƒ d S )N)rq  rk  r¿   )rO   rk   rZ   r  r   r  Úmethod_namer   r   r   r¾   ¹  s    z%WrapperGenerator._write_special_traitc             C   s   | j ||dd� d S )NT)r(   )r  )rO   rk   rZ   r  r   r   r   r]  ¾  s    z"WrapperGenerator._write_any_outputc             C   s   | j ||ƒ d S )N)r3  )rO   rk   rZ   r  r   r   r   r^  Á  s    z"WrapperGenerator._write_any_sourcec             C   s   dS )z This method does nothing Nr   )rO   rk   rZ   r  r   r   r   r_  Ä  s    z'WrapperGenerator._write_any_scalar_typec             C   s   | j ||ƒ d S )N)r8  )rO   rk   rZ   r  r   r   r   r`  È  s    z!WrapperGenerator._write_any_inputc             C   s   | j ||ƒ d S )N)r;  )rO   rk   rZ   r  r   r   r   ra  Ë  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Á   )rO   rk   rZ   r  r_   r>   rÇ   r   r   r   rb  Î  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Á   )rO   rk   rZ   r  r_   r>   rÇ   r   r   r   rc  Õ  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 )
NÚ
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·   )	ÚRuntimeErrorrJ   rý   r"   r   r   rº   r¿   rÁ   )	rO   rk   rZ   r  r?   r  rÇ   r_   r>   r   r   r   rd  Û  s    

z1WrapperGenerator._write_image_reader2_header_sizec             C   sF   |dkrt dƒ‚d}| j|ƒ}t|d| ƒ}| j||||ddd� d S )NÚ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ø   )rv  rº   r¿   rÁ   )rO   rk   rZ   r  rÇ   r_   r>   r   r   r   re  ö  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 )
NÚ	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·   )	rv  rJ   rý   r   r  r   rº   r¿   rÁ   )
rO   rk   rZ   r  r?   r  r\  rÇ   r_   r>   r   r   r   rf    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 )NÚ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·   )	rv  rJ   rý   r   r  r   rº   r¿   rÁ   )
rO   rk   rZ   r  r?   r  r\  rÇ   r_   r>   r   r   r   rh  !  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 )NÚ
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·   )	rv  rJ   rý   r   r  r   rº   r¿   rÁ   )
rO   rk   rZ   r  r?   r  r\  rÇ   r_   r>   r   r   r   rg  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 )	NÚVertexCellszENot sure why you ask for me! I only deal with VertexCells. Panicking.rz  zevtkHyperTreeGridCellCenters: VertexCells not updatable (VTK 8.x bug - value not properly initialized)ztvtk_base.true_bool_traitr¶   F)r·   )rv  r   r  rº   r¿   rÁ   )rO   rk   rZ   r  r\  rÇ   r_   r>   r   r   r   ri  K  s    
zAWrapperGenerator._write_hyper_tree_grid_cell_centers_vertex_cells)F)F)N)NF)F)FFr]  )FFr^  )FFr_  )FFr`  )FFra  )TFrb  )TFrc  )TFrd  )TTre  )TTrf  )TTrg  )TTrh  )TTri  )6r*   Ú
__module__Ú__qualname__rh   rP   rQ   rW   rT   rU   rV   r´   r‹   rŒ   r�   r�   r�   rº   rc   r&  r(  r*  r+  r,  r  r3  r  r  r8  r;  rê   rë   rÁ   r  r   rþ   rk  Úclassmethodrq  r¼   r»   r¾   r]  r^  r_  r`  ra  rb  rc  rd  re  rf  rh  rg  ri  r   r   r   r   rG   Ð   s‚   
#%/ /+  4"
	

9!
X
L
e 2rG   )rh   Ú
__future__r   rl  r+   rç   r“   r  r–   Ú	itertoolsr   Úcommonr   r   r   r   r   r	   r
   r   Úversion_infor"   r6   rF   rG   r   r   r   r   Ú<module>   s    
\U