1 #ifndef SEEN_SNAP_H
2 #define SEEN_SNAP_H
4 /**
5 * \file snap.h
6 * \brief Various snapping methods.
7 *
8 * Authors:
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 * Frank Felfe <innerspace@iname.com>
11 * Carl Hetherington <inkscape@carlh.net>
12 *
13 * Copyright (C) 2000-2002 Lauris Kaplinski
14 *
15 * Released under GNU GPL, read the file 'COPYING' for more information
16 */
18 #include <vector>
20 #include <libnr/nr-coord.h>
21 #include <libnr/nr-dim2.h>
22 #include <libnr/nr-forward.h>
23 #include <libnr/nr-scale.h>
24 #include "grid-snapper.h"
25 #include "guide-snapper.h"
26 #include "object-snapper.h"
28 class SPNamedView;
30 class SnapManager
31 {
32 public:
33 SnapManager(SPNamedView const *v);
35 bool willSnapSomething() const;
37 Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t,
38 NR::Point const &p,
39 SPItem const *it) const;
41 Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t,
42 NR::Point const &p,
43 std::list<SPItem const *> const &it) const;
45 Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType t,
46 NR::Point const &p,
47 Inkscape::Snapper::ConstraintLine const &c,
48 SPItem const *it) const;
50 Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType t,
51 NR::Point const &p,
52 Inkscape::Snapper::ConstraintLine const &c,
53 std::list<SPItem const *> const &it) const;
55 std::pair<NR::Point, bool> freeSnapTranslation(Inkscape::Snapper::PointType t,
56 std::vector<NR::Point> const &p,
57 std::list<SPItem const *> const &it,
58 NR::Point const &tr) const;
60 std::pair<NR::Point, bool> constrainedSnapTranslation(Inkscape::Snapper::PointType t,
61 std::vector<NR::Point> const &p,
62 std::list<SPItem const *> const &it,
63 Inkscape::Snapper::ConstraintLine const &c,
64 NR::Point const &tr) const;
66 std::pair<NR::scale, bool> freeSnapScale(Inkscape::Snapper::PointType t,
67 std::vector<NR::Point> const &p,
68 std::list<SPItem const *> const &it,
69 NR::scale const &s,
70 NR::Point const &o) const;
72 std::pair<NR::scale, bool> constrainedSnapScale(Inkscape::Snapper::PointType t,
73 std::vector<NR::Point> const &p,
74 std::list<SPItem const *> const &it,
75 Inkscape::Snapper::ConstraintLine const &c,
76 NR::scale const &s,
77 NR::Point const &o) const;
79 std::pair<NR::Coord, bool> freeSnapStretch(Inkscape::Snapper::PointType t,
80 std::vector<NR::Point> const &p,
81 std::list<SPItem const *> const &it,
82 NR::Coord const &s,
83 NR::Point const &o,
84 NR::Dim2 d,
85 bool uniform) const;
87 std::pair<NR::Coord, bool> freeSnapSkew(Inkscape::Snapper::PointType t,
88 std::vector<NR::Point> const &p,
89 std::list<SPItem const *> const &it,
90 NR::Coord const &s,
91 NR::Point const &o,
92 NR::Dim2 d) const;
94 Inkscape::GridSnapper grid;
95 Inkscape::GuideSnapper guide;
96 Inkscape::ObjectSnapper object;
98 typedef std::list<const Inkscape::Snapper*> SnapperList;
99 SnapperList getSnappers() const;
101 private:
103 enum Transformation {
104 TRANSLATION,
105 SCALE,
106 STRETCH,
107 SKEW
108 };
110 std::pair<NR::Point, bool> _snapTransformed(Inkscape::Snapper::PointType type,
111 std::vector<NR::Point> const &points,
112 std::list<SPItem const *> const &ignore,
113 bool constrained,
114 Inkscape::Snapper::ConstraintLine const &constraint,
115 Transformation transformation_type,
116 NR::Point const &transformation,
117 NR::Point const &origin,
118 NR::Dim2 dim,
119 bool uniform) const;
120 };
122 #endif /* !SEEN_SNAP_H */
124 /*
125 Local Variables:
126 mode:c++
127 c-file-style:"stroustrup"
128 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
129 indent-tabs-mode:nil
130 fill-column:99
131 End:
132 */
133 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :