diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index adef8e5a7e93b3fc7f7f9489427ba9828e7caef7..303c0fb75b6bf6f2a40e286eb85246761c13de71 100644 (file)
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
/**
* @class Handle
- * Represents a control point of a cubic Bezier curve in a path.
+ * @brief 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.
*/
double Handle::_saved_length = 0.0;
/**
* @class Node
- * Represents a curve endpoint in an editable path.
+ * @brief 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)
updateState();
}
+/** Pick the best type for this node, based on the position of its handles.
+ * This is what assigns types to nodes created using the pen tool. */
void Node::pickBestType()
{
_type = NODE_CUSP;
return ControlPoint::_eventHandler(event);
}
-// TODO Move this to 2Geom
+// TODO Move this to 2Geom!
static double bezier_length (Geom::Point a0, Geom::Point a1, Geom::Point a2, Geom::Point a3)
{
double lower = Geom::distance(a0, a3);
SnapManager &sm = _desktop->namedview->snap_manager;
Inkscape::SnapPreferences::PointType t = Inkscape::SnapPreferences::SNAPPOINT_NODE;
bool snap = sm.someSnapperMightSnap();
- std::vector< std::pair<Geom::Point, int> > unselected;
+ std::vector<Inkscape::SnapCandidatePoint> unselected;
if (snap) {
- // setup
- // TODO we are doing this every time a snap happens. It should once be done only once
- // per drag - maybe in the grabbed handler?
- // TODO "unselected" must be valid during the snap run, because it is not copied.
- // Fix this in snap.h and snap.cpp, then the above.
+ /* setup
+ * TODO We are doing this every time a snap happens. It should once be done only once
+ * per drag - maybe in the grabbed handler?
+ * TODO Unselected nodes vector must be valid during the snap run, because it is not
+ * copied. Fix this in snap.h and snap.cpp, then the above.
+ * TODO Snapping to unselected segments of selected paths doesn't work yet. */
// Build the list of unselected nodes.
typedef ControlPointSelection::Set Set;
for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) {
if (!(*i)->selected()) {
Node *n = static_cast<Node*>(*i);
- unselected.push_back(std::make_pair((*i)->position(), (int) n->_snapTargetType()));
+ Inkscape::SnapCandidatePoint p(n->position(), n->_snapSourceType(), n->_snapTargetType());
+ unselected.push_back(p);
}
}
sm.setupIgnoreSelection(_desktop, true, &unselected);
// TODO: combine these two branches by modifying snap.h / snap.cpp
if (snap) {
Inkscape::SnappedPoint fp, bp;
- fp = sm.constrainedSnap(t, position(), _snapSourceType(), line_front);
- bp = sm.constrainedSnap(t, position(), _snapSourceType(), line_back);
+ fp = sm.constrainedSnap(t, Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_front);
+ bp = sm.constrainedSnap(t, Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_back);
if (fp.isOtherSnapBetter(bp, false)) {
bp.getPoint(new_pos);
Inkscape::SnappedPoint fp, bp;
Inkscape::Snapper::ConstraintLine line_x(origin, Geom::Point(1, 0));
Inkscape::Snapper::ConstraintLine line_y(origin, Geom::Point(0, 1));
- fp = sm.constrainedSnap(t, position(), _snapSourceType(), line_x);
- bp = sm.constrainedSnap(t, position(), _snapSourceType(), line_y);
+ fp = sm.constrainedSnap(t, Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_x);
+ bp = sm.constrainedSnap(t, Inkscape::SnapCandidatePoint(position(), _snapSourceType()), line_y);
if (fp.isOtherSnapBetter(bp, false)) {
fp = bp;