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.

------------------------------------------------------------------------------
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

Reply via email to