
    g{&                         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y)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                 <    ! d}d } j                   j                         D ci c]9  \  }}|t         | t         d| d             |j	                                     ; }}}d j                         f|gt        j                  j                         D cg c]`  \  }}dd|j                          dfd	||   d
   fd||   d   fd|j                  j                         fd|j                         ddddgf|fb c}}      d}j                         D ci c]  \  }}||j	                          c}}j                         D ci c]  \  }}||j                          c}}g   j                         D ]+  }|j                         }	|	dk(  r j                  |	|f       - g }
d } D ]w  \  }	}t!        j"                  t!        j$                  |j'                         |j)                               d      }t!        j"                  t!        j$                  |j+                         |j)                               d      }t!        j"                  t!        j$                  |j-                         |j)                               d      }d|	f|dd |t.        |j1                               fd |t2        |j5                               fd|j7                         fd|f|dd |t8        |j;                               fd|j=                         fd |fd!|fg}|
j                  ||	d"g       z t?        |
      g !g  j@                   jB                  D ];  }|j                         }	|	dk(  s|jE                         )!j                  |	|f       = g }tG        tH        jJ                  j                               D cg c]	  \  }}||f }}}!D ]  \  }	}|jM                         }|jN                  tH        jJ                  vr||jN                  fg|}|jQ                         \  }}d|	fd#|jN                  g|z   fd$|fd%|fg}tS        |d&      rttG        tT        jV                        D cg c]  }||f }}|j                  d'|jY                         g|f       g d(}|j                  d)|j[                         g|f       |j                  ||	d"g       	 t?        |      |d*d"fg}|
r|j                  |
d+d"f       |r|j                  |d,d"f         !fd-}t]        j^                  |d.|ta        jb                  te        tg        jh                  d/d0                  |1       yc c}}w c c}}w c c}}w c c}}w c c}}w c c}w )2zEdit matplotlib figure options)NNc                 b    t        |t              rt        t        |       S t        t        |       S )z.Convert axis limits for correct input editors.)
isinstancer   mapr   float)lim	converters     h/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/matplotlib/backends/qt_editor/figureoptions.pyconvert_limitsz#figure_edit.<locals>.convert_limits#   s%    i/x%%5#    get_r   TitleNz<b>z	-Axis</b>Minr   Max   LabelScalelinearlogsymloglogit)z(Re-)Generate automatic legendF
_nolegend_c                     || vri | |t        |      i} | j                         D ci c]  \  }}||
 }}}|j                         D ci c]  \  }}||
 }}}|| |      }|gt        |j                         d       z   S c c}}w c c}}w )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                     | d   S )Nr%    )short_and_names    r   <lambda>z3figure_edit.<locals>.prepare_data.<locals>.<lambda>o   s    .2C r    )key)stritemssorted)dinitshortname
name2short
short2namecanonical_inits          r   prepare_dataz!figure_edit.<locals>.prepare_dataV   s     q=&1&dCI&A 67WWY?keTdEk?
?5?5E5E5GHkdEeTkH
H#AdG, z'')CEE 	F @Hs   BB
T)
keep_alpha)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) Colormapz
Min. valuez
Max. valueget_interpolationInterpolation)datargbaautozInterpolation stageAxesCurveszImages, etc.c                    )D ci c]  }| t        'd| d              }}| j                  d      }+r| j                  d      ng },r| j                  d      ng }| rt        d      |j                  d      }'j                  |       |j                         }t	        )j                               D ]  \  }\  }}	|d|z     }
|d|z  dz      }|d|z  dz      }|d|z  dz      }|	j                         |k7  r t        'd	| d
      |       |	j                  |
|d       |	j                  |       |	j                  (|          |	j                  *|           t	        |      D ]  \  }}-|   d   }|\	  }}}}}}}}}|j                  |       |j                  |       |j                  |       |j                  |       t        j                   |      }|j#                  d       |j%                  |       |dk7  s|j'                  |       |j)                  |       |j+                  |       |j-                  |        t	        |      D ]  \  }}.|   d   }t/        |      dk(  r,|\  }}}}} }!|j1                  |        |j3                  |!       nt/        |      dk(  r|\  }}}}|j                         |j5                          |j6                  t9        g         |r_d}"d}#'j:                  *'j=                         }$|$j>                  du}"|$j@                  }#'jC                  |#      }%|%r|%jE                  |"       'jG                         }&|&jH                  jK                          )D ]C  } t        'd| d             ||   k7  s|&jH                  jL                  jO                           y yc c}w )zA callback to apply changes.r!   r   r   zUnexpected field   r%         set_scaleF)rH   Nnone   )ncols)(getattrpop
ValueError	set_title	enumerater4   	get_scale_set_limset_label_text_set_converter	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_climr5   legend_
get_legend
_draggable_ncolslegendset_draggable
get_figurecanvasdrawtoolbarpush_current)/rF   r9   orig_limitsgeneralcurves	mappablestitlegenerate_legendiaxisaxis_minaxis_max
axis_label
axis_scaleindexcurvelinelabel	linestyle	drawstyle	linewidthcolormarker
markersizemarkerfacecolormarkeredgecolorrG   mappable_settingsmappablecmaplowhighinterpolationinterpolation_stage	draggablerS   
old_legend
new_legendfigureaxesaxis_converteraxis_map
axis_units	has_curvehas_smlabeled_lineslabeled_mappabless/                                          r   apply_callbackz#figure_edit.<locals>.apply_callback   s    !
 1'$$tfC 0133
 

 ((1+ )!r#)DHHQKr	/00Au!++-()9: 	-OA|dqs|HqsQw'H 1q)J 1q)J~~:-1TF%01*=MM(H5M9
+ t 45NN:d+,	-  &f- 	:LE5 '*D16/UIy)UFJoNN5!y)y)y)??5)DNN4 NN4 '##J/((9((9	:$ )2)(< 	4$E$(/2H$%*# KtS$7J**=9001DE&'1,):&tS$u%d#HvsDk23	4 IE||'!__.
&11=	"))51J((3 " 	D.wttD6-.0K4EE%%224	[
s   OzFigure optionsimageszqt4_editor_options.svg)r~   parenticonapply)5	_axis_mapr4   tuplerT   get_converter	get_titler   from_iterabler~   r   get_textrY   	get_units	get_lines	get_labelappendrb   to_hexrc   	get_color	get_alphaget_markeredgecolorget_markerfacecolor
LINESTYLESget_linestyle
DRAWSTYLESget_drawstyleget_linewidthMARKERS
get_markerget_markersizeboolr   collections	get_arrayr5   r   
_colormapsget_cmapr9   get_climhasattrmimageinterpolations_namesrD   get_interpolation_stager
   feditr	   QIconr3   r   _get_data_path)"r   r   sepr   r9   r   axis_limitsr{   r   r   r|   r=   r   ecfc	curvedatar   r}   r   cmapsr   r   mappabledatainterpolationsinterpolation_stagesdatalistr   r   r   r   r   r   r   r   s"   `                          @@@@@@@r   figure_editr      s   
