comparison framework/SVFileReader.cpp @ 710:3e930ea94db6

Rename time-frequency box to plain box - but also reload sessions if they have the "old" name (even though it was only used in 4.0-pre1 exports)
author Chris Cannam
date Wed, 25 Sep 2019 09:52:30 +0100
parents dde6ff56a84b
children
comparison
equal deleted inserted replaced
709:dde6ff56a84b 710:3e930ea94db6
32 #include "data/model/SparseTimeValueModel.h" 32 #include "data/model/SparseTimeValueModel.h"
33 #include "data/model/NoteModel.h" 33 #include "data/model/NoteModel.h"
34 #include "data/model/RegionModel.h" 34 #include "data/model/RegionModel.h"
35 #include "data/model/TextModel.h" 35 #include "data/model/TextModel.h"
36 #include "data/model/ImageModel.h" 36 #include "data/model/ImageModel.h"
37 #include "data/model/TimeFrequencyBoxModel.h" 37 #include "data/model/BoxModel.h"
38 #include "data/model/AlignmentModel.h" 38 #include "data/model/AlignmentModel.h"
39 #include "data/model/AggregateWaveModel.h" 39 #include "data/model/AggregateWaveModel.h"
40 40
41 #include "transform/TransformFactory.h" 41 #include "transform/TransformFactory.h"
42 42
685 m_models[id] = ModelById::add(model); 685 m_models[id] = ModelById::add(model);
686 } else if (attributes.value("subtype") == "path") { 686 } else if (attributes.value("subtype") == "path") {
687 // Paths are no longer actually models 687 // Paths are no longer actually models
688 Path *path = new Path(sampleRate, resolution); 688 Path *path = new Path(sampleRate, resolution);
689 m_paths[id] = path; 689 m_paths[id] = path;
690 } else if (attributes.value("subtype") == "timefrequencybox") { 690 } else if (attributes.value("subtype") == "box" ||
691 auto model = std::make_shared<TimeFrequencyBoxModel> 691 attributes.value("subtype") == "timefrequencybox") {
692 auto model = std::make_shared<BoxModel>
692 (sampleRate, resolution, notifyOnAdd); 693 (sampleRate, resolution, notifyOnAdd);
694 model->setScaleUnits(units);
693 model->setObjectName(name); 695 model->setObjectName(name);
694 m_models[id] = ModelById::add(model); 696 m_models[id] = ModelById::add(model);
695 } else { 697 } else {
696 std::shared_ptr<SparseTimeValueModel> model; 698 std::shared_ptr<SparseTimeValueModel> model;
697 if (haveMinMax) { 699 if (haveMinMax) {
1061 1063
1062 case 2: 1064 case 2:
1063 good = 1065 good =
1064 (ModelById::isa<SparseTimeValueModel>(modelId) || 1066 (ModelById::isa<SparseTimeValueModel>(modelId) ||
1065 ModelById::isa<TextModel>(modelId) || 1067 ModelById::isa<TextModel>(modelId) ||
1066 ModelById::isa<TimeFrequencyBoxModel>(modelId) || 1068 ModelById::isa<BoxModel>(modelId) ||
1067 path); 1069 path);
1068 break; 1070 break;
1069 1071
1070 case 3: 1072 case 3:
1071 if (ModelById::isa<EditableDenseThreeDimensionalModel>(modelId)) { 1073 if (ModelById::isa<EditableDenseThreeDimensionalModel>(modelId)) {
1150 QString label = attributes.value("label"); 1152 QString label = attributes.value("label");
1151 tm->add(Event(frame, height, label)); 1153 tm->add(Event(frame, height, label));
1152 return ok; 1154 return ok;
1153 } 1155 }
1154 1156
1155 if (auto bm = ModelById::getAs<TimeFrequencyBoxModel>(modelId)) { 1157 if (auto bm = ModelById::getAs<BoxModel>(modelId)) {
1156 float frequency = attributes.value("frequency").trimmed().toFloat(&ok); 1158 float value = attributes.value("value").trimmed().toFloat(&ok);
1159 if (!ok) {
1160 value = attributes.value("frequency").trimmed().toFloat(&ok);
1161 if (bm->getScaleUnits() == "") {
1162 bm->setScaleUnits("Hz");
1163 }
1164 }
1157 float extent = attributes.value("extent").trimmed().toFloat(&ok); 1165 float extent = attributes.value("extent").trimmed().toFloat(&ok);
1158 int duration = attributes.value("duration").trimmed().toInt(&ok); 1166 int duration = attributes.value("duration").trimmed().toInt(&ok);
1159 QString label = attributes.value("label"); 1167 QString label = attributes.value("label");
1160 bm->add(Event(frame, frequency, duration, extent, label)); 1168 bm->add(Event(frame, value, duration, extent, label));
1161 return ok; 1169 return ok;
1162 } 1170 }
1163 1171
1164 if (auto im = ModelById::getAs<ImageModel>(modelId)) { 1172 if (auto im = ModelById::getAs<ImageModel>(modelId)) {
1165 QString image = attributes.value("image"); 1173 QString image = attributes.value("image");