~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« 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: 2011-04-06 19:03:54 UTC
  • mfrom: (7.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110406190354-rwd55l2ezjecfo41
Tags: 3.4.0-2
d/rules: fix pyshared directory path (Closes: #621116)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
""" Defines the SimpleZoom class.
2
2
"""
 
3
from __future__ import with_statement
 
4
 
 
5
import warnings
 
6
warnings.warn("SimpleZoom has been deprecated, use ZoomTool", DeprecationWarning)
 
7
 
3
8
from numpy import array
4
9
 
5
10
# Enthought library imports
206
211
        """ Draws the overlay as a box.
207
212
        """
208
213
        if self._screen_start and self._screen_end:
209
 
            gc.save_state()
210
 
            try:
 
214
            with gc:
211
215
                gc.set_antialias(0)
212
216
                gc.set_line_width(self.border_size)
213
217
                gc.set_stroke_color(self.border_color_)
230
234
                else:
231
235
                    gc.rect(*rect)
232
236
                    gc.stroke_path()
233
 
            finally:
234
 
                gc.restore_state()
235
237
        return
236
238
 
237
239
    def overlay_range(self, component, gc):
245
247
        upper_right[axis_ndx] = self._screen_end[axis_ndx] - self._screen_start[axis_ndx]
246
248
        upper_right[1-axis_ndx] = self.component.bounds[1-axis_ndx]
247
249
 
248
 
        gc.save_state()
249
 
        try:
 
250
        with gc:
250
251
            gc.set_antialias(0)
251
252
            gc.set_alpha(self.alpha)
252
253
            gc.set_fill_color(self.color_)
254
255
            gc.clip_to_rect(component.x, component.y, component.width, component.height)
255
256
            gc.rect(lower_left[0], lower_left[1], upper_right[0], upper_right[1])
256
257
            gc.draw_path()
257
 
        finally:
258
 
            gc.restore_state()
 
258
 
259
259
        return
260
260
 
261
261
    def normal_left_down(self, event):