U
    d»{j³$  ã                   @   s~   d 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.é    )Ú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-postNc                    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 
¡ ‰g ‰ˆ  ¡ D ]$}	|	 ¡ }
|
dkräqÎˆ |
|	f¡ qÎg }d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 ‰ˆ jˆ j•D ]8}| ¡ }
|
dk�sú|  ¡ d"k�r"�qúˆ |
|f¡ �qúg }d#d$„ t!t"j# $¡ ƒD ƒ}ˆD ]ª\}
}| %¡ }|t"j# &¡ k�r„||j'ff|•}| (¡ \}}d|
fd%|j'g| fd&|fd'|fg}t)|d(ƒ�rìd)d$„ t!t*j+ƒD ƒ}| d*| ,¡ f|•f¡ | ||
d!g¡ �qTt|ƒ‰|d+d!fg}|�r*| |d,d!f¡ |�r@| |d-d!f¡ ‡ ‡‡‡‡‡‡‡‡f	d.d/„}t-j.|d0|t/ 0t1t2 3d1d2¡ƒ¡|d3� d"S )4z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   új/var/www/html/bwave/python/venv/lib/python3.8/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 legendFZ
_nolegend_c                 S   sb   || kr| |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>\   s      z5figure_edit.<locals>.prepare_data.<locals>.<dictcomp>c                 S   s   i | ]\}}||“qS r   r   )r   r   r   r   r   r   r   ^   s      c                 S   s   | d S )Né   r   )Zshort_and_namer   r   r   Ú<lambda>d   ó    z3figure_edit.<locals>.prepare_data.<locals>.<lambda>)Úkey)ÚstrÚitemsÚsorted)ÚdÚinitZ
name2shortZ
short2nameZcanonical_initr   r   r   Úprepare_dataK   s    ÿÿz!figure_edit.<locals>.prepare_dataT)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>Š   s     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   r*   —   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k	�rnˆ  '¡ }%|%j(dk	}#|%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é   é   )Úncols)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_ncolsZ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ÚlineÚlabelZ	linestyleZ	drawstyleZ	linewidthÚcolorÚmarkerZ
markersizeZmarkerfacecolorZmarkeredgecolorZrgbaZmappable_settingsÚmappabler)   ÚlowÚhighÚinterpolationZ	draggabler0   Z
old_legendZ
new_legendZ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)rC   ÚparentÚiconÚapply)4r8   r   r1   r9   r2   Z	get_titleZ
get_xlabelr5   Z
get_ylabelr6   Z	get_unitsÚ	get_linesZ	get_labelÚappendr;   Zto_hexr<   Ú	get_colorZ	get_alphaZget_markeredgecolorZget_markerfacecolorÚ
LINESTYLESZget_linestyleÚ
DRAWSTYLESZget_drawstyleZget_linewidthÚMARKERSZ
get_markerZget_markersizeÚboolrT   ÚcollectionsZ	get_arrayr"   r   Z
_colormapsr!   r>   Úvaluesr   Zget_climÚhasattrÚmimageZinterpolations_namesr+   r   Zfeditr   ZQIconr    r   Z_get_data_path)rR   rU   Úsepr   rD   rE   rF   rG   r@   rI   rJ   rA   r%   rK   ÚecÚfcZ	curvedatarM   rB   Zcmapsr)   rN   rO   ZmappabledataZinterpolationsZdatalistrS   r   rQ   r   Úfigure_edit   sä    
 
   ÿ 
   ÿò

þþþ

óüÿþR  ÿürf   )N)Ú__doc__Z
matplotlibr   r   r   r;   r   r   rb   Zmatplotlib.backends.qt_compatr   Zmatplotlib.backends.qt_editorr   Zmatplotlib.datesr	   r
   r[   r\   ZMarkerStyler]   rf   r   r   r   r   Ú<module>   s$   ü ü