From ee17bac8a5d9b6bf840272885c1eda57c45fb4ad Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 17 Sep 2011 01:00:05 +0200 Subject: Node tool, transforming a set of nodes: Fix crashes, and finish implementation of snapping Fixed bugs: - https://launchpad.net/bugs/590261 (bzr r10633) --- src/ui/tool/node.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 8e3da266b..e254fb9b2 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -307,12 +307,10 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) std::vector unselected; if (snap) { - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); + for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); - Inkscape::SnapCandidatePoint p(n->position(), n->_snapSourceType(), n->_snapTargetType()); - unselected.push_back(p); + unselected.push_back(n->snapCandidatePoint()); } sm.setupIgnoreSelection(_desktop, true, &unselected); @@ -326,7 +324,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } else if (ctrl_constraint) { // NOTE: this is subtly wrong. // We should get all possible constraints and snap along them using - // multipleConstrainedSnaps, instead of first snapping to angle and the to objects + // multipleConstrainedSnaps, instead of first snapping to angle and then to objects Inkscape::SnappedPoint p; p = sm.constrainedSnap(Inkscape::SnapCandidatePoint(new_pos, SNAPSOURCE_NODE_HANDLE), *ctrl_constraint); new_pos = p.getPoint(); @@ -1118,6 +1116,11 @@ Inkscape::SnapTargetType Node::_snapTargetType() return SNAPTARGET_NODE_CUSP; } +Inkscape::SnapCandidatePoint Node::snapCandidatePoint() +{ + return SnapCandidatePoint(position(), _snapSourceType(), _snapTargetType()); +} + /** @brief Gets the handle that faces the given adjacent node. * Will abort with error if the given node is not adjacent. */ Handle *Node::handleToward(Node *to) -- cgit v1.2.3 From 6343a24c5cd0a998e00ae05fc6abe2081be21c71 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 3 Oct 2011 00:24:15 -0700 Subject: Doxygen cleanup. (bzr r10660) --- src/ui/tool/node.cpp | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index e254fb9b2..d268a9f14 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1,5 +1,6 @@ -/** @file - * Editable node - implementation +/** + * @file + * Editable node - implementation. */ /* Authors: * Krzysztof KosiƄski @@ -70,13 +71,11 @@ static Geom::Point direction(Geom::Point const &first, Geom::Point const &second } /** - * @class Handle - * @brief Control point of a cubic Bezier curve in a path. + * Control point of a cubic Bezier curve in a path. * * Handle keeps the node type invariant only for the opposite handle of the same node. * Keeping the invariant on node moves is left to the %Node class. */ - Geom::Point Handle::_saved_other_pos(0, 0); double Handle::_saved_length = 0.0; bool Handle::_drag_out = false; @@ -467,12 +466,10 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) } /** - * @class Node - * @brief Curve endpoint in an editable path. + * Curve endpoint in an editable path. * * The method move() keeps node type invariants during translations. */ - Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : SelectableControlPoint(data.desktop, initial_pos, Gtk::ANCHOR_CENTER, SP_CTRL_SHAPE_DIAMOND, 9.0, *data.selection, &node_colors, data.node_group) @@ -1121,8 +1118,10 @@ Inkscape::SnapCandidatePoint Node::snapCandidatePoint() return SnapCandidatePoint(position(), _snapSourceType(), _snapTargetType()); } -/** @brief Gets the handle that faces the given adjacent node. - * Will abort with error if the given node is not adjacent. */ +/** + * Gets the handle that faces the given adjacent node. + * Will abort with error if the given node is not adjacent. + */ Handle *Node::handleToward(Node *to) { if (_next() == to) { @@ -1134,8 +1133,10 @@ Handle *Node::handleToward(Node *to) g_error("Node::handleToward(): second node is not adjacent!"); } -/** @brief Gets the node in the direction of the given handle. - * Will abort with error if the handle doesn't belong to this node. */ +/** + * Gets the node in the direction of the given handle. + * Will abort with error if the handle doesn't belong to this node. + */ Node *Node::nodeToward(Handle *dir) { if (front() == dir) { @@ -1147,8 +1148,10 @@ Node *Node::nodeToward(Handle *dir) g_error("Node::nodeToward(): handle is not a child of this node!"); } -/** @brief Gets the handle that goes in the direction opposite to the given adjacent node. - * Will abort with error if the given node is not adjacent. */ +/** + * Gets the handle that goes in the direction opposite to the given adjacent node. + * Will abort with error if the given node is not adjacent. + */ Handle *Node::handleAwayFrom(Node *to) { if (_next() == to) { @@ -1160,8 +1163,10 @@ Handle *Node::handleAwayFrom(Node *to) g_error("Node::handleAwayFrom(): second node is not adjacent!"); } -/** @brief Gets the node in the direction opposite to the given handle. - * Will abort with error if the handle doesn't belong to this node. */ +/** + * Gets the node in the direction opposite to the given handle. + * Will abort with error if the handle doesn't belong to this node. + */ Node *Node::nodeAwayFrom(Handle *h) { if (front() == h) { @@ -1262,14 +1267,12 @@ SPCtrlShapeType Node::_node_type_to_shape(NodeType type) /** - * @class NodeList - * @brief An editable list of nodes representing a subpath. + * An editable list of nodes representing a subpath. * * It can optionally be cyclic to represent a closed path. * The list has iterators that act like plain node iterators, but can also be used * to obtain shared pointers to nodes. */ - NodeList::NodeList(SubpathList &splist) : _list(splist) , _closed(false) @@ -1430,7 +1433,7 @@ NodeList &NodeList::get(iterator const &i) { /** * @class SubpathList - * @brief Editable path composed of one or more subpaths + * Editable path composed of one or more subpaths. */ } // namespace UI -- cgit v1.2.3