Context for the "About" label
[inkscape.git] / src / snapped-line.h
blobeda197cfc718365e4b6eec9b96ee9e5d5f9ff32e
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef SEEN_SNAPPEDLINE_H
3 #define SEEN_SNAPPEDLINE_H
5 /**
6 * \file src/snapped-line.h
7 * \brief SnappedLine class.
9 * Authors:
10 * Diederik van Lierop <mail@diedenrezi.nl>
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15 #include <vector>
16 #include <list>
17 #include "snapped-point.h"
19 namespace Inkscape
22 /// Class describing the result of an attempt to snap to a line segment.
23 class SnappedLineSegment : public SnappedPoint
25 public:
26 SnappedLineSegment();
27 SnappedLineSegment(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, 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);
28 ~SnappedLineSegment();
29 Inkscape::SnappedPoint intersect(SnappedLineSegment const &line) const; //intersect with another SnappedLineSegment
30 Geom::LineSegment getLineSegment() const {return Geom::LineSegment(_start_point_of_line, _end_point_of_line);}
32 private:
33 Geom::Point _start_point_of_line;
34 Geom::Point _end_point_of_line;
38 /// Class describing the result of an attempt to snap to a line.
39 class SnappedLine : public SnappedPoint
41 public:
42 SnappedLine();
43 SnappedLine(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Point const &normal_to_line, Geom::Point const &point_on_line);
44 ~SnappedLine();
45 Inkscape::SnappedPoint intersect(SnappedLine const &line) const; //intersect with another SnappedLine
46 // This line is described by this equation:
47 // a*x + b*y = c <-> nx*px + ny+py = c <-> n.p = c
48 Geom::Point getNormal() const {return _normal_to_line;} // n = (nx, ny)
49 Geom::Point getPointOnLine() const {return _point_on_line;} // p = (px, py)
50 Geom::Coord getConstTerm() const {return dot(_normal_to_line, _point_on_line);} // c = n.p = nx*px + ny*py;
51 Geom::Line getLine() const {return Geom::Line(_point_on_line, _point_on_line + Geom::rot90(_normal_to_line));}
53 private:
54 Geom::Point _normal_to_line;
55 Geom::Point _point_on_line;
60 bool getClosestSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedLineSegment &result);
61 bool getClosestIntersectionSLS(std::list<Inkscape::SnappedLineSegment> const &list, Inkscape::SnappedPoint &result);
62 bool getClosestSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedLine &result);
63 bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list, Inkscape::SnappedPoint &result);
64 bool getClosestIntersectionSL(std::list<Inkscape::SnappedLine> const &list1, std::list<Inkscape::SnappedLine> const &list2, Inkscape::SnappedPoint &result);
67 #endif /* !SEEN_SNAPPEDLINE_H */
70 Local Variables:
71 mode:c++
72 c-file-style:"stroustrup"
73 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
74 indent-tabs-mode:nil
75 fill-column:99
76 End:
78 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :