Code

Small comment cleanups.
[inkscape.git] / src / snap.h
1 #ifndef SEEN_SNAP_H
2 #define SEEN_SNAP_H
4 /**
5  * \file snap.h
6  * \brief SnapManager class.
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 to coordinate snapping operations
32 /**
33  *  Each SPNamedView has one of these.  It offers methods to snap points to whatever
34  *  snappers are defined (e.g. grid, guides etc.).  It also allows callers to snap
35  *  points which have undergone some transformation (e.g. translation, scaling etc.)
36  */
38 class SnapManager
39 {
40 public:
41     SnapManager(SPNamedView const *v);
42     
43     bool willSnapSomething() const;
45     Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t,
46                                     NR::Point const &p,
47                                     SPItem const *it) const;
49     Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t,
50                                     NR::Point const &p,
51                                     std::list<SPItem const *> const &it) const;
52     
53     Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType t,
54                                            NR::Point const &p,
55                                            Inkscape::Snapper::ConstraintLine const &c,
56                                            SPItem const *it) const;
57     
58     Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType t,
59                                            NR::Point const &p,
60                                            Inkscape::Snapper::ConstraintLine const &c,
61                                            std::list<SPItem const *> const &it) const;
63     std::pair<NR::Point, bool> freeSnapTranslation(Inkscape::Snapper::PointType t,
64                                                    std::vector<NR::Point> const &p,
65                                                    std::list<SPItem const *> const &it,
66                                                    NR::Point const &tr) const;
68     std::pair<NR::Point, bool> constrainedSnapTranslation(Inkscape::Snapper::PointType t,
69                                                           std::vector<NR::Point> const &p,
70                                                           std::list<SPItem const *> const &it,
71                                                           Inkscape::Snapper::ConstraintLine const &c,
72                                                           NR::Point const &tr) const;
74     std::pair<NR::scale, bool> freeSnapScale(Inkscape::Snapper::PointType t,
75                                              std::vector<NR::Point> const &p,
76                                              std::list<SPItem const *> const &it,
77                                              NR::scale const &s,
78                                              NR::Point const &o) const;
80     std::pair<NR::scale, bool> constrainedSnapScale(Inkscape::Snapper::PointType t,
81                                                     std::vector<NR::Point> const &p,
82                                                     std::list<SPItem const *> const &it,
83                                                     Inkscape::Snapper::ConstraintLine const &c,
84                                                     NR::scale const &s,
85                                                     NR::Point const &o) const;
87     std::pair<NR::Coord, bool> freeSnapStretch(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,
93                                                bool uniform) const;
95     std::pair<NR::Coord, bool> freeSnapSkew(Inkscape::Snapper::PointType t,
96                                             std::vector<NR::Point> const &p,
97                                             std::list<SPItem const *> const &it,
98                                             NR::Coord const &s,
99                                             NR::Point const &o,
100                                             NR::Dim2 d) const;
102     Inkscape::GridSnapper grid;     ///< grid snapper
103     Inkscape::GuideSnapper guide;   ///< guide snapper
104     Inkscape::ObjectSnapper object; ///< snapper to other objects
106     typedef std::list<const Inkscape::Snapper*> SnapperList;
107     SnapperList getSnappers() const;
109 private:
111     enum Transformation {
112         TRANSLATION,
113         SCALE,
114         STRETCH,
115         SKEW
116     };
117     
118     std::pair<NR::Point, bool> _snapTransformed(Inkscape::Snapper::PointType type,
119                                                 std::vector<NR::Point> const &points,
120                                                 std::list<SPItem const *> const &ignore,
121                                                 bool constrained,
122                                                 Inkscape::Snapper::ConstraintLine const &constraint,
123                                                 Transformation transformation_type,
124                                                 NR::Point const &transformation,
125                                                 NR::Point const &origin,
126                                                 NR::Dim2 dim,
127                                                 bool uniform) const;
128 };
130 #endif /* !SEEN_SNAP_H */
132 /*
133   Local Variables:
134   mode:c++
135   c-file-style:"stroustrup"
136   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
137   indent-tabs-mode:nil
138   fill-column:99
139   End:
140 */
141 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :