Mercurial > hg > svgui
changeset 1512:0fa155b84bac time-frequency-boxes
Add TimeFrequencyBoxes to layer factory
author | Chris Cannam |
---|---|
date | Thu, 19 Sep 2019 17:15:36 +0100 |
parents | a473b73fb045 |
children | 0586e6492785 |
files | layer/LayerFactory.cpp layer/LayerFactory.h |
diffstat | 2 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/LayerFactory.cpp Thu Sep 19 15:18:28 2019 +0100 +++ b/layer/LayerFactory.cpp Thu Sep 19 17:15:36 2019 +0100 @@ -23,6 +23,7 @@ #include "NoteLayer.h" #include "FlexiNoteLayer.h" #include "RegionLayer.h" +#include "TimeFrequencyBoxLayer.h" #include "TextLayer.h" #include "ImageLayer.h" #include "Colour3DPlotLayer.h" @@ -38,6 +39,7 @@ #include "data/model/SparseTimeValueModel.h" #include "data/model/NoteModel.h" #include "data/model/RegionModel.h" +#include "data/model/TimeFrequencyBoxModel.h" #include "data/model/TextModel.h" #include "data/model/ImageModel.h" #include "data/model/DenseThreeDimensionalModel.h" @@ -76,6 +78,7 @@ case Notes: return Layer::tr("Notes"); case FlexiNotes: return Layer::tr("Flexible Notes"); case Regions: return Layer::tr("Regions"); + case TimeFrequencyBoxes: return Layer::tr("Time-Frequency Boxes"); case Text: return Layer::tr("Text"); case Image: return Layer::tr("Images"); case Colour3DPlot: return Layer::tr("Colour 3D Plot"); @@ -173,6 +176,10 @@ types.insert(Regions); } + if (ModelById::getAs<TimeFrequencyBoxModel>(modelId)) { + types.insert(TimeFrequencyBoxes); + } + if (ModelById::getAs<TextModel>(modelId)) { types.insert(Text); } @@ -203,6 +210,7 @@ // types.insert(FlexiNotes); types.insert(Notes); types.insert(Regions); + types.insert(TimeFrequencyBoxes); types.insert(Text); types.insert(Image); //!!! and in principle Colour3DPlot -- now that's a challenge @@ -220,6 +228,7 @@ if (dynamic_cast<const FlexiNoteLayer *>(layer)) return FlexiNotes; if (dynamic_cast<const NoteLayer *>(layer)) return Notes; if (dynamic_cast<const RegionLayer *>(layer)) return Regions; + if (dynamic_cast<const TimeFrequencyBoxLayer *>(layer)) return TimeFrequencyBoxes; if (dynamic_cast<const TextLayer *>(layer)) return Text; if (dynamic_cast<const ImageLayer *>(layer)) return Image; if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot; @@ -240,6 +249,7 @@ case Notes: return "notes"; case FlexiNotes: return "flexinotes"; case Regions: return "regions"; + case TimeFrequencyBoxes: return "timefrequencyboxes"; case Text: return "text"; case Image: return "image"; case Colour3DPlot: return "colour3d"; @@ -266,6 +276,7 @@ case Notes: return "notes"; case FlexiNotes: return "flexinotes"; case Regions: return "regions"; + case TimeFrequencyBoxes: return "timefrequencyboxes"; case Text: return "text"; case Image: return "image"; case Colour3DPlot: return "colour3dplot"; @@ -291,6 +302,7 @@ if (name == "notes") return Notes; if (name == "flexinotes") return FlexiNotes; if (name == "regions") return Regions; + if (name == "timefrequencyboxes") return TimeFrequencyBoxes; if (name == "text") return Text; if (name == "image") return Image; if (name == "colour3dplot") return Colour3DPlot; @@ -329,6 +341,9 @@ if (trySetModel<RegionLayer, RegionModel>(layer, model)) return; + if (trySetModel<TimeFrequencyBoxLayer, TimeFrequencyBoxModel>(layer, model)) + return; + if (trySetModel<TextLayer, TextModel>(layer, model)) return; @@ -360,6 +375,8 @@ return std::make_shared<NoteModel>(rate, 1, true); } else if (layerType == Regions) { return std::make_shared<RegionModel>(rate, 1, true); + } else if (layerType == TimeFrequencyBoxes) { + return std::make_shared<TimeFrequencyBoxModel>(rate, 1, true); } else if (layerType == Text) { return std::make_shared<TextModel>(rate, 1, true); } else if (layerType == Image) { @@ -437,6 +454,10 @@ layer = new RegionLayer; break; + case TimeFrequencyBoxes: + layer = new TimeFrequencyBoxLayer; + break; + case Text: layer = new TextLayer; break;