chaco.tools.range_selection module

Defines the RangeSelection controller class.

class chaco.tools.range_selection.RangeSelection(component, *args, **kw)

Bases: chaco.abstract_controller.AbstractController

Selects a range along the index or value axis.

The user right-click-drags to select a region, which stays selected until the user left-clicks to deselect.

allow_deselection = Bool(True)

Allow the tool to be put into the deselected state via mouse clicks

append_key = Instance(KeySpec, args=(None, "control"))

The key which, if held down while the mouse is being dragged, will indicate that the selection should be appended to an existing selection as opposed to overwriting it.

axis = Enum("index", "value")

The axis to which this tool is perpendicular.

axis_index = Property

The index to use for axis. By default, this is self.plot.orientation, but it can be overriden and set to 0 or 1.

deselect(event=None)

Deselects the highlighted region.

This method essentially resets the tool. It takes the event causing the deselection as an optional argument.

disable_left_mouse = Bool(False)

Disable all left-mouse button interactions?

enable_resize = Bool(True)

Can the user resize the selection once it has been drawn?

event_state = Enum("normal", "selecting", "selected", "moving")

The possible event states of this selection tool (overrides enable.Interactor).

normal:

Nothing has been selected, and the user is not dragging the mouse.

selecting:

The user is dragging the mouse and actively changing the selection region; resizing of an existing selection also uses this mode.

selected:

The user has released the mouse and a selection has been finalized. The selection remains until the user left-clicks or self.deselect() is called.

moving:

The user moving (not resizing) the selection range.

left_button_selects = Bool(False)

Allow the left button begin a selection?

listeners = List

List of listeners that listen to selection events.

mapper = Property

The mapper for associated with this tool. By default, this is the mapper on plot that corresponds to axis.

mask_metadata_name = Str("selection_masks")

The name of the metadata on the datasource that we will set to a numpy boolean array for masking the datasource’s data

metadata_name = Str("selections")

The name of the metadata on the datasource that we will write self.selection to

minimum_selection = Int(5)

The minimum span, in pixels, of a selection region. Any attempt to select a region smaller than this will be treated as a deselection.

moving_left_up(event)

Handles the left mouse button coming up when the tool is in the ‘moving’ state.

Switches the tool to the ‘selected’ state.

moving_mouse_enter(event)
moving_mouse_leave(event)

Handles the mouse leaving the plot while the tool is in the ‘moving’ state.

If the mouse was within the selection region when it left, the method does nothing.

If the mouse was outside the selection region whe it left, the event is treated as moving the selection to the minimum or maximum.

moving_mouse_move(event)

Handles the mouse moving when the tool is in the ‘moving’ state.

Moves the selection range by an amount corresponding to the amount that the mouse has moved since its button was pressed. If the new selection range overlaps the endpoints of the data, it is truncated to that endpoint.

normal_left_down(event)

Handles the left mouse button being pressed when the tool is in the ‘normal’ state.

If the tool allows the left mouse button to start a selection, then it does so.

normal_right_down(event)

Handles the right mouse button being pressed when the tool is in the ‘normal’ state.

Puts the tool into ‘selecting’ mode, changes the cursor to show that it is selecting, and starts defining the selection.

plot = Property

The plot associated with this tool By default, this is just self.component.

resize_margin = Int(7)

The pixel distance between the mouse event and a selection endpoint at which the user action will be construed as a resize operation.

selected_left_down(event)

Handles the left mouse button being pressed when the tool is in the ‘selected’ state.

If the user is allowed to resize the selection, and the event occurred within the resize margin of an endpoint, then the tool switches to the ‘selecting’ state so that the user can resize the selection.

If the event is within the bounds of the selection region, then the tool switches to the ‘moving’ states.

Otherwise, the selection becomes deselected.

selected_mouse_leave(event)

Handles the mouse leaving the plot when the tool is in the ‘selected’ state.

Sets the cursor to an arrow.

selected_mouse_move(event)

Handles the mouse moving when the tool is in the ‘selected’ srate.

If the user is allowed to resize the selection, and the event occurred within the resize margin of an endpoint, then the cursor changes to indicate that the selection could be resized.

Otherwise, the cursor is set to an arrow.

selected_right_down(event)

Handles the right mouse button being pressed when the tool is in the ‘selected’ state.

If the user is allowed to resize the selection, and the event occurred within the resize margin of an endpoint, then the tool switches to the ‘selecting’ state so that the user can resize the selection.

Otherwise, the selection becomes deselected, and a new selection is started..

selecting_button_up(event)
selecting_left_up(event)

Handles the left mouse button coming up when the tool is in the ‘selecting’ state.

Switches the tool to the ‘selected’ state.

selecting_mouse_enter(event)

Handles the mouse entering the plot when the tool is in the ‘selecting’ state.

If the mouse does not have the right mouse button down, this event is treated as if the right mouse button was released. Otherwise, the method sets the cursor to show that it is selecting.

selecting_mouse_leave(event)

Handles the mouse leaving the plot when the tool is in the ‘selecting’ state.

Determines whether the event’s position is outside the component’s bounds, and if so, clips the selection. Sets the cursor to an arrow.

selecting_mouse_move(event)

Handles the mouse being moved when the tool is in the ‘selecting’ state.

Expands the selection range at the appropriate end, based on the new mouse position.

selecting_right_up(event)

Handles the right mouse button coming up when the tool is in the ‘selecting’ state.

Switches the tool to the ‘selected’ state and completes the selection.

selection = Property

The selected region, expressed as a tuple in data space. This updates and fires change-events as the user is dragging.

selection_completed = Event

This event is fired whenever the user completes the selection, or when a finalized selection gets modified. The value of the event is the data space range.

selection_mode_metadata_name = Str("selection_mode")

Either “set” or “append”, depending on whether self.append_key was held down