Code

85bbf1caa58b283057a1c90244fcae585ede9be6
[inkscape.git] / src / snapped-line.h
1 #ifndef SEEN_SNAPPEDLINE_H
2 #define SEEN_SNAPPEDLINE_H
4 /**
5  *    \file src/snapped-line.h
6  *    \brief SnappedLine class.
7  *
8  *    Authors:
9  *      Diederik van Lierop <mail@diedenrezi.nl>
10  *
11  *    Released under GNU GPL, read the file 'COPYING' for more information.
12  */
14 #include <vector>
15 #include <list>
16 #include "snapped-point.h"
18 namespace Inkscape
19 {
21 /// Class describing the result of an attempt to snap to a line segment.
22 class SnappedLineSegment : public SnappedPoint
23 {
24 public:
25     SnappedLineSegment();
26     SnappedLineSegment(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, SnapTargetType const &target, Geom::Coord const &snapped_tolerance,bool const &always_snap, Geom::Point const &start_point_of_line, Geom::Point const &end_point_of_line);
27     ~SnappedLineSegment();
28     Inkscape::SnappedPoint intersect(SnappedLineSegment const &line) const; //intersect with another SnappedLineSegment
30 private:
31     Geom::Point _start_point_of_line;
32     Geom::Point _end_point_of_line;
33 };
36 /// Class describing the result of an attempt to snap to a line.
37 class SnappedLine : public SnappedPoint
38 {
39 public:
40     SnappedLine();
41     SnappedLine(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, SnapTargetType const &target, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Point const &normal_to_line, Geom::Point const &point_on_line);
42     ~SnappedLine();
43     Inkscape::SnappedPoint intersect(SnappedLine const &line) const; //intersect with another SnappedLine
44     // This line is described by this equation:
45     //        a*x + b*y = c  <->  nx*px + ny+py = c  <->  n.p = c
46     Geom::Point getNormal() const {return _normal_to_line;}                             // n = (nx, ny)
47     Geom::Point getPointOnLine() const {return _point_on_line;}                         // p = (px, py)
48     Geom::Coord getConstTerm() const {return dot(_normal_to_line, _point_on_line);}     // c = n.p = nx*px + ny*py;
50 private:
51     Geom::Point _normal_to_line;
52     Geom::Point _point_on_line;
53 };
55 }
57 bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedLineSegment &result);
58 bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedPoint &result);
59 bool getClosestSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedLine &result);
60 bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedPoint &result);
61 bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list1, std::list<Inkscape::SnappedLine> const &list2, Inkscape::SnappedPoint &result);
64 #endif /* !SEEN_SNAPPEDLINE_H */
66 /*
67   Local Variables:
68   mode:c++
69   c-file-style:"stroustrup"
70   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
71   indent-tabs-mode:nil
72   fill-column:99
73   End:
74 */
75 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :