Ńņ 8”tJc@ sļdZddklZyddkZWnej oedƒ‚nXddkZddkZddkZddkZddk l Z l Z l Z ddk lZddklZlZlZlZddklZdd klZdd klZlZdd klZlZlZlZhZ e!Z"e!Z#e!Z$d efd „ƒYZ%dfd„ƒYZ&dfd„ƒYZ'defd„ƒYZ(defd„ƒYZ)d„Z*d„Z+d„Z,defd„ƒYZ-defd„ƒYZ.e.Z/dS(sZ Enhanced Metafile backend. See http://pyemf.sourceforge.net for the EMF driver library. i’’’’(tdivisionNs5You must first install pyemf from http://pyemf.sf.net(tverboset __version__trcParams(tGcf(t RendererBasetGraphicsContextBasetFigureManagerBasetFigureCanvasBase(tFigure(tBbox(tfindfonttFontProperties(tFT2FonttKERNING_UNFITTEDtKERNING_DEFAULTtKERNING_UNSCALEDtEMFFontPropertiescB s,eZd„Zd„Zd„Zd„ZRS(cC sPti||iƒ|iƒ|iƒ|iƒ|iƒ|iƒƒ||_dS(N( R t__init__t get_familyt get_stylet get_variantt get_weightt get_stretchtget_sizet_EMFFontProperties__angle(tselftothertangle((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR&s     cC stti|ƒ|ifƒS(N(thashR t__hash__R(R((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR/scC stti|ƒ|ifƒS(N(tstrR t__str__R(R((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR 2scC s ||_dS(N(R(RR((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt set_angle5s(t__name__t __module__RRR R!(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR%s  tEMFPencB s,eZd„Zd„Zd„Zd„ZRS(cC s¾||_||_|iƒ\}}}t|dƒ|_t|dƒ|_t|dƒ|_t|iƒƒ|_d|_ |i ƒt o+d|i |i|i|i|ifGHndS(Ni’is(EMFPen: style=%d width=%d rgb=(%d,%d,%d)( temftgctget_rgbtinttrtgtbt get_linewidthtwidthtstylet set_linestylet debugHandle(RR%R&R)R*R+((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR:s    cC s(t|i|i|i|i|ifƒS(N(RR.R-R)R*R+(R((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyRHscC s¢|idjoti|_nhtid6tid6tid6tid6}|ii dƒ}t o d|GHn||jo|||_n ti|_dS(NitsolidtdashedtdashdottdottedsEMFPen: style=%d( R-tpyemftPS_NULLR.tPS_SOLIDtPS_DASHt PS_DASHDOTtPS_DOTR&t get_linestyleR0(RtstylesR.((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR/Ks  cC s4|ii|i|i|i|i|ifƒ}|S(N(R%t CreatePenR.R-R)R*R+(Rthandle((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt get_handleZs0(R"R#RRR/R?(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR$9s   tEMFBrushcB s#eZd„Zd„Zd„ZRS(cC s{||_|\}}}t|dƒ|_t|dƒ|_t|dƒ|_tod|i|i|ifGHndS(Ni’sEMFBrush: rgb=(%d,%d,%d)(R%R(R)R*R+R0(RR%trgbR)R*R+((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR`s cC st|i|i|ifƒS(N(RR)R*R+(R((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyRhscC s(|ii|i|i|ifƒ}|S(N(R%tCreateSolidBrushR)R*R+(RR>((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR?ks$(R"R#RRR?(((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR@_s  t RendererEMFcB séeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z e d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s] The renderer handles drawing/rendering operations through a pyemf.EMF instance. cC sš||_h|_h|_hdd6dd6dd6|_ti|||dƒ|_t||ƒ|_t||ƒ|_ ||_ |d|_ d|_ |ii tiƒ|iititiBƒtod|i|i ||fGHnd S( s0Initialize the renderer with a gd image instancei’’’’tfonttpentbrushtingR@g@sRendererEMF: (%f,%f) %s dpi=%fN(toutfilet_cachedt _fontHandlet lastHandleR5tEMFR%R(R-theighttdpit pointstodpithackPointsForMathExponentt SetBkModet TRANSPARENTt SetTextAlignt TA_BOTTOMtTA_LEFTt debugPrint(RRHR-RMRN((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyRws      cC s|ii|iƒdS(N(R%tsaveRH(R((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyRW”sc C sqtod||||||fGHn|i|ƒ} |i|ƒ} |d} |d} t||dƒ}t||dƒ}| oõ|iit|| ƒt|i|| ƒt|| ƒt|i|| ƒt|ti|ti dƒ| ƒt|i|ti |ti dƒ| ƒt|ti|ti dƒ| ƒt|i|ti |ti dƒ| ƒƒnņ|ii t|| ƒt|i|| ƒt|| ƒt|i|| ƒt|ti|ti dƒ| ƒt|i|ti |ti dƒ| ƒt|ti|ti dƒ| ƒt|i|ti |ti dƒ| ƒƒdS(s Draw an arc using GraphicsContext instance gcEdge, centered at x,y, with width and height and angles from 0.0 to 360.0 0 degrees is at 3-o'clock positive angles are anti-clockwise If the color rgbFace is not None, fill the arc with it. s,draw_arc: (%f,%f) angles=(%f,%f) w,h=(%f,%f)ig€f@N( RVt select_pent select_brushR(R%tPieRMtmathtcostpitsintArc(RtgcEdgetrgbFacetxtyR-RMtangle1tangle2trotationRERFthwthhtx1ty1((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pytdraw_arc—s   õcC sdS(sˆ Draw the Image instance into the current axes; x is the distance in pixels from the left hand side of the canvas. y is the distance from the origin. That is, if origin is upper, y is the distance from top. If origin is lower, y is the distance from bottom bbox is a matplotlib.transforms.BBox instance for clipping, or None N((RRbRctimtbbox((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt draw_image³scC s tod||||fGHn|i|ƒoL|iit|ƒt|i|ƒft|ƒt|i|ƒfgƒn!tod||||fGHndS(s8 Draw a single line from x1,y1 to x2,y2 sdraw_line: (%f,%f) - (%f,%f)s,draw_line: optimizing away (%f,%f) - (%f,%f)N(RVRXR%tPolylinetlongRM(RR&RiRjtx2ty2((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt draw_lineÄs LcC s–todtt|ƒƒGHn|i|ƒobg}tt|ƒƒD].}|t||ƒt|i||ƒfqG~}|ii|ƒndS(sc x and y are equal length arrays, draw lines connecting each point in x, y sdraw_lines: %d pointsN( RVtlenRRXtrangeRpRMR%Ro(RR&RbRct_[1]titpoints((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt draw_linesĻs NcC sktod||fGHnt|i|ƒ}|iit|ƒt|i|ƒ|i|i|ifƒdS(s| Draw a single point at x,y Where 'point' is a device-unit point (or pixel), not a matplotlib point sdraw_point: (%f,%f)N( RVR$R%tSetPixelRpRMR)R*R+(RR&RbRcRE((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt draw_pointÜsc C stodt|ƒGHn|i|ƒ}|i|ƒ}|p|oTg}|D],\}}|t|ƒt|i|ƒfqQ~}|ii|ƒngg} |D],\}}| t|ƒt|i|ƒfq„~ }todt|ƒt|ƒfGHndS(sē Draw a polygon using the GraphicsContext instance gc. points is a len vertices tuple, each element giving the x,y coords a vertex If the color rgbFace is not None, fill the polygon with it sdraw_polygon: %d pointss5draw_polygon: optimizing away polygon: %d points = %sN( RVRtRXRYRpRMR%tPolygonR( RR`RaRxRERFRvRbRct_[2]((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt draw_polygončs@@c C sĒtod||||fGHn|i|ƒ}|i|ƒ}|p|oW|iit|ƒt|i|ƒt|ƒt|ƒt|i|ƒt|ƒƒn!tod||||fGHndS(sĖ Draw a non-filled rectangle using the GraphicsContext instance gcEdge, with lower left at x,y with width and height. If rgbFace is not None, fill the rectangle with it. s!draw_rectangle: (%f,%f) w=%f,h=%fs1draw_rectangle: optimizing away (%f,%f) w=%f,h=%fN(RVRXRYR%t RectangleR(RM( RR`RaRbRcR-RMRERF((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pytdraw_rectangleżsWcC sgtod||||fGHn|o |i||||||ƒn|i||||||ƒdS(s- Draw the text.Text instance s at x,y (display coords) with font properties instance prop at angle in degrees, using GraphicsContext gc **backend implementers note** When you are trying to determine if you have gotten your bounding box right (which is what enables the text layout/alignment to work properly), it helps to change the line in text.py if 0: bbox_artist(self, renderer) to if 1, and then the actual bounding box will be blotted along with your text. s#draw_text: (%f,%f) %d degrees: '%s'N(t debugTexttdraw_math_texttdraw_plain_text(RR&RbRctstpropRtismath((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt draw_texts  c C sŠtod||||fGHntodt|ƒGHn|i||ƒd}ti|tidƒ||id}ti|tidƒ||id} |ii t ||ƒt || ƒ|ƒdS(sE Draw a text string verbatim; no conversion is done. s)draw_plain_text: (%f,%f) %d degrees: '%s's properties: i g€f@gĄr@N( RRt select_fontR[R^R]RNR\R%tTextOutRp( RR&RbRcR„R…Rthackoffsetper300dpitxhacktyhack((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyRƒ's))c C sItod||||fGHn|dd!}tid|ƒ}|oć|idƒ}to d|GHn|i|ƒ} | iddƒ| iƒ\} } | d} | d} |i|||d||ƒ|iƒ} | i |i ƒd ƒ|i||| |i |i ƒ|| d || |ƒn|i||||||ƒd S( sµ Draw a subset of TeX, currently handles exponents only. Since pyemf doesn't have any raster functionality yet, the texmanager.get_rgba won't help. s(draw_math_text: (%f,%f) %d degrees: '%s'ii’’’’s 10\^\{(.+)\}s exponent=%st10ggP@gš™™™™™é?iN( Rtretmatchtgroupt _get_font_ttftset_texttget_width_heightRƒtcopytset_sizetget_size_in_pointstpoints_to_pixelsRP( RR&RbRcR„R…RRtexpRDtwthtpropexp((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyR‚:s$     <cC sfto dGHn|dd!}tid|ƒ}|o |idƒ}to d|GHn|i|ƒ}|iddƒ|iƒ\}}|iƒ}|i|i ƒdƒ|i|ƒ} | i|dƒ| iƒ\} } || } || d } | d } | d } | |i |i ƒ7} tod || | fGHq\n|i ||t ƒ\} } | | fS( sĢ get the width and height in display coords of the string s with FontPropertry prop, ripped right out of backend_ps. This method must be kept in sync with draw_math_text. sget_math_text_width_height:ii’’’’s 10\^\{(.+)\}s exponent=%sRggš™™™™™é?igP@s math string=%s w,h=(%f,%f)(RRŽRRR‘R’R“R”R•R–R—RPtget_text_width_heighttFalse(RR„R…RR˜RDtw1th1R›tfontexptw2th2R™Rš((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pytget_math_text_width_heightTs2       cC stS(s‚return true if y small numbers are top for renderer Is used for drawing text (text.py) and images (image.py) only (tTrue(R((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pytflipytscC s|i|ifS(sF return the canvas width and height in display coords (R-RM(R((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pytget_canvas_width_height{scC s9|i||jo!|ii|ƒ||i|((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyt set_handle‚scC s%t||ƒ}t|iƒ|iƒ}|iƒ}t|ƒ}|ii|ƒ}|djo•|i i | dt|ƒdt|ƒdt i dddt i t it it it it iB|ƒ}tod|||fGHn||i|((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pytget_font_handles$   *  cC s&|i||ƒ}|id|ƒdS(NRD(RøR©(RR…RR>((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyRˆ„scC sžt|i|ƒ}t|ƒ}|ii|ƒ}|djo|iƒ}||i|((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyRXŖs    cC s˜|dj oƒt|i|ƒ}t|ƒ}|ii|ƒ}|djo|iƒ}||i|((sE/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_emf.pyRY¾s     cC s•t|ƒ}ti|ƒ}|djo@t|ƒ}to d|GHntt|ƒƒ}|t|s:0""&’“