summaryrefslogtreecommitdiffstats
path: root/src/snap.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2008-05-12 18:58:04 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2008-05-12 18:58:04 +0000
commitde27d953d1c13d2e7563b43c2d959b1b02aee9c3 (patch)
treeefc8ed7eaba9a2b0ed87eaf14b797103bd8fa33a /src/snap.cpp
parentfix typo (diff)
downloadinkscape-de27d953d1c13d2e7563b43c2d959b1b02aee9c3.tar.gz
inkscape-de27d953d1c13d2e7563b43c2d959b1b02aee9c3.zip
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)
Diffstat (limited to 'src/snap.cpp')
-rw-r--r--src/snap.cpp51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/snap.cpp b/src/snap.cpp
index 885147063..bc81bdf3a 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -179,6 +179,26 @@ bool SnapManager::getSnapModeGuide() const
* \return Snapped point.
*/
+void SnapManager::freeSnapVoid(Inkscape::Snapper::PointType point_type,
+ NR::Point &p,
+ bool first_point,
+ NR::Maybe<NR::Rect> 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.
+ *
+ * \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.
+ */
+
Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_type,
NR::Point const &p,
bool first_point,
@@ -224,6 +244,28 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType point_
* \return Snapped point.
*/
+void SnapManager::constrainedSnapVoid(Inkscape::Snapper::PointType point_type,
+ NR::Point &p,
+ Inkscape::Snapper::ConstraintLine const &constraint,
+ bool first_point,
+ NR::Maybe<NR::Rect> 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.
+ *
+ * \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.
+ */
+
Inkscape::SnappedPoint SnapManager::constrainedSnap(Inkscape::Snapper::PointType point_type,
NR::Point const &p,
Inkscape::Snapper::ConstraintLine const &constraint,
@@ -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();
}