You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jd...@us...> - 2010-06-17 17:45:44
|
Revision: 8440 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8440&view=rev Author: jdh2358 Date: 2010-06-17 17:45:38 +0000 (Thu, 17 Jun 2010) Log Message: ----------- add np and plt to default plot namespace in plot directive Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py Modified: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py =================================================================== --- trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py 2010-06-16 17:08:43 UTC (rev 8439) +++ trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py 2010-06-17 17:45:38 UTC (rev 8440) @@ -194,7 +194,8 @@ # it can get at its data files, if any. Add its path to sys.path # so it can import any helper modules sitting beside it. if plot_code is not None: - exec(plot_code) + exec_code = 'import numpy as np; import matplotlib.pyplot as plt\n%s'%plot_code + exec(exec_code) else: pwd = os.getcwd() path, fname = os.path.split(plot_path) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-16 17:08:52
|
Revision: 8439 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8439&view=rev Author: mdboom Date: 2010-06-16 17:08:43 +0000 (Wed, 16 Jun 2010) Log Message: ----------- Fix accessing uninitialized memory error. Modified Paths: -------------- trunk/matplotlib/src/_image.cpp Modified: trunk/matplotlib/src/_image.cpp =================================================================== --- trunk/matplotlib/src/_image.cpp 2010-06-15 19:32:24 UTC (rev 8438) +++ trunk/matplotlib/src/_image.cpp 2010-06-16 17:08:43 UTC (rev 8439) @@ -44,7 +44,7 @@ Image::Image() : bufferIn(NULL), rbufIn(NULL), colsIn(0), rowsIn(0), bufferOut(NULL), rbufOut(NULL), colsOut(0), rowsOut(0), BPP(4), - interpolation(BILINEAR), aspect(ASPECT_FREE), bg(1,1,1,0) { + interpolation(BILINEAR), aspect(ASPECT_FREE), bg(1,1,1,0), resample(true) { _VERBOSE("Image::Image"); } @@ -196,7 +196,7 @@ std::pair<agg::int8u*,bool> bufpair = _get_output_buffer(); Py::Object ret = Py::asObject(Py_BuildValue("lls#", rowsOut, colsOut, - bufpair.first, colsOut*rowsOut*4)); + bufpair.first, colsOut*rowsOut*4)); if (bufpair.second) delete [] bufpair.first; return ret; @@ -229,7 +229,7 @@ agg::rendering_buffer rtmp; rtmp.attach(reinterpret_cast<unsigned char*>(buf), colsOut, rowsOut, - row_len); + row_len); switch (format) { case 0: @@ -259,7 +259,7 @@ args.verify_length(0); int row_len = colsOut * 4; PyObject* o = Py_BuildValue("lls#", rowsOut, colsOut, - rbufOut, row_len * rowsOut); + rbufOut, row_len * rowsOut); return Py::asObject(o); } @@ -362,9 +362,9 @@ typedef agg::span_allocator<agg::rgba8> span_alloc_type; span_alloc_type sa; agg::rgba8 background(agg::rgba8(int(255*bg.r), - int(255*bg.g), - int(255*bg.b), - int(255*bg.a))); + int(255*bg.g), + int(255*bg.b), + int(255*bg.a))); // the image path agg::path_storage path; @@ -396,11 +396,11 @@ case NEAREST: { - typedef agg::span_image_filter_rgba_nn<img_accessor_type, interpolator_type> span_gen_type; - typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; - span_gen_type sg(ia, interpolator); - renderer_type ri(rb, sa, sg); - agg::render_scanlines(ras, sl, ri); + typedef agg::span_image_filter_rgba_nn<img_accessor_type, interpolator_type> span_gen_type; + typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; + span_gen_type sg(ia, interpolator); + renderer_type ri(rb, sa, sg); + agg::render_scanlines(ras, sl, ri); } break; @@ -414,22 +414,22 @@ case HAMMING: filter.calculate(agg::image_filter_hamming(), norm); break; case HERMITE: filter.calculate(agg::image_filter_hermite(), norm); break; } - if (resample) - { - typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type; - typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; - span_gen_type sg(ia, interpolator, filter); - renderer_type ri(rb, sa, sg); - agg::render_scanlines(ras, sl, ri); - } - else - { - typedef agg::span_image_filter_rgba_2x2<img_accessor_type, interpolator_type> span_gen_type; - typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; - span_gen_type sg(ia, interpolator, filter); - renderer_type ri(rb, sa, sg); - agg::render_scanlines(ras, sl, ri); - } + if (resample) + { + typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type; + typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; + span_gen_type sg(ia, interpolator, filter); + renderer_type ri(rb, sa, sg); + agg::render_scanlines(ras, sl, ri); + } + else + { + typedef agg::span_image_filter_rgba_2x2<img_accessor_type, interpolator_type> span_gen_type; + typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; + span_gen_type sg(ia, interpolator, filter); + renderer_type ri(rb, sa, sg); + agg::render_scanlines(ras, sl, ri); + } } break; case BILINEAR: @@ -463,22 +463,22 @@ case LANCZOS: filter.calculate(agg::image_filter_lanczos(radius), norm); break; case BLACKMAN: filter.calculate(agg::image_filter_blackman(radius), norm); break; } - if (resample) - { - typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type; - typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; - span_gen_type sg(ia, interpolator, filter); - renderer_type ri(rb, sa, sg); - agg::render_scanlines(ras, sl, ri); - } - else - { - typedef agg::span_image_filter_rgba<img_accessor_type, interpolator_type> span_gen_type; - typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; - span_gen_type sg(ia, interpolator, filter); - renderer_type ri(rb, sa, sg); - agg::render_scanlines(ras, sl, ri); - } + if (resample) + { + typedef agg::span_image_resample_rgba_affine<img_accessor_type> span_gen_type; + typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; + span_gen_type sg(ia, interpolator, filter); + renderer_type ri(rb, sa, sg); + agg::render_scanlines(ras, sl, ri); + } + else + { + typedef agg::span_image_filter_rgba<img_accessor_type, interpolator_type> span_gen_type; + typedef agg::renderer_scanline_aa<renderer_base, span_alloc_type, span_gen_type> renderer_type; + span_gen_type sg(ia, interpolator, filter); + renderer_type ri(rb, sa, sg); + agg::render_scanlines(ras, sl, ri); + } } break; @@ -660,7 +660,7 @@ behaviors().supportSetattr(); add_varargs_method( "apply_rotation", &Image::apply_rotation, Image::apply_rotation__doc__); - add_varargs_method( "apply_scaling", &Image::apply_scaling, Image::apply_scaling__doc__); + add_varargs_method( "apply_scaling", &Image::apply_scaling, Image::apply_scaling__doc__); add_varargs_method( "apply_translation", &Image::apply_translation, Image::apply_translation__doc__); add_keyword_method( "as_rgba_str", &Image::as_rgba_str, Image::as_rgba_str__doc__); add_varargs_method( "color_conv", &Image::color_conv, Image::color_conv__doc__); @@ -744,25 +744,25 @@ size_t ind=0; for (size_t j=0; j<thisim->rowsOut; j++) { for (size_t i=0; i<thisim->colsOut; i++) { - thisx = i+ox; + thisx = i+ox; - if (isflip) - thisy = thisim->rowsOut - j + oy; - else - thisy = j+oy; + if (isflip) + thisy = thisim->rowsOut - j + oy; + else + thisy = j+oy; - if (thisx>=numcols || thisy>=numrows) { - ind +=4; - continue; - } + if (thisx>=numcols || thisy>=numrows) { + ind +=4; + continue; + } - pixfmt::color_type p; - p.r = *(thisim->bufferOut+ind++); - p.g = *(thisim->bufferOut+ind++); - p.b = *(thisim->bufferOut+ind++); - p.a = *(thisim->bufferOut+ind++); - pixf.blend_pixel(thisx, thisy, p, 255); + pixfmt::color_type p; + p.r = *(thisim->bufferOut+ind++); + p.g = *(thisim->bufferOut+ind++); + p.b = *(thisim->bufferOut+ind++); + p.a = *(thisim->bufferOut+ind++); + pixf.blend_pixel(thisx, thisy, p, 255); } } } @@ -854,20 +854,20 @@ for (size_t rownum=0; rownum<imo->rowsIn; rownum++) { for (size_t colnum=0; colnum<imo->colsIn; colnum++) { - offset = rownum*A->strides[0] + colnum*A->strides[1]; - r = *(double *)(A->data + offset); - g = *(double *)(A->data + offset + A->strides[2] ); - b = *(double *)(A->data + offset + 2*A->strides[2] ); + offset = rownum*A->strides[0] + colnum*A->strides[1]; + r = *(double *)(A->data + offset); + g = *(double *)(A->data + offset + A->strides[2] ); + b = *(double *)(A->data + offset + 2*A->strides[2] ); - if (rgba) - alpha = *(double *)(A->data + offset + 3*A->strides[2] ); - else - alpha = 1.0; + if (rgba) + alpha = *(double *)(A->data + offset + 3*A->strides[2] ); + else + alpha = 1.0; - *buffer++ = int(255*r); // red - *buffer++ = int(255*g); // green - *buffer++ = int(255*b); // blue - *buffer++ = int(255*alpha); // alpha + *buffer++ = int(255*r); // red + *buffer++ = int(255*g); // green + *buffer++ = int(255*b); // blue + *buffer++ = int(255*alpha); // alpha } } @@ -963,19 +963,19 @@ const size_t N = imo->rowsIn * imo->colsIn; size_t i = 0; while (i<N) { - r = *(double *)(A->data++); - g = *(double *)(A->data++); - b = *(double *)(A->data++); + r = *(double *)(A->data++); + g = *(double *)(A->data++); + b = *(double *)(A->data++); - if (rgba) - alpha = *(double *)(A->data++); - else - alpha = 1.0; + if (rgba) + alpha = *(double *)(A->data++); + else + alpha = 1.0; - *buffer++ = int(255*r); // red - *buffer++ = int(255*g); // green - *buffer++ = int(255*b); // blue - *buffer++ = int(255*alpha); // alpha + *buffer++ = int(255*r); // red + *buffer++ = int(255*g); // green + *buffer++ = int(255*b); // blue + *buffer++ = int(255*alpha); // alpha } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-15 19:32:30
|
Revision: 8438 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8438&view=rev Author: mdboom Date: 2010-06-15 19:32:24 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Fix out-of-buffer read errors. Modified Paths: -------------- trunk/matplotlib/ttconv/pprdrv_tt2.cpp Modified: trunk/matplotlib/ttconv/pprdrv_tt2.cpp =================================================================== --- trunk/matplotlib/ttconv/pprdrv_tt2.cpp 2010-06-15 19:10:19 UTC (rev 8437) +++ trunk/matplotlib/ttconv/pprdrv_tt2.cpp 2010-06-15 19:32:24 UTC (rev 8438) @@ -50,13 +50,13 @@ int advance_width; /* Variables to hold the character data. */ - int *epts_ctr; /* array of contour endpoints */ - int num_pts, num_ctr; /* number of points, number of coutours */ - FWord *xcoor, *ycoor; /* arrays of x and y coordinates */ - BYTE *tt_flags; /* array of TrueType flags */ + int *epts_ctr; /* array of contour endpoints */ + int num_pts, num_ctr; /* number of points, number of coutours */ + FWord *xcoor, *ycoor; /* arrays of x and y coordinates */ + BYTE *tt_flags; /* array of TrueType flags */ double *area_ctr; char *check_ctr; - int *ctrset; /* in contour index followed by out contour index */ + int *ctrset; /* in contour index followed by out contour index */ int stack_depth; /* A book-keeping variable for keeping track of the depth of the PS stack */ @@ -100,31 +100,31 @@ */ void GlyphToType3::stack(TTStreamWriter& stream, int new_elem) { - if( !pdf_mode && num_pts > 25 ) /* Only do something of we will */ - { /* have a log of points. */ - if(stack_depth == 0) - { - stream.put_char('{'); - stack_depth=1; - } + if( !pdf_mode && num_pts > 25 ) /* Only do something of we will */ + { /* have a log of points. */ + if(stack_depth == 0) + { + stream.put_char('{'); + stack_depth=1; + } - stack_depth += new_elem; /* Account for what we propose to add */ + stack_depth += new_elem; /* Account for what we propose to add */ - if(stack_depth > 100) - { - stream.puts("}_e{"); - stack_depth = 3 + new_elem; /* A rough estimate */ - } - } + if(stack_depth > 100) + { + stream.puts("}_e{"); + stack_depth = 3 + new_elem; /* A rough estimate */ + } + } } /* end of stack() */ -void GlyphToType3::stack_end(TTStreamWriter& stream) /* called at end */ +void GlyphToType3::stack_end(TTStreamWriter& stream) /* called at end */ { if( !pdf_mode && stack_depth ) - { - stream.puts("}_e"); - stack_depth=0; - } + { + stream.puts("}_e"); + stack_depth=0; + } } /* end of stack_end() */ /* @@ -163,79 +163,79 @@ area_ctr[0]=area(xcoor, ycoor, epts_ctr[0]+1); for (i=1; i<num_ctr; i++) - area_ctr[i]=area(xcoor+epts_ctr[i-1]+1, ycoor+epts_ctr[i-1]+1, epts_ctr[i]-epts_ctr[i-1]); + area_ctr[i]=area(xcoor+epts_ctr[i-1]+1, ycoor+epts_ctr[i-1]+1, epts_ctr[i]-epts_ctr[i-1]); for (i=0; i<num_ctr; i++) - { - if (area_ctr[i]>0) - { - ctrset[2*i]=i; ctrset[2*i+1]=nearout(i); - } - else - { - ctrset[2*i]=-1; ctrset[2*i+1]=-1; - } - } + { + if (area_ctr[i]>0) + { + ctrset[2*i]=i; ctrset[2*i+1]=nearout(i); + } + else + { + ctrset[2*i]=-1; ctrset[2*i+1]=-1; + } + } /* Step thru the coutours. */ /* I believe that a contour is a detatched */ /* set of curves and lines. */ i=j=k=0; while( i < num_ctr ) - { - fst = j = (k==0) ? 0 : (epts_ctr[k-1]+1); + { + fst = j = (k==0) ? 0 : (epts_ctr[k-1]+1); - /* Move to the first point on the contour. */ - stack(stream, 3); - PSMoveto(stream,xcoor[j],ycoor[j]); + /* Move to the first point on the contour. */ + stack(stream, 3); + PSMoveto(stream,xcoor[j],ycoor[j]); - start_offpt = 0; /* No off curve points yet. */ + start_offpt = 0; /* No off curve points yet. */ - /* Step thru the remaining points of this contour. */ - for(j++; j <= epts_ctr[k]; j++) - { - if (!(tt_flags[j]&1)) /* Off curve */ - { - if (!start_offpt) - { start_offpt = end_offpt = j; } - else - end_offpt++; - } - else - { /* On Curve */ - if (start_offpt) - { - stack(stream, 7); - PSCurveto(stream, xcoor[j],ycoor[j],start_offpt,end_offpt); - start_offpt = 0; - } - else - { + /* Step thru the remaining points of this contour. */ + for(j++; j <= epts_ctr[k]; j++) + { + if (!(tt_flags[j]&1)) /* Off curve */ + { + if (!start_offpt) + { start_offpt = end_offpt = j; } + else + end_offpt++; + } + else + { /* On Curve */ + if (start_offpt) + { + stack(stream, 7); + PSCurveto(stream, xcoor[j],ycoor[j],start_offpt,end_offpt); + start_offpt = 0; + } + else + { stack(stream, 3); - PSLineto(stream, xcoor[j], ycoor[j]); - } - } - } + PSLineto(stream, xcoor[j], ycoor[j]); + } + } + } - /* Do the final curve or line */ - /* of this coutour. */ - if (start_offpt) - { - stack(stream, 7); PSCurveto(stream, xcoor[fst],ycoor[fst],start_offpt,end_offpt); - } - else - { - stack(stream, 3); PSLineto(stream, xcoor[fst],ycoor[fst]); - } + /* Do the final curve or line */ + /* of this coutour. */ + if (start_offpt) + { + stack(stream, 7); PSCurveto(stream, xcoor[fst],ycoor[fst],start_offpt,end_offpt); + } + else + { + stack(stream, 3); PSLineto(stream, xcoor[fst],ycoor[fst]); + } - k=nextinctr(i,k); + k=nextinctr(i,k); - if (k==NOMOREINCTR) - i=k=nextoutctr(i); + if (k==NOMOREINCTR) + i=k=nextoutctr(i); - if (i==NOMOREOUTCTR) - break; - } + if (i==NOMOREOUTCTR) + break; + } /* Now, we can fill the whole thing. */ stack(stream, 1); @@ -251,98 +251,104 @@ } /* end of PSConvert() */ int GlyphToType3::nextoutctr(int co) - { - int j; + { + int j; - for(j=0; j<num_ctr; j++) - if (check_ctr[j]==0 && area_ctr[j] < 0) { - check_ctr[j]=1; - return j; - } + for(j=0; j<num_ctr; j++) + if (check_ctr[j]==0 && area_ctr[j] < 0) { + check_ctr[j]=1; + return j; + } - return NOMOREOUTCTR; - } /* end of nextoutctr() */ + return NOMOREOUTCTR; + } /* end of nextoutctr() */ int GlyphToType3::nextinctr(int co, int ci) - { - int j; + { + int j; - for(j=0; j<num_ctr; j++) + for(j=0; j<num_ctr; j++) if (ctrset[2*j+1]==co) if (check_ctr[ctrset[2*j]]==0) { - check_ctr[ctrset[2*j]]=1; - return ctrset[2*j]; - } + check_ctr[ctrset[2*j]]=1; + return ctrset[2*j]; + } - return NOMOREINCTR; - } + return NOMOREINCTR; + } /* ** find the nearest out contour to a specified in contour. */ int GlyphToType3::nearout(int ci) { - int k = 0; /* !!! is this right? */ + int k = 0; /* !!! is this right? */ int co; double a, a1=0; for (co=0; co < num_ctr; co++) - { - if(area_ctr[co] < 0) - { - a=intest(co,ci); - if (a<0 && a1==0) - { - k=co; - a1=a; - } - if(a<0 && a1!=0 && a>a1) - { - k=co; - a1=a; - } - } - } + { + if(area_ctr[co] < 0) + { + a=intest(co,ci); + if (a<0 && a1==0) + { + k=co; + a1=a; + } + if(a<0 && a1!=0 && a>a1) + { + k=co; + a1=a; + } + } + } return k; } /* end of nearout() */ double GlyphToType3::intest(int co, int ci) - { - int i, j, start, end; - double r1, r2, a; - FWord xi[3], yi[3]; + { + int i, j, start, end; + double r1, r2, a; + FWord xi[3], yi[3]; - j=start=(co==0)?0:(epts_ctr[co-1]+1); - end=epts_ctr[co]; - i=(ci==0)?0:(epts_ctr[ci-1]+1); - xi[0] = xcoor[i]; - yi[0] = ycoor[i]; - r1=sqr(xcoor[start] - xi[0]) + sqr(ycoor[start] - yi[0]); + j=start=(co==0)?0:(epts_ctr[co-1]+1); + end=epts_ctr[co]; + i=(ci==0)?0:(epts_ctr[ci-1]+1); + xi[0] = xcoor[i]; + yi[0] = ycoor[i]; + r1=sqr(xcoor[start] - xi[0]) + sqr(ycoor[start] - yi[0]); - for (i=start; i<=end; i++) { - r2 = sqr(xcoor[i] - xi[0])+sqr(ycoor[i] - yi[0]); - if (r2 < r1) { - r1=r2; j=i; - } - } - xi[1]=xcoor[j-1]; yi[1]=ycoor[j-1]; - xi[2]=xcoor[j+1]; yi[2]=ycoor[j+1]; - if (j==start) { xi[1]=xcoor[end]; yi[1]=ycoor[end]; } - if (j==end) { xi[2]=xcoor[start]; yi[2]=ycoor[start]; } - a=area(xi, yi, 3); + for (i=start; i<=end; i++) { + r2 = sqr(xcoor[i] - xi[0])+sqr(ycoor[i] - yi[0]); + if (r2 < r1) { + r1=r2; j=i; + } + } + if (j==start) { + xi[1]=xcoor[end]; yi[1]=ycoor[end]; + } else { + xi[1]=xcoor[j-1]; yi[1]=ycoor[j-1]; + } + if (j==end) { + xi[2]=xcoor[start]; yi[2]=ycoor[start]; + } else { + xi[2]=xcoor[j+1]; yi[2]=ycoor[j+1]; + } + a=area(xi, yi, 3); - return a; - } /* end of intest() */ + return a; + } /* end of intest() */ void GlyphToType3::PSMoveto(TTStreamWriter& stream, int x, int y) { stream.printf(pdf_mode ? "%d %d m\n" : "%d %d _m\n", - x, y); + x, y); } void GlyphToType3::PSLineto(TTStreamWriter& stream, int x, int y) { stream.printf(pdf_mode ? "%d %d l\n" : "%d %d _l\n", - x, y); + x, y); } /* @@ -355,26 +361,26 @@ N = t-s+2; for(i=0; i<N-1; i++) - { - sx[0] = i==0?xcoor[s-1]:(xcoor[i+s]+xcoor[i+s-1])/2; - sy[0] = i==0?ycoor[s-1]:(ycoor[i+s]+ycoor[i+s-1])/2; - sx[1] = xcoor[s+i]; - sy[1] = ycoor[s+i]; - sx[2] = i==N-2?x:(xcoor[s+i]+xcoor[s+i+1])/2; - sy[2] = i==N-2?y:(ycoor[s+i]+ycoor[s+i+1])/2; - cx[3] = sx[2]; - cy[3] = sy[2]; - cx[1] = (2*sx[1]+sx[0])/3; - cy[1] = (2*sy[1]+sy[0])/3; - cx[2] = (sx[2]+2*sx[1])/3; - cy[2] = (sy[2]+2*sy[1])/3; + { + sx[0] = i==0?xcoor[s-1]:(xcoor[i+s]+xcoor[i+s-1])/2; + sy[0] = i==0?ycoor[s-1]:(ycoor[i+s]+ycoor[i+s-1])/2; + sx[1] = xcoor[s+i]; + sy[1] = ycoor[s+i]; + sx[2] = i==N-2?x:(xcoor[s+i]+xcoor[s+i+1])/2; + sy[2] = i==N-2?y:(ycoor[s+i]+ycoor[s+i+1])/2; + cx[3] = sx[2]; + cy[3] = sy[2]; + cx[1] = (2*sx[1]+sx[0])/3; + cy[1] = (2*sy[1]+sy[0])/3; + cx[2] = (sx[2]+2*sx[1])/3; + cy[2] = (sy[2]+2*sy[1])/3; - stream.printf(pdf_mode ? - "%d %d %d %d %d %d c\n" : - "%d %d %d %d %d %d _c\n", - (int)cx[1], (int)cy[1], (int)cx[2], (int)cy[2], - (int)cx[3], (int)cy[3]); - } + stream.printf(pdf_mode ? + "%d %d %d %d %d %d c\n" : + "%d %d %d %d %d %d _c\n", + (int)cx[1], (int)cy[1], (int)cx[2], (int)cy[2], + (int)cx[3], (int)cy[3]); + } } /* end of PSCurveto() */ /* @@ -382,10 +388,10 @@ ** the data for the last simple glyph. */ GlyphToType3::~GlyphToType3() { - free(tt_flags); /* The flags array */ - free(xcoor); /* The X coordinates */ - free(ycoor); /* The Y coordinates */ - free(epts_ctr); /* The array of contour endpoints */ + free(tt_flags); /* The flags array */ + free(xcoor); /* The X coordinates */ + free(ycoor); /* The Y coordinates */ + free(epts_ctr); /* The array of contour endpoints */ // These last three should be NULL. Just // free'ing them for safety. free(area_ctr); @@ -406,10 +412,10 @@ /* Read the contour endpoints list. */ epts_ctr = (int *)calloc(num_ctr,sizeof(int)); for (x = 0; x < num_ctr; x++) - { - epts_ctr[x] = getUSHORT(glyph); - glyph += 2; - } + { + epts_ctr[x] = getUSHORT(glyph); + glyph += 2; + } /* From the endpoint of the last contour, we can */ /* determine the number of points. */ @@ -432,71 +438,71 @@ /* Read the flags array, uncompressing it as we go. */ /* There is danger of overflow here. */ for (x = 0; x < num_pts; ) - { - tt_flags[x++] = c = *(glyph++); + { + tt_flags[x++] = c = *(glyph++); - if (c&8) /* If next byte is repeat count, */ - { - ct = *(glyph++); + if (c&8) /* If next byte is repeat count, */ + { + ct = *(glyph++); - if( (x + ct) > num_pts ) - throw TTException("Error in TT flags"); + if( (x + ct) > num_pts ) + throw TTException("Error in TT flags"); - while (ct--) - tt_flags[x++] = c; - } - } + while (ct--) + tt_flags[x++] = c; + } + } /* Read the x coordinates */ for (x = 0; x < num_pts; x++) - { - if (tt_flags[x] & 2) /* one byte value with */ - { /* external sign */ - c = *(glyph++); - xcoor[x] = (tt_flags[x] & 0x10) ? c : (-1 * (int)c); - } - else if(tt_flags[x] & 0x10) /* repeat last */ - { - xcoor[x] = 0; - } - else /* two byte signed value */ - { - xcoor[x] = getFWord(glyph); - glyph+=2; - } - } + { + if (tt_flags[x] & 2) /* one byte value with */ + { /* external sign */ + c = *(glyph++); + xcoor[x] = (tt_flags[x] & 0x10) ? c : (-1 * (int)c); + } + else if(tt_flags[x] & 0x10) /* repeat last */ + { + xcoor[x] = 0; + } + else /* two byte signed value */ + { + xcoor[x] = getFWord(glyph); + glyph+=2; + } + } /* Read the y coordinates */ for(x = 0; x < num_pts; x++) - { - if (tt_flags[x] & 4) /* one byte value with */ - { /* external sign */ - c = *(glyph++); - ycoor[x] = (tt_flags[x] & 0x20) ? c : (-1 * (int)c); - } - else if (tt_flags[x] & 0x20) /* repeat last value */ - { - ycoor[x] = 0; - } - else /* two byte signed value */ - { - ycoor[x] = getUSHORT(glyph); - glyph+=2; - } - } + { + if (tt_flags[x] & 4) /* one byte value with */ + { /* external sign */ + c = *(glyph++); + ycoor[x] = (tt_flags[x] & 0x20) ? c : (-1 * (int)c); + } + else if (tt_flags[x] & 0x20) /* repeat last value */ + { + ycoor[x] = 0; + } + else /* two byte signed value */ + { + ycoor[x] = getUSHORT(glyph); + glyph+=2; + } + } /* Convert delta values to absolute values. */ for(x = 1; x < num_pts; x++) - { - xcoor[x] += xcoor[x-1]; - ycoor[x] += ycoor[x-1]; - } + { + xcoor[x] += xcoor[x-1]; + ycoor[x] += ycoor[x-1]; + } for(x=0; x < num_pts; x++) - { - xcoor[x] = topost(xcoor[x]); - ycoor[x] = topost(ycoor[x]); - } + { + xcoor[x] = topost(xcoor[x]); + ycoor[x] = topost(ycoor[x]); + } } /* end of load_char() */ @@ -515,101 +521,101 @@ USHORT scale10; /* Once around this loop for each component. */ - do { - flags = getUSHORT(glyph); /* read the flags word */ - glyph += 2; + do { + flags = getUSHORT(glyph); /* read the flags word */ + glyph += 2; - glyphIndex = getUSHORT(glyph); /* read the glyphindex word */ - glyph += 2; + glyphIndex = getUSHORT(glyph); /* read the glyphindex word */ + glyph += 2; - if(flags & ARG_1_AND_2_ARE_WORDS) - { /* The tt spec. seems to say these are signed. */ - arg1 = getSHORT(glyph); - glyph += 2; - arg2 = getSHORT(glyph); - glyph += 2; - } - else /* The tt spec. does not clearly indicate */ - { /* whether these values are signed or not. */ + if(flags & ARG_1_AND_2_ARE_WORDS) + { /* The tt spec. seems to say these are signed. */ + arg1 = getSHORT(glyph); + glyph += 2; + arg2 = getSHORT(glyph); + glyph += 2; + } + else /* The tt spec. does not clearly indicate */ + { /* whether these values are signed or not. */ arg1 = *(signed char *)(glyph++); arg2 = *(signed char *)(glyph++); - } + } - if(flags & WE_HAVE_A_SCALE) - { - xscale = yscale = getUSHORT(glyph); - glyph += 2; - scale01 = scale10 = 0; - } - else if(flags & WE_HAVE_AN_X_AND_Y_SCALE) - { - xscale = getUSHORT(glyph); - glyph += 2; - yscale = getUSHORT(glyph); - glyph += 2; - scale01 = scale10 = 0; - } - else if(flags & WE_HAVE_A_TWO_BY_TWO) - { - xscale = getUSHORT(glyph); - glyph += 2; - scale01 = getUSHORT(glyph); - glyph += 2; - scale10 = getUSHORT(glyph); - glyph += 2; - yscale = getUSHORT(glyph); - glyph += 2; - } - else - { - xscale = yscale = scale01 = scale10 = 0; - } + if(flags & WE_HAVE_A_SCALE) + { + xscale = yscale = getUSHORT(glyph); + glyph += 2; + scale01 = scale10 = 0; + } + else if(flags & WE_HAVE_AN_X_AND_Y_SCALE) + { + xscale = getUSHORT(glyph); + glyph += 2; + yscale = getUSHORT(glyph); + glyph += 2; + scale01 = scale10 = 0; + } + else if(flags & WE_HAVE_A_TWO_BY_TWO) + { + xscale = getUSHORT(glyph); + glyph += 2; + scale01 = getUSHORT(glyph); + glyph += 2; + scale10 = getUSHORT(glyph); + glyph += 2; + yscale = getUSHORT(glyph); + glyph += 2; + } + else + { + xscale = yscale = scale01 = scale10 = 0; + } - /* Debugging */ - #ifdef DEBUG_TRUETYPE - stream.printf("%% flags=%d, arg1=%d, arg2=%d, xscale=%d, yscale=%d, scale01=%d, scale10=%d\n", - (int)flags,arg1,arg2,(int)xscale,(int)yscale,(int)scale01,(int)scale10); - #endif + /* Debugging */ + #ifdef DEBUG_TRUETYPE + stream.printf("%% flags=%d, arg1=%d, arg2=%d, xscale=%d, yscale=%d, scale01=%d, scale10=%d\n", + (int)flags,arg1,arg2,(int)xscale,(int)yscale,(int)scale01,(int)scale10); + #endif - if (pdf_mode) { - if ( flags & ARGS_ARE_XY_VALUES ) { - /* We should have been able to use 'Do' to reference the - subglyph here. However, that doesn't seem to work with - xpdf or gs (only acrobat), so instead, this just includes - the subglyph here inline. */ - stream.printf("q 1 0 0 1 %d %d cm\n", topost(arg1), topost(arg2)); - } else { - stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2); - } - GlyphToType3(stream, font, glyphIndex, true); - if ( flags & ARGS_ARE_XY_VALUES ) { - stream.printf("\nQ\n"); - } - } else { - /* If we have an (X,Y) shif and it is non-zero, */ - /* translate the coordinate system. */ - if( flags & ARGS_ARE_XY_VALUES ) - { - if( arg1 != 0 || arg2 != 0 ) - stream.printf("gsave %d %d translate\n", topost(arg1), topost(arg2) ); - } - else - { - stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2); - } + if (pdf_mode) { + if ( flags & ARGS_ARE_XY_VALUES ) { + /* We should have been able to use 'Do' to reference the + subglyph here. However, that doesn't seem to work with + xpdf or gs (only acrobat), so instead, this just includes + the subglyph here inline. */ + stream.printf("q 1 0 0 1 %d %d cm\n", topost(arg1), topost(arg2)); + } else { + stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2); + } + GlyphToType3(stream, font, glyphIndex, true); + if ( flags & ARGS_ARE_XY_VALUES ) { + stream.printf("\nQ\n"); + } + } else { + /* If we have an (X,Y) shif and it is non-zero, */ + /* translate the coordinate system. */ + if( flags & ARGS_ARE_XY_VALUES ) + { + if( arg1 != 0 || arg2 != 0 ) + stream.printf("gsave %d %d translate\n", topost(arg1), topost(arg2) ); + } + else + { + stream.printf("%% unimplemented shift, arg1=%d, arg2=%d\n",arg1,arg2); + } - /* Invoke the CharStrings procedure to print the component. */ - stream.printf("false CharStrings /%s get exec\n", - ttfont_CharStrings_getname(font,glyphIndex)); + /* Invoke the CharStrings procedure to print the component. */ + stream.printf("false CharStrings /%s get exec\n", + ttfont_CharStrings_getname(font,glyphIndex)); - /* If we translated the coordinate system, */ - /* put it back the way it was. */ - if( flags & ARGS_ARE_XY_VALUES && (arg1 != 0 || arg2 != 0) ) { - stream.puts("grestore "); - } - } + /* If we translated the coordinate system, */ + /* put it back the way it was. */ + if( flags & ARGS_ARE_XY_VALUES && (arg1 != 0 || arg2 != 0) ) { + stream.puts("grestore "); + } + } - } while(flags & MORE_COMPONENTS); + } while(flags & MORE_COMPONENTS); } /* end of do_composite() */ @@ -623,24 +629,24 @@ /* Read the glyph offset from the index to location table. */ if(font->indexToLocFormat == 0) - { - off = getUSHORT( font->loca_table + (charindex * 2) ); - off *= 2; - length = getUSHORT( font->loca_table + ((charindex+1) * 2) ); - length *= 2; - length -= off; - } + { + off = getUSHORT( font->loca_table + (charindex * 2) ); + off *= 2; + length = getUSHORT( font->loca_table + ((charindex+1) * 2) ); + length *= 2; + length -= off; + } else - { - off = getULONG( font->loca_table + (charindex * 4) ); - length = getULONG( font->loca_table + ((charindex+1) * 4) ); - length -= off; - } + { + off = getULONG( font->loca_table + (charindex * 4) ); + length = getULONG( font->loca_table + ((charindex+1) * 4) ); + length -= off; + } if(length > 0) - return font->glyf_table + off; + return font->glyf_table + off; else - return (BYTE*)NULL; + return (BYTE*)NULL; } /* end of find_glyph_data() */ @@ -663,61 +669,61 @@ /* If the character is blank, it has no bounding box, */ /* otherwise read the bounding box. */ if( glyph == (BYTE*)NULL ) - { - llx=lly=urx=ury=0; /* A blank char has an all zero BoundingBox */ - num_ctr=0; /* Set this for later if()s */ - } + { + llx=lly=urx=ury=0; /* A blank char has an all zero BoundingBox */ + num_ctr=0; /* Set this for later if()s */ + } else - { - /* Read the number of contours. */ - num_ctr = getSHORT(glyph); + { + /* Read the number of contours. */ + num_ctr = getSHORT(glyph); - /* Read PostScript bounding box. */ - llx = getFWord(glyph + 2); - lly = getFWord(glyph + 4); - urx = getFWord(glyph + 6); - ury = getFWord(glyph + 8); + /* Read PostScript bounding box. */ + llx = getFWord(glyph + 2); + lly = getFWord(glyph + 4); + urx = getFWord(glyph + 6); + ury = getFWord(glyph + 8); - /* Advance the pointer. */ - glyph += 10; - } + /* Advance the pointer. */ + glyph += 10; + } /* If it is a simple character, load its data. */ if (num_ctr > 0) - load_char(font, glyph); + load_char(font, glyph); else num_pts=0; /* Consult the horizontal metrics table to determine */ /* the character width. */ if( charindex < font->numberOfHMetrics ) - advance_width = getuFWord( font->hmtx_table + (charindex * 4) ); + advance_width = getuFWord( font->hmtx_table + (charindex * 4) ); else - advance_width = getuFWord( font->hmtx_table + ((font->numberOfHMetrics-1) * 4) ); + advance_width = getuFWord( font->hmtx_table + ((font->numberOfHMetrics-1) * 4) ); /* Execute setcachedevice in order to inform the font machinery */ /* of the character bounding box and advance width. */ stack(stream, 7); if (pdf_mode) { - if (!embedded) - stream.printf("%d 0 %d %d %d %d d1\n", - topost(advance_width), - topost(llx), topost(lly), topost(urx), topost(ury) ); + if (!embedded) + stream.printf("%d 0 %d %d %d %d d1\n", + topost(advance_width), + topost(llx), topost(lly), topost(urx), topost(ury) ); } else - stream.printf("%d 0 %d %d %d %d _sc\n", - topost(advance_width), - topost(llx), topost(lly), topost(urx), topost(ury) ); + stream.printf("%d 0 %d %d %d %d _sc\n", + topost(advance_width), + topost(llx), topost(lly), topost(urx), topost(ury) ); /* If it is a simple glyph, convert it, */ /* otherwise, close the stack business. */ - if( num_ctr > 0 ) /* simple */ - { + if( num_ctr > 0 ) /* simple */ + { PSConvert(stream); - } - else if( num_ctr < 0 ) /* composite */ - { - do_composite(stream, font, glyph); - } + } + else if( num_ctr < 0 ) /* composite */ + { + do_composite(stream, font, glyph); + } stack_end(stream); } @@ -740,50 +746,50 @@ std::stack<int> glyph_stack; for (std::vector<int>::iterator i = glyph_ids.begin(); - i != glyph_ids.end(); ++i) { - glyph_stack.push(*i); + i != glyph_ids.end(); ++i) { + glyph_stack.push(*i); } while (glyph_stack.size()) { - int gind = glyph_stack.top(); - glyph_stack.pop(); + int gind = glyph_stack.top(); + glyph_stack.pop(); - BYTE* glyph = find_glyph_data( font, gind ); - if (glyph != (BYTE*)NULL) { + BYTE* glyph = find_glyph_data( font, gind ); + if (glyph != (BYTE*)NULL) { - int num_ctr = getSHORT(glyph); - if (num_ctr <= 0) { // This is a composite glyph + int num_ctr = getSHORT(glyph); + if (num_ctr <= 0) { // This is a composite glyph - glyph += 10; - USHORT flags = 0; + glyph += 10; + USHORT flags = 0; - do { - flags = getUSHORT(glyph); - glyph += 2; - gind = (int)getUSHORT(glyph); - glyph += 2; + do { + flags = getUSHORT(glyph); + glyph += 2; + gind = (int)getUSHORT(glyph); + glyph += 2; - std::vector<int>::iterator insertion = - std::lower_bound(glyph_ids.begin(), glyph_ids.end(), gind); - if (*insertion != gind) { - glyph_ids.insert(insertion, gind); - glyph_stack.push(gind); - } + std::vector<int>::iterator insertion = + std::lower_bound(glyph_ids.begin(), glyph_ids.end(), gind); + if (*insertion != gind) { + glyph_ids.insert(insertion, gind); + glyph_stack.push(gind); + } - if (flags & ARG_1_AND_2_ARE_WORDS) - glyph += 4; - else - glyph += 2; + if (flags & ARG_1_AND_2_ARE_WORDS) + glyph += 4; + else + glyph += 2; - if (flags & WE_HAVE_A_SCALE) - glyph += 2; - else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) - glyph += 4; - else if (flags & WE_HAVE_A_TWO_BY_TWO) - glyph += 8; - } while (flags & MORE_COMPONENTS); - } - } + if (flags & WE_HAVE_A_SCALE) + glyph += 2; + else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) + glyph += 4; + else if (flags & WE_HAVE_A_TWO_BY_TWO) + glyph += 8; + } while (flags & MORE_COMPONENTS); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-15 19:10:26
|
Revision: 8437 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8437&view=rev Author: mdboom Date: 2010-06-15 19:10:19 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Use the word "snapping" everywhere for consistency. This is the word used in the outward-facing interface all along. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/_backend_agg.h trunk/matplotlib/src/_macosx.m trunk/matplotlib/src/_path.cpp trunk/matplotlib/src/path_cleanup.cpp trunk/matplotlib/src/path_cleanup.h trunk/matplotlib/src/path_converters.h Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2010-06-15 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/lib/matplotlib/path.py 2010-06-15 19:10:19 UTC (rev 8437) @@ -188,7 +188,7 @@ return len(self.vertices) def iter_segments(self, transform=None, remove_nans=True, clip=None, - quantize=False, stroke_width=1.0, simplify=None, + snap=False, stroke_width=1.0, simplify=None, curves=True): """ Iterates over all of the curve segments in the path. Each @@ -208,11 +208,12 @@ *clip*: if not None, must be a four-tuple (x1, y1, x2, y2) defining a rectangle in which to clip the path. - *quantize*: if None, auto-quantize. If True, force quantize, - and if False, don't quantize. + *snap*: if None, auto-snap to pixels, to reduce + fuzziness of rectilinear lines. If True, force snapping, and + if False, don't snap. *stroke_width*: the width of the stroke being drawn. Needed - as a hint for the quantizer. + as a hint for the snapping algorithm. *simplify*: if True, perform simplification, to remove vertices that do not affect the appearance of the path. If @@ -236,7 +237,7 @@ STOP = self.STOP vertices, codes = cleanup_path(self, transform, remove_nans, clip, - quantize, stroke_width, simplify, curves) + snap, stroke_width, simplify, curves) len_vertices = len(vertices) i = 0 Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2010-06-15 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/_backend_agg.cpp 2010-06-15 19:10:19 UTC (rev 8437) @@ -270,11 +270,11 @@ Py::Callable method(method_obj); Py::Object py_snap = method.apply(Py::Tuple()); if (py_snap.isNone()) { - quantize_mode = QUANTIZE_AUTO; + snap_mode = SNAP_AUTO; } else if (py_snap.isTrue()) { - quantize_mode = QUANTIZE_TRUE; + snap_mode = SNAP_TRUE; } else { - quantize_mode = QUANTIZE_FALSE; + snap_mode = SNAP_FALSE; } } @@ -506,8 +506,8 @@ Py::Object RendererAgg::draw_markers(const Py::Tuple& args) { typedef agg::conv_transform<PathIterator> transformed_path_t; - typedef PathQuantizer<transformed_path_t> quantize_t; - typedef agg::conv_curve<quantize_t> curve_t; + typedef PathSnapper<transformed_path_t> snap_t; + typedef agg::conv_curve<snap_t> curve_t; typedef agg::conv_stroke<curve_t> stroke_t; typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; @@ -533,19 +533,19 @@ PathIterator marker_path(marker_path_obj); transformed_path_t marker_path_transformed(marker_path, marker_trans); - quantize_t marker_path_quantized(marker_path_transformed, - gc.quantize_mode, - marker_path.total_vertices(), - gc.linewidth); - curve_t marker_path_curve(marker_path_quantized); + snap_t marker_path_snapped(marker_path_transformed, + gc.snap_mode, + marker_path.total_vertices(), + gc.linewidth); + curve_t marker_path_curve(marker_path_snapped); PathIterator path(path_obj); transformed_path_t path_transformed(path, trans); - quantize_t path_quantized(path_transformed, - gc.quantize_mode, - path.total_vertices(), - 1.0); - curve_t path_curve(path_quantized); + snap_t path_snapped(path_transformed, + gc.snap_mode, + path.total_vertices(), + 1.0); + curve_t path_curve(path_snapped); path_curve.rewind(0); facepair_t face = _get_rgba_face(face_obj, gc.alpha); @@ -1079,8 +1079,8 @@ typedef agg::conv_transform<PathIterator> transformed_path_t; typedef PathNanRemover<transformed_path_t> nan_removed_t; typedef PathClipper<nan_removed_t> clipped_t; - typedef PathQuantizer<clipped_t> quantized_t; - typedef PathSimplifier<quantized_t> simplify_t; + typedef PathSnapper<clipped_t> snapped_t; + typedef PathSimplifier<snapped_t> simplify_t; typedef agg::conv_curve<simplify_t> curve_t; _VERBOSE("RendererAgg::draw_path"); @@ -1108,8 +1108,8 @@ transformed_path_t tpath(path, trans); nan_removed_t nan_removed(tpath, true, path.has_curves()); clipped_t clipped(nan_removed, clip, width, height); - quantized_t quantized(clipped, gc.quantize_mode, path.total_vertices(), gc.linewidth); - simplify_t simplified(quantized, simplify, path.simplify_threshold()); + snapped_t snapped(clipped, gc.snap_mode, path.total_vertices(), gc.linewidth); + simplify_t simplified(snapped, simplify, path.simplify_threshold()); curve_t curve(simplified); try { @@ -1141,8 +1141,8 @@ typedef agg::conv_transform<typename PathGenerator::path_iterator> transformed_path_t; typedef PathNanRemover<transformed_path_t> nan_removed_t; typedef PathClipper<nan_removed_t> clipped_t; - typedef PathQuantizer<clipped_t> quantized_t; - typedef agg::conv_curve<quantized_t> quantized_curve_t; + typedef PathSnapper<clipped_t> snapped_t; + typedef agg::conv_curve<snapped_t> snapped_curve_t; typedef agg::conv_curve<clipped_t> curve_t; PyArrayObject* offsets = NULL; @@ -1275,13 +1275,13 @@ transformed_path_t tpath(path, trans); nan_removed_t nan_removed(tpath, true, has_curves); clipped_t clipped(nan_removed, do_clip, width, height); - quantized_t quantized(clipped, gc.quantize_mode, - path.total_vertices(), gc.linewidth); + snapped_t snapped(clipped, gc.snap_mode, + path.total_vertices(), gc.linewidth); if (has_curves) { - quantized_curve_t curve(quantized); + snapped_curve_t curve(snapped); _draw_path(curve, has_clippath, face, gc); } else { - _draw_path(quantized, has_clippath, face, gc); + _draw_path(snapped, has_clippath, face, gc); } } else { gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); Modified: trunk/matplotlib/src/_backend_agg.h =================================================================== --- trunk/matplotlib/src/_backend_agg.h 2010-06-15 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/_backend_agg.h 2010-06-15 19:10:19 UTC (rev 8437) @@ -123,7 +123,7 @@ typedef std::vector<std::pair<double, double> > dash_t; double dashOffset; dash_t dashes; - e_quantize_mode quantize_mode; + e_snap_mode snap_mode; Py::Object hatchpath; Modified: trunk/matplotlib/src/_macosx.m =================================================================== --- trunk/matplotlib/src/_macosx.m 2010-06-15 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/_macosx.m 2010-06-15 19:10:19 UTC (rev 8437) @@ -288,7 +288,7 @@ 0, 0, rect, - QUANTIZE_FALSE, + SNAP_FALSE, 1.0, 0); Py_DECREF(transform); @@ -446,13 +446,13 @@ return p; } -static int _get_snap(GraphicsContext* self, enum e_quantize_mode* mode) +static int _get_snap(GraphicsContext* self, enum e_snap_mode* mode) { PyObject* snap = PyObject_CallMethod((PyObject*)self, "get_snap", ""); if(!snap) return 0; - if(snap==Py_None) *mode = QUANTIZE_AUTO; - else if (PyBool_Check(snap)) *mode = QUANTIZE_TRUE; - else *mode = QUANTIZE_FALSE; + if(snap==Py_None) *mode = SNAP_AUTO; + else if (PyBool_Check(snap)) *mode = SNAP_TRUE; + else *mode = SNAP_FALSE; Py_DECREF(snap); return 1; } @@ -662,7 +662,7 @@ 0, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, 1.0, 0); Py_DECREF(transform); @@ -892,7 +892,7 @@ 1, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, linewidth, rgbFace == NULL); if (!iterator) @@ -970,7 +970,7 @@ 1, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, linewidth, 0); if (!iterator) @@ -1006,7 +1006,7 @@ CGMutablePathRef marker; void* iterator; double rect[4] = {0.0, 0.0, self->size.width, self->size.height}; - enum e_quantize_mode mode; + enum e_snap_mode mode; double xc, yc; unsigned code; @@ -1071,7 +1071,7 @@ 1, 1, rect, - QUANTIZE_TRUE, + SNAP_TRUE, 1.0, 0); if (!iterator) @@ -1225,7 +1225,7 @@ /* --------- Prepare some variables for the path iterator ------------- */ void* iterator; double rect[4] = {0.0, 0.0, self->size.width, self->size.height}; - enum e_quantize_mode mode; + enum e_snap_mode mode; ok = _get_snap(self, &mode); if (!ok) { @@ -1382,7 +1382,7 @@ 0, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, 1.0, 0); if (!iterator) @@ -1690,7 +1690,7 @@ 0, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, 1.0, 0); if (iterator) @@ -2676,7 +2676,7 @@ 0, 0, rect, - QUANTIZE_AUTO, + SNAP_AUTO, 1.0, 0); if (iterator) Modified: trunk/matplotlib/src/_path.cpp =================================================================== --- trunk/matplotlib/src/_path.cpp 2010-06-15 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/_path.cpp 2010-06-15 19:10:19 UTC (rev 8437) @@ -55,7 +55,7 @@ add_varargs_method("convert_path_to_polygons", &_path_module::convert_path_to_polygons, "convert_path_to_polygons(path, trans, width, height)"); add_varargs_method("cleanup_path", &_path_module::cleanup_path, - "cleanup_path(path, trans, remove_nans, clip, quantize, simplify, curves)"); + "cleanup_path(path, trans, remove_nans, clip, snap, simplify, curves)"); initialize("Helper functions for paths"); } @@ -1228,22 +1228,22 @@ void _cleanup_path(PathIterator& path, const agg::trans_affine& trans, bool remove_nans, bool do_clip, const agg::rect_base<double>& rect, - e_quantize_mode quantize_mode, double stroke_width, + e_snap_mode snap_mode, double stroke_width, bool do_simplify, bool return_curves, std::vector<double>& vertices, std::vector<npy_uint8>& codes) { typedef agg::conv_transform<PathIterator> transformed_path_t; typedef PathNanRemover<transformed_path_t> nan_removal_t; typedef PathClipper<nan_removal_t> clipped_t; - typedef PathQuantizer<clipped_t> quantized_t; - typedef PathSimplifier<quantized_t> simplify_t; + typedef PathSnapper<clipped_t> snapped_t; + typedef PathSimplifier<snapped_t> simplify_t; typedef agg::conv_curve<simplify_t> curve_t; transformed_path_t tpath(path, trans); nan_removal_t nan_removed(tpath, remove_nans, path.has_curves()); clipped_t clipped(nan_removed, do_clip, rect); - quantized_t quantized(clipped, quantize_mode, path.total_vertices(), stroke_width); - simplify_t simplified(quantized, do_simplify, path.simplify_threshold()); + snapped_t snapped(clipped, snap_mode, path.total_vertices(), stroke_width); + simplify_t simplified(snapped, do_simplify, path.simplify_threshold()); vertices.reserve(path.total_vertices() * 2); codes.reserve(path.total_vertices()); @@ -1286,19 +1286,19 @@ do_clip = true; } - Py::Object quantize_obj = args[4]; - e_quantize_mode quantize_mode; - if (quantize_obj.isNone()) + Py::Object snap_obj = args[4]; + e_snap_mode snap_mode; + if (snap_obj.isNone()) { - quantize_mode = QUANTIZE_AUTO; + snap_mode = SNAP_AUTO; } - else if (quantize_obj.isTrue()) + else if (snap_obj.isTrue()) { - quantize_mode = QUANTIZE_TRUE; + snap_mode = SNAP_TRUE; } else { - quantize_mode = QUANTIZE_FALSE; + snap_mode = SNAP_FALSE; } double stroke_width = Py::Float(args[5]); @@ -1319,7 +1319,7 @@ std::vector<double> vertices; std::vector<npy_uint8> codes; - _cleanup_path(path, trans, remove_nans, do_clip, clip_rect, quantize_mode, + _cleanup_path(path, trans, remove_nans, do_clip, clip_rect, snap_mode, stroke_width, simplify, return_curves, vertices, codes); npy_intp length = codes.size(); Modified: trunk/matplotlib/src/path_cleanup.cpp =================================================================== --- trunk/matplotlib/src/path_cleanup.cpp 2010-06-15 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/path_cleanup.cpp 2010-06-15 19:10:19 UTC (rev 8437) @@ -12,8 +12,8 @@ typedef agg::conv_transform<PathIterator> transformed_path_t; typedef PathNanRemover<transformed_path_t> nan_removal_t; typedef PathClipper<nan_removal_t> clipped_t; - typedef PathQuantizer<clipped_t> quantized_t; - typedef PathSimplifier<quantized_t> simplify_t; + typedef PathSnapper<clipped_t> snapped_t; + typedef PathSimplifier<snapped_t> simplify_t; Py::Object m_path_obj; PathIterator m_path_iter; @@ -21,14 +21,14 @@ transformed_path_t m_transformed; nan_removal_t m_nan_removed; clipped_t m_clipped; - quantized_t m_quantized; + snapped_t m_snapped; simplify_t m_simplify; public: PathCleanupIterator(PyObject* path, agg::trans_affine trans, bool remove_nans, bool do_clip, const agg::rect_base<double>& rect, - e_quantize_mode quantize_mode, double stroke_width, + e_snap_mode snap_mode, double stroke_width, bool do_simplify) : m_path_obj(path, true), m_path_iter(m_path_obj), @@ -36,9 +36,9 @@ m_transformed(m_path_iter, m_transform), m_nan_removed(m_transformed, remove_nans, m_path_iter.has_curves()), m_clipped(m_nan_removed, do_clip, rect), - m_quantized(m_clipped, quantize_mode, m_path_iter.total_vertices(), - stroke_width), - m_simplify(m_quantized, do_simplify && m_path_iter.should_simplify(), + m_snapped(m_clipped, snap_mode, m_path_iter.total_vertices(), + stroke_width), + m_simplify(m_snapped, do_simplify && m_path_iter.should_simplify(), m_path_iter.simplify_threshold()) { Py_INCREF(path); @@ -55,7 +55,7 @@ void* get_path_iterator( PyObject* path, PyObject* trans, int remove_nans, int do_clip, - double rect[4], e_quantize_mode quantize_mode, double stroke_width, + double rect[4], e_snap_mode snap_mode, double stroke_width, int do_simplify) { agg::trans_affine agg_trans = py_to_agg_transformation_matrix(trans, false); @@ -63,7 +63,7 @@ PathCleanupIterator* pipeline = new PathCleanupIterator( path, agg_trans, remove_nans != 0, do_clip != 0, - clip_rect, quantize_mode, stroke_width, do_simplify != 0); + clip_rect, snap_mode, stroke_width, do_simplify != 0); return (void*)pipeline; } Modified: trunk/matplotlib/src/path_cleanup.h =================================================================== --- trunk/matplotlib/src/path_cleanup.h 2010-06-15 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/path_cleanup.h 2010-06-15 19:10:19 UTC (rev 8437) @@ -3,17 +3,17 @@ #include <Python.h> -enum e_quantize_mode +enum e_snap_mode { - QUANTIZE_AUTO, - QUANTIZE_FALSE, - QUANTIZE_TRUE + SNAP_AUTO, + SNAP_FALSE, + SNAP_TRUE }; void* get_path_iterator( PyObject* path, PyObject* trans, int remove_nans, int do_clip, - double rect[4], enum e_quantize_mode quantize_mode, double stroke_width, + double rect[4], enum e_snap_mode snap_mode, double stroke_width, int do_simplify); unsigned Modified: trunk/matplotlib/src/path_converters.h =================================================================== --- trunk/matplotlib/src/path_converters.h 2010-06-15 13:01:22 UTC (rev 8436) +++ trunk/matplotlib/src/path_converters.h 2010-06-15 19:10:19 UTC (rev 8437) @@ -26,7 +26,7 @@ Agg where coordinates can not be larger than 24-bit signed integers. - 4. PathQuantizer: Rounds the path to the nearest center-pixels. + 4. PathSnapper: Rounds the path to the nearest center-pixels. This makes rectilinear curves look much better. 5. PathSimplifier: Removes line segments from highly dense paths @@ -361,36 +361,36 @@ }; /************************************************************ - PathQuantizer rounds vertices to their nearest center-pixels. This + PathSnapper rounds vertices to their nearest center-pixels. This makes rectilinear paths (rectangles, horizontal and vertical lines etc.) look much cleaner. */ -enum e_quantize_mode +enum e_snap_mode { - QUANTIZE_AUTO, - QUANTIZE_FALSE, - QUANTIZE_TRUE + SNAP_AUTO, + SNAP_FALSE, + SNAP_TRUE }; template<class VertexSource> -class PathQuantizer +class PathSnapper { private: VertexSource* m_source; - bool m_quantize; - double m_quantize_value; + bool m_snap; + double m_snap_value; - static bool should_quantize(VertexSource& path, - e_quantize_mode quantize_mode, - unsigned total_vertices) { + static bool should_snap(VertexSource& path, + e_snap_mode snap_mode, + unsigned total_vertices) { // If this contains only straight horizontal or vertical lines, it should be - // quantized to the nearest pixels + // snapped to the nearest pixels double x0, y0, x1, y1; unsigned code; - switch (quantize_mode) + switch (snap_mode) { - case QUANTIZE_AUTO: + case SNAP_AUTO: if (total_vertices > 1024) { return false; @@ -420,9 +420,9 @@ } return true; - case QUANTIZE_FALSE: + case SNAP_FALSE: return false; - case QUANTIZE_TRUE: + case SNAP_TRUE: return true; } @@ -431,21 +431,21 @@ public: /* - quantize_mode should be one of: - - QUANTIZE_AUTO: Examine the path to determine if it should be quantized - - QUANTIZE_TRUE: Force quantization - - QUANTIZE_FALSE: No quantization + snap_mode should be one of: + - SNAP_AUTO: Examine the path to determine if it should be snapped + - SNAP_TRUE: Force snapping + - SNAP_FALSE: No snapping */ - PathQuantizer(VertexSource& source, e_quantize_mode quantize_mode, + PathSnapper(VertexSource& source, e_snap_mode snap_mode, unsigned total_vertices=15, double stroke_width=0.0) : m_source(&source) { - m_quantize = should_quantize(source, quantize_mode, total_vertices); + m_snap = should_snap(source, snap_mode, total_vertices); - if (m_quantize) + if (m_snap) { - int odd_even = (int)mpl_round(stroke_width) % 2; - m_quantize_value = (odd_even) ? 0.5 : 0.0; + int is_odd = (int)mpl_round(stroke_width) % 2; + m_snap_value = (is_odd) ? 0.5 : 0.0; } source.rewind(0); @@ -460,17 +460,17 @@ { unsigned code; code = m_source->vertex(x, y); - if (m_quantize && agg::is_vertex(code)) - { - *x = mpl_round(*x) + m_quantize_value; - *y = mpl_round(*y) + m_quantize_value; + if (m_snap && agg::is_vertex(code)) + { + *x = mpl_round(*x) + m_snap_value; + *y = mpl_round(*y) + m_snap_value; } return code; } - inline bool is_quantizing() + inline bool is_snapping() { - return m_quantize; + return m_snap; } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-15 13:01:29
|
Revision: 8436 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8436&view=rev Author: mdboom Date: 2010-06-15 13:01:22 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Support the "Enter" key event in the Qt4 backend. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-06-14 05:51:06 UTC (rev 8435) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-06-15 13:01:22 UTC (rev 8436) @@ -129,6 +129,7 @@ keyvald = { QtCore.Qt.Key_Control : 'control', QtCore.Qt.Key_Shift : 'shift', QtCore.Qt.Key_Alt : 'alt', + QtCore.Qt.Key_Return : 'enter' } # left 1, middle 2, right 3 buttond = {1:1, 2:3, 4:2} @@ -314,16 +315,19 @@ self.window._destroying = False self.toolbar = self._get_toolbar(self.canvas, self.window) - self.window.addToolBar(self.toolbar) - QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"), - self.window.statusBar().showMessage) + if self.toolbar is not None: + self.window.addToolBar(self.toolbar) + QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"), + self.window.statusBar().showMessage) + tbs_height = self.toolbar.sizeHint().height() + else: + tbs_height = 0 # resize the main window so it will display the canvas with the # requested size: cs = canvas.sizeHint() - tbs = self.toolbar.sizeHint() sbs = self.window.statusBar().sizeHint() - self.window.resize(cs.width(), cs.height()+tbs.height()+sbs.height()) + self.window.resize(cs.width(), cs.height()+tbs_height+sbs.height()) self.window.setCentralWidget(self.canvas) @@ -335,7 +339,8 @@ def notify_axes_change( fig ): # This will be called whenever the current axes is changed - if self.toolbar != None: self.toolbar.update() + if self.toolbar is not None: + self.toolbar.update() self.canvas.figure.add_axobserver( notify_axes_change ) def _widgetclosed( self ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-14 05:51:13
|
Revision: 8435 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8435&view=rev Author: efiring Date: 2010-06-14 05:51:06 +0000 (Mon, 14 Jun 2010) Log Message: ----------- cutils.py: fix and clarify absolute imports, so I don't get confused next time Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/config/cutils.py Modified: trunk/matplotlib/lib/matplotlib/config/cutils.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/cutils.py 2010-06-14 05:31:20 UTC (rev 8434) +++ trunk/matplotlib/lib/matplotlib/config/cutils.py 2010-06-14 05:51:06 UTC (rev 8435) @@ -8,9 +8,10 @@ import tempfile import warnings -# matplotlib imports -from matplotlib.verbose import verbose -from matplotlib.rcsetup import defaultParams +# imports from local modules that duplicate +# functionality in matplotlib.__init__ +from matplotlib.config.verbose import verbose +from matplotlib.config.rcsetup import defaultParams def is_string_like(obj): try: obj + '' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-14 05:31:26
|
Revision: 8434 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8434&view=rev Author: efiring Date: 2010-06-14 05:31:20 +0000 (Mon, 14 Jun 2010) Log Message: ----------- [2895114] _get_data_path: improve py2exe handling and readability. Also convert some imports to absolute. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/config/cutils.py Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2010-06-14 02:53:59 UTC (rev 8433) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2010-06-14 05:31:20 UTC (rev 8434) @@ -126,8 +126,10 @@ import sys, os, tempfile -from rcsetup import defaultParams, validate_backend, validate_toolbar -from rcsetup import validate_cairo_format +from matplotlib.rcsetup import (defaultParams, + validate_backend, + validate_toolbar, + validate_cairo_format) major, minor1, minor2, s, tmp = sys.version_info _python24 = major>=2 and minor1>=4 @@ -478,28 +480,33 @@ return path path = os.sep.join([os.path.dirname(__file__), 'mpl-data']) - if os.path.isdir(path): return path + if os.path.isdir(path): + return path # setuptools' namespace_packages may highjack this init file # so need to try something known to be in matplotlib, not basemap import matplotlib.afm path = os.sep.join([os.path.dirname(matplotlib.afm.__file__), 'mpl-data']) - if os.path.isdir(path): return path + if os.path.isdir(path): + return path # py2exe zips pure python, so still need special check if getattr(sys,'frozen',None): - path = os.path.join(os.path.split(sys.path[0])[0], 'mpl-data') - if os.path.isdir(path): return path - else: - # Try again assuming we need to step up one more directory - path = os.path.join(os.path.split(os.path.split(sys.path[0])[0])[0], - 'mpl-data') - if os.path.isdir(path): return path - else: - # Try again assuming sys.path[0] is a dir not a exe - path = os.path.join(sys.path[0], 'mpl-data') - if os.path.isdir(path): return path + exe_path = os.path.dirname(sys.executable) + path = os.path.join(exe_path, 'mpl-data') + if os.path.isdir(path): + return path + # Try again assuming we need to step up one more directory + path = os.path.join(os.path.split(exe_path)[0], 'mpl-data') + if os.path.isdir(path): + return path + + # Try again assuming sys.path[0] is a dir not a exe + path = os.path.join(sys.path[0], 'mpl-data') + if os.path.isdir(path): + return path + raise RuntimeError('Could not find the matplotlib data files') def _get_data_path_cached(): @@ -813,11 +820,12 @@ if NEWCONFIG: #print "importing from reorganized config system!" try: - from config import rcParams, rcdefaults, mplConfig, save_config + from matplotlib.config import (rcParams, rcdefaults, + mplConfig, save_config) verbose.set_level(rcParams['verbose.level']) verbose.set_fileo(rcParams['verbose.fileo']) except: - from config import rcParams, rcdefaults + from matplotlib.config import rcParams, rcdefaults _use_error_msg = """ This call to matplotlib.use() has no effect because the the backend has already been chosen; Modified: trunk/matplotlib/lib/matplotlib/config/cutils.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/cutils.py 2010-06-14 02:53:59 UTC (rev 8433) +++ trunk/matplotlib/lib/matplotlib/config/cutils.py 2010-06-14 05:31:20 UTC (rev 8434) @@ -9,8 +9,8 @@ import warnings # matplotlib imports -from verbose import verbose -from rcsetup import defaultParams +from matplotlib.verbose import verbose +from matplotlib.rcsetup import defaultParams def is_string_like(obj): try: obj + '' @@ -92,6 +92,10 @@ def _get_data_path(): 'get the path to matplotlib data' +## The following is duplicated in matplotlib.__init__ +def _get_data_path(): + 'get the path to matplotlib data' + if 'MATPLOTLIBDATA' in os.environ: path = os.environ['MATPLOTLIBDATA'] if not os.path.isdir(path): @@ -99,30 +103,36 @@ return path path = os.sep.join([os.path.dirname(__file__), 'mpl-data']) - if os.path.isdir(path): return path + if os.path.isdir(path): + return path # setuptools' namespace_packages may highjack this init file # so need to try something known to be in matplotlib, not basemap import matplotlib.afm path = os.sep.join([os.path.dirname(matplotlib.afm.__file__), 'mpl-data']) - if os.path.isdir(path): return path + if os.path.isdir(path): + return path # py2exe zips pure python, so still need special check if getattr(sys,'frozen',None): - path = os.path.join(os.path.split(sys.path[0])[0], 'mpl-data') - if os.path.isdir(path): return path - else: - # Try again assuming we need to step up one more directory - path = os.path.join(os.path.split(os.path.split(sys.path[0])[0])[0], - 'mpl-data') - if os.path.isdir(path): return path - else: - # Try again assuming sys.path[0] is a dir not a exe - path = os.path.join(sys.path[0], 'mpl-data') - if os.path.isdir(path): return path + exe_path = os.path.dirname(sys.executable) + path = os.path.join(exe_path, 'mpl-data') + if os.path.isdir(path): + return path + # Try again assuming we need to step up one more directory + path = os.path.join(os.path.split(exe_path)[0], 'mpl-data') + if os.path.isdir(path): + return path + + # Try again assuming sys.path[0] is a dir not a exe + path = os.path.join(sys.path[0], 'mpl-data') + if os.path.isdir(path): + return path + raise RuntimeError('Could not find the matplotlib data files') + def _get_data_path_cached(): if defaultParams['datapath'][0] is None: defaultParams['datapath'][0] = _get_data_path() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-14 02:54:05
|
Revision: 8433 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8433&view=rev Author: efiring Date: 2010-06-14 02:53:59 +0000 (Mon, 14 Jun 2010) Log Message: ----------- cbook: handle empty string returned by locale.getpreferredencoding Reported by Huziy Oleksandr. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2010-06-14 02:33:37 UTC (rev 8432) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2010-06-14 02:53:59 UTC (rev 8433) @@ -23,11 +23,14 @@ # On some systems, locale.getpreferredencoding returns None, # which can break unicode; and the sage project reports that # some systems have incorrect locale specifications, e.g., -# an encoding instead of a valid locale name. +# an encoding instead of a valid locale name. Another +# pathological case that has been reported is an empty string. try: - preferredencoding = locale.getpreferredencoding() -except (ValueError, ImportError): + preferredencoding = locale.getpreferredencoding().strip() + if not preferredencoding: + preferredencoding = None +except (ValueError, ImportError, AttributeError): preferredencoding = None def unicode_safe(s): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-14 02:33:43
|
Revision: 8432 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8432&view=rev Author: efiring Date: 2010-06-14 02:33:37 +0000 (Mon, 14 Jun 2010) Log Message: ----------- [3015614] give examples/api/font_file.py a fighting chance on Linux and Win Modified Paths: -------------- trunk/matplotlib/examples/api/font_file.py Modified: trunk/matplotlib/examples/api/font_file.py =================================================================== --- trunk/matplotlib/examples/api/font_file.py 2010-06-14 01:49:12 UTC (rev 8431) +++ trunk/matplotlib/examples/api/font_file.py 2010-06-14 02:33:37 UTC (rev 8432) @@ -1,19 +1,40 @@ -# -*- noplot -*- -""" -Although it is usually not a good idea to explicitly point to a single -ttf file for a font instance, you can do so using the -font_manager.FontProperties fname argument (for a more flexible -solution, see the font_fmaily_rc.py and fonts_demo.py examples). -""" -import matplotlib.font_manager as fm - -import matplotlib.pyplot as plt - -fig = plt.figure() -ax = fig.add_subplot(111) -ax.plot([1,2,3]) - -prop = fm.FontProperties(fname='/Library/Fonts/Tahoma.ttf') -ax.set_title('this is a special font', fontproperties=prop) -plt.show() - +# -*- noplot -*- +""" +Although it is usually not a good idea to explicitly point to a single +ttf file for a font instance, you can do so using the +font_manager.FontProperties fname argument (for a more flexible +solution, see the font_fmaily_rc.py and fonts_demo.py examples). +""" +import sys +import os +import matplotlib.font_manager as fm + +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.add_subplot(111) +ax.plot([1,2,3]) + +if sys.platform == 'win32': + fpath = 'C:\\Windows\\Fonts\\Tahoma.ttf' +elif sys.platform == 'linux2': + fonts = ['/usr/share/fonts/truetype/freefont/FreeSansBoldOblique.ttf', + '/usr/share/fonts/truetype/ttf-liberation/LiberationSans-BoldItalic.ttf', + '/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf', + ] + for fpath in fonts: + if os.path.exists(fpath): + break +else: + fpath = '/Library/Fonts/Tahoma.ttf' + +if os.path.exists(fpath): + prop = fm.FontProperties(fname=fpath) + fname = os.path.split(fpath)[1] + ax.set_title('this is a special font: %s' % fname, fontproperties=prop) +else: + ax.set_title('Demo fails--cannot find a demo font') +ax.set_xlabel('This is the default font') + +plt.show() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-14 01:49:18
|
Revision: 8431 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8431&view=rev Author: efiring Date: 2010-06-14 01:49:12 +0000 (Mon, 14 Jun 2010) Log Message: ----------- numpy version check: make it more readable Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/__init__.py Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2010-06-14 01:17:23 UTC (rev 8430) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2010-06-14 01:49:12 UTC (rev 8431) @@ -145,12 +145,10 @@ raise ImportError('matplotlib requires Python 2.4 or later') import numpy -nn = numpy.__version__.split('.') -if not (int(nn[0]) >= 1 and int(nn[1]) >= 1): - if not (int(nn[0]) >= 2): - raise ImportError( - 'numpy 1.1 or later is required; you have %s' % - numpy.__version__) +nmajor, nminor = [int(n) for n in numpy.__version__.split('.')[:2]] +if not (nmajor > 1 or (nmajor == 1 and nminor >= 1)): + raise ImportError( + 'numpy 1.1 or later is required; you have %s' % numpy.__version__) def is_string_like(obj): if hasattr(obj, 'shape'): return 0 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-14 01:17:30
|
Revision: 8430 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8430&view=rev Author: efiring Date: 2010-06-14 01:17:23 +0000 (Mon, 14 Jun 2010) Log Message: ----------- [1474254] getp, setp: minor clarifications Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/artist.py Modified: trunk/matplotlib/lib/matplotlib/artist.py =================================================================== --- trunk/matplotlib/lib/matplotlib/artist.py 2010-06-14 00:54:41 UTC (rev 8429) +++ trunk/matplotlib/lib/matplotlib/artist.py 2010-06-14 01:17:23 UTC (rev 8430) @@ -1082,25 +1082,25 @@ -def getp(o, property=None): +def getp(obj, property=None): """ - Return the value of handle property. property is an optional string + Return the value of object's property. *property* is an optional string for the property you want to return Example usage:: - getp(o) # get all the object properties - getp(o, 'linestyle') # get the linestyle property + getp(obj) # get all the object properties + getp(obj, 'linestyle') # get the linestyle property - *o* is a :class:`Artist` instance, eg + *obj* is a :class:`Artist` instance, eg :class:`~matplotllib.lines.Line2D` or an instance of a :class:`~matplotlib.axes.Axes` or :class:`matplotlib.text.Text`. If the *property* is 'somename', this function returns - o.get_somename() + obj.get_somename() :func:`getp` can be used to query all the gettable properties with - ``getp(o)``. Many properties have aliases for shorter typing, e.g. + ``getp(obj)``. Many properties have aliases for shorter typing, e.g. 'lw' is an alias for 'linewidth'. In the output, aliases and full property names will be listed as: @@ -1111,21 +1111,20 @@ linewidth or lw = 2 """ - insp = ArtistInspector(o) if property is None: + insp = ArtistInspector(obj) ret = insp.pprint_getters() print '\n'.join(ret) return - func = getattr(o, 'get_' + property) - + func = getattr(obj, 'get_' + property) return func() # alias get = getp -def setp(h, *args, **kwargs): +def setp(obj, *args, **kwargs): """ matplotlib supports the use of :func:`setp` ("set property") and :func:`getp` to set and get object properties, as well as to do @@ -1160,7 +1159,7 @@ >>> lines = plot(x, y1, x, y2) >>> setp(lines, linewidth=2, color='r') - :func:`setp` works with the matlab(TM) style string/value pairs or + :func:`setp` works with the matlab style string/value pairs or with python kwargs. For example, the following are equivalent:: >>> setp(lines, 'linewidth', 2, 'color', r') # matlab style @@ -1168,7 +1167,7 @@ >>> setp(lines, linewidth=2, color='r') # python style """ - insp = ArtistInspector(h) + insp = ArtistInspector(obj) if len(kwargs)==0 and len(args)==0: print '\n'.join(insp.pprint_setters()) @@ -1178,8 +1177,10 @@ print insp.pprint_setters(prop=args[0]) return - if not cbook.iterable(h): h = [h] - else: h = cbook.flatten(h) + if not cbook.iterable(obj): + objs = [obj] + else: + objs = cbook.flatten(obj) if len(args)%2: @@ -1191,11 +1192,11 @@ funcvals.extend(kwargs.items()) ret = [] - for o in h: + for o in objs: for s, val in funcvals: s = s.lower() funcName = "set_%s"%s - func = getattr(o,funcName) + func = getattr(o, funcName) ret.extend( [func(val)] ) return [x for x in cbook.flatten(ret)] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-14 00:54:48
|
Revision: 8429 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8429&view=rev Author: efiring Date: 2010-06-14 00:54:41 +0000 (Mon, 14 Jun 2010) Log Message: ----------- [1467533] pie shadows are tagged with _nolabel_ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2010-06-13 23:04:30 UTC (rev 8428) +++ trunk/matplotlib/lib/matplotlib/axes.py 2010-06-14 00:54:41 UTC (rev 8429) @@ -4777,6 +4777,7 @@ #props={'facecolor':w.get_facecolor()} ) shad.set_zorder(0.9*w.get_zorder()) + shad.set_label('_nolegend_') self.add_patch(shad) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-13 23:04:37
|
Revision: 8428 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8428&view=rev Author: efiring Date: 2010-06-13 23:04:30 +0000 (Sun, 13 Jun 2010) Log Message: ----------- [2922266] pyplot_tutorial.rst: remove tabs from code (patch by Ori Avtalion) Modified Paths: -------------- trunk/matplotlib/doc/users/pyplot_tutorial.rst Modified: trunk/matplotlib/doc/users/pyplot_tutorial.rst =================================================================== --- trunk/matplotlib/doc/users/pyplot_tutorial.rst 2010-06-13 22:53:25 UTC (rev 8427) +++ trunk/matplotlib/doc/users/pyplot_tutorial.rst 2010-06-13 23:04:30 UTC (rev 8428) @@ -75,7 +75,7 @@ one line so it is a list of length 1. I use tuple unpacking in the ``line, = plot(x, y, 'o')`` to get the first element of the list:: - line, = plt.plot(x, y, '-') + line, = plt.plot(x, y, '-') line.set_antialiased(False) # turn off antialising * Use the :func:`~matplotlib.pyplot.setp` command. The example below This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-13 22:53:31
|
Revision: 8427 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8427&view=rev Author: efiring Date: 2010-06-13 22:53:25 +0000 (Sun, 13 Jun 2010) Log Message: ----------- [2922387] axis.py: docstring fix by Ori Avtalion Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axis.py Modified: trunk/matplotlib/lib/matplotlib/axis.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis.py 2010-06-13 22:44:02 UTC (rev 8426) +++ trunk/matplotlib/lib/matplotlib/axis.py 2010-06-13 22:53:25 UTC (rev 8427) @@ -666,7 +666,7 @@ raise NotImplementedError('Derived must override') def set_data_interval(self): - 'Set the axis data limits' + 'set the axis data limits' raise NotImplementedError('Derived must override') def set_default_intervals(self): @@ -1510,7 +1510,7 @@ return self.axes.dataLim.intervalx def set_data_interval(self, vmin, vmax, ignore=False): - 'return the Interval instance for this axis data limits' + 'set the axis data limits' if ignore: self.axes.dataLim.intervalx = vmin, vmax else: @@ -1776,7 +1776,7 @@ return self.axes.dataLim.intervaly def set_data_interval(self, vmin, vmax, ignore=False): - 'return the Interval instance for this axis data limits' + 'set the axis data limits' if ignore: self.axes.dataLim.intervaly = vmin, vmax else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-13 22:44:09
|
Revision: 8426 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8426&view=rev Author: efiring Date: 2010-06-13 22:44:02 +0000 (Sun, 13 Jun 2010) Log Message: ----------- remade filesave icon bitmapped files from filesave.svg Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mpl-data/images/filesave.png trunk/matplotlib/lib/matplotlib/mpl-data/images/filesave.ppm trunk/matplotlib/lib/matplotlib/mpl-data/images/filesave.xpm Modified: trunk/matplotlib/lib/matplotlib/mpl-data/images/filesave.png =================================================================== (Binary files differ) Modified: trunk/matplotlib/lib/matplotlib/mpl-data/images/filesave.ppm =================================================================== --- trunk/matplotlib/lib/matplotlib/mpl-data/images/filesave.ppm 2010-06-13 21:31:46 UTC (rev 8425) +++ trunk/matplotlib/lib/matplotlib/mpl-data/images/filesave.ppm 2010-06-13 22:44:02 UTC (rev 8426) @@ -1,4 +1,33 @@ P6 24 24 255 -\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE6\xE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ѱ\xC4\xAA\xB8s\x96\xA8r\x95\xA7q\x94\xA5q\x92\xA2o\x91\xA3n\x8F\xA1m\x8E\xA1l\x8D\x9Ek\x8C\x9D\x83\x9C\xA9>u\x8DCgAcEh +Yz[|TvSu Tvz\xA2\xB4\xB6\xC9Ӳ\xC6Ю\xC2\xCBOv\x8B)G_(G_(F_'F_'F^'E^'E^&E]&E]\\x92@v\x8DEi |
From: <ef...@us...> - 2010-06-13 21:31:52
|
Revision: 8425 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8425&view=rev Author: efiring Date: 2010-06-13 21:31:46 +0000 (Sun, 13 Jun 2010) Log Message: ----------- [2924597] coding_guide.rst: refer to memleak_hawaii3.py Modified Paths: -------------- trunk/matplotlib/doc/devel/coding_guide.rst Modified: trunk/matplotlib/doc/devel/coding_guide.rst =================================================================== --- trunk/matplotlib/doc/devel/coding_guide.rst 2010-06-13 21:04:14 UTC (rev 8424) +++ trunk/matplotlib/doc/devel/coding_guide.rst 2010-06-13 21:31:46 UTC (rev 8425) @@ -57,7 +57,7 @@ * Can you add a test to :file:`unit/nose_tests.py` to test your changes? * If you have altered extension code, do you pass - :file:`unit/memleak_hawaii.py`? + :file:`unit/memleak_hawaii3.py`? * if you have added new files or directories, or reorganized existing ones, are the new files included in the match patterns in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-13 21:04:21
|
Revision: 8424 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8424&view=rev Author: efiring Date: 2010-06-13 21:04:14 +0000 (Sun, 13 Jun 2010) Log Message: ----------- [3015013] use atexit in _pylab_helpers to ensure orderly shutdown. It closes all windows; in the case of Tk, this calls the root.destroy() function, which should prevent the PyEval_RestoreThread error on Win. See http://mail.python.org/pipermail/python-bugs-list/2002-November/014207.html This changeset also refactors the close() functionality into three Gcf methods, fixing a bug (or inconsistency) in which calling close with a figure number failed to call mpl_disconnect. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/_pylab_helpers.py trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py trunk/matplotlib/lib/matplotlib/pyplot.py Modified: trunk/matplotlib/lib/matplotlib/_pylab_helpers.py =================================================================== --- trunk/matplotlib/lib/matplotlib/_pylab_helpers.py 2010-06-12 23:40:19 UTC (rev 8423) +++ trunk/matplotlib/lib/matplotlib/_pylab_helpers.py 2010-06-13 21:04:14 UTC (rev 8424) @@ -4,8 +4,12 @@ import sys, gc +import atexit +import traceback + + def error_msg(msg): - print >>sys.stderr, msgs + print >>sys.stderr, msg class Gcf(object): """ @@ -34,10 +38,10 @@ If figure manager *num* exists, make it the active figure and return the manager; otherwise return *None*. """ - figManager = Gcf.figs.get(num, None) - if figManager is not None: - Gcf.set_active(figManager) - return figManager + manager = Gcf.figs.get(num, None) + if manager is not None: + Gcf.set_active(manager) + return manager @staticmethod def destroy(num): @@ -48,22 +52,36 @@ window "destroy" and "delete" events. """ if not Gcf.has_fignum(num): return - figManager = Gcf.figs[num] + manager = Gcf.figs[num] + manager.canvas.mpl_disconnect(manager._cidgcf) # There must be a good reason for the following careful # rebuilding of the activeQue; what is it? oldQue = Gcf._activeQue[:] Gcf._activeQue = [] for f in oldQue: - if f != figManager: + if f != manager: Gcf._activeQue.append(f) del Gcf.figs[num] #print len(Gcf.figs.keys()), len(Gcf._activeQue) - figManager.destroy() + manager.destroy() gc.collect() @staticmethod + def destroy_fig(fig): + "*fig* is a Figure instance" + for manager in Gcf.figs.values(): + if manager.canvas.figure == fig: + Gcf.destroy(manager.num) + + @staticmethod + def destroy_all(): + for manager in Gcf.figs.values(): + Gcf.destroy(manager.num) + + + @staticmethod def has_fignum(num): """ Return *True* if figure *num* exists. @@ -105,3 +123,7 @@ Gcf._activeQue.append(manager) Gcf.figs[manager.num] = manager +atexit.register(Gcf.destroy_all) + + + Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2010-06-12 23:40:19 UTC (rev 8423) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2010-06-13 21:04:14 UTC (rev 8424) @@ -551,7 +551,7 @@ self.canvas.destroy() if self.toolbar: self.toolbar.destroy() - self.__dict__.clear() + self.__dict__.clear() #Is this needed? Other backends don't have it. if Gcf.get_num_fig_managers()==0 and \ not matplotlib.is_interactive() and \ Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 23:40:19 UTC (rev 8423) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-13 21:04:14 UTC (rev 8424) @@ -491,10 +491,8 @@ if self.window is not None: #self.toolbar.destroy() self.window.destroy() + self.window = None - pass - self.window = None - def set_window_title(self, title): self.window.wm_title(title) Modified: trunk/matplotlib/lib/matplotlib/pyplot.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pyplot.py 2010-06-12 23:40:19 UTC (rev 8423) +++ trunk/matplotlib/lib/matplotlib/pyplot.py 2010-06-13 21:04:14 UTC (rev 8424) @@ -315,21 +315,15 @@ figManager = _pylab_helpers.Gcf.get_active() if figManager is None: return else: - figManager.canvas.mpl_disconnect(figManager._cidgcf) _pylab_helpers.Gcf.destroy(figManager.num) elif len(args)==1: arg = args[0] if arg=='all': - for manager in _pylab_helpers.Gcf.get_all_fig_managers(): - manager.canvas.mpl_disconnect(manager._cidgcf) - _pylab_helpers.Gcf.destroy(manager.num) + _pylab_helpers.Gcf.destroy_all() elif isinstance(arg, int): _pylab_helpers.Gcf.destroy(arg) elif isinstance(arg, Figure): - for manager in _pylab_helpers.Gcf.get_all_fig_managers(): - if manager.canvas.figure==arg: - manager.canvas.mpl_disconnect(manager._cidgcf) - _pylab_helpers.Gcf.destroy(manager.num) + _pylab_helpers.Gcf.destroy_fig(arg) else: raise TypeError('Unrecognized argument type %s to close'%type(arg)) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-12 23:40:26
|
Revision: 8423 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8423&view=rev Author: efiring Date: 2010-06-12 23:40:19 +0000 (Sat, 12 Jun 2010) Log Message: ----------- backends: move windowing.py into backends--it is very backend-specific Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py Added Paths: ----------- trunk/matplotlib/lib/matplotlib/backends/windowing.py Removed Paths: ------------- trunk/matplotlib/lib/matplotlib/windowing.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2010-06-12 23:08:11 UTC (rev 8422) +++ trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2010-06-12 23:40:19 UTC (rev 8423) @@ -26,7 +26,7 @@ NavigationToolbar2, cursors from matplotlib.figure import Figure from matplotlib._pylab_helpers import Gcf -import matplotlib.windowing as windowing +import matplotlib.backends.windowing as windowing from matplotlib.widgets import SubplotTool Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 23:08:11 UTC (rev 8422) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 23:40:19 UTC (rev 8423) @@ -11,6 +11,7 @@ import matplotlib.backends.tkagg as tkagg from matplotlib.backends.backend_agg import FigureCanvasAgg +import matplotlib.backends.windowing as windowing import matplotlib from matplotlib.cbook import is_string_like @@ -21,7 +22,6 @@ from matplotlib.figure import Figure from matplotlib._pylab_helpers import Gcf -import matplotlib.windowing as windowing from matplotlib.widgets import SubplotTool import matplotlib.cbook as cbook Copied: trunk/matplotlib/lib/matplotlib/backends/windowing.py (from rev 8419, trunk/matplotlib/lib/matplotlib/windowing.py) =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/windowing.py (rev 0) +++ trunk/matplotlib/lib/matplotlib/backends/windowing.py 2010-06-12 23:40:19 UTC (rev 8423) @@ -0,0 +1,26 @@ +""" +MS Windows-specific helper for TkAgg and FltkAgg backends. + +With rcParams['tk.window_focus'] default of False, it is +effectively disabled. + +It uses a tiny C++ extension module to access MS Win functions. +""" +from matplotlib import rcParams + +try: + if not rcParams['tk.window_focus']: + raise ImportError + from matplotlib._windowing import GetForegroundWindow, SetForegroundWindow +except ImportError: + def GetForegroundWindow(): + return 0 + def SetForegroundWindow(hwnd): + pass + +class FocusManager: + def __init__(self): + self._shellWindow = GetForegroundWindow() + + def __del__(self): + SetForegroundWindow(self._shellWindow) Deleted: trunk/matplotlib/lib/matplotlib/windowing.py =================================================================== --- trunk/matplotlib/lib/matplotlib/windowing.py 2010-06-12 23:08:11 UTC (rev 8422) +++ trunk/matplotlib/lib/matplotlib/windowing.py 2010-06-12 23:40:19 UTC (rev 8423) @@ -1,26 +0,0 @@ -""" -MS Windows-specific helper for TkAgg and FltkAgg backends. - -With rcParams['tk.window_focus'] default of False, it is -effectively disabled. - -It uses a tiny C++ extension module to access MS Win functions. -""" -from matplotlib import rcParams - -try: - if not rcParams['tk.window_focus']: - raise ImportError - from matplotlib._windowing import GetForegroundWindow, SetForegroundWindow -except ImportError: - def GetForegroundWindow(): - return 0 - def SetForegroundWindow(hwnd): - pass - -class FocusManager: - def __init__(self): - self._shellWindow = GetForegroundWindow() - - def __del__(self): - SetForegroundWindow(self._shellWindow) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-12 23:08:17
|
Revision: 8422 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8422&view=rev Author: efiring Date: 2010-06-12 23:08:11 +0000 (Sat, 12 Jun 2010) Log Message: ----------- backend_tkagg: one more typo from commit before last Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 22:32:18 UTC (rev 8421) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 23:08:11 UTC (rev 8422) @@ -15,7 +15,7 @@ import matplotlib from matplotlib.cbook import is_string_like from matplotlib.backend_bases import RendererBase, GraphicsContextBase -from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase, +from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase from matplotlib.backend_bases import NavigationToolbar2, cursors, TimerBase from matplotlib.figure import Figure This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-12 22:32:24
|
Revision: 8421 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8421&view=rev Author: efiring Date: 2010-06-12 22:32:18 +0000 (Sat, 12 Jun 2010) Log Message: ----------- backend_tkagg: fix major typo from last commit Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 22:08:16 UTC (rev 8420) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 22:32:18 UTC (rev 8421) @@ -8,7 +8,7 @@ import Tkinter as Tk, FileDialog # Paint image to Tk photo blitter extension -import import matplotlib.backends.tkagg as tkagg +import matplotlib.backends.tkagg as tkagg from matplotlib.backends.backend_agg import FigureCanvasAgg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-12 22:08:23
|
Revision: 8420 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8420&view=rev Author: efiring Date: 2010-06-12 22:08:16 +0000 (Sat, 12 Jun 2010) Log Message: ----------- backend_tkagg: show() gets an experimental kwarg for testing blocking mode. By default, the behavior of show() is unchanged--it does not block, and it forces interactive mode on. show(block=True) is intended to make it behave the same as in the other common backends, blocking until all figures have been closed. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 21:30:38 UTC (rev 8419) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2010-06-12 22:08:16 UTC (rev 8420) @@ -3,17 +3,20 @@ from __future__ import division import os, sys, math +import os.path import Tkinter as Tk, FileDialog -import tkagg # Paint image to Tk photo blitter extension -from backend_agg import FigureCanvasAgg -import os.path +# Paint image to Tk photo blitter extension +import import matplotlib.backends.tkagg as tkagg +from matplotlib.backends.backend_agg import FigureCanvasAgg + import matplotlib from matplotlib.cbook import is_string_like -from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ - FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors, TimerBase +from matplotlib.backend_bases import RendererBase, GraphicsContextBase +from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase, +from matplotlib.backend_bases import NavigationToolbar2, cursors, TimerBase from matplotlib.figure import Figure from matplotlib._pylab_helpers import Gcf @@ -61,25 +64,43 @@ figManager.show() -def show(): +def show(block=False): """ - Show all the figures and enter the gtk mainloop + Show all figures. - This should be the last line of your script. This function sets - interactive mode to True, as detailed on - http://matplotlib.sf.net/interactive.html + Temporary, experimental kwarg *block* defaults to False to + provide the behavior present throughout mpl history to date: + interactive mode is forced on, and show does not block. + + Set *block* to True to test the proposed new behavior, + consistent with other backends, in which show does not affect + interactive mode, and always blocks until all figures are closed. + In addition, the rcParam['tk.pythoninspect'] is ignored. + + Use this kwarg only for testing; other backends do not accept + a kwarg to show, and might never do so. """ for manager in Gcf.get_all_fig_managers(): manager.show() - import matplotlib - matplotlib.interactive(True) - if rcParams['tk.pythoninspect']: - os.environ['PYTHONINSPECT'] = '1' - if show._needmain: + if block: + # proposed new behavior; seems to make this backend consistent + # with others, with no drawbacks identified yet. Tk.mainloop() - show._needmain = False -show._needmain = True + else: + # long-time behavior: non-blocking, forces interactive mode + import matplotlib + matplotlib.interactive(True) + if rcParams['tk.pythoninspect']: + os.environ['PYTHONINSPECT'] = '1' + if show._needmain: + Tk.mainloop() + show._needmain = False +show._needmain = True # This can go away if we eliminate block=False option. + + + + def new_figure_manager(num, *args, **kwargs): """ Create a new figure manager instance @@ -98,7 +119,7 @@ class TimerTk(TimerBase): ''' Subclass of :class:`backend_bases.TimerBase` that uses Tk's timer events. - + Attributes: * interval: The time between timer events in milliseconds. Default is 1000 ms. @@ -213,7 +234,7 @@ root = self._tkcanvas.winfo_toplevel() root.bind("<MouseWheel>", self.scroll_event_windows) - # Can't get destroy events by binding ot _tkcanvas. Therefore, bind + # Can't get destroy events by binding to _tkcanvas. Therefore, bind # to the window and filter. def filter_destroy(evt): if evt.widget is self._tkcanvas: @@ -363,9 +384,9 @@ Creates a new backend-specific subclass of :class:`backend_bases.Timer`. This is useful for getting periodic events through the backend's native event loop. Implemented only for backends with GUIs. - + optional arguments: - + *interval* Timer interval in milliseconds *callbacks* @@ -449,17 +470,15 @@ this function doesn't segfault but causes the PyEval_RestoreThread: NULL state bug on win32 """ - - def destroy(*args): - self.window = None - Gcf.destroy(self._num) - - if not self._shown: self.canvas._tkcanvas.bind("<Destroy>", destroy) _focus = windowing.FocusManager() if not self._shown: + def destroy(*args): + self.window = None + Gcf.destroy(self._num) + self.canvas._tkcanvas.bind("<Destroy>", destroy) self.window.deiconify() # anim.py requires this - if sys.platform=='win32' : self.window.update() + self.window.update() else: self.canvas.draw_idle() self._shown = True This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ef...@us...> - 2010-06-12 21:30:45
|
Revision: 8419 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8419&view=rev Author: efiring Date: 2010-06-12 21:30:38 +0000 (Sat, 12 Jun 2010) Log Message: ----------- windowing: add module docstring, fix import Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/windowing.py Modified: trunk/matplotlib/lib/matplotlib/windowing.py =================================================================== --- trunk/matplotlib/lib/matplotlib/windowing.py 2010-06-12 16:07:42 UTC (rev 8418) +++ trunk/matplotlib/lib/matplotlib/windowing.py 2010-06-12 21:30:38 UTC (rev 8419) @@ -1,3 +1,11 @@ +""" +MS Windows-specific helper for TkAgg and FltkAgg backends. + +With rcParams['tk.window_focus'] default of False, it is +effectively disabled. + +It uses a tiny C++ extension module to access MS Win functions. +""" from matplotlib import rcParams try: @@ -3,5 +11,5 @@ if not rcParams['tk.window_focus']: raise ImportError - from _windowing import GetForegroundWindow, SetForegroundWindow + from matplotlib._windowing import GetForegroundWindow, SetForegroundWindow except ImportError: def GetForegroundWindow(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lee...@us...> - 2010-06-12 16:07:50
|
Revision: 8418 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8418&view=rev Author: leejjoon Date: 2010-06-12 16:07:42 +0000 (Sat, 12 Jun 2010) Log Message: ----------- Fix markerscale and scatterpoints keyword arguments in legend. Thanks to Erik Tollerud Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/legend.py Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2010-06-12 07:48:54 UTC (rev 8417) +++ trunk/matplotlib/lib/matplotlib/legend.py 2010-06-12 16:07:42 UTC (rev 8418) @@ -53,9 +53,9 @@ bbox = self.legend.get_bbox_to_anchor() _bbox_transform = BboxTransformFrom(bbox) self.legend._loc = tuple(_bbox_transform.transform_point(loc_in_canvas)) - + class Legend(Artist): """ Place a legend on the axes at location loc. Labels are a @@ -256,7 +256,7 @@ self._scatteryoffsets = np.array([3./8., 4./8., 2.5/8.]) else: self._scatteryoffsets = np.asarray(scatteryoffsets) - reps = int(self.numpoints / len(self._scatteryoffsets)) + 1 + reps = int(self.scatterpoints / len(self._scatteryoffsets)) + 1 self._scatteryoffsets = np.tile(self._scatteryoffsets, reps)[:self.scatterpoints] # _legend_box is an OffsetBox instance that contains all @@ -519,6 +519,9 @@ legline_marker.set_clip_box(None) legline_marker.set_clip_path(None) legline_marker.set_linestyle('None') + if self.markerscale !=1: + newsz = legline_marker.get_markersize()*self.markerscale + legline_marker.set_markersize(newsz) # we don't want to add this to the return list because # the texts and handles are assumed to be in one-to-one # correpondence. @@ -554,11 +557,8 @@ #ydata = self._scatteryoffsets ydata = height*self._scatteryoffsets - size_max, size_min = max(handle.get_sizes()),\ - min(handle.get_sizes()) - # we may need to scale these sizes by "markerscale" - # attribute. But other handle types does not seem - # to care about this attribute and it is currently ignored. + size_max, size_min = max(handle.get_sizes())*self.markerscale**2,\ + min(handle.get_sizes())*self.markerscale**2 if self.scatterpoints < 4: sizes = [.5*(size_max+size_min), size_max, size_min] @@ -582,11 +582,8 @@ ydata = height*self._scatteryoffsets - size_max, size_min = max(handle.get_sizes()),\ - min(handle.get_sizes()) - # we may need to scale these sizes by "markerscale" - # attribute. But other handle types does not seem - # to care about this attribute and it is currently ignored. + size_max, size_min = max(handle.get_sizes())*self.markerscale**2,\ + min(handle.get_sizes())*self.markerscale**2 if self.scatterpoints < 4: sizes = [.5*(size_max+size_min), size_max, size_min] @@ -937,7 +934,7 @@ * True : turn draggable on * False : turn draggable off - + If draggable is on, you can drag the legend on the canvas with the mouse. The DraggableLegend helper instance is returned if draggable is on. @@ -947,7 +944,7 @@ # if state is None we'll toggle if state is None: state = not is_draggable - + if state: if self._draggable is None: self._draggable = DraggableLegend(self, use_blit) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-12 07:49:01
|
Revision: 8417 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8417&view=rev Author: mdehoon Date: 2010-06-12 07:48:54 +0000 (Sat, 12 Jun 2010) Log Message: ----------- No CGContextGetLineWidth in Cocoa; pass the line width from Python instead. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py trunk/matplotlib/src/_macosx.m Modified: trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py 2010-06-12 06:53:03 UTC (rev 8416) +++ trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py 2010-06-12 07:48:54 UTC (rev 8417) @@ -52,12 +52,14 @@ def draw_path(self, gc, path, transform, rgbFace=None): if rgbFace is not None: rgbFace = tuple(rgbFace) - gc.draw_path(path, transform, rgbFace) + linewidth = gc.get_linewidth() + gc.draw_path(path, transform, linewidth, rgbFace) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): if rgbFace is not None: rgbFace = tuple(rgbFace) - gc.draw_markers(marker_path, marker_trans, path, trans, rgbFace) + linewidth = gc.get_linewidth() + gc.draw_markers(marker_path, marker_trans, path, trans, linewidth, rgbFace) def draw_path_collection(self, gc, master_transform, paths, all_transforms, offsets, offsetTrans, facecolors, edgecolors, Modified: trunk/matplotlib/src/_macosx.m =================================================================== --- trunk/matplotlib/src/_macosx.m 2010-06-12 06:53:03 UTC (rev 8416) +++ trunk/matplotlib/src/_macosx.m 2010-06-12 07:48:54 UTC (rev 8417) @@ -864,6 +864,7 @@ PyObject* path; PyObject* transform; PyObject* rgbFace; + float linewidth; int n; @@ -878,9 +879,10 @@ return NULL; } - if(!PyArg_ParseTuple(args, "OO|O", + if(!PyArg_ParseTuple(args, "OOf|O", &path, &transform, + &linewidth, &rgbFace)) return NULL; if(rgbFace==Py_None) rgbFace = NULL; @@ -891,7 +893,7 @@ 0, rect, QUANTIZE_AUTO, - CGContextGetLineWidth(self), + linewidth, rgbFace == NULL); if (!iterator) { @@ -969,7 +971,7 @@ 0, rect, QUANTIZE_AUTO, - CGContextGetLineWidth(self), + linewidth, 0); if (!iterator) { @@ -995,6 +997,7 @@ PyObject* marker_transform; PyObject* path; PyObject* transform; + float linewidth; PyObject* rgbFace; int ok; @@ -1015,11 +1018,12 @@ return NULL; } - if(!PyArg_ParseTuple(args, "OOOO|O", + if(!PyArg_ParseTuple(args, "OOOOf|O", &marker_path, &marker_transform, &path, &transform, + &linewidth, &rgbFace)) return NULL; if(rgbFace==Py_None) rgbFace = NULL; @@ -1046,7 +1050,7 @@ 0, rect, mode, - CGContextGetLineWidth(self), + linewidth, 0); if (!iterator) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2010-06-12 06:53:09
|
Revision: 8416 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8416&view=rev Author: mdehoon Date: 2010-06-12 06:53:03 +0000 (Sat, 12 Jun 2010) Log Message: ----------- Update the declaration of get_path_iterator, which was changed in src/path_cleanup.cpp in revision 6897. Revision Links: -------------- http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6897&view=rev Modified Paths: -------------- trunk/matplotlib/src/path_cleanup.h Modified: trunk/matplotlib/src/path_cleanup.h =================================================================== --- trunk/matplotlib/src/path_cleanup.h 2010-06-11 18:17:52 UTC (rev 8415) +++ trunk/matplotlib/src/path_cleanup.h 2010-06-12 06:53:03 UTC (rev 8416) @@ -13,7 +13,8 @@ void* get_path_iterator( PyObject* path, PyObject* trans, int remove_nans, int do_clip, - double rect[4], enum e_quantize_mode quantize_mode, int do_simplify); + double rect[4], enum e_quantize_mode quantize_mode, double stroke_width, + int do_simplify); unsigned get_vertex(void* pipeline, double* x, double* y); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |