Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 633759b

Browse files
committed
Lots of progress on Polar transform refactoring. Added point_in_path algorithm.
svn path=/branches/transforms/; revision=3908
1 parent 479e1c8 commit 633759b

17 files changed

Lines changed: 1149 additions & 844 deletions

lib/matplotlib/artist.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import division
22
import sys, re
33
from cbook import iterable, flatten
4-
from transforms import Affine2D
4+
from transforms import Affine2D, Bbox, IdentityTransform, TransformedBbox, \
5+
TransformedPath
56
import matplotlib.units as units
67

78
## Note, matplotlib artists use the doc strings for set and get
@@ -145,7 +146,7 @@ def set_transform(self, t):
145146
def get_transform(self):
146147
'return the Transformation instance used by this artist'
147148
if self._transform is None:
148-
self._transform = Affine2D()
149+
self._transform = IdentityTransform()
149150
return self._transform
150151

151152
def hitlist(self,event):
@@ -284,17 +285,29 @@ def set_clip_box(self, clipbox):
284285
self._clipon = clipbox is not None or self._clippath is not None
285286
self.pchanged()
286287

287-
def set_clip_path(self, path):
288+
def set_clip_path(self, path, transform=None):
288289
"""
289290
Set the artist's clip path
290291
291-
ACCEPTS: an agg.path_storage instance
292-
"""
293-
self._clippath = path
292+
ACCEPTS: a Path instance and a Transform instance, or a Patch instance
293+
"""
294+
from patches import Patch, Rectangle
295+
if transform is None:
296+
if isinstance(path, Rectangle):
297+
self.clipbox = TransformedBbox(Bbox.unit(), path.get_transform())
298+
elif isinstance(path, Patch):
299+
self._clippath = TransformedPath(
300+
path.get_path(),
301+
path.get_transform())
302+
elif path is None:
303+
self._clippath = None
304+
else:
305+
raise TypeError("Invalid arguments to set_clip_path")
306+
else:
307+
self._clippath = TransformedPath(path, transform)
294308
self._clipon = self.clipbox is not None or path is not None
295309
self.pchanged()
296310

297-
298311
def get_alpha(self):
299312
"""
300313
Return the alpha value used for blending - not supported on all
@@ -431,6 +444,7 @@ def update_from(self, other):
431444
self._alpha = other._alpha
432445
self.clipbox = other.clipbox
433446
self._clipon = other._clipon
447+
self._clippath = other._clippath
434448
self._lod = other._lod
435449
self._label = other._label
436450
self.pchanged()

0 commit comments

Comments
 (0)