1 #ifndef SEEN_OBJECT_SNAPPER_H
2 #define SEEN_OBJECT_SNAPPER_H
4 /**
5 * \file object-snapper.h
6 * \brief Snapping things to objects.
7 *
8 * Authors:
9 * Carl Hetherington <inkscape@carlh.net>
10 *
11 * Copyright (C) 2005 Authors
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #include "snapper.h"
18 struct SPNamedView;
19 struct SPItem;
20 struct SPObject;
22 namespace Inkscape
23 {
25 class ObjectSnapper : public Snapper
26 {
27 public:
28 ObjectSnapper(SPNamedView const *nv, NR::Coord const d);
30 void setSnapToNodes(bool s) {
31 _snap_to_nodes = s;
32 }
34 bool getSnapToNodes() const {
35 return _snap_to_nodes;
36 }
38 void setSnapToPaths(bool s) {
39 _snap_to_paths = s;
40 }
42 bool getSnapToPaths() const {
43 return _snap_to_paths;
44 }
46 bool ThisSnapperMightSnap() const;
48 private:
49 SnappedPoint _doFreeSnap(NR::Point const &p,
50 std::list<SPItem const *> const &it) const;
52 SnappedPoint _doConstrainedSnap(NR::Point const &p,
53 ConstraintLine const &c,
54 std::list<SPItem const *> const &it) const;
56 void _findCandidates(std::list<SPItem*>& c,
57 SPObject* r,
58 std::list<SPItem const *> const &it,
59 NR::Point const &p) const;
61 void _snapNodes(Inkscape::SnappedPoint &s, NR::Point const &p, std::list<SPItem*> const &cand) const;
62 void _snapPaths(Inkscape::SnappedPoint &s, NR::Point const &p, std::list<SPItem*> const &cand) const;
64 bool _snap_to_nodes;
65 bool _snap_to_paths;
66 };
68 }
70 #endif