From 16768888debdb6cec38cb9ac57441c0f6c865eda Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 20 Mar 2007 19:58:07 +0000 Subject: Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. (bzr r2721) --- src/snap.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/snap.cpp') diff --git a/src/snap.cpp b/src/snap.cpp index 86fae1572..ff05858fd 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -9,7 +9,7 @@ * Frank Felfe * Carl Hetherington * - * Copyright (C) 2006 Johan Engelen + * Copyright (C) 2006-2007 Johan Engelen * Copyright (C) 1999-2002 Authors * * Released under GNU GPL, read the file 'COPYING' for more information @@ -21,6 +21,8 @@ #include #include +#include "display/canvas-grid.h" + /** * Construct a SnapManager for a SPNamedView. * @@ -52,6 +54,18 @@ SnapManager::SnapperList SnapManager::getSnappers() const } s.push_back(&guide); s.push_back(&object); + + //add new grid snappers that are active for this desktop +// SPDesktop* desktop = SP_ACTIVE_DESKTOP; +// if (desktop) { + + for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) { + Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data; + s.push_back(grid->snapper); + } + +// } + return s; } @@ -213,7 +227,7 @@ std::pair SnapManager::_snapTransformed( /* The current best transformation */ NR::Point best_transformation = transformation; - + /* The current best metric for the best transformation; lower is better, NR_HUGE ** means that we haven't snapped anything. */ @@ -249,7 +263,7 @@ std::pair SnapManager::_snapTransformed( default: g_assert_not_reached(); } - + /* Snap it */ Inkscape::SnappedPoint const snapped = constrained ? constrainedSnap(type, transformed, constraint, ignore) : freeSnap(type, transformed, ignore); @@ -300,7 +314,7 @@ std::pair SnapManager::_snapTransformed( } } } - + // Using " < 1e6" instead of " < NR::HUGE" for catching some rounding errors // These rounding errors might be caused by NRRects, see bug #1584301 return std::make_pair(best_transformation, best_metric < 1e6); -- cgit v1.2.3