/usr/lib/python2.7/dist-packages/chaco/selectable_overlay_container.py is in python-chaco 4.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | """ Defines the SelectableOverlayPlotContainer class.
"""
from __future__ import with_statement
from numpy import array, float64
# Enthought library imports
from traits.api import Bool, Float, Enum
from enable.api import ColorTrait
# Local imports
from plot_containers import OverlayPlotContainer
class SelectableOverlayPlotContainer(OverlayPlotContainer):
"""
An OverlayPlotContainer that can show a selection region on top of it.
"""
# Screen position of the start of the selection, which can be in the x- or
# y-dimension, depending on **selection_direction**.
selection_screen_start = Float(0.0)
# Screen position of the end of the selection, which can be in the x- or
# y-dimension, depending on **selection_direction**.
selection_screen_end = Float(0.0)
# Is there an active selection?
selection_active = Bool(False)
# The direction of the selection.
selection_direction = Enum('v', 'h')
# The color to use to fill the selected region.
selection_fill_color = ColorTrait('lightskyblue')
# The color to use to draw the border of the selected region.
selection_border_color = ColorTrait('dodgerblue')
# The transparency of the **selection_fill_color**.
selection_alpha = Float(0.3)
def _draw_overlays(self, gc, view_bounds=None, mode='normal'):
""" Method for backward compatability with old drawing scheme.
Overrides BasePlotContainer.
"""
self._draw_selection(gc, view_bounds=view_bounds, mode=mode)
return
def _draw_selection(self, gc, view_bounds=None, mode='normal'):
""" Renders a selected subset of a component's data.
Overrides PlotComponent.
"""
if self.selection_active:
if self.selection_direction == 'h':
x1 = self.selection_screen_start
x2 = self.selection_screen_end
y1 = self.y
y2 = self.position[1] + self.bounds[1] - 1
else:
x1 = self.x
x2 = self.position[0] + self.bounds[0] - 1
y1 = self.selection_screen_start
y2 = self.selection_screen_end
lowerleft = array((min(x1, x2), min(y1, y2)), float64)
upperright = array((max(x1, x2), max(y1, y2)), float64)
with gc:
gc.translate_ctm(*self.position)
gc.set_fill_color(self.selection_fill_color_)
gc.set_stroke_color(self.selection_border_color_)
gc.set_alpha(self.selection_alpha)
gc.rect(lowerleft[0], lowerleft[1], upperright[0], upperright[1])
gc.draw_path()
return
|