@@ -3236,6 +3236,7 @@ class NavigationBase(object):
3236
3236
locked
3237
3237
messagelock : `LockDraw` to know if the message is available to write
3238
3238
"""
3239
+
3239
3240
_default_cursor = cursors .POINTER
3240
3241
_default_tools = [tools .ToolToggleGrid ,
3241
3242
tools .ToolToggleFullScreen ,
@@ -3255,6 +3256,7 @@ class NavigationBase(object):
3255
3256
3256
3257
def __init__ (self , canvas , toolbar = None ):
3257
3258
""".. automethod:: _toolbar_callback"""
3259
+
3258
3260
self .canvas = canvas
3259
3261
self .toolbar = self ._get_toolbar (toolbar , canvas )
3260
3262
@@ -3273,9 +3275,9 @@ def __init__(self, canvas, toolbar=None):
3273
3275
self ._instances = {}
3274
3276
self ._toggled = None
3275
3277
3276
- #to process keypress event
3278
+ # to process keypress event
3277
3279
self .keypresslock = widgets .LockDraw ()
3278
- #to write into toolbar message
3280
+ # to write into toolbar message
3279
3281
self .messagelock = widgets .LockDraw ()
3280
3282
3281
3283
for tool in self ._default_tools :
@@ -3290,11 +3292,13 @@ def __init__(self, canvas, toolbar=None):
3290
3292
@classmethod
3291
3293
def get_default_tools (cls ):
3292
3294
"""Get the default tools"""
3295
+
3293
3296
return cls ._defau
10000
lt_tools
3294
3297
3295
3298
@classmethod
3296
3299
def set_default_tools (cls , tools ):
3297
3300
"""Set default tools"""
3301
+
3298
3302
cls ._default_tools = tools
3299
3303
3300
3304
def _get_toolbar (self , toolbar , canvas ):
@@ -3312,6 +3316,7 @@ def active_toggle(self):
3312
3316
3313
3317
**string** : Currently toggled tool, or None
3314
3318
"""
3319
+
3315
3320
return self ._toggled
3316
3321
3317
3322
@property
@@ -3320,6 +3325,7 @@ def instances(self):
3320
3325
3321
3326
**dictionary** : Contains the active instances that are registered
3322
3327
"""
3328
+
3323
3329
return self ._instances
3324
3330
3325
3331
def get_tool_keymap (self , name ):
@@ -3334,6 +3340,7 @@ def get_tool_keymap(self, name):
3334
3340
----------
3335
3341
list : list of keys associated with the Tool
3336
3342
"""
3343
+
3337
3344
keys = [k for k , i in six .iteritems (self ._keys ) if i == name ]
3338
3345
return keys
3339
3346
@@ -3380,6 +3387,7 @@ def unregister(self, name):
3380
3387
If called, next time the `Tool` is used it will be reinstantiated
3381
3388
instead of using the existing instance.
3382
3389
"""
3390
+
3383
3391
if self ._toggled == name :
3384
3392
self ._handle_toggle (name , from_toolbar = False )
3385
3393
if name in self ._instances :
@@ -3393,6 +3401,7 @@ def remove_tool(self, name):
3393
3401
name : string
3394
3402
Name of the Tool
3395
3403
"""
3404
+
3396
3405
self .unregister (name )
3397
3406
del self ._tools [name ]
3398
3407
keys = [k for k , v in six .iteritems (self ._keys ) if v == name ]
@@ -3410,6 +3419,7 @@ def add_tool(self, tool):
3410
3419
tool : string or `Tool` class
3411
3420
Reference to find the class of the Tool to be added
3412
3421
"""
3422
+
3413
3423
tool_cls = self ._get_cls_to_instantiate (tool )
3414
3424
name = tool_cls .name
3415
3425
@@ -3445,7 +3455,7 @@ def add_tool(self, tool):
3445
3455
3446
3456
def _get_cls_to_instantiate (self , callback_class ):
3447
3457
if isinstance (callback_class , six .string_types ):
3448
- #FIXME: make more complete searching structure
3458
+ # FIXME: make more complete searching structure
3449
3459
if callback_class in globals ():
3450
3460
return globals ()[callback_class ]
3451
3461
@@ -3462,6 +3472,7 @@ def trigger_tool(self, name):
3462
3472
3463
3473
Method to programatically "click" on Tools
3464
3474
"""
3475
+
3465
3476
self ._trigger_tool (name , None , False )
3466
3477
3467
3478
def _trigger_tool (self , name , event , from_toolbar ):
@@ -3475,8 +3486,7 @@ def _trigger_tool(self, name, event, from_toolbar):
3475
3486
instance = self ._get_instance (name )
3476
3487
instance .trigger (event )
3477
3488
else :
3478
- #Non persistent tools, are
3479
- #instantiated and forgotten (reminds me an exgirlfriend?)
3489
+ # Non persistent tools, are instantiated and forgotten
3480
3490
tool (self .canvas .figure , event )
3481
3491
3482
3492
def _key_press (self , event ):
@@ -3491,7 +3501,7 @@ def _key_press(self, event):
3491
3501
def _get_instance (self , name ):
3492
3502
if name not in self ._instances :
3493
3503
instance = self ._tools [name ](self .canvas .figure )
3494
- #register instance
3504
+ # register instance
3495
3505
self ._instances [name ] = instance
3496
3506
3497
3507
return self ._instances [name ]
@@ -3508,24 +3518,25 @@ def _toolbar_callback(self, name):
3508
3518
Name of the tool that was activated (click) by the user using the
3509
3519
toolbar
3510
3520
"""
3521
+
3511
3522
self ._trigger_tool (name , None , True )
3512
3523
3513
3524
def _handle_toggle (self , name , event = None , from_toolbar = False ):
3514
- #toggle toolbar without callback
3525
+ # toggle toolbar without callback
3515
3526
if not from_toolbar and self .toolbar :
3516
3527
self .toolbar ._toggle (name , False )
3517
3528
3518
3529
instance = self ._get_instance (name )
3519
3530
if self ._toggled is None :
3520
- #first trigger of tool
3531
+ # first trigger of tool
3521
3532
self ._toggled = name
3522
3533
elif self ._toggled == name :
3523
- #second trigger of tool
3534
+ # second trigger of tool
3524
3535
self ._toggled = None
3525
3536
else :
3526
- #other tool is triggered so trigger toggled tool
3537
+ # other tool is triggered so trigger toggled tool
3527
3538
if self .toolbar :
3528
- #untoggle the previous toggled tool
3539
+ # untoggle the previous toggled tool
3529
3540
self .toolbar ._toggle (self ._toggled , False )
3530
3541
self ._get_instance (self ._toggled ).trigger (event )
3531
3542
self ._toggled = name
@@ -3537,6 +3548,7 @@ def _handle_toggle(self, name, event=None, from_toolbar=False):
3537
3548
3538
3549
def list_tools (self ):
3539
3550
"""Print the list the tools controlled by `Navigation`"""
3551
+
3540
3552
print ('_' * 80 )
3541
3553
print ("{0:20} {1:50} {2}" .format ('Name (id)' , 'Tool description' ,
3542
3554
'Keymap' ))
@@ -3550,6 +3562,7 @@ def list_tools(self):
3550
3562
3551
3563
def update (self ):
3552
3564
"""Reset the axes stack"""
3565
+
3553
3566
self .views .clear ()
3554
3567
self .positions .clear ()
3555
3568
# self.set_history_buttons()
@@ -3585,16 +3598,21 @@ def _mouse_move(self, event):
3585
3598
3586
3599
def draw (self ):
3587
3600
"""Redraw the canvases, update the locators"""
3601
+
3588
3602
for a in self .canvas .figure .get_axes ():
3589
3603
xaxis = getattr (a , 'xaxis' , None )
3590
3604
yaxis = getattr (a , 'yaxis' , None )
3605
+ zaxis = getattr (a , 'zaxis' , None )
3591
3606
locators = []
3592
3607
if xaxis is not None :
3593
3608
locators .append (xaxis .get_major_locator ())
3594
3609
locators .append (xaxis .get_minor_locator ())
3595
3610
if yaxis is not None :
3596
3611
locators .append (yaxis .get_major_locator ())
3597
3612
locators .append (yaxis .get_minor_locator ())
3613
+ if zaxis is not None :
3614
+ locators .append (zaxis .get_major_locator ())
3615
+ locators .append (zaxis .get_minor_locator ())
3598
3616
3599
3617
for loc in locators :
3600
3618
loc .refresh ()
@@ -3608,6 +3626,7 @@ def set_cursor(self, cursor):
3608
3626
Set the current cursor to one of the :class:`Cursors`
3609
3627
enums values
3610
3628
"""
3629
+
3611
3630
pass
3612
3631
3613
3632
def update_view (self ):
@@ -3633,6 +3652,7 @@ def update_view(self):
3633
3652
3634
3653
def push_current (self ):
3635
3654
"""push the current view limits and position onto the stack"""
3655
+
3636
3656
lims = []
3637
3657
pos = []
3638
3658
for a in self .canvas .figure .get_axes ():
@@ -3659,6 +3679,7 @@ def draw_rubberband(self, event, caller, x0, y0, x1, y1):
3659
3679
caller : instance trying to draw the rubberband
3660
3680
x0, y0, x1, y1 : coordinates
3661
3681
"""
3682
+
3662
3683
if not self .canvas .widgetlock .available (caller ):
3663
3684
warnings .warn ("%s doesn't own the canvas widgetlock" % caller )
3664
3685
@@ -3673,6 +3694,7 @@ def remove_rubberband(self, event, caller):
3673
3694
event : `FigureCanvas` event
3674
3695
caller : instance trying to remove the rubberband
3675
3696
"""
3697
+
3676
3698
if not self .canvas .widgetlock .available (caller ):
3677
3699
warnings .warn ("%s doesn't own the canvas widgetlock" % caller )
3678
3700
@@ -3684,12 +3706,14 @@ class ToolbarBase(object):
3684
3706
----------
3685
3707
manager : `FigureManager` instance that integrates this `Toolbar`
3686
3708
"""
3709
+
3687
3710
def __init__ (self , manager ):
3688
3711
"""
3689
3712
.. automethod:: _add_toolitem
3690
3713
.. automethod:: _remove_toolitem
3691
3714
.. automethod:: _toggle
3692
3715
"""
3716
+
3693
3717
self .manager = manager
3694
3718
3695
3719
def _add_toolitem (self , name , description , image_file , position ,
@@ -3717,6 +3741,7 @@ def _add_toolitem(self, name, description, image_file, position,
3717
3741
* `False` : The button is a normal button (returns to unpressed
3718
3742
state after release)
3719
3743
"""
3744
+
3720
3745
raise NotImplementedError
3721
3746
3722
3747
def add_separator (self , pos ):
@@ -3728,10 +3753,12 @@ def add_separator(self, pos):
3728
3753
Position where to add the separator within the toolitems
3729
3754
if -1 at the end
3730
3755
"""
3756
+
3731
3757
pass
3732
3758
3733
3759
def set_message (self , s ):
3734
3760
"""Display a message on toolbar or in status bar"""
3761
+
3735
3762
pass
3736
3763
3737
3764
def _toggle (self , name , callback = False ):
@@ -3746,7 +3773,8 @@ def _toggle(self, name, callback=False):
3746
3773
* `False`: toggle the button without calling the callback
3747
3774
3748
3775
"""
3749
- #carefull, callback means to perform or not the callback while toggling
3776
+
3777
+ # carefull, callback means to perform or not the callback while toggling
3750
3778
raise NotImplementedError
3751
3779
3752
3780
def _remove_toolitem (self , name ):
@@ -3758,6 +3786,7 @@ def _remove_toolitem(self, name):
3758
3786
Name of the tool to remove
3759
3787
3760
3788
"""
3789
+
3761
3790
raise NotImplementedError
3762
3791
3763
3792
def move_toolitem (self , pos_ini , pos_fin ):
@@ -3770,6 +3799,7 @@ def move_toolitem(self, pos_ini, pos_fin):
3770
3799
pos_fin : integer
3771
3800
Final position of the toolitem
3772
3801
"""
3802
+
3773
3803
pass
3774
3804
3775
3805
def set_toolitem_visibility (self , name , visible ):
@@ -3783,4 +3813,5 @@ def set_toolitem_visibility(self, name, visible):
3783
3813
* `True`: set the toolitem visible
3784
3814
* `False`: set the toolitem invisible
3785
3815
"""
3816
+
3786
3817
pass
0 commit comments