comparison layer/LayerFactory.cpp @ 1522:d5ef91dc2ea7

Merge from branch time-frequency-boxes
author Chris Cannam
date Wed, 25 Sep 2019 13:48:04 +0100
parents 2e94c268f7a0
children 1acd7be4df9a
comparison
equal deleted inserted replaced
1510:872873aa6463 1522:d5ef91dc2ea7
21 #include "TimeInstantLayer.h" 21 #include "TimeInstantLayer.h"
22 #include "TimeValueLayer.h" 22 #include "TimeValueLayer.h"
23 #include "NoteLayer.h" 23 #include "NoteLayer.h"
24 #include "FlexiNoteLayer.h" 24 #include "FlexiNoteLayer.h"
25 #include "RegionLayer.h" 25 #include "RegionLayer.h"
26 #include "BoxLayer.h"
26 #include "TextLayer.h" 27 #include "TextLayer.h"
27 #include "ImageLayer.h" 28 #include "ImageLayer.h"
28 #include "Colour3DPlotLayer.h" 29 #include "Colour3DPlotLayer.h"
29 #include "SpectrumLayer.h" 30 #include "SpectrumLayer.h"
30 #include "SliceLayer.h" 31 #include "SliceLayer.h"
36 #include "data/model/DenseTimeValueModel.h" 37 #include "data/model/DenseTimeValueModel.h"
37 #include "data/model/SparseOneDimensionalModel.h" 38 #include "data/model/SparseOneDimensionalModel.h"
38 #include "data/model/SparseTimeValueModel.h" 39 #include "data/model/SparseTimeValueModel.h"
39 #include "data/model/NoteModel.h" 40 #include "data/model/NoteModel.h"
40 #include "data/model/RegionModel.h" 41 #include "data/model/RegionModel.h"
42 #include "data/model/BoxModel.h"
41 #include "data/model/TextModel.h" 43 #include "data/model/TextModel.h"
42 #include "data/model/ImageModel.h" 44 #include "data/model/ImageModel.h"
43 #include "data/model/DenseThreeDimensionalModel.h" 45 #include "data/model/DenseThreeDimensionalModel.h"
44 #include "data/model/WaveFileModel.h" 46 #include "data/model/WaveFileModel.h"
45 #include "data/model/WritableWaveFileModel.h" 47 #include "data/model/WritableWaveFileModel.h"
74 case TimeInstants: return Layer::tr("Time Instants"); 76 case TimeInstants: return Layer::tr("Time Instants");
75 case TimeValues: return Layer::tr("Time Values"); 77 case TimeValues: return Layer::tr("Time Values");
76 case Notes: return Layer::tr("Notes"); 78 case Notes: return Layer::tr("Notes");
77 case FlexiNotes: return Layer::tr("Flexible Notes"); 79 case FlexiNotes: return Layer::tr("Flexible Notes");
78 case Regions: return Layer::tr("Regions"); 80 case Regions: return Layer::tr("Regions");
81 case Boxes: return Layer::tr("Boxes");
79 case Text: return Layer::tr("Text"); 82 case Text: return Layer::tr("Text");
80 case Image: return Layer::tr("Images"); 83 case Image: return Layer::tr("Images");
81 case Colour3DPlot: return Layer::tr("Colour 3D Plot"); 84 case Colour3DPlot: return Layer::tr("Colour 3D Plot");
82 case Spectrum: return Layer::tr("Spectrum"); 85 case Spectrum: return Layer::tr("Spectrum");
83 case Slice: return Layer::tr("Time Slice"); 86 case Slice: return Layer::tr("Time Slice");
171 174
172 if (ModelById::getAs<RegionModel>(modelId)) { 175 if (ModelById::getAs<RegionModel>(modelId)) {
173 types.insert(Regions); 176 types.insert(Regions);
174 } 177 }
175 178
179 if (ModelById::getAs<BoxModel>(modelId)) {
180 types.insert(Boxes);
181 }
182
176 if (ModelById::getAs<TextModel>(modelId)) { 183 if (ModelById::getAs<TextModel>(modelId)) {
177 types.insert(Text); 184 types.insert(Text);
178 } 185 }
179 186
180 if (ModelById::getAs<ImageModel>(modelId)) { 187 if (ModelById::getAs<ImageModel>(modelId)) {
201 // to show in a menu -- it should not contain FlexiNotes; the 208 // to show in a menu -- it should not contain FlexiNotes; the
202 // layer isn't meaningfully editable in SV 209 // layer isn't meaningfully editable in SV
203 // types.insert(FlexiNotes); 210 // types.insert(FlexiNotes);
204 types.insert(Notes); 211 types.insert(Notes);
205 types.insert(Regions); 212 types.insert(Regions);
213 types.insert(Boxes);
206 types.insert(Text); 214 types.insert(Text);
207 types.insert(Image); 215 types.insert(Image);
208 //!!! and in principle Colour3DPlot -- now that's a challenge 216 //!!! and in principle Colour3DPlot -- now that's a challenge
209 return types; 217 return types;
210 } 218 }
218 if (dynamic_cast<const TimeInstantLayer *>(layer)) return TimeInstants; 226 if (dynamic_cast<const TimeInstantLayer *>(layer)) return TimeInstants;
219 if (dynamic_cast<const TimeValueLayer *>(layer)) return TimeValues; 227 if (dynamic_cast<const TimeValueLayer *>(layer)) return TimeValues;
220 if (dynamic_cast<const FlexiNoteLayer *>(layer)) return FlexiNotes; 228 if (dynamic_cast<const FlexiNoteLayer *>(layer)) return FlexiNotes;
221 if (dynamic_cast<const NoteLayer *>(layer)) return Notes; 229 if (dynamic_cast<const NoteLayer *>(layer)) return Notes;
222 if (dynamic_cast<const RegionLayer *>(layer)) return Regions; 230 if (dynamic_cast<const RegionLayer *>(layer)) return Regions;
231 if (dynamic_cast<const BoxLayer *>(layer)) return Boxes;
223 if (dynamic_cast<const TextLayer *>(layer)) return Text; 232 if (dynamic_cast<const TextLayer *>(layer)) return Text;
224 if (dynamic_cast<const ImageLayer *>(layer)) return Image; 233 if (dynamic_cast<const ImageLayer *>(layer)) return Image;
225 if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot; 234 if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot;
226 if (dynamic_cast<const SpectrumLayer *>(layer)) return Spectrum; 235 if (dynamic_cast<const SpectrumLayer *>(layer)) return Spectrum;
227 if (dynamic_cast<const SliceLayer *>(layer)) return Slice; 236 if (dynamic_cast<const SliceLayer *>(layer)) return Slice;
238 case TimeInstants: return "instants"; 247 case TimeInstants: return "instants";
239 case TimeValues: return "values"; 248 case TimeValues: return "values";
240 case Notes: return "notes"; 249 case Notes: return "notes";
241 case FlexiNotes: return "flexinotes"; 250 case FlexiNotes: return "flexinotes";
242 case Regions: return "regions"; 251 case Regions: return "regions";
252 case Boxes: return "boxes";
243 case Text: return "text"; 253 case Text: return "text";
244 case Image: return "image"; 254 case Image: return "image";
245 case Colour3DPlot: return "colour3d"; 255 case Colour3DPlot: return "colour3d";
246 case Spectrum: return "spectrum"; 256 case Spectrum: return "spectrum";
247 case Slice: return "spectrum"; 257 case Slice: return "spectrum";
264 case TimeInstants: return "timeinstants"; 274 case TimeInstants: return "timeinstants";
265 case TimeValues: return "timevalues"; 275 case TimeValues: return "timevalues";
266 case Notes: return "notes"; 276 case Notes: return "notes";
267 case FlexiNotes: return "flexinotes"; 277 case FlexiNotes: return "flexinotes";
268 case Regions: return "regions"; 278 case Regions: return "regions";
279 case Boxes: return "boxes";
269 case Text: return "text"; 280 case Text: return "text";
270 case Image: return "image"; 281 case Image: return "image";
271 case Colour3DPlot: return "colour3dplot"; 282 case Colour3DPlot: return "colour3dplot";
272 case Spectrum: return "spectrum"; 283 case Spectrum: return "spectrum";
273 case Slice: return "slice"; 284 case Slice: return "slice";
289 if (name == "timeinstants") return TimeInstants; 300 if (name == "timeinstants") return TimeInstants;
290 if (name == "timevalues") return TimeValues; 301 if (name == "timevalues") return TimeValues;
291 if (name == "notes") return Notes; 302 if (name == "notes") return Notes;
292 if (name == "flexinotes") return FlexiNotes; 303 if (name == "flexinotes") return FlexiNotes;
293 if (name == "regions") return Regions; 304 if (name == "regions") return Regions;
305 if (name == "boxes" || name == "timefrequencybox") return Boxes;
294 if (name == "text") return Text; 306 if (name == "text") return Text;
295 if (name == "image") return Image; 307 if (name == "image") return Image;
296 if (name == "colour3dplot") return Colour3DPlot; 308 if (name == "colour3dplot") return Colour3DPlot;
297 if (name == "spectrum") return Spectrum; 309 if (name == "spectrum") return Spectrum;
298 if (name == "slice") return Slice; 310 if (name == "slice") return Slice;
325 337
326 if (trySetModel<FlexiNoteLayer, NoteModel>(layer, model)) 338 if (trySetModel<FlexiNoteLayer, NoteModel>(layer, model))
327 return; 339 return;
328 340
329 if (trySetModel<RegionLayer, RegionModel>(layer, model)) 341 if (trySetModel<RegionLayer, RegionModel>(layer, model))
342 return;
343
344 if (trySetModel<BoxLayer, BoxModel>(layer, model))
330 return; 345 return;
331 346
332 if (trySetModel<TextLayer, TextModel>(layer, model)) 347 if (trySetModel<TextLayer, TextModel>(layer, model))
333 return; 348 return;
334 349
358 return std::make_shared<NoteModel>(rate, 1, true); 373 return std::make_shared<NoteModel>(rate, 1, true);
359 } else if (layerType == Notes) { 374 } else if (layerType == Notes) {
360 return std::make_shared<NoteModel>(rate, 1, true); 375 return std::make_shared<NoteModel>(rate, 1, true);
361 } else if (layerType == Regions) { 376 } else if (layerType == Regions) {
362 return std::make_shared<RegionModel>(rate, 1, true); 377 return std::make_shared<RegionModel>(rate, 1, true);
378 } else if (layerType == Boxes) {
379 return std::make_shared<BoxModel>(rate, 1, true);
363 } else if (layerType == Text) { 380 } else if (layerType == Text) {
364 return std::make_shared<TextModel>(rate, 1, true); 381 return std::make_shared<TextModel>(rate, 1, true);
365 } else if (layerType == Image) { 382 } else if (layerType == Image) {
366 return std::make_shared<ImageModel>(rate, 1, true); 383 return std::make_shared<ImageModel>(rate, 1, true);
367 } else { 384 } else {
433 layer = new NoteLayer; 450 layer = new NoteLayer;
434 break; 451 break;
435 452
436 case Regions: 453 case Regions:
437 layer = new RegionLayer; 454 layer = new RegionLayer;
455 break;
456
457 case Boxes:
458 layer = new BoxLayer;
438 break; 459 break;
439 460
440 case Text: 461 case Text:
441 layer = new TextLayer; 462 layer = new TextLayer;
442 break; 463 break;