17
17
from . import artist , colors as mcolors
18
18
from .artist import Artist
19
19
from .cbook import (iterable , is_string_like , is_numlike , ls_mapper_r ,
20
- pts_to_prestep , pts_to_poststep , pts_to_midstep )
20
+ STEP_LOOKUP_MAP )
21
21
22
22
from .path import Path
23
23
from .transforms import Bbox , TransformedPath , IdentityTransform
@@ -237,6 +237,7 @@ class Line2D(Artist):
237
237
'steps' : '_draw_steps_pre' ,
238
238
}
239
239
240
+ # drawStyles should now be deprecated.
240
241
drawStyles = {}
241
242
drawStyles .update (_drawStyles_l )
242
243
drawStyles .update (_drawStyles_s )
@@ -470,8 +471,7 @@ def contains(self, mouseevent):
470
471
# application has set the error flags such that an exception is raised
471
472
# on overflow, we temporarily set the appropriate error flags here and
472
473
# set them back when we are finished.
473
- olderrflags = np .seterr (all = 'ignore' )
474
- try :
474
+ with np .errstate (all = 'ignore' ):
475
475
# Check for collision
476
476
if self ._linestyle in ['None' , None ]:
477
477
# If no line, return the nearby point(s)
@@ -480,20 +480,9 @@ def contains(self, mouseevent):
480
480
else :
481
481
# If line, return the nearby segment(s)
482
482
ind = segment_hits (mouseevent .x , mouseevent .y , xt , yt , pixels )
483
- finally :
484
- np .seterr (** olderrflags )
485
483
486
484
ind += self .ind_offset
487
485
488
- # Debugging message
489
- if False and self ._label != '' :
490
- print ("Checking line" , self ._label ,
491
- "at" , mouseevent .x , mouseevent .y )
492
- print ('xt' , xt )
493
- print ('yt' , yt )
494
- #print 'dx,dy', (xt-mouseevent.x)**2., (yt-mouseevent.y)**2.
495
- print ('ind' , ind )
496
-
497
486
# Return the point(s) within radius
498
487
return len (ind ) > 0 , dict (ind = ind )
499
488
@@ -691,7 +680,8 @@ def recache(self, always=False):
691
680
interpolation_steps = self ._path ._interpolation_steps
692
681
else :
693
682
interpolation_steps = 1
694
- self ._path = Path (self ._xy , None , interpolation_steps )
683
+ xy = STEP_LOOKUP_MAP [self ._drawstyle ](* self ._xy .T )
684
+ self ._path = Path (np .asarray (xy ).T , None , interpolation_steps )
695
685
self ._transformed_path = None
696
686
self ._invalidx = False
697
687
self ._invalidy = False
@@ -764,8 +754,6 @@ def draw(self, renderer):
764
754
tpath , affine = transf_path .get_transformed_path_and_affine ()
765
755
if len (tpath .vertices ):
766
756
self ._lineFunc = getattr (self , funcname )
767
- funcname = self .drawStyles .get (self ._drawstyle , '_draw_lines' )
768
- drawFunc = getattr (self , funcname )
769
757
gc = renderer .new_gc ()
770
758
self ._set_gc_clip (gc )
771
759
@@ -788,7 +776,7 @@ def draw(self, renderer):
788
776
if self .get_sketch_params () is not None :
789
777
gc .set_sketch_params (* self .get_sketch_params ())
790
778
791
- drawFunc (renderer , gc , tpath , affine .frozen ())
779
+ self . _draw_lines (renderer , gc , tpath , affine .frozen ())
792
780
gc .restore ()
793
781
794
782
if self ._marker and self ._markersize > 0 :
@@ -1234,27 +1222,6 @@ def set_dashes(self, seq):
1234
1222
def _draw_lines (self , renderer , gc , path , trans ):
1235
1223
self ._lineFunc (renderer , gc , path , trans )
1236
1224
1237
- def _draw_steps_pre (self , renderer , gc , path , trans ):
1238
- steps = np .vstack (pts_to_prestep (* self ._xy .T )).T
1239
-
1240
- path = Path (steps )
1241
- path = path .transformed (self .get_transform ())
1242
- self ._lineFunc (renderer , gc , path , IdentityTransform ())
1243
-
1244
- def _draw_steps_post (self , renderer , gc , path , trans ):
1245
- steps = np .vstack (pts_to_poststep (* self ._xy .T )).T
1246
-
1247
- path = Path (steps )
1248
- path = path .transformed (self .get_transform ())
1249
- self ._lineFunc (renderer , gc , path , IdentityTransform ())
1250
-
1251
- def _draw_steps_mid (self , renderer , gc , path , trans ):
1252
- steps = np .vstack (pts_to_midstep (* self ._xy .T )).T
1253
-
1254
- path = Path (steps )
1255
- path = path .transformed (self .get_transform ())
1256
- self ._lineFunc (renderer , gc , path , IdentityTransform ())
1257
-
1258
1225
def _draw_solid (self , renderer , gc , path , trans ):
1259
1226
gc .set_linestyle ('solid' )
1260
1227
renderer .draw_path (gc , path , trans )
0 commit comments