diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2007-12-04 19:09:09 +0000 |
|---|---|---|
| committer | dvlierop2 <dvlierop2@users.sourceforge.net> | 2007-12-04 19:09:09 +0000 |
| commit | 41c6a833adf57cfe1b3cf52b499f242bcf4a4174 (patch) | |
| tree | 6b33a3a852cd38463ab5dfbfe8f52fdb045b3422 /src/display/canvas-grid.cpp | |
| parent | Implemented use of "short_label" for toolbar items. (diff) | |
| download | inkscape-41c6a833adf57cfe1b3cf52b499f242bcf4a4174.tar.gz inkscape-41c6a833adf57cfe1b3cf52b499f242bcf4a4174.zip | |
When snapping, consider all four grid lines around the current point instead of only the nearest two
(bzr r4168)
Diffstat (limited to 'src/display/canvas-grid.cpp')
| -rw-r--r-- | src/display/canvas-grid.cpp | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index a2443ca17..db4648ec0 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -15,6 +15,7 @@ #include "sp-canvas-util.h" +#include "util/mathfns.h" #include "display-forward.h" #include <libnr/nr-pixops.h> #include "desktop-handles.h" @@ -859,24 +860,6 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) } } - - - -/** - * \return x rounded to the nearest multiple of c1 plus c0. - * - * \note - * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero - * mean "ignore the grid in this dimention". We're currently discussing "good" semantics - * for guide/grid snapping. - */ - -/* FIXME: move this somewhere else, perhaps */ -static double round_to_nearest_multiple_plus(double x, double const c1, double const c0) -{ - return floor((x - c0) / c1 + .5) * c1 + c0; -} - CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SPNamedView const *nv, NR::Coord const d) : LineSnapper(nv, d) { this->grid = grid; @@ -902,10 +885,10 @@ CanvasXYGridSnapper::_getSnapLines(NR::Point const &p) const scaled_spacing /= SP_ACTIVE_DESKTOP->current_zoom(); } - NR::Coord const rounded = round_to_nearest_multiple_plus(p[i], - scaled_spacing, - grid->origin[i]); - + NR::Coord rounded; + rounded = Inkscape::Util::round_to_upper_multiple_plus(p[i], scaled_spacing, grid->origin[i]); + s.push_back(std::make_pair(NR::Dim2(i), rounded)); + rounded = Inkscape::Util::round_to_lower_multiple_plus(p[i], scaled_spacing, grid->origin[i]); s.push_back(std::make_pair(NR::Dim2(i), rounded)); } |
