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 Inkscape::GridSnapper grid;
88 Inkscape::GuideSnapper guide;
89 Inkscape::ObjectSnapper object;
91 typedef std::list<const Inkscape::Snapper*> SnapperList;
92 SnapperList getSnappers() const;
94 private:
96 enum Transformation {
97 TRANSLATION,
98 SCALE,
99 STRETCH
100 };
102 std::pair<NR::Point, bool> _snapTransformed(Inkscape::Snapper::PointType type,
103 std::vector<NR::Point> const &points,
104 std::list<SPItem const *> const &ignore,
105 bool constrained,
106 Inkscape::Snapper::ConstraintLine const &constraint,
107 Transformation transformation_type,
108 NR::Point const &transformation,
109 NR::Point const &origin,
110 NR::Dim2 dim,
111 bool uniform) const;
112 };
115 /* Single point methods */
116 NR::Coord namedview_vector_snap(SPNamedView const *nv, Inkscape::Snapper::PointType t, NR::Point &req,
117 NR::Point const &d, std::list<SPItem const *> const &it);
118 NR::Coord namedview_vector_snap(SPNamedView const *nv, Inkscape::Snapper::PointType t, NR::Point &req,
119 NR::Point const &d, SPItem const *it);
120 NR::Coord namedview_dim_snap(SPNamedView const *nv, Inkscape::Snapper::PointType t, NR::Point& req,
121 NR::Dim2 const dim, SPItem const *it);
122 NR::Coord namedview_dim_snap(SPNamedView const *nv, Inkscape::Snapper::PointType t, NR::Point& req,
123 NR::Dim2 const dim, std::list<SPItem const *> const &it);
125 /* List of points methods */
127 NR::Coord namedview_dim_snap_list_skew(SPNamedView const *nv, Inkscape::Snapper::PointType t,
128 const std::vector<NR::Point> &p,
129 NR::Point const &norm, double const sx, NR::Dim2 const dim);
132 #endif /* !SEEN_SNAP_H */
134 /*
135 Local Variables:
136 mode:c++
137 c-file-style:"stroustrup"
138 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
139 indent-tabs-mode:nil
140 fill-column:99
141 End:
142 */
143 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :