a
    ìÝEbs&  ã                   @   s†   d Z ddlZddlmZmZmZmZmZ	 ddl
mZ ddlmZ ddlmZmZ ddd	d
ddœZddddddœZejjZddd„ZdS )zHModule that provides a GUI-based editor for Matplotlib's figure options.é    N)ÚcbookÚcmÚcolorsÚmarkersÚimage)ÚQtGui)Ú_formlayout)ÚDateConverterÚnum2dateZSolidZDashedZDashDotZDottedÚNone)ú-z--z-.ú:r   ZDefaultzSteps (Pre)zSteps (Mid)zSteps (Post))Údefaultz	steps-preZstepsz	steps-midz
steps-postc                    s¢  d}dd„ }ˆ j j‰|ˆ  ¡ ˆƒ\}}ˆ jj‰|ˆ  ¡ ˆƒ\}}dˆ  ¡ f|dd|fd|fdˆ  ¡ fd	ˆ  ¡ d
dddgf|dd|fd|fdˆ  ¡ fd	ˆ  	¡ d
dddgf|dg}ˆ j  
¡ ‰ˆ j 
¡ ‰dd„ }	g ‰ˆ  ¡ D ]$}
|
 ¡ }|dkrìqÖˆ ||
f¡ qÖg }dd„ }tˆ|	d�D ]Ü\}}
tjt |
 ¡ |
 ¡ ¡dd�}tjt |
 ¡ |
 ¡ ¡dd�}tjt |
 ¡ |
 ¡ ¡dd�}d|f|dd|t|
 ¡ ƒfd|t|
 ¡ ƒfd|
 ¡ fd|f|dd |t|
 ¡ ƒfd!|
 ¡ fd"|fd#|fg}| ||d$g¡ �qt|ƒ‰g ‰g ˆ j¢ˆ j ¢D ]8}| ¡ }|dk�s| !¡ d%u �r6�qˆ ||f¡ �qg }d&d'„ tt"j# $¡ ƒD ƒ}tˆ|	d�D ]ª\}}| %¡ }|t"j# &¡ v�r ||j'fg|¢}| (¡ \}}d|fd(|j'g| fd)|fd*|fg}t)|d+ƒ�rd,d'„ tt*j+ƒD ƒ}| d-| ,¡ g|¢f¡ | ||d$g¡ �qpt|ƒ‰|d.d$fg}|�rF| |d/d$f¡ |�r\| |d0d$f¡ ‡ ‡‡‡‡‡‡‡‡f	d1d2„}t-j.|d3|t/ 0t1t2 3d4d5¡ƒ¡|d6� d%S )7zEdit matplotlib figure options)NNc                 S   s   t |tƒrtt| ƒS tt| ƒS )z.Convert axis limits for correct input editors.)Ú
isinstancer	   Úmapr
   Úfloat)ZlimÚ	converter© r   úk/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/matplotlib/backends/qt_editor/figureoptions.pyÚconvert_limits$   s    

z#figure_edit.<locals>.convert_limitsZTitle)Nz<b>X-Axis</b>ZLeftZRightÚLabelZScaleZlinearÚlogZsymlogZlogit)Nz<b>Y-Axis</b>ZBottomZTop)z(Re-)Generate automatic legendFc                 S   s<   t  d| d ¡}|r,| d¡t| d¡ƒfS | d dfS dS )zw
        Label should be a tuple consisting of the string label,
        and the object being sorted by label.
        z(_line|_image)(\d+)r   é   é   N)ÚreÚmatchÚgroupÚint)Úlabelr   r   r   r   Úcmp_keyE   s    zfigure_edit.<locals>.cmp_keyZ
_nolegend_c                 S   sf   || vri | ¥|t |ƒi¥} dd„ |  ¡ D ƒ}dd„ | ¡ D ƒ}|| |  }|gt| ¡ dd„ d� S )aâ  
        Prepare entry for FormLayout.

        *d* is a mapping of shorthands to style names (a single style may
        have multiple shorthands, in particular the shorthands `None`,
        `"None"`, `"none"` and `""` are synonyms); *init* is one shorthand
        of the initial style.

        This function returns an list suitable for initializing a
        FormLayout combobox, namely `[initial_name, (shorthand,
        style_name), (shorthand, style_name), ...]`.
        c                 S   s   i | ]\}}||“qS r   r   )Ú.0ÚshortÚnamer   r   r   Ú
<dictcomp>j   ó    z5figure_edit.<locals>.prepare_data.<locals>.<dictcomp>c                 S   s   i | ]\}}||“qS r   r   )r    r"   r!   r   r   r   r#   l   r$   c                 S   s   | d S )Nr   r   )Zshort_and_namer   r   r   Ú<lambda>r   r$   z3figure_edit.<locals>.prepare_data.<locals>.<lambda>©Úkey)ÚstrÚitemsÚsorted)ÚdÚinitZ
name2shortZ
short2nameZcanonical_initr   r   r   Úprepare_dataY   s    ÿÿz!figure_edit.<locals>.prepare_datar&   T)Z
keep_alpha)Nz<b>Line</b>z
Line stylez
Draw styleZWidthzColor (RGBA))Nz<b>Marker</b>ÚStyleÚSizezFace color (RGBA)zEdge color (RGBA)Ú Nc                 S   s   g | ]\}}||f‘qS r   r   )r    r"   Úcmapr   r   r   Ú
<listcomp>˜   r$   zfigure_edit.<locals>.<listcomp>ZColormapz
Min. valuez
Max. valueÚget_interpolationc                 S   s   g | ]}||f‘qS r   r   )r    r"   r   r   r   r2   ¥   s   ÚInterpolationZAxesZCurveszImages, etc.c           (   
      sÈ  ˆ   ¡ }ˆ  ¡ }|  d¡}ˆr(|  d¡ng }ˆr:|  d¡ng }| rJtdƒ‚|\
}}}}	}
}}}}}ˆ  ¡ |
krxˆ  |
¡ ˆ  ¡ |krŽˆ  |¡ ˆ  |¡ ˆ  	||¡ ˆ  
|	¡ ˆ  ||¡ ˆ  |¡ ˆˆ j_ˆˆ j_ˆ j ˆ¡ ˆ j ˆ¡ ˆ j ¡  ˆ j ¡  t|ƒD ]¤\}}ˆ| d }|\	}}}}}}}}}| |¡ | |¡ | |¡ | |¡ t |¡}| d¡ | |¡ |dk�r| |¡ | |¡ | |¡ | |¡ �qt|ƒD ]„\}}ˆ| d }t|ƒdk�rò|\}}} }!}"|  |"¡ nt|ƒdk�r|\}}} }!| |¡ | !t" #|¡¡ |j$t%| |!gƒŽ  �q¶|�rŠd}#d}$ˆ j&du�rnˆ  '¡ }%|%j(du}#|%j)}$ˆ j*|$d�}&|&�rŠ|& +|#¡ ˆ  ,¡ }'|'j- .¡  ˆ   ¡ |k�r¸ˆ  ¡ |k�sÄ|'j-j/ 0¡  dS )	zA callback to apply changes.r   zUnexpected fieldr   NÚnoneé   é   )Úncol)1Úget_xlimÚget_ylimÚpopÚ
ValueErrorÚ
get_xscaleZ
set_xscaleÚ
get_yscaleZ
set_yscaleÚ	set_titleZset_xlimZ
set_xlabelZset_ylimZ
set_ylabelÚxaxisr   ÚyaxisZ	set_unitsZ_update_axisinfoÚ	enumerateZ	set_labelZset_linestyleZset_drawstyleZset_linewidthÚmcolorsÚto_rgbaZ	set_alphaZ	set_colorZ
set_markerZset_markersizeZset_markerfacecolorZset_markeredgecolorÚlenZset_interpolationZset_cmapr   Úget_cmapZset_climr*   Zlegend_Z
get_legendZ
_draggableZ_ncolZlegendZset_draggableZ
get_figureZcanvasZdrawZtoolbarZpush_current)(ÚdataZ	orig_xlimZ	orig_ylimÚgeneralÚcurvesÚ	mappablesÚtitleÚxminÚxmaxZxlabelZxscaleÚyminÚymaxZylabelZyscaleZgenerate_legendÚindexZcurveÚliner   Z	linestyleZ	drawstyleZ	linewidthÚcolorÚmarkerZ
markersizeZmarkerfacecolorZmarkeredgecolorZrgbaZmappable_settingsÚmappabler1   ÚlowÚhighÚinterpolationZ	draggabler8   Z
old_legendZ
new_legendÚfigure©	ÚaxesZ	has_curveZhas_smZlabeled_linesZlabeled_mappablesZ
xconverterZxunitsZ
yconverterZyunitsr   r   Úapply_callback´   s„    
ÿ






ÿ














z#figure_edit.<locals>.apply_callbackzFigure optionsÚimageszqt4_editor_options.svg)rK   ÚparentÚiconÚapply)4r@   r   r9   rA   r:   Z	get_titleZ
get_xlabelr=   Z
get_ylabelr>   Z	get_unitsÚ	get_linesZ	get_labelÚappendr*   rC   Zto_hexrD   Ú	get_colorZ	get_alphaZget_markeredgecolorZget_markerfacecolorÚ
LINESTYLESZget_linestyleÚ
DRAWSTYLESZget_drawstyleZget_linewidthÚMARKERSZ
get_markerZget_markersizeÚboolr\   ÚcollectionsZ	get_arrayr   Z_cmap_registryr)   rF   Úvaluesr"   Zget_climÚhasattrÚmimageZinterpolations_namesr3   r   Zfeditr   ZQIconr(   r   Z_get_data_path)rZ   r]   Úsepr   rL   rM   rN   rO   rH   r   rQ   r   rI   r-   rR   ÚecZfcZ	curvedatarT   rJ   Zcmapsr1   rU   rV   ZmappabledataZinterpolationsZdatalistr[   r   rY   r   Úfigure_edit   sÒ    

ÿ
ÿò

þþþ

óüÿþRÿürm   )N)Ú__doc__r   Z
matplotlibr   r   r   rC   r   r   rj   Zmatplotlib.backends.qt_compatr   Zmatplotlib.backends.qt_editorr   Zmatplotlib.datesr	   r
   rc   rd   ZMarkerStylere   rm   r   r   r   r   Ú<module>   s$   üü