Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/layer/LayerFactory.cpp Mon Mar 13 17:55:19 2006 +0000 +++ b/layer/LayerFactory.cpp Wed Mar 15 18:11:23 2006 +0000 @@ -230,8 +230,33 @@ } } +int +LayerFactory::getChannel(Layer *layer) +{ + if (dynamic_cast<WaveformLayer *>(layer)) { + return dynamic_cast<WaveformLayer *>(layer)->getChannel(); + } + if (dynamic_cast<SpectrogramLayer *>(layer)) { + return dynamic_cast<SpectrogramLayer *>(layer)->getChannel(); + } + return -1; +} + +void +LayerFactory::setChannel(Layer *layer, int channel) +{ + if (dynamic_cast<WaveformLayer *>(layer)) { + dynamic_cast<WaveformLayer *>(layer)->setChannel(channel); + return; + } + if (dynamic_cast<SpectrogramLayer *>(layer)) { + dynamic_cast<SpectrogramLayer *>(layer)->setChannel(channel); + return; + } +} + Layer * -LayerFactory::createLayer(LayerType type, int channel) +LayerFactory::createLayer(LayerType type) { Layer *layer = 0; @@ -239,12 +264,10 @@ case Waveform: layer = new WaveformLayer; - static_cast<WaveformLayer *>(layer)->setChannel(channel); break; case Spectrogram: layer = new SpectrogramLayer; - static_cast<SpectrogramLayer *>(layer)->setChannel(channel); break; case TimeRuler: @@ -273,12 +296,10 @@ case MelodicRangeSpectrogram: layer = new SpectrogramLayer(SpectrogramLayer::MelodicRange); - static_cast<SpectrogramLayer *>(layer)->setChannel(channel); break; case PeakFrequencySpectrogram: layer = new SpectrogramLayer(SpectrogramLayer::MelodicPeaks); - static_cast<SpectrogramLayer *>(layer)->setChannel(channel); break; default: break;