C ~~H
 #..*	 D$ 	eN+GDDc*+-t/A/A/C
  	K  
$.."# 
		 'nn.
 d TZZ\N)45D)!,-D)!,-$**--/04>>+#UHg? @
 
 	2G* #..*D$ 	d  ""N #..*D$ 	dnnJ M  , L eT]+	,
 FF6 % .tOODNN,dnn.>? ^^OOD4468HI ^^OOD4468HI e!<
D4F4F4HIJ<
D4F4F4HIJd((*+U##l7DOO,=>?T((*+ "% "%'	 	y%,-1.4 VI 5dkk5D$4$45 4""$L H$6$6$8$@  %!23	4
 I,22==3F3F3H,IJjdDdD\JEJ, 4x  "99BMM)DII&//E%%'	Te$))u,-34 	
 801)/0K0K)LN!%tNN N++-??!A B $< %113K6JK!M N 	,r23/42 )_F&"%&H2./NB78R Rh ([[$$X/GHIK	A
 Z KNs$   >U;#A%V&VV
V7V)N)__doc__	itertoolsr   
matplotlibr   r   r   rb   r   r   r   matplotlib.backends.qt_compatr	   matplotlib.backends.qt_editorr
   matplotlib.datesr   r   r   r   MarkerStyler   r   r/   r    r   <module>r      sc    O  M M / 5 4	
  	"
 


%
%qr    