Code

7767fe2ea5a0f25a4fbc87313ca3399b086e9c4c
[inkscape.git] / src / line-snapper.h
1 #ifndef SEEN_LINE_SNAPPER_H
2 #define SEEN_LINE_SNAPPER_H
4 /**
5  *    \file src/line-snapper.h
6  *    \brief Superclass for snappers to horizontal and vertical lines.
7  *
8  *    Authors:
9  *      Carl Hetherington <inkscape@carlh.net>
10  *
11  *    Released under GNU GPL, read the file 'COPYING' for more information.
12  */
14 #include "snapper.h"
16 namespace Inkscape
17 {
19 class LineSnapper : public Snapper
20 {
21 public:
22   LineSnapper(SnapManager const *sm, Geom::Coord const d);
24   void freeSnap(SnappedConstraints &sc,
25                    Inkscape::Snapper::PointType const &t,
26                    Geom::Point const &p,
27                    bool const &first_point,
28                    boost::optional<Geom::Rect> const &bbox_to_snap,
29                    std::vector<SPItem const *> const *it,
30                    std::vector<Geom::Point> *unselected_nodes) const;
31   
32   void constrainedSnap(SnappedConstraints &sc,
33                           Inkscape::Snapper::PointType const &t,
34                           Geom::Point const &p,
35                           bool const &first_point,
36                           boost::optional<Geom::Rect> const &bbox_to_snap,
37                           ConstraintLine const &c,
38                           std::vector<SPItem const *> const *it) const;
40 protected:
41   typedef std::list<std::pair<Geom::Point, Geom::Point> > LineList; 
42   //first point is a vector normal to the line
43   //second point is a point on the line
45 private:
46   /**
47    *  \param p Point that we are trying to snap.
48    *  \return List of lines that we should try snapping to.
49    */
50   virtual LineList _getSnapLines(Geom::Point const &p) const = 0;
51   
52   virtual void _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 = 0;
53 };
55 }
57 #endif /* !SEEN_LINE_SNAPPER_H */