Skip to content

Commit fe4c4c9

Browse files
committed
Adding calls to gc.restore() whenever new_gc is called. This is necessary for the Mac OS X and the Cairo backend to work correctly. Also, updating the Mac OS X backend to be consistent with recent changes in SVN. See issue 2844845 on sourceforge.
svn path=/trunk/matplotlib/; revision=7625
1 parent d365785 commit fe4c4c9

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

lib/matplotlib/axes.py

+1
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,7 @@ def draw(self, renderer=None, inframe=False):
17491749
self.patch.get_transform()))
17501750

17511751
renderer.draw_image(gc, round(l), round(b), im)
1752+
gc.restore()
17521753

17531754
if dsu_rasterized:
17541755
for zorder, i, a in dsu_rasterized:

lib/matplotlib/backends/backend_macosx.py

+36-17
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,49 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
5858
rgbFace = tuple(rgbFace)
5959
gc.draw_markers(marker_path, marker_trans, path, trans, rgbFace)
6060

61-
def draw_path_collection(self, *args):
62-
# TODO: We should change this in the C code eventually, but this
63-
# re-ordering of arguments should work for now
64-
gc = args[0]
65-
args = tuple([gc, args[1], gc.get_clip_rectangle()] + \
66-
list(gc.get_clip_path()) + list(args[2:]))
67-
gc.draw_path_collection(*args)
68-
69-
def draw_quad_mesh(self, *args):
70-
# TODO: We should change this in the C code eventually, but this
71-
# re-ordering of arguments should work for now
72-
gc = args[0]
73-
args = [gc, args[1], gc.get_clip_rectangle()] + \
74-
list(gc.get_clip_path()) + list(args[2:])
75-
gc.draw_quad_mesh(*args)
61+
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
62+
offsets, offsetTrans, facecolors, edgecolors,
63+
linewidths, linestyles, antialiaseds, urls):
64+
cliprect = gc.get_clip_rectangle()
65+
clippath, clippath_transform = gc.get_clip_path()
66+
gc.draw_path_collection(master_transform,
67+
cliprect,
68+
clippath,
69+
clippath_transform,
70+
paths,
71+
all_transforms,
72+
offsets,
73+
offsetTrans,
74+
facecolors,
75+
edgecolors,
76+
linewidths,
77+
linestyles,
78+
antialiaseds)
79+
80+
def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
81+
coordinates, offsets, offsetTrans, facecolors,
82+
antialiased, showedges):
83+
cliprect = gc.get_clip_rectangle()
84+
clippath, clippath_transform = gc.get_clip_path()
85+
gc.draw_quad_mesh(master_transform,
86+
cliprect,
87+
clippath,
88+
clippath_transform,
89+
meshWidth,
90+
meshHeight,
91+
coordinates,
92+
offsets,
93+
offsetTrans,
94+
facecolors,
95+
antialiased,
96+
showedges)
7697

7798
def new_gc(self):
7899
self.gc.save()
79100
self.gc.set_hatch(None)
80101
return self.gc
81102

82103
def draw_image(self, gc, x, y, im):
83-
# TODO: We should change this in the C code eventually, but this
84-
# re-ordering of arguments should work for now
85104
im.flipud_out()
86105
nrows, ncols, data = im.as_rgba_str()
87106
gc.draw_image(x, y, nrows, ncols, data, gc.get_clip_rectangle(),

lib/matplotlib/collections.py

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ def draw(self, renderer):
214214
gc, transform.frozen(), paths, self.get_transforms(),
215215
offsets, transOffset, self.get_facecolor(), self.get_edgecolor(),
216216
self._linewidths, self._linestyles, self._antialiaseds, self._urls)
217+
218+
gc.restore()
217219
renderer.close_group(self.__class__.__name__)
218220

219221
def contains(self, mouseevent):
@@ -1223,6 +1225,7 @@ def draw(self, renderer):
12231225
gc, transform.frozen(), self._meshWidth, self._meshHeight,
12241226
coordinates, offsets, transOffset, self.get_facecolor(),
12251227
self._antialiased, self._showedges)
1228+
gc.restore()
12261229
renderer.close_group(self.__class__.__name__)
12271230

12281231

lib/matplotlib/figure.py

+1
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ def draw(self, renderer):
766766
gc.set_clip_rectangle(self.bbox)
767767
gc.set_clip_path(self.get_clip_path())
768768
renderer.draw_image(gc, l, b, im)
769+
gc.restore()
769770

770771
# render the axes
771772
for a in self.axes: a.draw(renderer)

lib/matplotlib/image.py

+4
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def draw(self, renderer, *args, **kwargs):
142142
gc.set_clip_rectangle(self.axes.bbox.frozen())
143143
gc.set_clip_path(self.get_clip_path())
144144
renderer.draw_image(gc, l, b, im)
145+
gc.restore()
145146

146147
def contains(self, mouseevent):
147148
"""
@@ -637,6 +638,7 @@ def draw(self, renderer, *args, **kwargs):
637638
round(self.axes.bbox.xmin),
638639
round(self.axes.bbox.ymin),
639640
im)
641+
gc.restore()
640642

641643

642644
def set_data(self, x, y, A):
@@ -790,6 +792,7 @@ def draw(self, renderer, *args, **kwargs):
790792
gc.set_clip_rectangle(self.figure.bbox)
791793
gc.set_clip_path(self.get_clip_path())
792794
renderer.draw_image(gc, round(self.ox), round(self.oy), im)
795+
gc.restore()
793796

794797
def write_png(self, fname):
795798
"""Write the image to png file with fname"""
@@ -931,6 +934,7 @@ def draw(self, renderer, *args, **kwargs):
931934
self._set_gc_clip(gc)
932935
#gc.set_clip_path(self.get_clip_path())
933936
renderer.draw_image(gc, round(l), round(b), im)
937+
gc.restore()
934938

935939

936940

0 commit comments

Comments
 (0)