chaco.tools.line_segment_tool module¶
Defines the LineSegmentTool class.
-
class
chaco.tools.line_segment_tool.
LineSegmentTool
(component=None, **kwtraits)¶ Bases:
chaco.abstract_overlay.AbstractOverlay
The base class for tools that allow the user to draw a series of points connected by lines.
-
add_point
(point)¶ Given a screen-space point (x,y), adds the corresponding data space point to the list for this tool.
-
component
= Instance(Component)¶ The component that this tool overlays
-
delete_cursor
= Pointer("bullseye")¶ Cursor shape for deleting points.
-
dragging_draw
(gc)¶ Draws the polygon in the ‘dragging’ state.
-
dragging_key_pressed
(event)¶ Handles a key being pressed in the ‘dragging’ state.
If the key is “Esc”, the drag operation is canceled.
-
dragging_left_up
(event)¶ Handles the left mouse coming up in the ‘dragging’ state.
Switches to ‘normal’ state.
-
dragging_mouse_leave
(event)¶ Handles the mouse leaving the tool area in the ‘dragging’ state.
The drag is canceled and the cursor changes to an arrow.
-
dragging_mouse_move
(event)¶ Handles the user moving the mouse while in the ‘dragging’ state.
The screen is updated to show the new mouse position as the end of the line segment being drawn.
-
event_state
= Enum("normal", "selecting", "dragging")¶ The event states are:
- normal:
The user may have selected points, and is moving the cursor around.
- selecting:
The user has clicked down but hasn’t let go of the button yet, and can still drag the point around.
- dragging:
The user has clicked on an existing point and is dragging it around. When the user releases the mouse button, the tool returns to the “normal” state
-
get_point
(index)¶ Retrieves the indexed point and returns its screen space value.
-
line
= Instance(Line, args=())¶ The current line segment being drawn.
-
mouse_position
= Optional(Tuple)¶ The data (index, value) position of the mouse cursor; this is used by various draw() routines.
-
move_cursor
= Pointer("sizing")¶ Cursor shape for moving points.
-
normal_cursor
= Pointer("pencil")¶ Cursor shape for drawing.
-
normal_draw
(gc)¶ Draws the line.
-
normal_key_pressed
(event)¶ Handles the user pressing a key in the ‘normal’ state.
If the user presses the Enter key, the tool is reset.
-
normal_left_down
(event)¶ Handles the left mouse button being pressed while the tool is in the ‘normal’ state.
For an existing point, if the user is pressing the Control key, the point is deleted. Otherwise, the user can drag the point.
For a new point, the point is added, and the user can drag it.
-
normal_mouse_leave
(event)¶ Handles the user moving the cursor away from the tool area.
-
normal_mouse_move
(event)¶ Handles the user moving the mouse in the ‘normal’ state.
When the user moves the cursor over an existing point, if the Control key is pressed, the cursor changes to the delete_cursor, indicating that the point can be deleted. Otherwise, the cursor changes to the move_cursor, indicating that the point can be moved.
When the user moves the cursor over any other point, the cursor changes to (or stays) the normal_cursor.
-
original_cursor
= Pointer("arrow")¶ Cursor shape for non-tool use.
-
overlay
(component, gc, view_bounds, mode='normal')¶ Draws this component overlaid on another component.
Implements AbstractOverlay.
-
points
= List¶ A list of the points in data space as (index,value)
-
proximity_distance
= Int(4)¶ The pixel distance from a vertex that is considered ‘on’ the vertex.
-
remove_point
(index)¶ Removes the point for a given index from this tool’s list of points.
-
request_redraw
()¶ Requests that the component redraw itself.
Overrides Enable Component.
-
reset
()¶ Resets the tool, throwing away any points, and making the tool invisible.
-
set_point
(index, point)¶ Sets the data-space index for a screen-space point.
-
visible
= Bool(False)¶ The tool is initially invisible, because there is nothing to draw.
-