Code

Fixed ctor intialization order
[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 // overloaded constructor
15 Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool a)
16     : _point(p), _distance(d), _tolerance(t), _always_snap(a)
17 {
18     _at_intersection = false;
19     _second_distance = NR_HUGE;
20     _second_tolerance = 0;
21     _second_always_snap = false;
22 }
24 Inkscape::SnappedPoint::SnappedPoint(NR::Point p, NR::Coord d, NR::Coord t, bool a, bool at_intersection, NR::Coord d2, NR::Coord t2, bool a2)
25     : _point(p), _at_intersection(at_intersection), _distance(d), _tolerance(t), _always_snap(a),
26     _second_distance(d2), _second_tolerance(t2), _second_always_snap(a2)
27 {
28 }
30 Inkscape::SnappedPoint::SnappedPoint()
31 {
32     _point = NR::Point(0,0);
33     _distance = NR_HUGE;
34     _tolerance = 0;
35     _always_snap = false;
36     _at_intersection = false;
37     _second_distance = NR_HUGE;
38     _second_tolerance = 0;
39     _second_always_snap = false;
40 }
44 Inkscape::SnappedPoint::~SnappedPoint()
45 {
46 }
48 NR::Coord Inkscape::SnappedPoint::getDistance() const
49 {
50     return _distance;
51 }
53 NR::Coord Inkscape::SnappedPoint::getTolerance() const
54 {
55     return _tolerance;
56 }
58 bool Inkscape::SnappedPoint::getAlwaysSnap() const
59 {
60     return _always_snap;
61 }
63 NR::Coord Inkscape::SnappedPoint::getSecondDistance() const
64 {
65     return _second_distance;
66 }
68 NR::Coord Inkscape::SnappedPoint::getSecondTolerance() const
69 {
70     return _second_tolerance;
71 }
73 bool Inkscape::SnappedPoint::getSecondAlwaysSnap() const
74 {
75     return _second_always_snap;
76 }
79 NR::Point Inkscape::SnappedPoint::getPoint() const
80 {
81     return _point;
82 }
84 // search for the closest snapped point
85 bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result)
86 {
87     bool success = false;
89     for (std::list<Inkscape::SnappedPoint>::const_iterator i = list.begin(); i != list.end(); i++) {
90         if ((i == list.begin()) || (*i).getDistance() < result.getDistance()) {
91             result = *i;
92             success = true;
93         }
94     }
96     return success;
97 }
99 /*
100   Local Variables:
101   mode:c++
102   c-file-style:"stroustrup"
103   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
104   indent-tabs-mode:nil
105   fill-column:99
106   End:
107 */
108 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :