B
    îq\©  ã               @   sD   d dl Zd dlmZmZ d dlmZ d dlmZ G dd„ deƒZ	dS )é    N)ÚPathÚLine2D)ÚAffine2D)ÚrcParamsc               @   sÂ   e Zd ZdZd+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edd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zed%d%gd&d%ggƒZd'd(„ Zd)d*„ ZdS ),ÚTicksa]  
    Ticks are derived from Line2D, and note that ticks themselves
    are markers. Thus, you should use set_mec, set_mew, etc.

    To change the tick size (length), you need to use
    set_ticksize. To change the direction of the ticks (ticks are
    in opposite direction of ticklabels by default), use
    set_tick_out(False).

    Note that Matplotlib's defaults dictionary :data:`~matplotlib.rcParams`
    contains default settings (color, size, width) of the form `xtick.*` and
    `ytick.*`. In a WCS projection, there may not be a clear relationship
    between axes of the projection and 'x' or 'y' axes. For this reason,
    we read defaults from `xtick.*`. The following settings affect the
    default appearance of ticks:

    * `xtick.direction`
    * `xtick.major.size`
    * `xtick.major.width`
    * `xtick.minor.size`
    * `xtick.color`
    Nc             K   sˆ   |d krt d }|  |¡ |  t d ¡ |  t d dk¡ |  ¡  t d t d dœ}| |¡ tj| dgdgf|Ž |  d	¡ d
| _	d S )Nzxtick.major.sizezxtick.minor.sizezxtick.directionÚoutzxtick.colorzxtick.major.width)ZcolorZ	linewidthg        ÚallF)
r   Úset_ticksizeÚset_minor_ticksizeÚset_tick_outÚclearÚupdater   Ú__init__Úset_visible_axesÚ_display_minor_ticks)ÚselfÚticksizeÚtick_outÚkwargsZline2d_kwargs© r   úBlib/python3.7/site-packages/astropy/visualization/wcsaxes/ticks.pyr   #   s    


zTicks.__init__c             C   s
   || _ d S )N)r   )r   Údisplay_minor_ticksr   r   r   r   1   s    zTicks.display_minor_ticksc             C   s   | j S )N)r   )r   r   r   r   Úget_display_minor_ticks4   s    zTicks.get_display_minor_ticksc             C   s
   || _ dS )zD
        set True if tick need to be rotated by 180 degree.
        N)Ú	_tick_out)r   r   r   r   r   r   7   s    zTicks.set_tick_outc             C   s   | j S )zH
        Return True if the tick will be rotated by 180 degree.
        )r   )r   r   r   r   Úget_tick_out=   s    zTicks.get_tick_outc             C   s
   || _ dS )z4
        set length of the ticks in points.
        N)Ú	_ticksize)r   r   r   r   r   r	   C   s    zTicks.set_ticksizec             C   s   | j S )z7
        Return length of the ticks in points.
        )r   )r   r   r   r   Úget_ticksizeI   s    zTicks.get_ticksizec             C   s
   || _ dS )z:
        set length of the minor ticks in points.
        N)Ú_minor_ticksize)r   r   r   r   r   r
   O   s    zTicks.set_minor_ticksizec             C   s   | j S )z=
        Return length of the minor ticks in points.
        )r   )r   r   r   r   Úget_minor_ticksizeU   s    zTicks.get_minor_ticksizec             C   s   | j r| jS dS d S )Ng        )r   r   )r   r   r   r   Úout_size[   s    zTicks.out_sizec             C   s
   || _ d S )N)Ú_visible_axes)r   Zvisible_axesr   r   r   r   b   s    zTicks.set_visible_axesc                s,   ˆ j dkrˆ j ¡ S ‡ fdd„ˆ j D ƒS d S )Nr   c                s   g | ]}|ˆ j kr|‘qS r   )Úworld)Ú.0Úx)r   r   r   ú
<listcomp>i   s    z*Ticks.get_visible_axes.<locals>.<listcomp>)r    r!   Úkeys)r   r   )r   r   Úget_visible_axese   s    

zTicks.get_visible_axesc             C   s4   i | _ i | _i | _i | _i | _i | _i | _i | _d S )N)r!   ÚpixelÚangleÚdispÚminor_worldÚminor_pixelÚminor_angleÚ
minor_disp)r   r   r   r   r   k   s    zTicks.clearc             C   s€   || j kr<|g| j |< |g| j|< |g| j|< |g| j|< n@| j |  |¡ | j|  |¡ | j|  |¡ | j|  |¡ d S )N)r!   r'   r(   r)   Úappend)r   Úaxisr!   r'   r(   Zaxis_displacementr   r   r   Úaddu   s    
z	Ticks.addc             C   s   | j S )N)r*   )r   r   r   r   Úget_minor_world   s    zTicks.get_minor_worldc             C   s€   || j kr<|g| j |< |g| j|< |g| j|< |g| j|< n@| j |  |¡ | j|  |¡ | j|  |¡ | j|  |¡ d S )N)r*   r+   r,   r-   r.   )r   Z
minor_axisr*   r+   r,   Zminor_axis_displacementr   r   r   Ú	add_minor„   s    
zTicks.add_minorc             C   s
   t | jƒS )N)Úlenr!   )r   r   r   r   Ú__len__‘   s    zTicks.__len__g        g      ð?c             C   s^   |   ¡ sdS | |  ¡ ¡}|  || j| j||¡ | jrZ| |  ¡ ¡}|  || j| j	||¡ dS )z!
        Draw the ticks.
        N)
Zget_visibleZpoints_to_pixelsr   Ú_draw_ticksr'   r(   r   r   r+   r,   )r   ÚrendererÚ
ticks_locsÚoffsetr   r   r   Údraw–   s    z
Ticks.drawc          
   C   s  |   ¡ }| ¡ }| |  ¡ ¡ | |  ¡ ¡ | |  ¡ ¡ tƒ  	||¡}tƒ }	||	 }
|  
¡ rbdnd}xŽ|  ¡ D ]‚}||kr~qpxrt|| || ƒD ]\\}}|	 || ¡ | t ||g¡¡}| || j|
t|ƒ| ¡ ¡ |	 ¡  ||  |¡ q’W qpW | ¡  dS )z'
        Draw the minor ticks.
        g     €f@g        N)Zget_transformZnew_gcZset_foregroundZ	get_colorZ	set_alphaZ	get_alphaZset_linewidthZget_linewidthr   Zscaler   r&   ÚzipZ
rotate_degZtransform_non_affineÚnpZarrayZdraw_markersÚ_tickvert_pathr   Z
get_affiner   r.   Zrestore)r   r6   Zpixel_arrayZangle_arrayr8   r7   Z
path_transÚgcZmarker_scaleZmarker_rotationZmarker_transformZinitial_angler/   Zlocr(   Zlocsr   r   r   r5   ¤   s(    zTicks._draw_ticks)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r	   r   r
   r   Úpropertyr   r   r&   r   r0   r1   r2   r4   r   r<   r9   r5   r   r   r   r   r      s*   

r   )
Znumpyr;   Zmatplotlib.linesr   r   Zmatplotlib.transformsr   Z
matplotlibr   r   r   r   r   r   Ú<module>   s   