chaco.tools.cursor_tool module

Defines some chaco tools to provide draggable cursor functionality

For XY-plots, the cursor tool requires the index_sort flag to be set to either ‘ascending’ or ‘descending’.

TODO:

  • add some visual feedback to the user when a cursor is “grabbed”

    (e.g. highlight the cursor line)

  • update cursor position to the “selections” metadata on the owning

    plot component

class chaco.tools.cursor_tool.BaseCursorTool(component=None, **traits)

Bases: chaco.tools.line_inspector.LineInspector, enable.tools.drag_tool.DragTool

Abstract base class for CursorTool objects

current_index = Disallow

The current index-value of the cursor. Over-ridden in subclasses

current_position = Property(observe=["current_index"])

The current position of the cursor in data units

marker = Instance(CircleMarker, ())

the marker object. this should probably be private

marker_size = Float(3.0)

the radius of the marker in pixels

normal_mouse_leave(event)

Handles the mouse leaving the plot.

normal_mouse_move(event)

Handles the mouse being moved.

show_marker = Bool(True)

if true, draw a small circle at the cursor/line intersection

threshold = Float(5.0)

pick threshold, in screen units (pixels)

chaco.tools.cursor_tool.CursorTool(component, *args, **kwds)

Factory function returning either a CursorTool1D or CursorTool2D instance depending on whether the provided plot component is an XY-plot or a 2D plot.

class chaco.tools.cursor_tool.CursorTool1D(component=None, **traits)

Bases: chaco.tools.cursor_tool.BaseCursorTool

This tools provides a draggable cursor bound to a XY plot component instance.

Note, be sure to select an drag_button which does not conflict with other tools (e.g. the PanTool).

dragging(event)

This method is called for every mouse_move event that the tool receives while the user is dragging the mouse.

It is recommended that subclasses do most of their work in this method.

draw(gc, view_bounds=None)

Draws this tool on a graphics context.

Overrides LineInspector, BaseTool.

is_draggable(x, y)

Returns whether the (x,y) position is in a region that is OK to drag.

Used by the tool to determine when to start a drag.

class chaco.tools.cursor_tool.CursorTool2D(component=None, **traits)

Bases: chaco.tools.cursor_tool.BaseCursorTool

dragging(event)

This method is called for every mouse_move event that the tool receives while the user is dragging the mouse.

It is recommended that subclasses do most of their work in this method.

draw(gc, view_bounds=None)

Draws this tool on a graphics context.

Overrides LineInspector, BaseTool.

is_draggable(x, y)

Returns whether the (x,y) position is in a region that is OK to drag.

Used by the tool to determine when to start a drag.