diff options
| author | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-03-08 21:06:42 +0000 |
|---|---|---|
| committer | Diederik van Lierop <mailat-signdiedenrezidotnl> | 2010-03-08 21:06:42 +0000 |
| commit | 3484bb5eb21a117e39cb50f65fe6f0541be78d45 (patch) | |
| tree | 6ea2a904d91bd59c89036ee34263f505f8abcb58 /src | |
| parent | Win32. Adding revno in the splash screen. (diff) | |
| download | inkscape-3484bb5eb21a117e39cb50f65fe6f0541be78d45.tar.gz inkscape-3484bb5eb21a117e39cb50f65fe6f0541be78d45.zip | |
Don't snap to points which are off-screen
(bzr r9167)
Diffstat (limited to 'src')
| -rw-r--r-- | src/snap.cpp | 20 | ||||
| -rw-r--r-- | src/snap.h | 2 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/snap.cpp b/src/snap.cpp index 0df58080e..352683623 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -281,7 +281,7 @@ Geom::Point SnapManager::multipleOfGridPitch(Geom::Point const &t, Geom::Point c // Find the best snap for this grid, including intersections of the grid-lines bool old_val = _snapindicator; _snapindicator = false; - Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false); + Inkscape::SnappedPoint s = findBestSnap(Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH), sc, false, false, true); _snapindicator = old_val; if (s.getSnapped() && (s.getSnapDistance() < nearest_distance)) { // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position @@ -898,13 +898,15 @@ Inkscape::SnappedPoint SnapManager::constrainedSnapSkew(std::vector<Inkscape::Sn * \param sc A structure holding all snap targets that have been found so far * \param constrained True if the snap is constrained, e.g. for stretching or for purely horizontal translation. * \param noCurves If true, then do consider snapping to intersections of curves, but not to the curves themselves + * \param allowOffScreen If true, then snapping to points which are off the screen is allowed (needed for example when pasting to the grid) * \return An instance of the SnappedPoint class, which holds data on the snap source, snap target, and various metrics */ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint const &p, SnappedConstraints const &sc, bool constrained, - bool noCurves) const + bool noCurves, + bool allowOffScreen) const { /* @@ -992,13 +994,15 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Inkscape::SnapCandidatePoint co Inkscape::SnappedPoint bestSnappedPoint(p.getPoint()); // std::cout << "Finding the best snap..." << std::endl; for (std::list<Inkscape::SnappedPoint>::const_iterator i = sp_list.begin(); i != sp_list.end(); i++) { - // first find out if this snapped point is within snapping range // std::cout << "sp = " << (*i).getPoint() << " | source = " << (*i).getSource() << " | target = " << (*i).getTarget(); - if ((*i).getSnapDistance() <= (*i).getTolerance()) { - // if it's the first point, or if it is closer than the best snapped point so far - if (i == sp_list.begin() || bestSnappedPoint.isOtherSnapBetter(*i, false)) { - // then prefer this point over the previous one - bestSnappedPoint = *i; + bool onScreen = _desktop->get_display_area().contains((*i).getPoint()); + if (onScreen || allowOffScreen) { // Only snap to points which are not off the screen + if ((*i).getSnapDistance() <= (*i).getTolerance()) { // Only snap to points within snapping range + // if it's the first point, or if it is closer than the best snapped point so far + if (i == sp_list.begin() || bestSnappedPoint.isOtherSnapBetter(*i, false)) { + // then prefer this point over the previous one + bestSnappedPoint = *i; + } } } // std::cout << std::endl; diff --git a/src/snap.h b/src/snap.h index 24f62ec6f..8a5688bea 100644 --- a/src/snap.h +++ b/src/snap.h @@ -170,7 +170,7 @@ public: bool getSnapIndicator() const {return _snapindicator;} - Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, SnappedConstraints const &sc, bool constrained, bool noCurves = false) const; + Inkscape::SnappedPoint findBestSnap(Inkscape::SnapCandidatePoint const &p, SnappedConstraints const &sc, bool constrained, bool noCurves = false, bool allowOffScreen = false) const; protected: SPNamedView const *_named_view; |
