
    Ngi&                         d Z ddlm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ZdS )zHModule that provides a GUI-based editor for Matplotlib's figure options.    )chain)cbookcmcolorsmarkersimage)QtGui)_formlayout)DateConverternum2dateSolidDashedDashDotDottedNone)-z--z-.:r   DefaultzSteps (Pre)zSteps (Mid)zSteps (Post))defaultz	steps-prestepsz	steps-midz
steps-postNc                 0
    dd  j          fd                                D             d                                 fgt          j        fd                                D                       d}d                                 D             d                                 D             g                                  D ]4}|                                }|d	k    r                    ||f           5g }d
 }D ]\  }}t          j	        t          j
        |                                |                                          d          }t          j	        t          j
        |                                |                                          d          }t          j	        t          j
        |                                |                                          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           t/          |          g g  j         j        D ]H}|                                }|d	k    s|                                1                    ||f           Ig }d t7          t8          j                                                  D             }D ]\  }}|                                }|j        t8          j        vr||j        fg|}|                                 \  }}d|fd|j        g|z   fd|fd|fg}tC          |d          rd t7          tD          j#                  D             }|                    d |$                                g|f           d!d"g}|                    d#|%                                g|f           |                    ||dg           t/          |          |d$dfg}|r|                    |d%df           |r|                    |d&df            fd'}tM          j'        |d(|tQ          j)        tU          tW          j,        d)d*                              |+           dS ),zEdit matplotlib figure options)NNc                     t          |t                    rt          t          |           S t          t          |           S )z.Convert axis limits for correct input editors.)
isinstancer   mapr   float)lim	converters     g/var/www/html/ai-engine/env/lib/python3.11/site-packages/matplotlib/backends/qt_editor/figureoptions.pyconvert_limitsz#figure_edit.<locals>.convert_limits#   s2    i// 	&x%%%5#    c                     i | ]>\  }}|t            t          d | d                      |j                            ?S get_r   )tuplegetattrr   ).0nameaxisaxesr   s      r   
<dictcomp>zfigure_edit.<locals>.<dictcomp>+   sn        D$ 	eNN+GD****++--t~
 
    r    Titlec                    g | ]\  }}d d|                                  dfd|         d         fd|         d         fd|                                                                fd|                                d	d
ddgffS )Nz<b>z	-Axis</b>Minr   Max   LabelScalelinearlogsymloglogit)title	get_labelget_text	get_scale)r&   r'   r(   axis_limitsseps      r   
<listcomp>zfigure_edit.<locals>.<listcomp>4   s     
 
 
 d 4TZZ\\4445D)!,-D)!,-$..**335564>>++#UHg? @
 
 
r    )z(Re-)Generate automatic legendFc                 $    i | ]\  }}||j         S  )r   r&   r'   r(   s      r   r*   zfigure_edit.<locals>.<dictcomp>D   s0       D$ 	dn  r    c                 >    i | ]\  }}||                                 S r>   )	get_unitsr?   s      r   r*   zfigure_edit.<locals>.<dictcomp>H   s8       D$ 	dnn  r    
_nolegend_c                    || vri | |t          |          i} d |                                 D             }d |                                D             }|| |                  }|gt          |                                d           z   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                     i | ]\  }}||	S r>   r>   )r&   shortr'   s      r   r*   z5figure_edit.<locals>.prepare_data.<locals>.<dictcomp>g   s    ???keTdE???r    c                     i | ]\  }}||	S r>   r>   )r&   r'   rE   s      r   r*   z5figure_edit.<locals>.prepare_data.<locals>.<dictcomp>i   s    HHHkdEeTHHHr    c                     | d         S )Nr/   r>   )short_and_names    r   <lambda>z3figure_edit.<locals>.prepare_data.<locals>.<lambda>o   s    .2C r    )key)stritemssorted)dinit
name2short
short2namecanonical_inits        r   prepare_dataz!figure_edit.<locals>.prepare_dataV   s     q==&1&dCII&&A @?QWWYY???
HHZ5E5E5G5GHHH
#AdG, z''))CCE E EE 	Fr    T)
keep_alphar0   )Nz<b>Line</b>z
Line stylez
Draw styleWidthzColor (RGBA))Nz<b>Marker</b>StyleSizezFace color (RGBA)zEdge color (RGBA) Nc                     g | ]	\  }}||f
S r>   r>   )r&   r'   cmaps      r   r<   zfigure_edit.<locals>.<listcomp>   s     JJJjdDdD\JJJr    Colormapz
Min. valuez
Max. valueget_interpolationc                     g | ]}||fS r>   r>   )r&   r'   s     r   r<   zfigure_edit.<locals>.<listcomp>   s/     N N N!%tN N Nr    InterpolationdatargbazInterpolation stageAxesCurveszImages, etc.c           
         'fd)D             }|                      d          }+r|                      d          ng },r|                      d          ng }| rt          d          |                     d          }'                    |           |                                 }t          )                                          D ]\  }\  }}	|d|z           }
