Revision: 4162
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4162&view=rev
Author:   mdboom
Date:     2007-11-08 08:27:18 -0800 (Thu, 08 Nov 2007)

Log Message:
-----------
Put a generic non-optimized draw_markers implementation in backend_bases.

Modified Paths:
--------------
    branches/transforms/lib/matplotlib/backend_bases.py
    branches/transforms/lib/matplotlib/backends/backend_cairo.py
    branches/transforms/lib/matplotlib/backends/backend_template.py

Modified: branches/transforms/lib/matplotlib/backend_bases.py
===================================================================
--- branches/transforms/lib/matplotlib/backend_bases.py 2007-11-08 16:26:31 UTC 
(rev 4161)
+++ branches/transforms/lib/matplotlib/backend_bases.py 2007-11-08 16:27:18 UTC 
(rev 4162)
@@ -15,7 +15,21 @@
 from matplotlib import rcParams
 
 class RendererBase:
-    """An abstract base class to handle drawing/rendering operations
+    """An abstract base class to handle drawing/rendering operations.
+
+    The following methods *must* be implemented in the backend:
+
+       draw_path
+       draw_image
+       draw_text
+       get_text_width_height_descent
+
+    The following methods *should* be implemented in the backend for
+    optimization reasons:
+    
+       draw_markers
+       draw_path_collection
+       draw_quad_mesh
     """
     def __init__(self):
         self._texmanager = None
@@ -47,22 +61,41 @@
 
         marker_trans is an affine transform applied to the marker.
         trans is an affine transform applied to the path.
+
+        This provides a fallback implementation of draw_markers that
+        makes multiple calls to draw_path.  Some backends may want to
+        override this method in order to draw the marker only once and
+        reuse it multiple times.
         """
-        raise NotImplementedError
-
+        ctx = gc.ctx
+        ctx.new_path()
+        tpath = trans.transform_path(path)
+        for x, y in tpath.vertices:
+            self.draw_path(gc, marker_path,
+                           marker_trans + transforms.Affine2D().translate(x, 
y),
+                           rgbFace)
+        
     def draw_path_collection(self, master_transform, cliprect, clippath,
                              clippath_trans, paths, all_transforms, offsets,
                              offsetTrans, facecolors, edgecolors, linewidths,
                              linestyles, antialiaseds):
         """
+        Draws a collection of paths, selecting drawing properties from
+        the lists facecolors, edgecolors, linewidths, linestyles and
+        antialiaseds.  offsets is a list of offsets to apply to each
+        of the paths.  The offsets in offsets are first transformed by
+        offsetTrans before being applied.
+
         This provides a fallback implementation of
         draw_path_collection that makes multiple calls to draw_path.
-        Often, the backend will want to override this in order to
-        render each set of path data only once, and then reference
-        that path multiple times with the different offsets, colors,
-        styles etc.  The methods _iter_collection_raw_paths and
+        Some backends may want to override this in order to render
+        each set of path data only once, and then reference that path
+        multiple times with the different offsets, colors, styles etc.
+        The generator methods _iter_collection_raw_paths and
         _iter_collection are provided to help with (and standardize)
-        the implementation across backends.
+        the implementation across backends.  It is highly recommended
+        to use those generators, so that changes to the behavior of
+        draw_path_collection can be made globally.
         """
         path_ids = []
         for path, transform in self._iter_collection_raw_paths(

Modified: branches/transforms/lib/matplotlib/backends/backend_cairo.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_cairo.py        
2007-11-08 16:26:31 UTC (rev 4161)
+++ branches/transforms/lib/matplotlib/backends/backend_cairo.py        
2007-11-08 16:27:18 UTC (rev 4162)
@@ -156,21 +156,6 @@
 
         self._fill_and_stroke(ctx, rgbFace)
 
-    def draw_markers(self, gc, marker_path, marker_trans, path, trans, 
rgbFace=None):
-        ctx = gc.ctx
-        ctx.new_path()
-        marker_trans = marker_trans + Affine2D().scale(1.0, -1.0)
-        tmarker_path = marker_trans.transform_path(marker_path)
-        
-        trans = trans + Affine2D().scale(1.0, -1.0).translate(0, self.height)
-        tpath = trans.transform_path(path)
-        for x, y in tpath.vertices:
-            ctx.save()
-            ctx.translate(x, y)
-            self.convert_path(ctx, tmarker_path)
-            self._fill_and_stroke(ctx, rgbFace)
-            ctx.restore()
-
     def draw_image(self, x, y, im, bbox):
         # bbox - not currently used
         if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name())

Modified: branches/transforms/lib/matplotlib/backends/backend_template.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_template.py     
2007-11-08 16:26:31 UTC (rev 4161)
+++ branches/transforms/lib/matplotlib/backends/backend_template.py     
2007-11-08 16:27:18 UTC (rev 4162)
@@ -69,8 +69,10 @@
     def draw_path(self, gc, path, transform, rgbFace=None):
         pass
 
-    def draw_markers(self, gc, marker_path, marker_trans, path, trans, 
rgbFace=None):
-        pass
+    # draw_markers is optional, and we get more correct
+    # relative timings by leaving it out.
+#     def draw_markers(self, gc, marker_path, marker_trans, path, trans, 
rgbFace=None):
+#         pass
 
     # draw_path_collection is optional, and we get more correct
     # relative timings by leaving it out.
@@ -79,7 +81,15 @@
 #                              offsetTrans, facecolors, edgecolors, linewidths,
 #                              linestyles, antialiaseds):
 #         pass
-    
+
+    # draw_quad_mesh is optional, and we get more correct
+    # relative timings by leaving it out.
+#     def draw_quad_mesh(self, master_transform, cliprect, clippath,
+#                        clippath_trans, meshWidth, meshHeight, coordinates,
+#                        offsets, offsetTrans, facecolors, antialiased,
+#                        showedges):
+#         pass
+        
     def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
         pass
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to