@@ -123,25 +123,33 @@ def _process_radius(self, radius):
123
123
return _radius
124
124
125
125
def contains (self , mouseevent , radius = None ):
126
- """Test whether the mouse event occurred in the patch.
126
+ """
127
+ Test whether the mouse event occurred in the patch.
127
128
128
- Returns T/F, {}
129
+ Returns
130
+ -------
131
+ (bool, empty dict)
129
132
"""
130
133
if self ._contains is not None :
131
134
return self ._contains (self , mouseevent )
132
135
radius = self ._process_radius (radius )
133
136
codes = self .get_path ().codes
134
- vertices = self .get_path ().vertices
135
- # if the current path is concatenated by multiple sub paths.
136
- # get the indexes of the starting code(MOVETO) of all sub paths
137
- idxs , = np .where (codes == Path .MOVETO )
138
- # Don't split before the first MOVETO.
139
- idxs = idxs [1 :]
140
- return any (
141
- subpath .contains_point (
137
+ if codes is not None :
138
+ vertices = self .get_path ().vertices
139
+ # if the current path is concatenated by multiple sub paths.
140
+ # get the indexes of the starting code(MOVETO) of all sub paths
141
+ idxs , = np .where (codes == Path .MOVETO )
142
+ # Don't split before the first MOVETO.
143
+ idxs = idxs [1 :]
144
+ inside = any (
145
+ subpath .contains_point (
146
+ (mouseevent .x , mouseevent .y ), self .get_transform (), radius )
147
+ for subpath in map (
148
+ Path , np .split (vertices , idxs ), np .split (codes , idxs )))
149
+ else :
150
+ inside = self .get_path ().contains_point (
142
151
(mouseevent .x , mouseevent .y ), self .get_transform (), radius )
143
- for subpath in map (
144
- Path , np .split (vertices , idxs ), np .split (codes , idxs ))), {}
152
+ return inside , {}
145
153
146
154
def contains_point (self , point , radius = None ):
147
155
"""
0 commit comments