GSoC2009 Node Tool Rewrite

This page tracks the progress of the node tool rewrite project which is a part of the Google Summer of Code 2009. This project is being implemented by Krzysztof Kosiński, and the mentor is Bulia Byak. This page will be kept updated with the current status of the student's code (it may not reflect the code in the trunk).

The code has been merged into lp:inkscape. development continues in the trunk.

Implementation details

Control points (Knots) are represented by a new class called ControlPoint, reusing the SPCtrl canvas item of SPKnot, but with a different set of signals. A set of control points that can edit something is called a Manipulator. For paths, there will be three classes: PathManipulator (edits a single path, but is not standalone), MultiPathManipulator (edits everal paths at once and allows multipath operations on them) and SinglePathManipulator (edits only one path and can be used to edit path parameters of path effects).

A subclass of ControlPoint, SelectableControlPoint, can belong to a ControlPointSelection. Control points selections are a reusable selection metaphor. Each point is bound to a selection that it can be part of or not; there can be multiple simultaneously active selections for different kinds of points. Having separate selections means that the points will be dragged separately. The event context is responsible for handling selection by rubberband, and a separate selector component is provided for this.

ControlPoint virtual methods

Control points have two important virtual methods:
- setPosition(), which takes a Geom::Point in desktop coordinates and updates the position without side effects
- move(), which updates the position with side effects, like realigning the second handle of a smooth node or recomputing the handles of auto nodes.

ControlPoint signals

(obsoleted by performance work - signals were changed into virtual functions)

Additional features

Control points automatically enable forced redraws while dragging to ensure smooth updates and handle drag tolerance. There's also a transferGrab() method that allows to drag a different point that the one that was initially clicked for dragging; this is used to implement dragging out handles.

Examples of implementation

Dragging out handles: the grabbed handler of a node shows the handle and calls its transferGrab() method if Shift is pressed.

Constrained dragging: a handler for the dragged signal modifies the new position parameter it was passed, based on the information from the event.

Handle dragging: updating opposite handles in smooth nodes and smooth handles at ends of linear segments is done in an overridden move() method.

Feature Checklist

Selection

Selecting objects that are not paths shows their manipulators. This is unlikely to get fixed correctly during GSoC, as it requires at least partially rewriting the shape tools, but some short-term hack will be added.

Yes

Yes

Gradient editors

Control points for gradients are displayed when the preference setting is enabled

Yes

Yes

Selecting single nodes

Whether selecting single nodes with left-click works correctly.

Yes

Yes

Select segment

Click on a path segment to select adjacent nodes. Also works with Shift

Yes

Yes

Selecting multiple nodes

Shift-click to toggle selection of a node

Yes

Yes

Select all

Ctrl+A selects all nodes in subpaths that have something selected, Ctrl+Alt+A selects all nodes

Yes

Yes

Deselect

Esc or click outside of selected paths to deselect

Yes

Yes

Multi-path selection

Selecting nodes in two or more different paths; all per-node actions work on all selected nodes

Scrolling the mouse wheel when a selected node is hovered over causes the selection to propagate from this node to adjacent nodes in the path (without Ctrl) or to geometrically closest nodes (with Ctrl)

Yes

Yes

Preserve selection on undo

An attempt is made to preserve the node selection when undoing / redoing

Yes

Yes

Transform handles

Whether transform handles can be toggled for sets of nodes (needs sensible behavior when one node is selected). Should have 3 settings: never show handles, show for 2+ nodes (default), always show