Code

noop: address ‘no newline at end of file’ warning
[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     void setDistance(NR::Coord d) {_distance = d;}
35     NR::Coord getTolerance() const;
36     bool getAlwaysSnap() const;
37     NR::Coord getSecondDistance() const;
38     NR::Coord getSecondTolerance() const;
39     bool getSecondAlwaysSnap() const;
40     NR::Point getPoint() const;
41     bool getAtIntersection() const {return _at_intersection;}
42     bool getSnapped() const {return _distance < NR_HUGE;}
43     NR::Point getTransformation() const {return _transformation;}
44     void setTransformation(NR::Point t) {_transformation = t;}
45     
46 protected:
47     NR::Point _point; // Location of the snapped point
48     bool _at_intersection; // If true, the snapped point is at an intersection 
49     
50     /* Distance from original point to snapped point. If the snapped point is at
51        an intersection of e.g. two lines, then this is the distance to the closest
52        line */    
53     NR::Coord _distance; 
54     /* The snapping tolerance in screen pixels (depends on zoom)*/  
55     NR::Coord _tolerance;
56     /* If true then "Always snap" is on */
57     bool _always_snap;
58     
59     /* If the snapped point is at an intersection of e.g. two lines, then this is
60        the distance to the fartest line */    
61     NR::Coord _second_distance;
62     /* The snapping tolerance in screen pixels (depends on zoom)*/
63     NR::Coord _second_tolerance;
64     /* If true then "Always snap" is on */
65     bool _second_always_snap;
66     /* The transformation (translation, scale, skew, or stretch) from the original point to the snapped point */
67     NR::Point _transformation;
68 };    
70 }
72 bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result);
75 #endif /* !SEEN_SNAPPEDPOINT_H */
77 /*
78   Local Variables:
79   mode:c++
80   c-file-style:"stroustrup"
81   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
82   indent-tabs-mode:nil
83   fill-column:99
84   End:
85 */
86 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :