comparison data/model/AlignmentModel.h @ 407:88ad01799040

* Save alignments to session file. Needs much testing.
author Chris Cannam
date Tue, 29 Apr 2008 15:34:17 +0000
parents 700cd3350391
children 59e7fe1b1003
comparison
equal deleted inserted replaced
406:d095214ffbaf 407:88ad01799040
15 15
16 #ifndef _ALIGNMENT_MODEL_H_ 16 #ifndef _ALIGNMENT_MODEL_H_
17 #define _ALIGNMENT_MODEL_H_ 17 #define _ALIGNMENT_MODEL_H_
18 18
19 #include "Model.h" 19 #include "Model.h"
20 #include "SparseModel.h" 20 #include "PathModel.h"
21 #include "base/RealTime.h" 21 #include "base/RealTime.h"
22 22
23 #include <QString> 23 #include <QString>
24 #include <QStringList> 24 #include <QStringList>
25 25
50 const Model *getAlignedModel() const; 50 const Model *getAlignedModel() const;
51 51
52 size_t toReference(size_t frame) const; 52 size_t toReference(size_t frame) const;
53 size_t fromReference(size_t frame) const; 53 size_t fromReference(size_t frame) const;
54 54
55 void setPath(PathModel *path);
56
57 virtual void toXml(QTextStream &stream,
58 QString indent = "",
59 QString extraAttributes = "") const;
60
55 signals: 61 signals:
56 void modelChanged(); 62 void modelChanged();
57 void modelChanged(size_t startFrame, size_t endFrame); 63 void modelChanged(size_t startFrame, size_t endFrame);
58 void completionChanged(); 64 void completionChanged();
59 65
66 Model *m_reference; // I don't own this 72 Model *m_reference; // I don't own this
67 Model *m_aligned; // I don't own this 73 Model *m_aligned; // I don't own this
68 74
69 Model *m_inputModel; // I own this 75 Model *m_inputModel; // I own this
70 76
71 struct PathPoint
72 {
73 PathPoint(long _frame) : frame(_frame), mapframe(_frame) { }
74 PathPoint(long _frame, long _mapframe) :
75 frame(_frame), mapframe(_mapframe) { }
76
77 int getDimensions() const { return 2; }
78
79 long frame;
80 long mapframe;
81
82 QString getLabel() const { return ""; }
83
84 void toXml(QTextStream &stream, QString indent = "",
85 QString extraAttributes = "") const {
86 stream << QString("%1<point frame=\"%2\" mapframe=\"%3\" %4/>\n")
87 .arg(indent).arg(frame).arg(mapframe).arg(extraAttributes);
88 }
89
90 QString toDelimitedDataString(QString delimiter,
91 size_t sampleRate) const {
92 QStringList list;
93 list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
94 list << QString("%1").arg(mapframe);
95 return list.join(delimiter);
96 }
97
98 struct Comparator {
99 bool operator()(const PathPoint &p1, const PathPoint &p2) const {
100 if (p1.frame != p2.frame) return p1.frame < p2.frame;
101 return p1.mapframe < p2.mapframe;
102 }
103 };
104
105 struct OrderComparator {
106 bool operator()(const PathPoint &p1, const PathPoint &p2) const {
107 return p1.frame < p2.frame;
108 }
109 };
110 };
111
112 class PathModel : public SparseModel<PathPoint>
113 {
114 public:
115 PathModel(size_t sampleRate, size_t resolution, bool notify = true) :
116 SparseModel<PathPoint>(sampleRate, resolution, notify) { }
117 };
118
119 SparseTimeValueModel *m_rawPath; // I own this 77 SparseTimeValueModel *m_rawPath; // I own this
120 mutable PathModel *m_path; // I own this 78 mutable PathModel *m_path; // I own this
121 mutable PathModel *m_reversePath; // I own this 79 mutable PathModel *m_reversePath; // I own this
122 bool m_pathBegun; 80 bool m_pathBegun;
123 bool m_pathComplete; 81 bool m_pathComplete;