2 #include "satisfied-guide-cns.h"
3 #include "sp-guide-constraint.h"
4 #include <sp-guide.h>
5 #include <sp-item.h>
6 #include <algorithm>
7 using std::find;
8 using std::vector;
10 void sp_item_update_cns(SPItem &item, SPDesktop const &desktop)
11 {
12 std::vector<Inkscape::SnapCandidatePoint> snappoints;
13 sp_item_snappoints(&item, snappoints, NULL);
14 /* TODO: Implement the ordering. */
15 vector<SPGuideConstraint> found_cns;
16 satisfied_guide_cns(desktop, snappoints, found_cns);
17 /* effic: It might be nice to avoid an n^2 algorithm, but in practice n will be
18 small enough that it's still usually more efficient. */
20 for (vector<SPGuideConstraint>::const_iterator fi(found_cns.begin()),
21 fiEnd(found_cns.end());
22 fi != fiEnd; ++fi)
23 {
24 SPGuideConstraint const &cn = *fi;
25 if ( find(item.constraints.begin(),
26 item.constraints.end(),
27 cn)
28 == item.constraints.end() )
29 {
30 item.constraints.push_back(cn);
31 cn.g->attached_items.push_back(SPGuideAttachment(&item, cn.snappoint_ix));
32 }
33 }
34 }
37 /*
38 Local Variables:
39 mode:c++
40 c-file-style:"stroustrup"
41 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
42 indent-tabs-mode:nil
43 fill-column:99
44 End:
45 */
46 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :