X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrackattachment.cpp;h=64704b11b5290bab5e17d24da21e06f61b9eb230;hb=0443ca05cbd306487131f5f5bd3b91181ae4a733;hp=3d28651d882395bdd8baab18162e3e201ad3b1bc;hpb=e3e3a940c75dcad126d5cf08f0802efdab914568;p=r2c2.git diff --git a/source/libr2c2/trackattachment.cpp b/source/libr2c2/trackattachment.cpp index 3d28651..64704b1 100644 --- a/source/libr2c2/trackattachment.cpp +++ b/source/libr2c2/trackattachment.cpp @@ -8,8 +8,7 @@ using namespace std; namespace R2C2 { TrackAttachment::TrackAttachment(Layout &l): - Object(l), - offset(0) + Object(l) { layout.signal_object_removed.connect(sigc::mem_fun(this, &TrackAttachment::object_removed)); } @@ -20,13 +19,20 @@ TrackAttachment::~TrackAttachment() track->remove_attachment(*this); } -void TrackAttachment::attach_to(const TrackIter &t, float o) +float TrackAttachment::get_offset_from_endpoint(unsigned epi) const +{ + if(epi==track.entry()) + return track.offset(); + else + return track->get_type().get_path_length(0)-track.offset(); +} + +void TrackAttachment::attach_to(const TrackOffsetIter &t) { if(track) track->remove_attachment(*this); track = t; - offset = o; if(track) track->add_attachment(*this); @@ -66,13 +72,13 @@ void TrackAttachment::attach_to_closest(float limit) if(adiffget_snap_node(trk.entry()).position; float dist = distance(epp, point); - float offs = dist; + float offs = min(dist, trk->get_type().get_path_length(0)); while(1) { TrackPoint tp = trk->get_point(trk.entry(), offs);