SF.net SVN: matplotlib:[8436] trunk/matplotlib/lib/matplotlib/backends/ backend_qt4.py

2010-06-15 Thread mdboom
Revision: 8436
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8436&view=rev
Author:   mdboom
Date: 2010-06-15 13:01:22 + (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.

--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[8437] trunk/matplotlib

2010-06-15 Thread mdboom
Revision: 8437
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8437&view=rev
Author:   mdboom
Date: 2010-06-15 19:10:19 + (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  
transformed_path_t;
-  typedef PathQuantizer  quantize_t;
-  typedef agg::conv_curvecurve_t;
+  typedef PathSnappersnap_t;
+  typedef agg::conv_curvecurve_t;
   typedef agg::conv_stroke  stroke_t;
   typedef agg::pixfmt_amask_adaptor pixfmt_amask_type;
   typedef agg::renderer_base  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_tmarker_path_curve(marker_path_quantized);
+  snap_t marker_path_snapped(marker_path_transformed,
+ gc.snap_mode,
+ marker_path.total_vertices(),
+ gc.linewidth);
+  curve_tmarker_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_tpath_curve(path_quantized);
+  snap_t path_snapped(path_transformed,
+  gc.snap_mode,
+  path.total_vertices(),
+  1.0);
+  curve_tpa

SF.net SVN: matplotlib:[8438] trunk/matplotlib/ttconv/pprdrv_tt2.cpp

2010-06-15 Thread mdboom
Revision: 8438
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8438&view=rev
Author:   mdboom
Date: 2010-06-15 19:32:24 + (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; i0)
-   {
-   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],s