comparison data/model/RegionModel.h @ 1429:48e9f538e6e9

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 57633d605547
children c01cbe41aeb5
comparison
equal deleted inserted replaced
1428:87ae75da6527 1429:48e9f538e6e9
37 { 37 {
38 public: 38 public:
39 RegionRec() : frame(0), value(0.f), duration(0) { } 39 RegionRec() : frame(0), value(0.f), duration(0) { }
40 RegionRec(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0) { } 40 RegionRec(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0) { }
41 RegionRec(sv_frame_t _frame, float _value, sv_frame_t _duration, QString _label) : 41 RegionRec(sv_frame_t _frame, float _value, sv_frame_t _duration, QString _label) :
42 frame(_frame), value(_value), duration(_duration), label(_label) { } 42 frame(_frame), value(_value), duration(_duration), label(_label) { }
43 43
44 int getDimensions() const { return 3; } 44 int getDimensions() const { return 3; }
45 45
46 sv_frame_t frame; 46 sv_frame_t frame;
47 float value; 47 float value;
52 52
53 void toXml(QTextStream &stream, 53 void toXml(QTextStream &stream,
54 QString indent = "", 54 QString indent = "",
55 QString extraAttributes = "") const 55 QString extraAttributes = "") const
56 { 56 {
57 stream << 57 stream <<
58 QString("%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" label=\"%5\" %6/>\n") 58 QString("%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" label=\"%5\" %6/>\n")
59 .arg(indent).arg(frame).arg(value).arg(duration) 59 .arg(indent).arg(frame).arg(value).arg(duration)
60 .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); 60 .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
61 } 61 }
62 62
63 QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const 63 QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const
64 { 64 {
69 if (label != "") list << label; 69 if (label != "") list << label;
70 return list.join(delimiter); 70 return list.join(delimiter);
71 } 71 }
72 72
73 struct Comparator { 73 struct Comparator {
74 bool operator()(const RegionRec &p1, 74 bool operator()(const RegionRec &p1,
75 const RegionRec &p2) const { 75 const RegionRec &p2) const {
76 if (p1.frame != p2.frame) return p1.frame < p2.frame; 76 if (p1.frame != p2.frame) return p1.frame < p2.frame;
77 if (p1.value != p2.value) return p1.value < p2.value; 77 if (p1.value != p2.value) return p1.value < p2.value;
78 if (p1.duration != p2.duration) return p1.duration < p2.duration; 78 if (p1.duration != p2.duration) return p1.duration < p2.duration;
79 return p1.label < p2.label; 79 return p1.label < p2.label;
80 } 80 }
81 }; 81 };
82 82
83 struct OrderComparator { 83 struct OrderComparator {
84 bool operator()(const RegionRec &p1, 84 bool operator()(const RegionRec &p1,
85 const RegionRec &p2) const { 85 const RegionRec &p2) const {
86 return p1.frame < p2.frame; 86 return p1.frame < p2.frame;
87 } 87 }
88 }; 88 };
89 }; 89 };
90 90
91 91
92 class RegionModel : public IntervalModel<RegionRec> 92 class RegionModel : public IntervalModel<RegionRec>
94 Q_OBJECT 94 Q_OBJECT
95 95
96 public: 96 public:
97 RegionModel(sv_samplerate_t sampleRate, int resolution, 97 RegionModel(sv_samplerate_t sampleRate, int resolution,
98 bool notifyOnAdd = true) : 98 bool notifyOnAdd = true) :
99 IntervalModel<RegionRec>(sampleRate, resolution, notifyOnAdd), 99 IntervalModel<RegionRec>(sampleRate, resolution, notifyOnAdd),
100 m_valueQuantization(0), 100 m_valueQuantization(0),
101 m_haveDistinctValues(false) 101 m_haveDistinctValues(false)
102 { 102 {
103 } 103 }
104 104
105 RegionModel(sv_samplerate_t sampleRate, int resolution, 105 RegionModel(sv_samplerate_t sampleRate, int resolution,
106 float valueMinimum, float valueMaximum, 106 float valueMinimum, float valueMaximum,
107 bool notifyOnAdd = true) : 107 bool notifyOnAdd = true) :
108 IntervalModel<RegionRec>(sampleRate, resolution, 108 IntervalModel<RegionRec>(sampleRate, resolution,
109 valueMinimum, valueMaximum, 109 valueMinimum, valueMaximum,
110 notifyOnAdd), 110 notifyOnAdd),
111 m_valueQuantization(0), 111 m_valueQuantization(0),
112 m_haveDistinctValues(false) 112 m_haveDistinctValues(false)
113 { 113 {
114 } 114 }
115 115
116 virtual ~RegionModel() 116 virtual ~RegionModel()
130 { 130 {
131 std::cerr << "RegionModel::toXml: extraAttributes = \"" 131 std::cerr << "RegionModel::toXml: extraAttributes = \""
132 << extraAttributes.toStdString() << std::endl; 132 << extraAttributes.toStdString() << std::endl;
133 133
134 IntervalModel<RegionRec>::toXml 134 IntervalModel<RegionRec>::toXml
135 (out, 135 (out,
136 indent, 136 indent,
137 QString("%1 subtype=\"region\" valueQuantization=\"%2\"") 137 QString("%1 subtype=\"region\" valueQuantization=\"%2\"")
138 .arg(extraAttributes).arg(m_valueQuantization)); 138 .arg(extraAttributes).arg(m_valueQuantization));
139 } 139 }
140 140
141 /** 141 /**
142 * TabularModel methods. 142 * TabularModel methods.
143 */ 143 */