Code

f0584812d8a9814b6106067b01e87b06c9528880
[inkscape.git] / src / snapped-point.h
1 #ifndef SEEN_SNAPPEDPOINT_H
2 #define SEEN_SNAPPEDPOINT_H
4 /**
5  *    \file src/snapped-point.h
6  *    \brief SnappedPoint class.
7  *
8  *    Authors:
9  *      Mathieu Dimanche <mdimanche@free.fr>
10  *      Diederik van Lierop <mail@diedenrezi.nl>
11  *
12  *    Released under GNU GPL, read the file 'COPYING' for more information.
13  */
15 #include <vector>
16 #include <list>
17 #include "libnr/nr-coord.h"
18 #include "libnr/nr-point.h"
19 #include <libnr/nr-values.h>
21 namespace Inkscape
22 {
23     
24 /// Class describing the result of an attempt to snap.
25 class SnappedPoint
26 {
27 public:
28     SnappedPoint();
29     SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool a, bool at_intersection, NR::Coord d2, NR::Coord t2, bool a2);
30     SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool a);
31     ~SnappedPoint();
33     NR::Coord getDistance() const;
34     NR::Coord getTolerance() const;
35     bool getAlwaysSnap() const;
36     NR::Coord getSecondDistance() const;
37     NR::Coord getSecondTolerance() const;
38     bool getSecondAlwaysSnap() const;
39     NR::Point getPoint() const;
40     bool getAtIntersection() const {return _at_intersection;}
41     
42 protected:
43     NR::Point _point; // Location of the snapped point
44     bool _at_intersection; // If true, the snapped point is at an intersection 
45     
46     /* Distance from original point to snapped point. If the snapped point is at
47        an intersection of e.g. two lines, then this is the distance to the closest
48        line */    
49     NR::Coord _distance; 
50     /* The snapping tolerance in screen pixels (depends on zoom)*/  
51     NR::Coord _tolerance;
52     /* If true then "Always snap" is on */
53     bool _always_snap;
54     
55     /* If the snapped point is at an intersection of e.g. two lines, then this is
56        the distance to the fartest line */    
57     NR::Coord _second_distance;
58     /* The snapping tolerance in screen pixels (depends on zoom)*/
59     NR::Coord _second_tolerance;
60     /* If true then "Always snap" is on */
61     bool _second_always_snap;
62 };    
64 }
66 bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result);
69 #endif /* !SEEN_SNAPPEDPOINT_H */
71 /*
72   Local Variables:
73   mode:c++
74   c-file-style:"stroustrup"
75   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
76   indent-tabs-mode:nil
77   fill-column:99
78   End:
79 */
80 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :