Code

af36b8330126cf5331e1b942122118b9f6008aa2
[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  *      Diederik van Lierop <mail@diedenrezi.nl>
11  *
12  *        Copyright (C) 1999-2008 Authors
13  *
14  *    Released under GNU GPL, read the file 'COPYING' for more information.
15  */
17 #include "snapper.h"
19 namespace Inkscape
20 {
22 class LineSnapper : public Snapper
23 {
24 public:
25   LineSnapper(SnapManager *sm, Geom::Coord const d);
27   void freeSnap(SnappedConstraints &sc,
28                    Inkscape::SnapPreferences::PointType const &t,
29                    Geom::Point const &p,
30                    SnapSourceType const &source_type,
31                    long source_num,
32                    Geom::OptRect const &bbox_to_snap,
33                    std::vector<SPItem const *> const *it,
34                    std::vector<std::pair<Geom::Point, int> > *unselected_nodes) const;
36   void constrainedSnap(SnappedConstraints &sc,
37                           Inkscape::SnapPreferences::PointType const &t,
38                           Geom::Point const &p,
39                           SnapSourceType const &source_type,
40                           long source_num,
41                           Geom::OptRect const &bbox_to_snap,
42                           ConstraintLine const &c,
43                           std::vector<SPItem const *> const *it) const;
45 protected:
46   typedef std::list<std::pair<Geom::Point, Geom::Point> > LineList;
47   //first point is a vector normal to the line
48   //second point is a point on the line
50 private:
51   /**
52    *  \param p Point that we are trying to snap.
53    *  \return List of lines that we should try snapping to.
54    */
55   virtual LineList _getSnapLines(Geom::Point const &p) const = 0;
57   virtual void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const = 0;
59   // Will only be implemented for guide lines, because grid lines don't have an origin
60   virtual void _addSnappedLinesOrigin(SnappedConstraints &sc, Geom::Point const origin, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const;
62   virtual void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num) const = 0;
63 };
65 }
67 #endif /* !SEEN_LINE_SNAPPER_H */