1
""" Defines the TrackingPanTool class.
4
from enthought.chaco.tools.api import PanTool
6
class TrackingPanTool(PanTool):
7
""" Allows the user to pan around a plot.
9
The user clicks a mouse button and drags to pan; the tool then returns to
13
def _end_pan(self, event):
15
xrange = plot.x_mapper.range
16
yrange = plot.y_mapper.range
18
if not self.constrain or self.constrain_direction == "x":
21
if xrange.default_state == 'low_track':
22
hi_val = max([source.get_bounds()[1] for source in xrange.sources])
23
if hi_val >= low and hi_val <= high:
24
xrange.set_bounds('track','auto')
25
elif xrange.default_state == 'high_track':
26
lo_val = min([source.get_bounds()[0] for source in xrange.sources])
27
if lo_val >= low and lo_val <= high:
28
xrange.set_bounds('auto','track')
30
if not self.constrain or self.constrain_direction == "y":
33
if yrange.default_state == 'low_track':
34
hi_val = max([source.get_bounds()[1] for source in yrange.sources])
35
if hi_val >= low and hi_val <= high:
36
yrange.set_bounds('track','auto')
37
elif yrange.default_state == 'high_track':
38
lo_val = min([source.get_bounds()[0] for source in yrange.sources])
39
if lo_val >= low and lo_val <= high:
40
yrange.set_bounds('auto','track')
42
if self._auto_constrain:
43
self.constrain = False
44
self.constrain_direction = None
45
self.event_state = "normal"
46
event.window.set_pointer("arrow")
47
if event.window.mouse_owner == self:
48
event.window.set_mouse_owner(None)