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

« back to all changes in this revision

Viewing changes to chaco/lasso_overlay.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
# Enthought library imports
9
9
from enable.api import ColorTrait, LineStyle
10
 
from traits.api import Float, Instance
 
10
from traits.api import Float, Instance, Bool
11
11
 
12
12
# Local imports
13
13
from abstract_overlay import AbstractOverlay
34
34
    # The background color (overrides AbstractOverlay).
35
35
    bgcolor = 'clear'
36
36
 
 
37
    # Whether to draw the lasso
 
38
    # depends on the state of the lasso tool
 
39
    _draw_selection = Bool(False)
 
40
 
37
41
    def overlay(self, other_component, gc, view_bounds=None, mode="normal"):
38
42
        """ Draws this component overlaid on another component.
39
43
 
40
44
        Implements AbstractOverlay.
41
45
        """
 
46
        if not self._draw_selection:
 
47
            return
42
48
        with gc:
43
49
            c = other_component
44
50
            gc.clip_to_rect(c.x, c.y, c.width, c.height)
49
55
        self.component.invalidate_draw()
50
56
        self.component.request_redraw()
51
57
 
 
58
    def _event_state_fired_for_lasso_selection(self, val):
 
59
        self._draw_selection = val == 'selecting'
 
60
        self.component.invalidate_draw()
 
61
        self.component.request_redraw()
 
62
 
52
63
    def _draw_component(self, gc, view_bounds=None, mode='normal'):
53
64
        """ Draws the component.
54
65
 
63
74
                if len(points) == 0:
64
75
                    return
65
76
                points = concatenate((points, points[0, newaxis]), axis=0)
66
 
                gc.set_line_width(self.border_width)
 
77
                gc.set_line_width(self.selection_border_width)
67
78
                gc.set_line_dash(self.selection_border_dash_)
68
79
                gc.set_fill_color(self.selection_fill_color_)
69
80
                gc.set_stroke_color(self.selection_border_color_)