Mercurial > hg > svgui
comparison layer/LayerFactory.cpp @ 133:9e6b3e239b9d
* Add zoom thumbwheels to Pane. Implement horizontal thumbwheel, and
vertical depending on layer type (supported for waveform and spectrogram,
though wrong for log-scale spectrogram at the moment).
* Add bare bones of a spectrum layer.
* Add window icon
* Add shortcut for "insert time instant" on laptops without keypad enter (";")
* Delete FFT processing thread when it exits (at least, next time we're asked
for something interesting)
* Get audio file extensions from the file readers, and thus from libsndfile for
the wave file reader -- leads to rather a wide combo box in file dialog though
* Better refresh order for spectrogram (redraw centre section first)
author | Chris Cannam |
---|---|
date | Fri, 04 Aug 2006 17:01:37 +0000 |
parents | 33929e0c3c6b |
children | b32282fefccd |
comparison
equal
deleted
inserted
replaced
132:5d3a483856ff | 133:9e6b3e239b9d |
---|---|
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 "TextLayer.h" | 24 #include "TextLayer.h" |
25 #include "Colour3DPlotLayer.h" | 25 #include "Colour3DPlotLayer.h" |
26 #include "SpectrumLayer.h" | |
26 | 27 |
27 #include "data/model/RangeSummarisableTimeValueModel.h" | 28 #include "data/model/RangeSummarisableTimeValueModel.h" |
28 #include "data/model/DenseTimeValueModel.h" | 29 #include "data/model/DenseTimeValueModel.h" |
29 #include "data/model/SparseOneDimensionalModel.h" | 30 #include "data/model/SparseOneDimensionalModel.h" |
30 #include "data/model/SparseTimeValueModel.h" | 31 #include "data/model/SparseTimeValueModel.h" |
55 case TimeInstants: return Layer::tr("Time Instants"); | 56 case TimeInstants: return Layer::tr("Time Instants"); |
56 case TimeValues: return Layer::tr("Time Values"); | 57 case TimeValues: return Layer::tr("Time Values"); |
57 case Notes: return Layer::tr("Notes"); | 58 case Notes: return Layer::tr("Notes"); |
58 case Text: return Layer::tr("Text"); | 59 case Text: return Layer::tr("Text"); |
59 case Colour3DPlot: return Layer::tr("Colour 3D Plot"); | 60 case Colour3DPlot: return Layer::tr("Colour 3D Plot"); |
61 case Spectrum: return Layer::tr("Spectrum"); | |
60 | 62 |
61 case MelodicRangeSpectrogram: | 63 case MelodicRangeSpectrogram: |
62 // The user can change all the parameters of this after the | 64 // The user can change all the parameters of this after the |
63 // fact -- there's nothing permanently melodic-range about it | 65 // fact -- there's nothing permanently melodic-range about it |
64 // that should be encoded in its name | 66 // that should be encoded in its name |
105 types.insert(Notes); | 107 types.insert(Notes); |
106 } | 108 } |
107 | 109 |
108 if (dynamic_cast<TextModel *>(model)) { | 110 if (dynamic_cast<TextModel *>(model)) { |
109 types.insert(Text); | 111 types.insert(Text); |
112 } | |
113 | |
114 if (dynamic_cast<DenseTimeValueModel *>(model)) { | |
115 types.insert(Spectrum); | |
110 } | 116 } |
111 | 117 |
112 // We don't count TimeRuler here as it doesn't actually display | 118 // We don't count TimeRuler here as it doesn't actually display |
113 // the data, although it can be backed by any model | 119 // the data, although it can be backed by any model |
114 | 120 |
136 if (dynamic_cast<const TimeInstantLayer *>(layer)) return TimeInstants; | 142 if (dynamic_cast<const TimeInstantLayer *>(layer)) return TimeInstants; |
137 if (dynamic_cast<const TimeValueLayer *>(layer)) return TimeValues; | 143 if (dynamic_cast<const TimeValueLayer *>(layer)) return TimeValues; |
138 if (dynamic_cast<const NoteLayer *>(layer)) return Notes; | 144 if (dynamic_cast<const NoteLayer *>(layer)) return Notes; |
139 if (dynamic_cast<const TextLayer *>(layer)) return Text; | 145 if (dynamic_cast<const TextLayer *>(layer)) return Text; |
140 if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot; | 146 if (dynamic_cast<const Colour3DPlotLayer *>(layer)) return Colour3DPlot; |
147 if (dynamic_cast<const SpectrumLayer *>(layer)) return Spectrum; | |
141 return UnknownLayer; | 148 return UnknownLayer; |
142 } | 149 } |
143 | 150 |
144 QString | 151 QString |
145 LayerFactory::getLayerIconName(LayerType type) | 152 LayerFactory::getLayerIconName(LayerType type) |
151 case TimeInstants: return "instants"; | 158 case TimeInstants: return "instants"; |
152 case TimeValues: return "values"; | 159 case TimeValues: return "values"; |
153 case Notes: return "notes"; | 160 case Notes: return "notes"; |
154 case Text: return "text"; | 161 case Text: return "text"; |
155 case Colour3DPlot: return "colour3d"; | 162 case Colour3DPlot: return "colour3d"; |
163 case Spectrum: return "spectrum"; | |
156 default: return "unknown"; | 164 default: return "unknown"; |
157 } | 165 } |
158 } | 166 } |
159 | 167 |
160 QString | 168 QString |
167 case TimeInstants: return "timeinstants"; | 175 case TimeInstants: return "timeinstants"; |
168 case TimeValues: return "timevalues"; | 176 case TimeValues: return "timevalues"; |
169 case Notes: return "notes"; | 177 case Notes: return "notes"; |
170 case Text: return "text"; | 178 case Text: return "text"; |
171 case Colour3DPlot: return "colour3dplot"; | 179 case Colour3DPlot: return "colour3dplot"; |
180 case Spectrum: return "spectrum"; | |
172 default: return "unknown"; | 181 default: return "unknown"; |
173 } | 182 } |
174 } | 183 } |
175 | 184 |
176 LayerFactory::LayerType | 185 LayerFactory::LayerType |
182 if (name == "timeinstants") return TimeInstants; | 191 if (name == "timeinstants") return TimeInstants; |
183 if (name == "timevalues") return TimeValues; | 192 if (name == "timevalues") return TimeValues; |
184 if (name == "notes") return Notes; | 193 if (name == "notes") return Notes; |
185 if (name == "text") return Text; | 194 if (name == "text") return Text; |
186 if (name == "colour3dplot") return Colour3DPlot; | 195 if (name == "colour3dplot") return Colour3DPlot; |
196 if (name == "spectrum") return Spectrum; | |
187 return UnknownLayer; | 197 return UnknownLayer; |
188 } | 198 } |
189 | 199 |
190 void | 200 void |
191 LayerFactory::setModel(Layer *layer, Model *model) | 201 LayerFactory::setModel(Layer *layer, Model *model) |
214 if (trySetModel<Colour3DPlotLayer, DenseThreeDimensionalModel>(layer, model)) | 224 if (trySetModel<Colour3DPlotLayer, DenseThreeDimensionalModel>(layer, model)) |
215 return; | 225 return; |
216 | 226 |
217 if (trySetModel<SpectrogramLayer, DenseTimeValueModel>(layer, model)) | 227 if (trySetModel<SpectrogramLayer, DenseTimeValueModel>(layer, model)) |
218 return; | 228 return; |
229 | |
230 if (trySetModel<SpectrumLayer, DenseTimeValueModel>(layer, model)) | |
231 return; | |
219 } | 232 } |
220 | 233 |
221 Model * | 234 Model * |
222 LayerFactory::createEmptyModel(LayerType layerType, Model *baseModel) | 235 LayerFactory::createEmptyModel(LayerType layerType, Model *baseModel) |
223 { | 236 { |
298 | 311 |
299 case Colour3DPlot: | 312 case Colour3DPlot: |
300 layer = new Colour3DPlotLayer; | 313 layer = new Colour3DPlotLayer; |
301 break; | 314 break; |
302 | 315 |
316 case Spectrum: | |
317 layer = new SpectrumLayer; | |
318 break; | |
319 | |
303 case MelodicRangeSpectrogram: | 320 case MelodicRangeSpectrogram: |
304 layer = new SpectrogramLayer(SpectrogramLayer::MelodicRange); | 321 layer = new SpectrogramLayer(SpectrogramLayer::MelodicRange); |
305 break; | 322 break; |
306 | 323 |
307 case PeakFrequencySpectrogram: | 324 case PeakFrequencySpectrogram: |