diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2008-03-08 11:32:18 +0000 |
|---|---|---|
| committer | dvlierop2 <dvlierop2@users.sourceforge.net> | 2008-03-08 11:32:18 +0000 |
| commit | 0a78ad638f3bbcd46631cb2c741fca031356b725 (patch) | |
| tree | e7e0378939debb249a67c9e658bcef959b3b1a57 /src/nodepath.cpp | |
| parent | make the infobox narrower and place add button above it (diff) | |
| download | inkscape-0a78ad638f3bbcd46631cb2c741fca031356b725.tar.gz inkscape-0a78ad638f3bbcd46631cb2c741fca031356b725.zip | |
Node tool: snap to paths and their nodes, incl. to the path currently being edited
(bzr r4989)
Diffstat (limited to 'src/nodepath.cpp')
| -rw-r--r-- | src/nodepath.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 380a740fa..a563696cc 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -1102,18 +1102,36 @@ static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath, NR::Point best_pt = delta; NR::Point best_abs(NR_HUGE, NR_HUGE); - if (snap) { - SnapManager const &m = nodepath->desktop->namedview->snap_manager; - + + if (snap) { + /* When dragging a (selected) node, it should only snap to other nodes (i.e. unselected nodes), and + * not to itself. The snapper however can not tell which nodes are selected and which are not, so we + * must provide that information. */ + + // Build a list of the unselected nodes to which the snapper should snap + std::vector<NR::Point> unselected_nodes; + for (GList *spl = nodepath->subpaths; spl != NULL; spl = spl->next) { + Inkscape::NodePath::SubPath *subpath = (Inkscape::NodePath::SubPath *) spl->data; + for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) { + Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data; + if (!node->selected) { + unselected_nodes.push_back(node->pos); + } + } + } + + SnapManager &m = nodepath->desktop->namedview->snap_manager; + for (GList *l = nodepath->selected; l != NULL; l = l->next) { Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data; - Inkscape::SnappedPoint const s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, n->pos + delta, SP_PATH(n->subpath->nodepath->item)); + Inkscape::SnappedPoint s = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, n->pos + delta, SP_PATH(n->subpath->nodepath->item), &unselected_nodes); if (s.getDistance() < best) { best = s.getDistance(); best_abs = s.getPoint(); best_pt = best_abs - n->pos; } } + if (best_abs[NR::X] < NR_HUGE) { nodepath->desktop->snapindicator->set_new_snappoint(best_abs.to_2geom()); } |
