|
From: <md...@us...> - 2008-06-17 14:41:11
|
Revision: 5570
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5570&view=rev
Author: mdboom
Date: 2008-06-17 07:40:10 -0700 (Tue, 17 Jun 2008)
Log Message:
-----------
Support getting the vertices of curved paths.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/patches.py
trunk/matplotlib/lib/matplotlib/path.py
trunk/matplotlib/src/_path.cpp
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2008-06-17 14:04:19 UTC (rev 5569)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2008-06-17 14:40:10 UTC (rev 5570)
@@ -83,11 +83,17 @@
def get_verts(self):
"""
return a copy of the vertices used in this patch
+
+ If the patch contains Bezier curves, the curves will be
+ interpolated by line segments. To access the curves as
+ curves, use :meth:`get_path`.
"""
trans = self.get_transform()
path = self.get_path()
- tverts = trans.transform(path.vertices)
- return tverts
+ polygons = path.to_polygons(trans)
+ if len(polygons):
+ return polygons[0]
+ return []
def contains(self, mouseevent):
"""Test whether the mouse event occurred in the patch.
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py 2008-06-17 14:04:19 UTC (rev 5569)
+++ trunk/matplotlib/lib/matplotlib/path.py 2008-06-17 14:40:10 UTC (rev 5570)
@@ -290,14 +290,21 @@
``MOVETO`` instructions or curves. This is useful for
displaying in backends that do not support compound paths or
Bezier curves, such as GDK.
+
+ If width and height are both non-zero then the lines will be
+ simplified so that vertices outside of (0, 0), (width, height)
+ will be clipped.
"""
+ if len(self.vertices) == 0:
+ return []
+
if transform is not None:
transform = transform.frozen()
- # Deal with the common and simple case
- if self.codes is None and len(self.vertices) < 100:
- if len(self.vertices):
+ if self.codes is None:
return [transform.transform(self.vertices)]
- return []
+ else:
+ if self.codes is None:
+ return [self.vertices]
# Deal with the case where there are curves and/or multiple
# subpaths (using extension code)
return convert_path_to_polygons(self, transform, width, height)
Modified: trunk/matplotlib/src/_path.cpp
===================================================================
--- trunk/matplotlib/src/_path.cpp 2008-06-17 14:04:19 UTC (rev 5569)
+++ trunk/matplotlib/src/_path.cpp 2008-06-17 14:40:10 UTC (rev 5570)
@@ -52,7 +52,7 @@
add_varargs_method("path_intersects_path", &_path_module::path_intersects_path,
"path_intersects_path(p1, p2)");
add_varargs_method("convert_path_to_polygons", &_path_module::convert_path_to_polygons,
- "convert_path_to_polygons(path, trans)");
+ "convert_path_to_polygons(path, trans, width, height)");
initialize("Helper functions for paths");
}
@@ -1115,7 +1115,7 @@
double width = Py::Float(args[2]);
double height = Py::Float(args[3]);
- bool simplify = !path.has_curves();
+ bool simplify = !path.has_curves() && width != 0.0 && height != 0.0;
transformed_path_t tpath(path, trans);
simplify_t simplified(tpath, false, simplify, width, height);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|