From de27d953d1c13d2e7563b43c2d959b1b02aee9c3 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 12 May 2008 18:58:04 +0000 Subject: Add a centralized check (i.e. in the snapper mechanism) whether we've snapped or not, instead of leaving it up to the various tools. This should prevent these tools from moving to (0,0) if they bluntly use the value returned by the snapping mechanism without checking whether snapping has really occured. (bzr r5659) --- src/snap.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 885147063..bc81bdf3a 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -168,6 +168,26 @@ bool SnapManager::getSnapModeGuide() const return object.getSnapFrom(Inkscape::Snapper::SNAPPOINT_GUIDE); } +/** + * Try to snap a point to any of the specified snappers. + * + * \param point_type Type of point. + * \param p Point. + * \param first_point If true then this point is the first one from a whole bunch of points + * \param points_to_snap The whole bunch of points, all from the same selection and having the same transformation + * \param snappers List of snappers to try to snap to + * \return Snapped point. + */ + +void SnapManager::freeSnapVoid(Inkscape::Snapper::PointType point_type, + NR::Point &p, + bool first_point, + NR::Maybe const &bbox_to_snap) const +{ + Inkscape::SnappedPoint const s = freeSnap(point_type, p, first_point, bbox_to_snap); + s.getPoint(p); +} + /** * Try to snap a point to any of the specified snappers. * @@ -212,6 +232,28 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_ return findBestSnap(p, sc, false); } +/** + * Try to snap a point to any interested snappers. A snap will only occur along + * a line described by a Inkscape::Snapper::ConstraintLine. + * + * \param point_type Type of point. + * \param p Point. + * \param first_point If true then this point is the first one from a whole bunch of points + * \param points_to_snap The whole bunch of points, all from the same selection and having the same transformation + * \param constraint Constraint line. + * \return Snapped point. + */ + +void SnapManager::constrainedSnapVoid(Inkscape::Snapper::PointType point_type, + NR::Point &p, + Inkscape::Snapper::ConstraintLine const &constraint, + bool first_point, + NR::Maybe const &bbox_to_snap) const +{ + Inkscape::SnappedPoint const s = constrainedSnap(point_type, p, constraint, first_point, bbox_to_snap); + s.getPoint(p); +} + /** * Try to snap a point to any interested snappers. A snap will only occur along * a line described by a Inkscape::Snapper::ConstraintLine. @@ -257,19 +299,19 @@ Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::Snapper::PointType return findBestSnap(p, sc, true); } -Inkscape::SnappedPoint SnapManager::guideSnap(NR::Point const &p, - NR::Point const &guide_normal) const +void SnapManager::guideSnap(NR::Point &p, NR::Point const &guide_normal) const { // This method is used to snap a guide to nodes, while dragging the guide around if (!(object.GuidesMightSnap() && _snap_enabled_globally)) { - return Inkscape::SnappedPoint(p, Inkscape::SNAPTARGET_UNDEFINED, NR_HUGE, 0, false); + return; } SnappedConstraints sc; object.guideSnap(sc, p, guide_normal); - return findBestSnap(p, sc, false); + Inkscape::SnappedPoint const s = findBestSnap(p, sc, false); + s.getPoint(p); } @@ -309,6 +351,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( ** Also used to globally disable all snapping */ if (SomeSnapperMightSnap() == false) { + g_assert(points.size() > 0); return Inkscape::SnappedPoint(); } -- cgit v1.2.3