~ubuntu-branches/ubuntu/vivid/python-chaco/vivid-proposed

« back to all changes in this revision

Viewing changes to enthought/chaco/tools/simple_zoom.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2010-02-28 14:05:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100228140525-1eo43ddoakb2j3j9
Tags: 3.3.0-1
* New upstream release
* Switch to source format 3.0 (quilt)
* Bump Standards-Version to 3.8.4
* Remove transition package: python-enthought-chaco2

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
    import Bool, Enum, Float, Instance, Int, Str, Trait, Tuple
9
9
 
10
10
# Chaco imports
11
 
from enthought.chaco.api import AbstractOverlay
 
11
from enthought.chaco.abstract_overlay import AbstractOverlay
12
12
from base_zoom_tool import BaseZoomTool
13
13
from tool_history_mixin import ToolHistoryMixin
14
14
 
394
394
 
395
395
    def _do_zoom(self):
396
396
        """ Does the zoom operation.
 
397
        
 
398
        This method does not handle zooms triggered by scrolling the mouse wheel.
 
399
        Those are handled by `normal_mouse_wheel()`.
397
400
        """
398
 
        # Sets the bounds on the component using _cur_stack_index
 
401
        # Sets the bounds on the component using _history_index.
399
402
        low, high = self._current_state()
400
403
        orig_low, orig_high = self._history[0]
401
404
 
402
405
        if self._history_index == 0:
 
406
            # Reset to the original range(s).
403
407
            if self.tool_mode == "range":
 
408
                # "range" mode; reset the one axis.
404
409
                mapper = self._get_mapper()
405
410
                mapper.range.low_setting = self._orig_low_setting
406
411
                mapper.range.high_setting = self._orig_high_setting
407
412
            else:
 
413
                # "box" mode; reset both axes.
408
414
                x_range = self.component.x_mapper.range
409
415
                y_range = self.component.y_mapper.range
410
416
                x_range.low_setting, y_range.low_setting = \
417
423
                y_range.reset()
418
424
 
419
425
        else:
 
426
            # Do a new zoom.
420
427
            if self.tool_mode == "range":
 
428
                # "range" mode; zoom the one axis.
421
429
                mapper = self._get_mapper()
422
430
                if self._zoom_limit_reached(orig_low, orig_high, low, high, mapper):
423
431
                    self._pop_state()
425
433
                mapper.range.low = low
426
434
                mapper.range.high = high
427
435
            else:
 
436
                # "box" mode; zoom both axes.
428
437
                for ndx in (0, 1):
429
438
                    mapper = (self.component.x_mapper, self.component.y_mapper)[ndx]
430
439
                    if self._zoom_limit_reached(orig_low[ndx], orig_high[ndx],
522
531
            # Check the domain limits on each dimension, and rescale the zoom
523
532
            # amount if necessary.
524
533
            for ndx, (mapper, newlow, newhigh) in enumerate(todo_list):
 
534
                if newlow > newhigh:
 
535
                    # This happens when the orientation of the axis is reversed.
 
536
                    newlow, newhigh = newhigh, newlow                    
525
537
                domain_min, domain_max = getattr(mapper, "domain_limits", (None,None))
526
538
                if domain_min is not None and newlow < domain_min:
527
539
                    newlow = domain_min