Code

1) Improving snapping logic 2) When skewing, don't snap to selection itself
[inkscape.git] / src / snapped-point.cpp
1 /**
2  *  \file src/snapped-point.cpp
3  *  \brief SnappedPoint class.
4  *
5  *  Authors:
6  *    Mathieu Dimanche <mdimanche@free.fr>
7  *    Diederik van Lierop <mail@diedenrezi.nl>
8  *
9  *  Released under GNU GPL, read the file 'COPYING' for more information.
10  */
12 #include "snapped-point.h"
14 Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, bool at_intersection, NR::Coord d2)
15     : _distance(d), _point(p), _at_intersection(at_intersection), _second_distance(d2)
16 {
17 }
19 Inkscape::SnappedPoint::SnappedPoint()
20 {
21     _distance = NR_HUGE;
22     _point = NR::Point(0,0);
23     _at_intersection = false;
24     _second_distance = NR_HUGE;
25 }
29 Inkscape::SnappedPoint::~SnappedPoint()
30 {
31 }
33 NR::Coord Inkscape::SnappedPoint::getDistance() const
34 {
35     return _distance;
36 }
38 NR::Coord Inkscape::SnappedPoint::getSecondDistance() const
39 {
40     return _second_distance;
41 }
44 NR::Point Inkscape::SnappedPoint::getPoint() const
45 {
46     return _point;
47 }
49 // search for the closest snapped point
50 bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result) 
51 {
52     bool success = false;
53     
54     for (std::list<Inkscape::SnappedPoint>::const_iterator i = list.begin(); i != list.end(); i++) {
55         if ((i == list.begin()) || (*i).getDistance() < result.getDistance()) {
56             result = *i;
57             success = true;
58         }    
59     }
60     
61     return success;
62 }
64 /*
65   Local Variables:
66   mode:c++
67   c-file-style:"stroustrup"
68   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
69   indent-tabs-mode:nil
70   fill-column:99
71   End:
72 */
73 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :