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

void SnapManager::freeSnapReturnByRef ( Geom::Point p,
Inkscape::SnapSourceType const   source_type,
Geom::OptRect const &  bbox_to_snap = Geom::OptRect() 
) const

Try to snap a point to grids, guides or objects.

Try to snap a point to grids, guides or objects, in two degrees-of-freedom, i.e. snap in any direction on the two dimensional canvas to the nearest snap target. freeSnapReturnByRef() is equal in snapping behavior to freeSnap(), but the former returns the snapped point trough the referenced parameter p. This parameter p initially contains the position of the snap source and will we overwritten by the target position if snapping has occurred. This makes snapping transparent to the calling code. If this is not desired because either the calling code must know whether snapping has occurred, or because the original position should not be touched, then freeSnap() should be called instead.

PS: 1) SnapManager::setup() must have been called before calling this method, but only once for a set of points 2) Only to be used when a single source point is to be snapped; it assumes that source_num = 0, which is inefficient when snapping sets our source points

Parameters:
p Current position of the snap source; will be overwritten by the position of the snap target if snapping has occurred
source_type Detailed description of the source type, will be used by the snap indicator
bbox_to_snap Bounding box hulling the set of points, all from the same selection and having the same transformation

Definition at line 173 of file snap.cpp.

References freeSnap(), and Inkscape::SnappedPoint::getPoint().

Referenced by Inkscape::UI::Handle::dragged(), and pen_handle_button_press().

{
    //TODO: SnapCandidatePoint and point_type are somewhat redundant; can't we get rid of the point_type parameter?
    Inkscape::SnappedPoint const s = freeSnap(Inkscape::SnapCandidatePoint(p, source_type), bbox_to_snap);
    s.getPoint(p);
}


Generated by  Doxygen 1.6.0   Back to index