chaco.tools.lasso_selection module

Defines the LassoSelection controller class.

class chaco.tools.lasso_selection.LassoSelection(component, *args, **kw)

Bases: chaco.abstract_controller.AbstractController

A controller that represents the interaction of “lassoing” a set of points.

“Lassoing” means drawing an arbitrary selection region around the points by dragging the mouse along the outline of the region.

dataspace_points = Property(Array)

An Nx2 array of points in data space representing all selected points.

disjoint_selections = Property(List)

A list of all the selection polygons.

drag_button = Enum("left", "right")

The button which this tool responds to

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

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 is actively changing the selection region.

incremental_select = Bool(False)

If True, the selection mask is updated as the mouse moves, rather than only at the beginning and end of the selection operation.

metadata_name = Str("selection")

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

normal_key_pressed(event)

Handles the user pressing a key in the ‘normal’ state.

If the user presses the Escape key, the tool is reset.

normal_left_down(event)
normal_mouse_down(event)

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

Puts the tool into ‘selecting’ mode, and starts defining the selection.

normal_right_down(event)
plot = Property

Mapping from screen space to data space. By default, it is just self.component.

selecting_left_up(event)
selecting_mouse_leave(event)

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

Ends the selection operation.

selecting_mouse_move(event)

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

The selection is extended to the current mouse position.

selecting_mouse_up(event)

Handles the mouse button coming up in the ‘selecting’ state.

Completes the selection and switches to the ‘normal’ state.

selecting_right_up(event)
selection_changed = Event

Fires when the selection mask changes.

selection_completed = Event

Fires when the user release the mouse button and finalizes the selection.

selection_datasource = Instance(AbstractDataSource)

The data source that the mask of selected points is attached to. Note that the indices in this data source must match the indices of the data in the plot.

selection_mode = Enum("include", "exclude", "invert")

The selection mode of the lasso pointer: “include”, “exclude” or “invert” points from the selection. The “include” and “exclude” settings essentially invert the selection mask. The “invert” setting differs from “exclude” in that “invert” inverses the selection of all points the the lasso’ed polygon, while “exclude” operates only on points included in a previous selection.

updated = Event

Fires whenever dataspace_points changes, necessitating a redraw of the selection region.