comparison layer/LayerFactory.cpp @ 53:68869408f5c7

* Restore proper channel selection support for new layers * Use binary mode for SV file I/O on Windows * Commands for selection
author Chris Cannam
date Wed, 15 Mar 2006 18:11:23 +0000
parents f2fe98a7c57e
children 01ab51f72e84
comparison
equal deleted inserted replaced
52:f2fe98a7c57e 53:68869408f5c7
228 } else { 228 } else {
229 return 0; 229 return 0;
230 } 230 }
231 } 231 }
232 232
233 int
234 LayerFactory::getChannel(Layer *layer)
235 {
236 if (dynamic_cast<WaveformLayer *>(layer)) {
237 return dynamic_cast<WaveformLayer *>(layer)->getChannel();
238 }
239 if (dynamic_cast<SpectrogramLayer *>(layer)) {
240 return dynamic_cast<SpectrogramLayer *>(layer)->getChannel();
241 }
242 return -1;
243 }
244
245 void
246 LayerFactory::setChannel(Layer *layer, int channel)
247 {
248 if (dynamic_cast<WaveformLayer *>(layer)) {
249 dynamic_cast<WaveformLayer *>(layer)->setChannel(channel);
250 return;
251 }
252 if (dynamic_cast<SpectrogramLayer *>(layer)) {
253 dynamic_cast<SpectrogramLayer *>(layer)->setChannel(channel);
254 return;
255 }
256 }
257
233 Layer * 258 Layer *
234 LayerFactory::createLayer(LayerType type, int channel) 259 LayerFactory::createLayer(LayerType type)
235 { 260 {
236 Layer *layer = 0; 261 Layer *layer = 0;
237 262
238 switch (type) { 263 switch (type) {
239 264
240 case Waveform: 265 case Waveform:
241 layer = new WaveformLayer; 266 layer = new WaveformLayer;
242 static_cast<WaveformLayer *>(layer)->setChannel(channel);
243 break; 267 break;
244 268
245 case Spectrogram: 269 case Spectrogram:
246 layer = new SpectrogramLayer; 270 layer = new SpectrogramLayer;
247 static_cast<SpectrogramLayer *>(layer)->setChannel(channel);
248 break; 271 break;
249 272
250 case TimeRuler: 273 case TimeRuler:
251 layer = new TimeRulerLayer; 274 layer = new TimeRulerLayer;
252 break; 275 break;
271 layer = new Colour3DPlotLayer; 294 layer = new Colour3DPlotLayer;
272 break; 295 break;
273 296
274 case MelodicRangeSpectrogram: 297 case MelodicRangeSpectrogram:
275 layer = new SpectrogramLayer(SpectrogramLayer::MelodicRange); 298 layer = new SpectrogramLayer(SpectrogramLayer::MelodicRange);
276 static_cast<SpectrogramLayer *>(layer)->setChannel(channel);
277 break; 299 break;
278 300
279 case PeakFrequencySpectrogram: 301 case PeakFrequencySpectrogram:
280 layer = new SpectrogramLayer(SpectrogramLayer::MelodicPeaks); 302 layer = new SpectrogramLayer(SpectrogramLayer::MelodicPeaks);
281 static_cast<SpectrogramLayer *>(layer)->setChannel(channel);
282 break; 303 break;
283 304
284 default: break; 305 default: break;
285 } 306 }
286 307