Mercurial > hg > svgui
comparison layer/LayerFactory.cpp @ 718:e5f4385615ac tony_integration
Merge from tonioni branch
author | Chris Cannam |
---|---|
date | Tue, 28 Jan 2014 15:02:09 +0000 |
parents | 917039d333bb |
children | 6a8d922f991d |
comparison
equal
deleted
inserted
replaced
704:b81f21f2c4c3 | 718:e5f4385615ac |
---|---|
19 #include "SpectrogramLayer.h" | 19 #include "SpectrogramLayer.h" |
20 #include "TimeRulerLayer.h" | 20 #include "TimeRulerLayer.h" |
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 "RegionLayer.h" | 25 #include "RegionLayer.h" |
25 #include "TextLayer.h" | 26 #include "TextLayer.h" |
26 #include "ImageLayer.h" | 27 #include "ImageLayer.h" |
27 #include "Colour3DPlotLayer.h" | 28 #include "Colour3DPlotLayer.h" |
28 #include "SpectrumLayer.h" | 29 #include "SpectrumLayer.h" |
34 #include "data/model/RangeSummarisableTimeValueModel.h" | 35 #include "data/model/RangeSummarisableTimeValueModel.h" |
35 #include "data/model/DenseTimeValueModel.h" | 36 #include "data/model/DenseTimeValueModel.h" |
36 #include "data/model/SparseOneDimensionalModel.h" | 37 #include "data/model/SparseOneDimensionalModel.h" |
37 #include "data/model/SparseTimeValueModel.h" | 38 #include "data/model/SparseTimeValueModel.h" |
38 #include "data/model/NoteModel.h" | 39 #include "data/model/NoteModel.h" |
40 #include "data/model/FlexiNoteModel.h" | |
39 #include "data/model/RegionModel.h" | 41 #include "data/model/RegionModel.h" |
40 #include "data/model/TextModel.h" | 42 #include "data/model/TextModel.h" |
41 #include "data/model/ImageModel.h" | 43 #include "data/model/ImageModel.h" |
42 #include "data/model/DenseThreeDimensionalModel.h" | 44 #include "data/model/DenseThreeDimensionalModel.h" |
43 #include "data/model/WaveFileModel.h" | 45 #include "data/model/WaveFileModel.h" |
71 case Spectrogram: return Layer::tr("Spectrogram"); | 73 case Spectrogram: return Layer::tr("Spectrogram"); |
72 case TimeRuler: return Layer::tr("Ruler"); | 74 case TimeRuler: return Layer::tr("Ruler"); |
73 case TimeInstants: return Layer::tr("Time Instants"); | 75 case TimeInstants: return Layer::tr("Time Instants"); |
74 case TimeValues: return Layer::tr("Time Values"); | 76 case TimeValues: return Layer::tr("Time Values"); |
75 case Notes: return Layer::tr("Notes"); | 77 case Notes: return Layer::tr("Notes"); |
78 case FlexiNotes: return Layer::tr("Flexible Notes"); | |
76 case Regions: return Layer::tr("Regions"); | 79 case Regions: return Layer::tr("Regions"); |
77 case Text: return Layer::tr("Text"); | 80 case Text: return Layer::tr("Text"); |
78 case Image: return Layer::tr("Images"); | 81 case Image: return Layer::tr("Images"); |
79 case Colour3DPlot: return Layer::tr("Colour 3D Plot"); | 82 case Colour3DPlot: return Layer::tr("Colour 3D Plot"); |
80 case Spectrum: return Layer::tr("Spectrum"); | 83 case Spectrum: return Layer::tr("Spectrum"); |
159 | 162 |
160 if (dynamic_cast<NoteModel *>(model)) { | 163 if (dynamic_cast<NoteModel *>(model)) { |
161 types.insert(Notes); | 164 types.insert(Notes); |
162 } | 165 } |
163 | 166 |
167 // NOTE: GF: types is a set, so order of insertion does not matter | |
168 if (dynamic_cast<FlexiNoteModel *>(model)) { | |
169 types.insert(FlexiNotes); | |
170 } | |
171 | |
164 if (dynamic_cast<RegionModel *>(model)) { | 172 if (dynamic_cast<RegionModel *>(model)) { |
165 types.insert(Regions); | 173 types.insert(Regions); |
166 } | 174 } |
167 | 175 |
168 if (dynamic_cast<TextModel *>(model)) { | 176 if (dynamic_cast<TextModel *>(model)) { |
187 LayerFactory::getValidEmptyLayerTypes() | 195 LayerFactory::getValidEmptyLayerTypes() |
188 { | 196 { |
189 LayerTypeSet types; | 197 LayerTypeSet types; |
190 types.insert(TimeInstants); | 198 types.insert(TimeInstants); |
191 types.insert(TimeValues); | 199 types.insert(TimeValues); |
200 types.insert(FlexiNotes); | |
192 types.insert(Notes); | 201 types.insert(Notes); |
193 types.insert(Regions); | 202 types.insert(Regions); |
194 types.insert(Text); | 203 types.insert(Text); |
195 types.insert(Image); | 204 types.insert(Image); |
196 //!!! and in principle Colour3DPlot -- now that's a challenge | 205 //!!! and in principle Colour3DPlot -- now that's a challenge |
203 if (dynamic_cast<const WaveformLayer *>(layer)) return Waveform; | 212 if (dynamic_cast<const WaveformLayer *>(layer)) return Waveform; |
204 if (dynamic_cast<const SpectrogramLayer *>(layer)) return Spectrogram; | 213 if (dynamic_cast<const SpectrogramLayer *>(layer)) return Spectrogram; |
205 if (dynamic_cast<const TimeRulerLayer *>(layer)) return TimeRuler; | 214 if (dynamic_cast<const TimeRulerLayer *>(layer)) return TimeRuler; |
206 if (dynamic_cast<const TimeInstantLayer *>(layer)) return TimeInstants; | 215 if (dynamic_cast<const TimeInstantLayer *>(layer)) return TimeInstants; |
207 if (dynamic_cast<const TimeValueLayer *>(layer)) return TimeValues; | 216 if (dynamic_cast<const TimeValueLayer *>(layer)) return TimeValues; |
217 if (dynamic_cast<const FlexiNoteLayer *>(layer)) return FlexiNotes; | |
208 if (dynamic_cast<const NoteLayer *>(layer)) return Notes; | 218 if (dynamic_cast<const NoteLayer *>(layer)) return Notes; |
209 if (dynamic_cast<const RegionLayer *>(layer)) return Regions; | 219 if (dynamic_cast<const RegionLayer *>(layer)) return Regions; |
210 if (dynamic_cast<const TextLayer *>(layer)) return Text; | 220 if (dynamic_cast<const TextLayer *>(layer)) return Text; |
211 if (dynamic_cast<const ImageLayer *>(layer)) return Image; | 221 if (dynamic_cast<const ImageLayer *>(layer)) return Image; |
212 if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot; | 222 if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot; |
223 case Spectrogram: return "spectrogram"; | 233 case Spectrogram: return "spectrogram"; |
224 case TimeRuler: return "timeruler"; | 234 case TimeRuler: return "timeruler"; |
225 case TimeInstants: return "instants"; | 235 case TimeInstants: return "instants"; |
226 case TimeValues: return "values"; | 236 case TimeValues: return "values"; |
227 case Notes: return "notes"; | 237 case Notes: return "notes"; |
238 case FlexiNotes: return "flexible notes"; | |
228 case Regions: return "regions"; | 239 case Regions: return "regions"; |
229 case Text: return "text"; | 240 case Text: return "text"; |
230 case Image: return "image"; | 241 case Image: return "image"; |
231 case Colour3DPlot: return "colour3d"; | 242 case Colour3DPlot: return "colour3d"; |
232 case Spectrum: return "spectrum"; | 243 case Spectrum: return "spectrum"; |
245 case Spectrogram: return "spectrogram"; | 256 case Spectrogram: return "spectrogram"; |
246 case TimeRuler: return "timeruler"; | 257 case TimeRuler: return "timeruler"; |
247 case TimeInstants: return "timeinstants"; | 258 case TimeInstants: return "timeinstants"; |
248 case TimeValues: return "timevalues"; | 259 case TimeValues: return "timevalues"; |
249 case Notes: return "notes"; | 260 case Notes: return "notes"; |
261 case FlexiNotes: return "flexinotes"; | |
250 case Regions: return "regions"; | 262 case Regions: return "regions"; |
251 case Text: return "text"; | 263 case Text: return "text"; |
252 case Image: return "image"; | 264 case Image: return "image"; |
253 case Colour3DPlot: return "colour3dplot"; | 265 case Colour3DPlot: return "colour3dplot"; |
254 case Spectrum: return "spectrum"; | 266 case Spectrum: return "spectrum"; |
265 if (name == "waveform") return Waveform; | 277 if (name == "waveform") return Waveform; |
266 if (name == "spectrogram") return Spectrogram; | 278 if (name == "spectrogram") return Spectrogram; |
267 if (name == "timeruler") return TimeRuler; | 279 if (name == "timeruler") return TimeRuler; |
268 if (name == "timeinstants") return TimeInstants; | 280 if (name == "timeinstants") return TimeInstants; |
269 if (name == "timevalues") return TimeValues; | 281 if (name == "timevalues") return TimeValues; |
270 if (name == "notes") return Notes; | 282 if (name == "flexinotes") return FlexiNotes; |
271 if (name == "regions") return Regions; | 283 if (name == "regions") return Regions; |
272 if (name == "text") return Text; | 284 if (name == "text") return Text; |
273 if (name == "image") return Image; | 285 if (name == "image") return Image; |
274 if (name == "colour3dplot") return Colour3DPlot; | 286 if (name == "colour3dplot") return Colour3DPlot; |
275 if (name == "spectrum") return Spectrum; | 287 if (name == "spectrum") return Spectrum; |
280 void | 292 void |
281 LayerFactory::setModel(Layer *layer, Model *model) | 293 LayerFactory::setModel(Layer *layer, Model *model) |
282 { | 294 { |
283 // if (trySetModel<WaveformLayer, RangeSummarisableTimeValueModel>(layer, model)) | 295 // if (trySetModel<WaveformLayer, RangeSummarisableTimeValueModel>(layer, model)) |
284 // return; | 296 // return; |
285 | 297 |
286 if (trySetModel<WaveformLayer, WaveFileModel>(layer, model)) | 298 if (trySetModel<WaveformLayer, WaveFileModel>(layer, model)) |
287 return; | 299 return; |
288 | 300 |
289 if (trySetModel<WaveformLayer, WritableWaveFileModel>(layer, model)) | 301 if (trySetModel<WaveformLayer, WritableWaveFileModel>(layer, model)) |
290 return; | 302 return; |
299 return; | 311 return; |
300 | 312 |
301 if (trySetModel<TimeValueLayer, SparseTimeValueModel>(layer, model)) | 313 if (trySetModel<TimeValueLayer, SparseTimeValueModel>(layer, model)) |
302 return; | 314 return; |
303 | 315 |
304 if (trySetModel<NoteLayer, NoteModel>(layer, model)) | 316 if (trySetModel<NoteLayer, NoteModel>(layer, model)) |
305 return; | 317 return; |
306 | 318 |
319 // GF: added FlexiNoteLayer | |
320 if (trySetModel<FlexiNoteLayer, FlexiNoteModel>(layer, model)) | |
321 return; | |
322 | |
307 if (trySetModel<RegionLayer, RegionModel>(layer, model)) | 323 if (trySetModel<RegionLayer, RegionModel>(layer, model)) |
308 return; | 324 return; |
309 | 325 |
310 if (trySetModel<TextLayer, TextModel>(layer, model)) | 326 if (trySetModel<TextLayer, TextModel>(layer, model)) |
311 return; | 327 return; |
331 { | 347 { |
332 if (layerType == TimeInstants) { | 348 if (layerType == TimeInstants) { |
333 return new SparseOneDimensionalModel(baseModel->getSampleRate(), 1); | 349 return new SparseOneDimensionalModel(baseModel->getSampleRate(), 1); |
334 } else if (layerType == TimeValues) { | 350 } else if (layerType == TimeValues) { |
335 return new SparseTimeValueModel(baseModel->getSampleRate(), 1, true); | 351 return new SparseTimeValueModel(baseModel->getSampleRate(), 1, true); |
352 } else if (layerType == FlexiNotes) { | |
353 return new FlexiNoteModel(baseModel->getSampleRate(), 1, true); | |
336 } else if (layerType == Notes) { | 354 } else if (layerType == Notes) { |
337 return new NoteModel(baseModel->getSampleRate(), 1, true); | 355 return new NoteModel(baseModel->getSampleRate(), 1, true); |
338 } else if (layerType == Regions) { | 356 } else if (layerType == Regions) { |
339 return new RegionModel(baseModel->getSampleRate(), 1, true); | 357 return new RegionModel(baseModel->getSampleRate(), 1, true); |
340 } else if (layerType == Text) { | 358 } else if (layerType == Text) { |
398 layer = new TimeInstantLayer; | 416 layer = new TimeInstantLayer; |
399 break; | 417 break; |
400 | 418 |
401 case TimeValues: | 419 case TimeValues: |
402 layer = new TimeValueLayer; | 420 layer = new TimeValueLayer; |
421 break; | |
422 | |
423 case FlexiNotes: | |
424 layer = new FlexiNoteLayer; | |
403 break; | 425 break; |
404 | 426 |
405 case Notes: | 427 case Notes: |
406 layer = new NoteLayer; | 428 layer = new NoteLayer; |
407 break; | 429 break; |