Code

Some consistency cleanup for descriptions.
[inkscape.git] / src / guide-snapper.cpp
1 /**
2  *  \file guide-snapper.cpp
3  *  \brief Snapping things to guides.
4  *
5  * Authors:
6  *   Lauris Kaplinski <lauris@kaplinski.com>
7  *   Frank Felfe <innerspace@iname.com>
8  *   Carl Hetherington <inkscape@carlh.net>
9  *
10  * Copyright (C) 1999-2002 Authors
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include "libnr/nr-values.h"
16 #include "libnr/nr-point-fns.h"
17 #include "sp-namedview.h"
18 #include "sp-guide.h"
20 Inkscape::GuideSnapper::GuideSnapper(SnapManager *sm, Geom::Coord const d) : LineSnapper(sm, d)
21 {
23 }
25 Inkscape::GuideSnapper::LineList Inkscape::GuideSnapper::_getSnapLines(Geom::Point const &/*p*/) const
26 {
27     LineList s;
29     if ( NULL == _snapmanager->getNamedView() || ThisSnapperMightSnap() == false) {
30         return s;
31     }
33     for (GSList const *l = _snapmanager->getNamedView()->guides; l != NULL; l = l->next) {
34         SPGuide const *g = SP_GUIDE(l->data);
35         s.push_back(std::make_pair(g->normal_to_line, g->point_on_line));
36     }
38     return s;
39 }
41 /**
42  *  \return true if this Snapper will snap at least one kind of point.
43  */
44 bool Inkscape::GuideSnapper::ThisSnapperMightSnap() const
45 {
46         if (_snapmanager->getNamedView() == NULL) {
47                 return false;
48         }
50         return (_snap_enabled && _snapmanager->snapprefs.getSnapToGuides() && _snapmanager->snapprefs.getSnapModeBBoxOrNodes() && _snapmanager->getNamedView()->showguides);
51 }
53 void Inkscape::GuideSnapper::_addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, Geom::Point const normal_to_line, Geom::Point const point_on_line) const
54 {
55     SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line);
56     sc.guide_lines.push_back(dummy);
57 }
59 /*
60   Local Variables:
61   mode:c++
62   c-file-style:"stroustrup"
63   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
64   indent-tabs-mode:nil
65   fill-column:99
66   End:
67 */
68 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :