comparison main/MainWindow.cpp @ 895:509b4649b172

Quick hack at a multiplex option for transform input (see #1108)
author Chris Cannam
date Thu, 04 Dec 2014 14:48:19 +0000
parents c62c3e4825ee
children 35ce47084c84
comparison
equal deleted inserted replaced
894:966dc61430f8 895:509b4649b172
22 #include "view/PaneStack.h" 22 #include "view/PaneStack.h"
23 #include "data/model/WaveFileModel.h" 23 #include "data/model/WaveFileModel.h"
24 #include "data/model/SparseOneDimensionalModel.h" 24 #include "data/model/SparseOneDimensionalModel.h"
25 #include "data/model/RangeSummarisableTimeValueModel.h" 25 #include "data/model/RangeSummarisableTimeValueModel.h"
26 #include "data/model/NoteModel.h" 26 #include "data/model/NoteModel.h"
27 #include "data/model/AggregateWaveModel.h"
27 #include "data/model/Labeller.h" 28 #include "data/model/Labeller.h"
28 #include "data/osc/OSCQueue.h" 29 #include "data/osc/OSCQueue.h"
29 #include "framework/Document.h" 30 #include "framework/Document.h"
30 #include "framework/TransformUserConfigurator.h" 31 #include "framework/TransformUserConfigurator.h"
31 #include "view/ViewManager.h" 32 #include "view/ViewManager.h"
3703 3704
3704 std::vector<Model *> candidateInputModels = 3705 std::vector<Model *> candidateInputModels =
3705 m_document->getTransformInputModels(); 3706 m_document->getTransformInputModels();
3706 3707
3707 Model *defaultInputModel = 0; 3708 Model *defaultInputModel = 0;
3709
3708 for (int j = 0; j < pane->getLayerCount(); ++j) { 3710 for (int j = 0; j < pane->getLayerCount(); ++j) {
3711
3709 Layer *layer = pane->getLayer(j); 3712 Layer *layer = pane->getLayer(j);
3710 if (!layer) continue; 3713 if (!layer) continue;
3714
3711 if (LayerFactory::getInstance()->getLayerType(layer) != 3715 if (LayerFactory::getInstance()->getLayerType(layer) !=
3712 LayerFactory::Waveform && 3716 LayerFactory::Waveform &&
3713 !layer->isLayerOpaque()) continue; 3717 !layer->isLayerOpaque()) continue;
3718
3714 Model *model = layer->getModel(); 3719 Model *model = layer->getModel();
3715 if (!model) continue; 3720 if (!model) continue;
3721
3716 for (size_t k = 0; k < candidateInputModels.size(); ++k) { 3722 for (size_t k = 0; k < candidateInputModels.size(); ++k) {
3717 if (candidateInputModels[k] == model) { 3723 if (candidateInputModels[k] == model) {
3718 defaultInputModel = model; 3724 defaultInputModel = model;
3719 break; 3725 break;
3720 } 3726 }
3721 } 3727 }
3728
3722 if (defaultInputModel) break; 3729 if (defaultInputModel) break;
3730 }
3731
3732 if (candidateInputModels.size() > 1) {
3733 // Add an aggregate model as another option
3734 AggregateWaveModel::ChannelSpecList sl;
3735 foreach (Model *m, candidateInputModels) {
3736 RangeSummarisableTimeValueModel *r =
3737 qobject_cast<RangeSummarisableTimeValueModel *>(m);
3738 if (r) {
3739 sl.push_back(AggregateWaveModel::ModelChannelSpec(r, -1));
3740 }
3741 }
3742 if (!sl.empty()) {
3743 AggregateWaveModel *aggregate = new AggregateWaveModel(sl);
3744 aggregate->setObjectName(tr("Multiplex all of the above"));
3745 candidateInputModels.push_back(aggregate);
3746 //!!! but it leaks
3747 }
3723 } 3748 }
3724 3749
3725 int startFrame = 0, duration = 0; 3750 int startFrame = 0, duration = 0;
3726 int endFrame = 0; 3751 int endFrame = 0;
3727 m_viewManager->getSelection().getExtents(startFrame, endFrame); 3752 m_viewManager->getSelection().getExtents(startFrame, endFrame);