Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

Inkscape::SnappedPoint SnapManager::constrainedSnap ( Inkscape::SnapCandidatePoint const &  p,
Inkscape::Snapper::ConstraintLine const &  constraint,
Geom::OptRect const &  bbox_to_snap = Geom::OptRect() 
) const

Try to snap a point along a constraint line to grids, guides or objects.

Try to snap a point to grids, guides or objects, in only one degree-of-freedom, i.e. snap in a specific direction on the two dimensional canvas to the nearest snap target. constrainedSnap is equal in snapping behavior to constrainedSnapReturnByRef(). Please read the comments of the latter for more details.

PS: SnapManager::setup() must have been called before calling this method, but only once for a set of points

Parameters:
pSource point to be snapped
constraintThe direction or line along which snapping must occur
bbox_to_snapBounding box hulling the set of points, all from the same selection and having the same transformation

Definition at line 361 of file snap.cpp.

References _items_to_ignore, _snapindicator, findBestSnap(), getSnappers(), Geom::L2(), and someSnapperMightSnap().

Referenced by _snapTransformed(), constrainedSnapReturnByRef(), Inkscape::UI::RotationCenter::dragged(), Inkscape::UI::Node::dragged(), and Inkscape::UI::Handle::dragged().

{
    // First project the mouse pointer onto the constraint
    Geom::Point pp = constraint.projection(p.getPoint());

    Inkscape::SnappedPoint no_snap = Inkscape::SnappedPoint(pp, p.getSourceType(), p.getSourceNum(), Inkscape::SNAPTARGET_CONSTRAINT, Geom::L2(pp - p.getPoint()), 0, false, true, false);

    if (!someSnapperMightSnap()) {
        // Always return point on constraint
        return no_snap;
    }

    SnappedConstraints sc;
    SnapperList const snappers = getSnappers();
    for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
        (*i)->constrainedSnap(sc, p, bbox_to_snap, constraint, &_items_to_ignore);
    }

    Inkscape::SnappedPoint result = findBestSnap(p, sc, true);

    if (result.getSnapped()) {
        // only change the snap indicator if we really snapped to something
        if (_snapindicator) {
            _desktop->snapindicator->set_new_snaptarget(result);
        }
        return result;
    }
    return no_snap;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index