|d|z  dz            }|d|z  dz            }|d|z  dz            }|	                                |k    r t          'd| d	          |           |	                    |
|d
           |	                    |           (|         |	_	        |	
                    *|                    t          |          D ]\  }}-|         d         }|\	  }}}}}}}}}|                    |           |                    |           |                    |           |                    |           t          j        |          }|                    d           |                    |           |dk    rT|                    |           |                    |           |                    |           |                    |           t          |          D ]\  }}.|         d         }t/          |          dk    r4|\  }}}}} }!|                    |            |                    |!           nt/          |          dk    r|\  }}}}|                    |           |                    |            |j        t9          ||g            |r\d}"d}#'j        $'                                }$|$j        du}"|$j         }#'!                    |#          }%|%r|%"                    |"           '#                                }&|&j$        %                                 )D ]I} t          'd| d                      ||         k    r!|&j$        j&        '                                  dS JdS )zA callback to apply changes.c           
      J    i | ]}| t          d | d                       S r"   )r%   )r&   r'   r)   s     r   r*   z7figure_edit.<locals>.apply_callback.<locals>.<dictcomp>   sJ     
 
 
 1'$ 0t 0 0 01133
 
 
r    r   zUnexpected field   r/         set_scaleF)autoNnone   )ncolsr#   r   )(pop
ValueError	set_title	enumeraterL   r9   r%   _set_limset_label_textr   	set_units	set_labelset_linestyleset_drawstyleset_linewidthmcolorsto_rgba	set_alpha	set_color
set_markerset_markersizeset_markerfacecolorset_markeredgecolorlenset_interpolationset_interpolation_stageset_cmapset_climrM   legend_
get_legend
_draggable_ncolslegendset_draggable
get_figurecanvasdrawtoolbarpush_current)/r_   orig_limitsgeneralcurves	mappablesr6   generate_legendir'   r(   axis_minaxis_max
axis_label
axis_scaleindexcurvelinelabel	linestyle	drawstyle	linewidthcolormarker
markersizemarkerfacecolormarkeredgecolorr`   mappable_settingsmappablerZ   lowhighinterpolationinterpolation_stage	draggablerm   
old_legend
new_legendfigurer)   axis_converteraxis_map
axis_units	has_curvehas_smlabeled_lineslabeled_mappabless/                                          r   apply_callbackz#figure_edit.<locals>.apply_callback   s   
 
 
 
 
 
 

 ((1++ )1!r#)1DHHQKKKr	 	1/000Au!++--()9)9:: 	- 	-OA|dqs|HqsQw'H 1q)J 1q)J~~:--10T00011*===MM(H5M999
+++ ,D1DNNN:d+,,,, &f-- 	: 	:LE5 '*D16/UIy)UFJoNN5!!!y)))y)))y)))?5))DNN4   NN4   '''##J///((999((999 )2)(<(< 	4 	4$E$(/2H$%%**# KtS$7J**=999001DEEEE&''1,,):&tS$u%%%d###HvsDk22333  		4IE|'!__..
&1=	")511J 4((333 "" 	 	D.wt-D---..00K4EEE%22444 F	 	r    zFigure optionsimageszqt4_editor_options.svg)r6   parenticonapply)-	_axis_maprL   	get_titler   from_iterable	get_linesr7   appendry   to_hexrz   	get_color	get_alphaget_markeredgecolorget_markerfacecolor
LINESTYLESget_linestyle
DRAWSTYLESget_drawstyleget_linewidthMARKERS
get_markerget_markersizeboolr   collections	get_arrayrM   r   
_colormapsget_cmapr'   get_climhasattrmimageinterpolations_namesr\   get_interpolation_stager
   feditr	   QIconrK   r   _get_data_path) r)   r   r   r   r   r   rS   r   ecfc	curvedatar   r   cmapsrZ   r   r   mappabledatainterpolationsinterpolation_stagesdatalistr   r   r:   r   r   r   r   r   r   r   r;   s    `                     @@@@@@@@@@r   figure_editr      sa   
C   ~H     #..**	  K 
$..""# 
	 
 
 
 
 
 'nn..
 
 
 
 
 	2G& "..**  N "..**  J M   , ,  L  eT]++++FF F F6 % . .tODNN,,dnn.>.>??   ^OD44668H8HII   ^OD44668H8HII   e!<<
D4F4F4H4HIIJ<<
D4F4F4H4HIIJd((**+U##ll7DOO,=,=>>?T((**+ "% "%'	 	y%,----VI 5dk5D$45 4 4""$$L  H$6$6$8$8$@  %!23333IJJF2=3F3F3H3H,I,IJJJE, 4 4x  ""9BM))DI&//E%%''	Te$)u,-34 	
 8011 
	NN N)/0K)L)LN N NN++--??!A B B B %+F#3 %1133K6JK!M N N N 	,r23333)__F&"%&H 02./// 9NB7888R R R R R R R R R R R Rh ([$X/GHHIIK K	     r    )N)__doc__	itertoolsr   
matplotlibr   r   r   ry   r   r   r   matplotlib.backends.qt_compatr	   matplotlib.backends.qt_editorr
   matplotlib.datesr   r   r   r   MarkerStyler   r   r>   r    r   <module>r      s    O N       M M M M M M M M M M M M M M / / / / / / 5 5 5 5 5 5 4 4 4 4 4 4 4 4	 
  	" "
 

%q q q q q qr    