#include "driver.h"
#include "layout.h"
#include "track.h"
+#include "trackattachment.h"
#include "tracktype.h"
using namespace std;
using namespace Msp;
+namespace {
+
+struct AttachmentCompare
+{
+ unsigned entry;
+
+ AttachmentCompare(unsigned e): entry(e) { }
+
+ bool operator()(const R2C2::TrackAttachment *a1, const R2C2::TrackAttachment *a2) const
+ { return a1->get_offset_from_endpoint(entry)<a2->get_offset_from_endpoint(entry); }
+};
+
+}
+
namespace R2C2 {
Track::Track(Layout &l, const TrackType &t):
attachments.erase(i);
}
+Track::AttachmentList Track::get_attachments_ordered(unsigned epi) const
+{
+ AttachmentList result = attachments;
+ result.sort(AttachmentCompare(epi));
+ return result;
+}
+
void Track::save(list<DataFile::Statement> &st) const
{
st.push_back((DataFile::Statement("position"), position.x, position.y, position.z));
void add_attachment(TrackAttachment &);
void remove_attachment(TrackAttachment &);
const AttachmentList &get_attachments() const { return attachments; }
+ AttachmentList get_attachments_ordered(unsigned) const;
void save(std::list<Msp::DataFile::Statement> &) const;
private:
track->remove_attachment(*this);
}
+float TrackAttachment::get_offset_from_endpoint(unsigned epi) const
+{
+ if(epi==track.entry())
+ return offset;
+ else
+ return track->get_type().get_path_length(0)-offset;
+}
+
void TrackAttachment::attach_to(const TrackIter &t, float o)
{
if(track)
#define LIBR2C2_TRACKATTACHMENT_H_
#include "object.h"
+#include "track.h"
#include "trackiter.h"
namespace R2C2 {
Track *get_track() const { return track.track(); }
unsigned get_entry() const { return track.entry(); }
float get_offset() const { return offset; }
+ float get_offset_from_endpoint(unsigned) const;
protected:
void attach_to(const TrackIter &, float);
void attach_to_closest(float);